q5 2.10.7 → 2.10.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/deno.json +35 -0
  2. package/package.json +3 -6
  3. package/q5-deno-server.js +38 -0
  4. package/q5-server.js +3 -3
  5. package/q5.js +14 -8
  6. package/q5.min.js +1 -1
  7. package/src/q5-canvas.js +14 -8
  8. package/test/core.test.js +33 -0
  9. package/test/readme.md +5 -0
  10. package/.vscode/launch.json +0 -26
  11. package/.vscode/settings.json +0 -3
  12. package/bun.lockb +0 -0
  13. package/p5-tests/js/chai_helpers.js +0 -20
  14. package/p5-tests/js/mocha_setup.js +0 -2
  15. package/p5-tests/js/modernizr.js +0 -5
  16. package/p5-tests/js/p5_helpers.js +0 -135
  17. package/p5-tests/js/sinon.js +0 -5949
  18. package/p5-tests/mocha.css +0 -289
  19. package/p5-tests/test.html +0 -71
  20. package/p5-tests/unit/color/color_conversion.js +0 -68
  21. package/p5-tests/unit/color/creating_reading.js +0 -217
  22. package/p5-tests/unit/color/p5.Color.js +0 -1000
  23. package/p5-tests/unit/color/setting.js +0 -289
  24. package/p5-tests/unit/core/2d_primitives.js +0 -490
  25. package/p5-tests/unit/core/attributes.js +0 -115
  26. package/p5-tests/unit/core/curves.js +0 -139
  27. package/p5-tests/unit/core/environment.js +0 -248
  28. package/p5-tests/unit/core/error_helpers.js +0 -1158
  29. package/p5-tests/unit/core/main.js +0 -340
  30. package/p5-tests/unit/core/p5.Element.js +0 -773
  31. package/p5-tests/unit/core/p5.Graphics.js +0 -179
  32. package/p5-tests/unit/core/preload.js +0 -285
  33. package/p5-tests/unit/core/rendering.js +0 -116
  34. package/p5-tests/unit/core/structure.js +0 -293
  35. package/p5-tests/unit/core/transform.js +0 -144
  36. package/p5-tests/unit/core/version.js +0 -28
  37. package/p5-tests/unit/core/vertex.js +0 -137
  38. package/p5-tests/unit/dom/dom.js +0 -2146
  39. package/p5-tests/unit/events/acceleration.js +0 -213
  40. package/p5-tests/unit/events/keyboard.js +0 -179
  41. package/p5-tests/unit/events/mouse.js +0 -487
  42. package/p5-tests/unit/events/touch.js +0 -180
  43. package/p5-tests/unit/image/downloading.js +0 -379
  44. package/p5-tests/unit/image/filters.js +0 -92
  45. package/p5-tests/unit/image/loading.js +0 -413
  46. package/p5-tests/unit/image/p5.Image.js +0 -201
  47. package/p5-tests/unit/image/pixels.js +0 -234
  48. package/p5-tests/unit/io/files.js +0 -378
  49. package/p5-tests/unit/io/loadBytes.js +0 -149
  50. package/p5-tests/unit/io/loadImage.js +0 -123
  51. package/p5-tests/unit/io/loadJSON.js +0 -185
  52. package/p5-tests/unit/io/loadModel.js +0 -215
  53. package/p5-tests/unit/io/loadShader.js +0 -176
  54. package/p5-tests/unit/io/loadStrings.js +0 -140
  55. package/p5-tests/unit/io/loadTable.js +0 -183
  56. package/p5-tests/unit/io/loadXML.js +0 -127
  57. package/p5-tests/unit/io/saveModel.js +0 -113
  58. package/p5-tests/unit/io/saveTable.js +0 -142
  59. package/p5-tests/unit/math/calculation.js +0 -452
  60. package/p5-tests/unit/math/noise.js +0 -66
  61. package/p5-tests/unit/math/p5.Vector.js +0 -1886
  62. package/p5-tests/unit/math/random.js +0 -177
  63. package/p5-tests/unit/math/trigonometry.js +0 -144
  64. package/p5-tests/unit/spec.js +0 -50
  65. package/p5-tests/unit/typography/attributes.js +0 -120
  66. package/p5-tests/unit/typography/loadFont.js +0 -162
  67. package/p5-tests/unit/typography/p5.Font.js +0 -63
  68. package/p5-tests/unit/utilities/conversion.js +0 -329
  69. package/p5-tests/unit/utilities/time_date.js +0 -133
