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,490 +0,0 @@
1
- suite('2D Primitives', 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.arc', function() {
18
- test('should be a function', function() {
19
- assert.ok(myp5.arc);
20
- assert.typeOf(myp5.arc, 'function');
21
- });
22
- test('no friendly-err-msg', function() {
23
- assert.doesNotThrow(
24
- function() {
25
- myp5.arc(1, 1, 10.5, 10, 0, Math.PI, 'pie');
26
- },
27
- Error,
28
- 'got unwanted exception'
29
- );
30
- });
31
- test('missing param #4, #5', function() {
32
- assert.validationError(function() {
33
- myp5.arc(1, 1, 10.5, 10);
34
- });
35
- });
36
- test('wrong param type at #0', function() {
37
- assert.validationError(function() {
38
- myp5.arc('a', 1, 10.5, 10, 0, Math.PI, 'pie');
39
- });
40
- });
41
- });
42
-
43
- suite('p5.prototype.ellipse', function() {
44
- test('should be a function', function() {
45
- assert.ok(myp5.ellipse);
46
- assert.typeOf(myp5.ellipse, 'function');
47
- });
48
- test('no friendly-err-msg', function() {
49
- assert.doesNotThrow(
50
- function() {
51
- myp5.ellipse(0, 0, 100);
52
- },
53
- Error,
54
- 'got unwanted exception'
55
- );
56
- });
57
- test('missing param #2', function() {
58
- assert.validationError(function() {
59
- myp5.ellipse(0, 0);
60
- });
61
- });
62
- test('missing param #2', function() {
63
- assert.validationError(function() {
64
- var size;
65
- myp5.ellipse(0, 0, size);
66
- });
67
- });
68
- test('wrong param type at #0', function() {
69
- assert.validationError(function() {
70
- myp5.ellipse('a', 0, 100, 100);
71
- });
72
- });
73
- });
74
-
75
- suite('p5.prototype.line', function() {
76
- test('should be a function', function() {
77
- assert.ok(myp5.line);
78
- assert.typeOf(myp5.line, 'function');
79
- });
80
- test('no friendly-err-msg, 2D', function() {
81
- assert.doesNotThrow(
82
- function() {
83
- myp5.line(0, 0, 100, 100);
84
- },
85
- Error,
86
- 'got unwanted exception'
87
- );
88
- });
89
- test('no friendly-err-msg, 3D', function() {
90
- assert.doesNotThrow(
91
- function() {
92
- myp5.line(0, 0, 100, 100, 20, Math.PI);
93
- },
94
- Error,
95
- 'got unwanted exception'
96
- );
97
- });
98
- test('missing param #3', function() {
99
- assert.validationError(function() {
100
- myp5.line(0, 0, Math.PI);
101
- });
102
- });
103
- test('missing param #4 ', function() {
104
- // this err case escapes
105
- assert.validationError(function() {
106
- var x3;
107
- myp5.line(0, 0, 100, 100, x3, Math.PI);
108
- });
109
- });
110
- test('wrong param type at #1', function() {
111
- assert.validationError(function() {
112
- myp5.line(0, 'a', 100, 100);
113
- });
114
- });
115
- });
116
-
117
- suite('p5.prototype.point', function() {
118
- test('should be a function', function() {
119
- assert.ok(myp5.point);
120
- assert.typeOf(myp5.point, 'function');
121
- });
122
- test('no friendly-err-msg, 2D', function() {
123
- assert.doesNotThrow(
124
- function() {
125
- myp5.point(Math.PI, 0);
126
- },
127
- Error,
128
- 'got unwanted exception'
129
- );
130
- });
131
- test('no friendly-err-msg, 3D', function() {
132
- assert.doesNotThrow(
133
- function() {
134
- myp5.point(Math.PI, 0, 100);
135
- },
136
- Error,
137
- 'got unwanted exception'
138
- );
139
- });
140
- test('missing param #1', function() {
141
- assert.validationError(function() {
142
- myp5.point(0);
143
- });
144
- });
145
- /* this is not an error because 2d point exists.
146
- test('missing param #3', function() {
147
- // this err case escapes
148
- assert.validationError(function() {
149
- var z;
150
- myp5.point(0, Math.PI, z);
151
- });
152
- });
153
- */
154
- test('wrong param type at #1', function() {
155
- assert.validationError(function() {
156
- myp5.point(Math.PI, 'a');
157
- });
158
- });
159
- });
160
-
161
- suite('p5.prototype.quad', function() {
162
- test('should be a function', function() {
163
- assert.ok(myp5.quad);
164
- assert.typeOf(myp5.quad, 'function');
165
- });
166
- test('no friendly-err-msg, 2D', function() {
167
- assert.doesNotThrow(
168
- function() {
169
- myp5.quad(Math.PI, 0, Math.PI, 5.1, 10, 5.1, 10, 0);
170
- },
171
- Error,
172
- 'got unwanted exception'
173
- );
174
- });
175
- test('missing param #7', function() {
176
- assert.validationError(function() {
177
- myp5.quad(Math.PI, 0, Math.PI, 5.1, 10, 5.1, 10);
178
- });
179
- });
180
- test('wrong param type at #1', function() {
181
- assert.validationError(function() {
182
- myp5.quad(Math.PI, 'a', Math.PI, 5.1, 10, 5.1, 10, 0);
183
- });
184
- });
185
- });
186
-
187
- suite('p5.prototype.rect', function() {
188
- test('should be a function', function() {
189
- assert.ok(myp5.rect);
190
- assert.typeOf(myp5.rect, 'function');
191
- });
192
- test('no friendly-err-msg, format I', function() {
193
- assert.doesNotThrow(
194
- function() {
195
- myp5.rect(0, 0, 100);
196
- },
197
- Error,
198
- 'got unwanted exception'
199
- );
200
- });
201
- test('no friendly-err-msg, format II', function() {
202
- assert.doesNotThrow(
203
- function() {
204
- myp5.rect(0, 0, 100, 100, 1, Math.PI, 1, Math.PI);
205
- },
206
- Error,
207
- 'got unwanted exception'
208
- );
209
- });
210
- test('missing param #4', function() {
211
- // this err case escapes
212
- assert.validationError(function() {
213
- var r1;
214
- myp5.rect(0, 0, 100, 100, r1, Math.PI, 1, Math.PI);
215
- });
216
- });
217
- test('wrong param type at #1', function() {
218
- assert.validationError(function() {
219
- myp5.rect(0, 'a', 100, 100);
220
- });
221
- });
222
- });
223
-
224
- suite('p5.prototype.triangle', function() {
225
- test('should be a function', function() {
226
- assert.ok(myp5.triangle);
227
- assert.typeOf(myp5.triangle, 'function');
228
- });
229
- test('no friendly-err-msg', function() {
230
- assert.doesNotThrow(
231
- function() {
232
- myp5.triangle(Math.PI, 0, Math.PI, 5.1, 10, 5.1);
233
- },
234
- Error,
235
- 'got unwanted exception'
236
- );
237
- });
238
- test('missing param #5', function() {
239
- assert.validationError(function() {
240
- myp5.triangle(Math.PI, 0, Math.PI, 5.1, 10);
241
- });
242
- });
243
- test('wrong param type at #1', function() {
244
- assert.validationError(function() {
245
- myp5.triangle(Math.PI, 'a', Math.PI, 5.1, 10, 5.1);
246
- });
247
- });
248
- });
249
- suite('p5.prototype.square', function() {
250
- test('should be a function', function() {
251
- assert.ok(myp5.square);
252
- assert.typeOf(myp5.square, 'function');
253
- });
254
- test('no friendly-err-msg, format I', function() {
255
- assert.doesNotThrow(
256
- function() {
257
- myp5.square(0, 0, 100);
258
- },
259
- Error,
260
- 'got unwanted exception'
261
- );
262
- });
263
- test('no friendly-err-msg, format II', function() {
264
- assert.doesNotThrow(
265
- function() {
266
- myp5.square(0, 0, 100, 100, Math.PI);
267
- },
268
- Error,
269
- 'got unwanted exception'
270
- );
271
- });
272
- test('missing param #2', function() {
273
- assert.validationError(function() {
274
- myp5.square(0, 0);
275
- });
276
- });
277
- test('wrong param type at #1', function() {
278
- assert.validationError(function() {
279
- myp5.square(0, 'a', 100);
280
- });
281
- });
282
- });
283
-
284
- suite('p5.prototype._normalizeArcAngles', function() {
285
- test('start/stop both at zero', function() {
286
- var i, j, angles;
287
- for (i = -2; i <= 2; i++) {
288
- for (j = -2; j <= 2; j++) {
289
- angles = myp5._normalizeArcAngles(
290
- 2 * Math.PI * i,
291
- 2 * Math.PI * j,
292
- 500,
293
- 5,
294
- false
295
- );
296
- assert.approximately(angles.start, 0, 0.000005);
297
- assert.approximately(angles.stop, 0, 0.000005);
298
- assert.isTrue(angles.correspondToSamePoint);
299
- }
300
- }
301
- });
302
- test('start/stop same but non-zero', function() {
303
- var i, j, angles;
304
- for (i = -2; i <= 2; i++) {
305
- for (j = -2; j <= 2; j++) {
306
- angles = myp5._normalizeArcAngles(
307
- 2 * Math.PI * i + 1,
308
- 2 * Math.PI * j + 1,
309
- 500,
310
- 5,
311
- false
312
- );
313
- assert.approximately(angles.start, 1, 0.000005);
314
- assert.approximately(angles.stop, 1, 0.000005);
315
- assert.isTrue(angles.correspondToSamePoint);
316
- }
317
- }
318
- });
319
- test('start/stop both close to zero, start < stop', function() {
320
- var i, j, angles;
321
- for (i = -2; i <= 2; i++) {
322
- for (j = -2; j <= 2; j++) {
323
- angles = myp5._normalizeArcAngles(
324
- 2 * Math.PI * i - 0.000001,
325
- 2 * Math.PI * j + 0.000001,
326
- 500,
327
- 5,
328
- false
329
- );
330
- assert.approximately(angles.start, 2 * Math.PI - 0.000001, 0.000005);
331
- assert.approximately(angles.stop, 2 * Math.PI + 0.000001, 0.000005);
332
- assert.isTrue(angles.correspondToSamePoint);
333
- }
334
- }
335
- });
336
- test('start/stop both close to zero, start > stop', function() {
337
- var i, j, angles;
338
- for (i = -2; i <= 2; i++) {
339
- for (j = -2; j <= 2; j++) {
340
- angles = myp5._normalizeArcAngles(
341
- 2 * Math.PI * i + 0.000001,
342
- 2 * Math.PI * j - 0.000001,
343
- 500,
344
- 5,
345
- false
346
- );
347
- assert.approximately(angles.start, 0.000001, 0.000005);
348
- assert.approximately(angles.stop, 2 * Math.PI - 0.000001, 0.000005);
349
- assert.isTrue(angles.correspondToSamePoint);
350
- }
351
- }
352
- });
353
- test('start/stop both close to same non-zero, start < stop', function() {
354
- var i, j, angles;
355
- for (i = -2; i <= 2; i++) {
356
- for (j = -2; j <= 2; j++) {
357
- angles = myp5._normalizeArcAngles(
358
- 2 * Math.PI * i + 0.999999,
359
- 2 * Math.PI * j + 1.000001,
360
- 500,
361
- 5,
362
- false
363
- );
364
- assert.approximately(angles.start, 0.999999, 0.000005);
365
- assert.approximately(angles.stop, 1.000001, 0.000005);
366
- assert.isTrue(angles.correspondToSamePoint);
367
- }
368
- }
369
- });
370
- test('start/stop both close to same non-zero, start > stop', function() {
371
- var i, j, angles;
372
- for (i = -2; i <= 2; i++) {
373
- for (j = -2; j <= 2; j++) {
374
- angles = myp5._normalizeArcAngles(
375
- 2 * Math.PI * i + 1.000001,
376
- 2 * Math.PI * j + 0.999999,
377
- 500,
378
- 5,
379
- false
380
- );
381
- assert.approximately(angles.start, 1.000001, 0.000005);
382
- assert.approximately(angles.stop, 2 * Math.PI + 0.999999, 0.000005);
383
- assert.isTrue(angles.correspondToSamePoint);
384
- }
385
- }
386
- });
387
- test('start/stop around zero but not close, start < stop', function() {
388
- var i, j, angles;
389
- for (i = -2; i <= 2; i++) {
390
- for (j = -2; j <= 2; j++) {
391
- angles = myp5._normalizeArcAngles(
392
- 2 * Math.PI * i - 0.1,
393
- 2 * Math.PI * j + 0.1,
394
- 500,
395
- 5,
396
- false
397
- );
398
- assert.approximately(angles.start, 2 * Math.PI - 0.1, 0.000005);
399
- assert.approximately(angles.stop, 2 * Math.PI + 0.1, 0.000005);
400
- assert.isFalse(angles.correspondToSamePoint);
401
- }
402
- }
403
- });
404
- test('start/stop around zero but not close, start > stop', function() {
405
- var i, j, angles;
406
- for (i = -2; i <= 2; i++) {
407
- for (j = -2; j <= 2; j++) {
408
- angles = myp5._normalizeArcAngles(
409
- 2 * Math.PI * i + 0.1,
410
- 2 * Math.PI * j - 0.1,
411
- 500,
412
- 5,
413
- false
414
- );
415
- assert.approximately(angles.start, 0.1, 0.000005);
416
- assert.approximately(angles.stop, 2 * Math.PI - 0.1, 0.000005);
417
- assert.isFalse(angles.correspondToSamePoint);
418
- }
419
- }
420
- });
421
- test('start/stop away from zero and not close, start < stop', function() {
422
- var i, j, angles;
423
- for (i = -2; i <= 2; i++) {
424
- for (j = -2; j <= 2; j++) {
425
- angles = myp5._normalizeArcAngles(
426
- 2 * Math.PI * i + 0.9,
427
- 2 * Math.PI * j + 1.1,
428
- 500,
429
- 5,
430
- false
431
- );
432
- assert.approximately(angles.start, 0.9, 0.000005);
433
- assert.approximately(angles.stop, 1.1, 0.000005);
434
- assert.isFalse(angles.correspondToSamePoint);
435
- }
436
- }
437
- });
438
- test('start/stop away from zero and not close, start > stop', function() {
439
- var i, j, angles;
440
- for (i = -2; i <= 2; i++) {
441
- for (j = -2; j <= 2; j++) {
442
- angles = myp5._normalizeArcAngles(
443
- 2 * Math.PI * i + 1.1,
444
- 2 * Math.PI * j + 0.9,
445
- 500,
446
- 5,
447
- false
448
- );
449
- assert.approximately(angles.start, 1.1, 0.000005);
450
- assert.approximately(angles.stop, 2 * Math.PI + 0.9, 0.000005);
451
- assert.isFalse(angles.correspondToSamePoint);
452
- }
453
- }
454
- });
455
- test('scaling correction, quadrants 1 and 3', function() {
456
- var i, j, angles;
457
- for (i = -2; i <= 2; i++) {
458
- for (j = -2; j <= 2; j++) {
459
- angles = myp5._normalizeArcAngles(
460
- 2 * Math.PI * (i + 40 / 360),
461
- 2 * Math.PI * (j + 230 / 360),
462
- 500,
463
- 5,
464
- true
465
- );
466
- assert.approximately(angles.start, 1.558879, 0.000005);
467
- assert.approximately(angles.stop, 4.703998, 0.000005);
468
- assert.isFalse(angles.correspondToSamePoint);
469
- }
470
- }
471
- });
472
- test('scaling correction, quadrants 2 and 4', function() {
473
- var i, j, angles;
474
- for (i = -2; i <= 2; i++) {
475
- for (j = -2; j <= 2; j++) {
476
- angles = myp5._normalizeArcAngles(
477
- 2 * Math.PI * (i + 320 / 360),
478
- 2 * Math.PI * (j + 130 / 360),
479
- 500,
480
- 5,
481
- true
482
- );
483
- assert.approximately(angles.start, 4.724306, 0.000005);
484
- assert.approximately(angles.stop, 7.862372, 0.000005);
485
- assert.isFalse(angles.correspondToSamePoint);
486
- }
487
- }
488
- });
489
- });
490
- });
@@ -1,115 +0,0 @@
1
- suite('Attributes', 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.ellipseMode', function() {
18
- test('should be a function', function() {
19
- assert.ok(myp5.ellipseMode);
20
- assert.typeOf(myp5.ellipseMode, 'function');
21
- });
22
- test('missing param #0', function() {
23
- assert.validationError(function() {
24
- myp5.ellipseMode();
25
- });
26
- });
27
- test('wrong param type at #0', function() {
28
- assert.validationError(function() {
29
- myp5.ellipseMode(myp5.BEVEL);
30
- });
31
- });
32
- test('wrong param type at #0', function() {
33
- assert.validationError(function() {
34
- myp5.ellipseMode(20);
35
- });
36
- });
37
- });
38
-
39
- suite('p5.prototype.rectMode', function() {
40
- test('should be a function', function() {
41
- assert.ok(myp5.rectMode);
42
- assert.typeOf(myp5.rectMode, 'function');
43
- });
44
- test('wrong param type at #0', function() {
45
- assert.validationError(function() {
46
- myp5.rectMode(myp5.MITER);
47
- });
48
- });
49
- test('wrong param type at #0', function() {
50
- assert.validationError(function() {
51
- myp5.rectMode(64);
52
- });
53
- });
54
- });
55
-
56
- suite('p5.prototype.noSmooth', function() {
57
- test('should be a function', function() {
58
- assert.ok(myp5.noSmooth);
59
- assert.typeOf(myp5.noSmooth, 'function');
60
- });
61
- });
62
-
63
- suite('p5.prototype.smooth', function() {
64
- test('should be a function', function() {
65
- assert.ok(myp5.smooth);
66
- assert.typeOf(myp5.smooth, 'function');
67
- });
68
- });
69
-
70
- suite('p5.prototype.strokeCap', function() {
71
- test('should be a function', function() {
72
- assert.ok(myp5.strokeCap);
73
- assert.typeOf(myp5.strokeCap, 'function');
74
- });
75
- test('wrong param type at #0', function() {
76
- assert.validationError(function() {
77
- myp5.strokeCap(myp5.CORNER);
78
- });
79
- });
80
- test('wrong param type at #0', function() {
81
- assert.validationError(function() {
82
- myp5.strokeCap(40);
83
- });
84
- });
85
- });
86
-
87
- suite('p5.prototype.strokeJoin', function() {
88
- test('should be a function', function() {
89
- assert.ok(myp5.strokeJoin);
90
- assert.typeOf(myp5.strokeJoin, 'function');
91
- });
92
- test('wrong param type at #0', function() {
93
- assert.validationError(function() {
94
- myp5.strokeJoin(myp5.CORNER);
95
- });
96
- });
97
- test('wrong param type at #0', function() {
98
- assert.validationError(function() {
99
- myp5.strokeJoin(35);
100
- });
101
- });
102
- });
103
-
104
- suite('p5.prototype.strokeWeight', function() {
105
- test('should be a function', function() {
106
- assert.ok(myp5.strokeWeight);
107
- assert.typeOf(myp5.strokeWeight, 'function');
108
- });
109
- test('wrong param type at #0', function() {
110
- assert.validationError(function() {
111
- myp5.strokeWeight('a');
112
- });
113
- });
114
- });
115
- });