@@ -1,177 +0,0 @@
1
- suite('Random', function() {
2
- var myp5;
3
-
4
- setup(function(done) {
5
- new p5(function(p) {
6
- p.setup = function() {
7
- myp5 = p;
8
- done();
9
- };
10
- });
11
- });
12
-
13
- teardown(function() {
14
- myp5.remove();
15
- });
16
-
17
- suite('p5.prototype.random', function() {
18
- var result;
19
-
20
- var results = [];
21
-
22
- suite('random()', function() {
23
- setup(function() {
24
- myp5.randomSeed(99);
25
- for (var i = 0; i < 5; i++) {
26
- results[i] = myp5.random();
27
- }
28
- myp5.randomSeed(99);
29
- for (i = 5; i < 10; i++) {
30
- results[i] = myp5.random();
31
- }
32
- });
33
- test('should return a number', function() {
34
- for (var i = 0; i < 10; i++) {
35
- assert.typeOf(results[i], 'number');
36
- }
37
- });
38
- test('should return a number 0 <= n < 1', function() {
39
- for (var i = 0; i < 10; i++) {
40
- assert.isTrue(results[i] >= 0);
41
- assert.isTrue(results[i] < 1);
42
- }
43
- });
44
- test('should return same sequence of numbers', function() {
45
- for (var i = 0; i < 5; i++) {
46
- assert.isTrue(results[i] === results[i + 5]);
47
- }
48
- });
49
- });
50
-
51
- suite('random(5)', function() {
52
- test('should return a number 0 <= n < 5', function() {
53
- result = myp5.random(5);
54
- assert.isTrue(result >= 0);
55
- assert.isTrue(result < 5);
56
- });
57
- });
58
-
59
- suite('random(1, 10)', function() {
60
- test('should return a number 1 <= n < 10', function() {
61
- result = myp5.random(1, 10);
62
- assert.isTrue(result >= 1);
63
- assert.isTrue(result < 10);
64
- });
65
- });
66
-
67
- suite('random(["apple", "pear", "orange", "grape"])', function() {
68
- test('should return a fruit', function() {
69
- var fruits = ['apple', 'pear', 'orange', 'grape'];
70
- result = myp5.random(fruits);
71
- assert.include(fruits, result);
72
- });
73
- });
74
- });
75
- suite('instance mode', function() {
76
- var instances = [];
77
-
78
- function addInstance(max, done) {
79
- new p5(function(p) {
80
- p.setup = function() {
81
- instances.push(p);
82
- if (instances.length >= max) {
83
- done();
84
- }
85
- };
86
- });
87
- }
88
-
89
- setup(function(done) {
90
- var instanceCount = 2;
91
- for (var i = 0; i < instanceCount; i++) {
92
- addInstance(instanceCount, done);
93
- }
94
- });
95
-
96
- teardown(function() {
97
- instances.forEach(function(instance) {
98
- instance.remove();
99
- });
100
- });
101
-
102
- test('should be independent', function() {
103
- var SEED = 42;
104
-
105
- instances.forEach(function(instance) {
106
- instance.randomSeed(SEED);
107
- });
108
-
109
- for (var i = 0; i < 10; i++) {
110
- instances.reduce(function(prev, instance) {
111
- var randomValue = instance.random();
112
- if (prev != null) {
113
- assert.equal(randomValue, prev);
114
- }
115
-
116
- return randomValue;
117
- }, null);
118
- }
119
- });
120
- });
121
-
122
- suite('p5.prototype.randomGaussian', function() {
123
- suite('instance mode', function() {
124
- var instances = [];
125
-
126
- function addInstance(max, done) {
127
- new p5(function(p) {
128
- p.setup = function() {
129
- instances.push(p);
130
- if (instances.length >= max) {
131
- done();
132
- }
133
- };
134
- });
135
- }
136
-
137
- setup(function(done) {
138
- var instanceCount = 2;
139
- for (var i = 0; i < instanceCount; i++) {
140
- addInstance(instanceCount, done);
141
- }
142
- });
143
-
144
- teardown(function() {
145
- instances.forEach(function(instance) {
146
- instance.remove();
147
- });
148
- });
149
-
150
- test('should be independent', function() {
151
- var SEED = 42;
152
-
153
- instances.forEach(function(instance) {
154
- instance.randomSeed(SEED);
155
- });
156
-
157
- for (var i = 0; i < 10; i++) {
158
- instances.reduce(function(prev, instance) {
159
- var randomValue = instance.randomGaussian(0, 15);
160
- if (prev != null) {
161
- assert.equal(randomValue, prev);
162
- }
163
-
164
- return randomValue;
165
- }, null);
166
- }
167
- });
168
- });
169
-
170
- suite('randomGaussian(42, 0)', function() {
171
- test('should return 42', function() {
172
- result = myp5.randomGaussian(42, 0);
173
- assert.isTrue(result === 42);
174
- });
175
- });
176
- });
177
- });
@@ -1,144 +0,0 @@
1
- suite('Trigonometry', function() {
2
- var theta = 90;
3
- var x = 0;
4
- var y = 1;
5
- var ratio = 0.5;
6
- var RADIANS = 'radians';
7
- var DEGREES = 'degrees';
8
- var myp5;
9
-
10
- setup(function(done) {
11
- new p5(function(p) {
12
- p.setup = function() {
13
- myp5 = p;
14
- done();
15
- };
16
- });
17
- });
18
-
19
- teardown(function() {
20
- myp5.remove();
21
- });
22
-
23
- var handleDegreesAndRadians = function(func) {
24
- test('should handle degrees', function() {
25
- myp5.angleMode(DEGREES);
26
- var degToRad = myp5.radians(theta);
27
- assert.equal(Math[func](degToRad), myp5[func](theta));
28
- });
29
-
30
- test('should handle radians', function() {
31
- myp5.angleMode(RADIANS);
32
- assert.equal(Math[func](theta), myp5[func](theta));
33
- });
34
- };
35
-
36
- var ahandleDegreesAndRadians = function(func) {
37
- test('should handle degrees', function() {
38
- myp5.angleMode(DEGREES);
39
- assert.equal(myp5.degrees(Math[func](ratio)), myp5[func](ratio));
40
- });
41
-
42
- test('should handle radians', function() {
43
- myp5.angleMode(RADIANS);
44
- assert.equal(Math[func](ratio), myp5[func](ratio));
45
- });
46
- };
47
-
48
- suite('p5.prototype.angleMode', function() {
49
- test('should set constant to DEGREES', function() {
50
- myp5.angleMode(DEGREES);
51
- assert.equal(myp5.angleMode(), 'degrees');
52
- });
53
-
54
- test('should set constant to RADIANS', function() {
55
- myp5.angleMode(RADIANS);
56
- assert.equal(myp5.angleMode(), 'radians');
57
- });
58
-
59
- test('wrong param type', function() {
60
- assert.validationError(function() {
61
- myp5.angleMode('wtflolzkk');
62
- });
63
- });
64
-
65
- test('should return radians', function() {
66
- myp5.angleMode(RADIANS);
67
- assert.equal(myp5.angleMode(), 'radians');
68
- });
69
-
70
- test('should return degrees', function() {
71
- myp5.angleMode(DEGREES);
72
- assert.equal(myp5.angleMode(), 'degrees');
73
- });
74
-
75
- test('should always be RADIANS or DEGREES', function() {
76
- myp5.angleMode('wtflolzkk');
77
- assert.equal(myp5.angleMode(), 'radians');
78
- });
79
- });
80
-
81
- suite('p5.prototype.degrees', function() {
82
- test('should return the angle in radians when angleMode is DEGREES', function() {
83
- myp5.angleMode(DEGREES);
84
- var angleInRad = 360 * theta / (2 * Math.PI); // This is degToRad conversion
85
- assert.equal(myp5.degrees(theta), angleInRad);
86
- });
87
-
88
- test('should return the angle in radians when angleMode is RADIANS', function() {
89
- myp5.angleMode(RADIANS);
90
- var angleInRad = 360 * theta / (2 * Math.PI); // This is degToRad conversion
91
- assert.equal(myp5.degrees(theta), angleInRad);
92
- });
93
- });
94
-
95
- suite('p5.prototype.radians', function() {
96
- test('should return the angle in degrees when angleMode is RADIANS', function() {
97
- myp5.angleMode(RADIANS);
98
- var angleInDeg = 2 * Math.PI * theta / 360; // This is RadToDeg conversion
99
- assert.equal(myp5.radians(theta), angleInDeg);
100
- });
101
-
102
- test('should return the angle in degrees when angleMode is DEGREES', function() {
103
- myp5.angleMode(DEGREES);
104
- var angleInDeg = 2 * Math.PI * theta / 360; // This is RadToDeg conversion
105
- assert.equal(myp5.radians(theta), angleInDeg);
106
- });
107
- });
108
-
109
- suite('p5.prototype.asin', function() {
110
- ahandleDegreesAndRadians('asin');
111
- });
112
-
113
- suite('p5.prototype.atan', function() {
114
- ahandleDegreesAndRadians('atan');
115
- });
116
-
117
- suite('p5.prototype.acos', function() {
118
- ahandleDegreesAndRadians('acos');
119
- });
120
-
121
- suite('p5.prototype.sin', function() {
122
- handleDegreesAndRadians('sin');
123
- });
124
-
125
- suite('p5.prototype.cos', function() {
126
- handleDegreesAndRadians('cos');
127
- });
128
-
129
- suite('p5.prototype.tan', function() {
130
- handleDegreesAndRadians('tan');
131
- });
132
-
133
- suite('p5.prototype.atan2', function() {
134
- test('should handle degrees', function() {
135
- myp5.angleMode(DEGREES);
136
- assert.equal(myp5.degrees(Math.atan2(y, x)), myp5.atan2(y, x));
137
- });
138
-
139
- test('should handle radians', function() {
140
- myp5.angleMode(RADIANS);
141
- assert.equal(Math.atan2(y, x), myp5.atan2(y, x));
142
- });
143
- });
144
- });
@@ -1,50 +0,0 @@
1
- var spec = {
2
- // color: ['color_conversion', 'creating_reading', 'p5.Color', 'setting'],
3
- core: [
4
- '2d_primitives',
5
- 'attributes',
6
- 'curves',
7
- 'environment',
8
- // 'error_helpers',
9
- 'main',
10
- // 'p5.Element',
11
- 'p5.Graphics',
12
- 'preload',
13
- 'rendering',
14
- 'structure',
15
- 'transform',
16
- 'version',
17
- 'vertex'
18
- ],
19
- // dom: ['dom'],
20
- events: ['keyboard', 'mouse', 'touch', 'acceleration'],
21
- image: [
22
- 'p5.Image',
23
- 'loading',
24
- 'pixels',
25
- 'filters',
26
- 'downloading'
27
- ],
28
- io: [
29
- 'files',
30
- // 'loadBytes',
31
- // 'loadStrings',
32
- // 'loadXML',
33
- 'loadJSON',
34
- // 'loadTable',
35
- // 'saveTable',
36
- 'loadImage'
37
- // 'loadModel',
38
- // 'loadShader'
39
- ],
40
- math: ['calculation', 'noise', 'p5.Vector', 'random', 'trigonometry'],
41
- typography: ['attributes', 'loadFont', 'p5.Font'],
42
- utilities: ['conversion', 'time_date']
43
- };
44
-
45
- Object.keys(spec).map(function (folder) {
46
- spec[folder].map(function (file) {
47
- var string = ['<script src="unit/', folder, '/', file, '.js" type="text/javascript" ></script>'];
48
- document.write(string.join(''));
49
- });
50
- });
@@ -1,120 +0,0 @@
1
- suite('Typography Attributes', function() {
2
- let myp5;
3
-
4
- setup(function(done) {
5
- new p5(function(p) {
6
- p.setup = function() {
7
- myp5 = p;
8
- done();
9
- };
10
- });
11
- });
12
-
13
- teardown(function() {
14
- myp5.remove();
15
- });
16
-
17
- suite('p5.prototype.textAlign', function() {
18
- test('wrong param at #0', function() {
19
- assert.validationError(function() {
20
- myp5.textAlign('a');
21
- });
22
- });
23
- test('wrong param at #1', function() {
24
- assert.validationError(function() {
25
- myp5.textAlign(myp5.CENTER, 'a');
26
- });
27
- });
28
- test('wrong param at #0. vertAlign as #0 param.', function() {
29
- assert.validationError(function() {
30
- myp5.textAlign(myp5.BOTTOM);
31
- });
32
- });
33
- test('wrong param at #1. horizAlign as #1 param.', function() {
34
- assert.validationError(function() {
35
- myp5.textAlign(myp5.CENTER, myp5.LEFT);
36
- });
37
- });
38
- });
39
-
40
- suite('p5.prototype.textLeading', function() {
41
- test('sets and gets the spacing value', function() {
42
- myp5.textLeading(20);
43
- assert.strictEqual(myp5.textLeading(), 20);
44
- });
45
- test('should work for negative spacing value', function() {
46
- myp5.textLeading(-20);
47
- assert.strictEqual(myp5.textLeading(), -20);
48
- });
49
- test('wrong param type at #0', function() {
50
- assert.validationError(function() {
51
- myp5.textLeading('C');
52
- });
53
- });
54
- test.skip('wrong param type at #0', function() {
55
- assert.validationError(function() {
56
- myp5.textLeading('25');
57
- });
58
- });
59
- });
60
-
61
- suite('p5.prototype.textSize', function() {
62
- test('sets and gets the font size', function() {
63
- myp5.textSize(24);
64
- assert.strictEqual(myp5.textSize(), 24);
65
- });
66
- test('wrong param type at #0', function() {
67
- assert.validationError(function() {
68
- myp5.textSize('A');
69
- });
70
- });
71
- test.skip('wrong param type at #0', function() {
72
- assert.validationError(function() {
73
- myp5.textSize('30');
74
- });
75
- });
76
- });
77
-
78
- suite('p5.prototype.textStyle', function() {
79
- test('sets and gets the font style', function() {
80
- myp5.textStyle(myp5.ITALIC);
81
- assert.strictEqual(myp5.textStyle(), myp5.ITALIC);
82
- });
83
- test('wrong param at #0', function() {
84
- assert.validationError(function() {
85
- myp5.textStyle('a');
86
- });
87
- });
88
- });
89
-
90
- suite('p5.prototype.textWidth', function() {
91
- test('should return a number for char input', function() {
92
- assert.isNumber(myp5.textWidth('P'));
93
- });
94
- test('should return a number for string input.', function() {
95
- assert.isNumber(myp5.textWidth('p5.js'));
96
- });
97
- // Either should not throw error
98
- test('should return a number for number input', function() {
99
- assert.isNumber(myp5.textWidth('p5.js'));
100
- });
101
- });
102
-
103
- suite('p5.prototype.textAscent', function() {
104
- test('should return a number', function() {
105
- assert.isNumber(myp5.textAscent());
106
- });
107
- });
108
-
109
- suite('p5.prototype.textDescent', function() {
110
- test('should return a number', function() {
111
- assert.isNumber(myp5.textDescent());
112
- });
113
- });
114
-
115
- suite('p5.prototype.textWrap', function() {
116
- test('returns textWrap text attribute', function() {
117
- assert.strictEqual(myp5.textWrap(myp5.WORD), myp5.WORD);
118
- });
119
- });
120
- });
@@ -1,162 +0,0 @@
1
- suite('Loading Displaying Fonts', function() {
2
- var myp5;
3
-
4
- setup(function(done) {
5
- new p5(function(p) {
6
- p.setup = function() {
7
- myp5 = p;
8
- done();
9
- };
10
- });
11
- });
12
-
13
- teardown(function() {
14
- myp5.remove();
15
- });
16
-
17
- suite('p5.prototype.loadFont', function() {
18
- var invalidFile = '404file';
19
- var fontFile = 'manual-test-examples/p5.Font/acmesa.ttf';
20
-
21
- test('_friendlyFileLoadError is called', async function() {
22
- const _friendlyFileLoadErrorStub = sinon.stub(
23
- p5,
24
- '_friendlyFileLoadError'
25
- );
26
- try {
27
- await promisedSketch(function(sketch, resolve, reject) {
28
- sketch.preload = function() {
29
- sketch.loadFont(invalidFile, reject, resolve);
30
- };
31
- });
32
- expect(
33
- _friendlyFileLoadErrorStub.calledOnce,
34
- 'p5._friendlyFileLoadError was not called'
35
- ).to.be.true;
36
- } finally {
37
- _friendlyFileLoadErrorStub.restore();
38
- }
39
- });
40
-
41
- testSketchWithPromise('error prevents sketch continuing', function(
42
- sketch,
43
- resolve,
44
- reject
45
- ) {
46
- sketch.preload = function() {
47
- sketch.loadFont(invalidFile, reject, function() {
48
- setTimeout(resolve, 50);
49
- });
50
- };
51
-
52
- sketch.setup = function() {
53
- reject(new Error('Setup called'));
54
- };
55
-
56
- sketch.draw = function() {
57
- reject(new Error('Draw called'));
58
- };
59
- });
60
-
61
- testSketchWithPromise('error callback is called', function(
62
- sketch,
63
- resolve,
64
- reject
65
- ) {
66
- sketch.preload = function() {
67
- sketch.loadFont(
68
- invalidFile,
69
- function() {
70
- reject(new Error('Success callback executed.'));
71
- },
72
- function() {
73
- // Wait a bit so that if both callbacks are executed we will get an error.
74
- setTimeout(resolve, 50);
75
- }
76
- );
77
- };
78
- });
79
-
80
- testSketchWithPromise('loading correctly triggers setup', function(
81
- sketch,
82
- resolve,
83
- reject
84
- ) {
85
- sketch.preload = function() {
86
- sketch.loadFont(fontFile);
87
- };
88
-
89
- sketch.setup = function() {
90
- resolve();
91
- };
92
- });
93
-
94
- testSketchWithPromise('success callback is called', function(
95
- sketch,
96
- resolve,
97
- reject
98
- ) {
99
- var hasBeenCalled = false;
100
- sketch.preload = function() {
101
- sketch.loadFont(
102
- fontFile,
103
- function() {
104
- hasBeenCalled = true;
105
- },
106
- function(err) {
107
- reject(new Error('Error callback was entered: ' + err));
108
- }
109
- );
110
- };
111
-
112
- sketch.setup = function() {
113
- if (!hasBeenCalled) {
114
- reject(new Error('Setup called prior to success callback'));
115
- } else {
116
- setTimeout(resolve, 50);
117
- }
118
- };
119
- });
120
-
121
- test('returns a p5.Font object', async function() {
122
- const font = await promisedSketch(function(sketch, resolve, reject) {
123
- let _font;
124
- sketch.preload = function() {
125
- _font = sketch.loadFont(fontFile, function() {}, reject);
126
- };
127
-
128
- sketch.setup = function() {
129
- resolve(_font);
130
- };
131
- });
132
- assert.instanceOf(font, p5.Font);
133
- });
134
-
135
- test('passes a p5.Font object to success callback', async function() {
136
- const font = await promisedSketch(function(sketch, resolve, reject) {
137
- sketch.preload = function() {
138
- sketch.loadFont(fontFile, resolve, reject);
139
- };
140
- });
141
- assert.isObject(font);
142
- });
143
- });
144
-
145
- suite('p5.prototype.textFont', function() {
146
- test('sets the current font as Georgia', function() {
147
- myp5.textFont('Georgia');
148
- assert.strictEqual(myp5.textFont(), 'Georgia');
149
- });
150
-
151
- test('sets the current font as Helvetica', function() {
152
- myp5.textFont('Helvetica');
153
- assert.strictEqual(myp5.textFont(), 'Helvetica');
154
- });
155
-
156
- test('sets the current font and text size', function() {
157
- myp5.textFont('Courier New', 24);
158
- assert.strictEqual(myp5.textFont(), 'Courier New');
159
- assert.strictEqual(myp5.textSize(), 24);
160
- });
161
- });
162
- });
@@ -1,63 +0,0 @@
1
- suite('p5.Font', function() {
2
- var myp5;
3
-
4
- setup(function(done) {
5
- new p5(function(p) {
6
- p.setup = function() {
7
- myp5 = p;
8
- done();
9
- };
10
- });
11
- });
12
-
13
- teardown(function() {
14
- myp5.remove();
15
- });
16
-
17
- suite('p5.Font.prototype.textBounds', function() {
18
- test('returns a tight bounding box for the given text string', async function() {
19
- let fontFile = 'manual-test-examples/p5.Font/acmesa.ttf';
20
- const bbox = await promisedSketch(function(sketch, resolve, reject) {
21
- let _font;
22
- let textString = 'Lorem ipsum dolor sit amet.';
23
- sketch.preload = function() {
24
- _font = sketch.loadFont(fontFile, function() {}, reject);
25
- };
26
- sketch.setup = function() {
27
- let _bbox = _font.textBounds(textString, 10, 30, 12);
28
- resolve(_bbox);
29
- };
30
- });
31
- assert.isObject(bbox);
32
- assert.property(bbox, 'x');
33
- assert.property(bbox, 'y');
34
- assert.property(bbox, 'w');
35
- assert.property(bbox, 'h');
36
- });
37
- });
38
-
39
- suite('p5.Font.prototype.textToPoints', function() {
40
- test('returns array of points', async function() {
41
- let fontFile = 'manual-test-examples/p5.Font/acmesa.ttf';
42
- const points = await promisedSketch(function(sketch, resolve, reject) {
43
- let _font;
44
- sketch.preload = function() {
45
- _font = sketch.loadFont(fontFile, function() {}, reject);
46
- };
47
- sketch.setup = function() {
48
- let _points = _font.textToPoints('p5', 0, 0, 10, {
49
- sampleFactor: 5,
50
- simplifyThreshold: 0
51
- });
52
- resolve(_points);
53
- };
54
- });
55
- assert.isArray(points);
56
- points.forEach(p => {
57
- assert.property(p, 'x');
58
- assert.property(p, 'y');
59
- assert.property(p, 'alpha');
60
- });
61
- });
62
- });
63
- });