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,329 +0,0 @@
1
- suite('Conversion', 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
- var result;
18
-
19
- suite('p5.prototype.float', function() {
20
- test('should be a function', function() {
21
- assert.ok(myp5.float);
22
- assert.typeOf(myp5.float, 'function');
23
- });
24
-
25
- test('should convert a string to its floating point representation', function() {
26
- result = myp5.float('56.99998');
27
- assert.typeOf(result, 'Number');
28
- assert.strictEqual(result, 56.99998);
29
- });
30
-
31
- test('should return NaN for invalid string', function() {
32
- result = myp5.float('cat');
33
- assert.isNaN(result);
34
- });
35
-
36
- test('should return Infinity for Infinity', function() {
37
- result = myp5.float(Infinity);
38
- assert.strictEqual(result, Infinity);
39
- });
40
-
41
- test('should return -Infinity for -Infinity', function() {
42
- result = myp5.float(-Infinity);
43
- assert.strictEqual(result, -Infinity);
44
- });
45
-
46
- test('should return array of floating points and Nan', function() {
47
- result = myp5.float(['1', '2.0', '3.1', 'giraffe']);
48
- assert.typeOf(result, 'Array');
49
- assert.deepEqual(result, [1, 2.0, 3.1, NaN]);
50
- });
51
- });
52
-
53
- suite('p5.prototype.int', function() {
54
- test('should be a function', function() {
55
- assert.ok(myp5.int);
56
- assert.typeOf(myp5.int, 'function');
57
- });
58
-
59
- test('should convert false to its integer representation i.e. 0', function() {
60
- result = myp5.int(false);
61
- assert.typeOf(result, 'Number');
62
- assert.strictEqual(result, 0);
63
- });
64
-
65
- test('should convert true to its integer representation i.e. 1', function() {
66
- result = myp5.int(true);
67
- assert.strictEqual(result, 1);
68
- });
69
-
70
- test('should convert a string to its integer representation', function() {
71
- result = myp5.int('1001');
72
- assert.strictEqual(result, 1001);
73
- });
74
-
75
- test('should return NaN for invalid string', function() {
76
- result = myp5.int('cat');
77
- assert.isNaN(result);
78
- });
79
-
80
- test('should return Infinity for Infinity', function() {
81
- result = myp5.int(Infinity);
82
- assert.strictEqual(result, Infinity);
83
- });
84
-
85
- test('should return -Infinity for -Infinity', function() {
86
- result = myp5.int(-Infinity);
87
- assert.strictEqual(result, -Infinity);
88
- });
89
-
90
- test('should convert float to its integer representation', function() {
91
- result = myp5.int('-1001.9');
92
- assert.strictEqual(result, -1001);
93
- });
94
-
95
- test('should return array of integers and NaN', function() {
96
- result = myp5.int(['1', '2.3', '-3.5', 'giraffe', false, 4.7]);
97
- assert.typeOf(result, 'Array');
98
- assert.deepEqual(result, [1, 2, -3, NaN, 0, 4]);
99
- });
100
- });
101
-
102
- suite('p5.prototype.str', function() {
103
- test('should be a function', function() {
104
- assert.ok(myp5.str);
105
- assert.typeOf(myp5.str, 'function');
106
- });
107
-
108
- test('should convert false to string', function() {
109
- result = myp5.str(false);
110
- assert.typeOf(result, 'String');
111
- assert.strictEqual(result, 'false');
112
- });
113
-
114
- test('should convert true to string', function() {
115
- result = myp5.str(true);
116
- assert.strictEqual(result, 'true');
117
- });
118
-
119
- test('should convert a number to string', function() {
120
- result = myp5.str(45);
121
- assert.strictEqual(result, '45');
122
- });
123
-
124
- test('should return array of strings', function() {
125
- result = myp5.str([1, 2.3, true, -4.5]);
126
- assert.typeOf(result, 'Array');
127
- assert.deepEqual(result, ['1', '2.3', 'true', '-4.5']);
128
- });
129
- });
130
-
131
- suite('p5.prototype.boolean', function() {
132
- test('should be a function', function() {
133
- assert.ok(myp5.boolean);
134
- assert.typeOf(myp5.boolean, 'function');
135
- });
136
-
137
- test('should convert 1 to true', function() {
138
- result = myp5.boolean(1);
139
- assert.strictEqual(result, true);
140
- });
141
-
142
- test('should convert a number to true', function() {
143
- result = myp5.boolean(154);
144
- assert.strictEqual(result, true);
145
- });
146
-
147
- test('should return true for Infinity', function() {
148
- result = myp5.boolean(Infinity);
149
- assert.strictEqual(result, true);
150
- });
151
-
152
- test('should convert 0 to false', function() {
153
- result = myp5.boolean(0);
154
- assert.strictEqual(result, false);
155
- });
156
-
157
- test('should convert a string to false', function() {
158
- result = myp5.boolean('1');
159
- assert.strictEqual(result, false);
160
- });
161
-
162
- test('should convert a string to false', function() {
163
- result = myp5.boolean('0');
164
- assert.strictEqual(result, false);
165
- });
166
-
167
- test('should convert "true" to true', function() {
168
- result = myp5.boolean('true');
169
- assert.strictEqual(result, true);
170
- });
171
-
172
- test('should return false for empty string', function() {
173
- result = myp5.boolean('');
174
- assert.strictEqual(result, false);
175
- });
176
-
177
- test('should return array of boolean', function() {
178
- result = myp5.boolean([1, true, -4.5, Infinity, 'cat', '23']);
179
- assert.typeOf(result, 'Array');
180
- assert.deepEqual(result, [true, true, true, true, false, false]);
181
- });
182
- });
183
-
184
- suite('p5.prototype.byte', function() {
185
- test('should be a function', function() {
186
- assert.ok(myp5.byte);
187
- assert.typeOf(myp5.byte, 'function');
188
- });
189
-
190
- test('should return 127 for 127', function() {
191
- result = myp5.byte(127);
192
- assert.strictEqual(result, 127);
193
- });
194
-
195
- test('should return -128 for 128', function() {
196
- result = myp5.byte(128);
197
- assert.strictEqual(result, -128);
198
- });
199
-
200
- test('should return 23 for 23.4', function() {
201
- result = myp5.byte(23.4);
202
- assert.strictEqual(result, 23);
203
- });
204
-
205
- test('should return 1 for true', function() {
206
- result = myp5.byte(true);
207
- assert.strictEqual(result, 1);
208
- });
209
-
210
- test('should return 23 for "23.4"', function() {
211
- result = myp5.byte('23.4');
212
- assert.strictEqual(result, 23);
213
- });
214
-
215
- test('should return NaN for invalid string', function() {
216
- result = myp5.byte('cat');
217
- assert.isNaN(result);
218
- });
219
-
220
- test('should return array', function() {
221
- result = myp5.byte([0, 255, '100']);
222
- assert.typeOf(result, 'Array');
223
- assert.deepEqual(result, [0, -1, 100]);
224
- });
225
- });
226
-
227
- suite('p5.prototype.char', function() {
228
- test('should be a function', function() {
229
- assert.ok(myp5.char);
230
- assert.typeOf(myp5.char, 'function');
231
- });
232
-
233
- test('should return the char representation of the number', function() {
234
- result = myp5.char(65);
235
- assert.typeOf(result, 'String');
236
- assert.strictEqual(result, 'A');
237
- });
238
-
239
- test('should return the char representation of the string', function() {
240
- result = myp5.char('65');
241
- assert.strictEqual(result, 'A');
242
- });
243
-
244
- test('should return array', function() {
245
- result = myp5.char([65, 66, '67']);
246
- assert.typeOf(result, 'Array');
247
- assert.deepEqual(result, ['A', 'B', 'C']);
248
- });
249
- });
250
-
251
- suite('p5.prototype.unchar', function() {
252
- test('should be a function', function() {
253
- assert.ok(myp5.unchar);
254
- assert.typeOf(myp5.unchar, 'function');
255
- });
256
-
257
- test('should return the integer representation of char', function() {
258
- result = myp5.unchar('A');
259
- assert.typeOf(result, 'Number');
260
- assert.strictEqual(result, 65);
261
- });
262
-
263
- test('should return array of numbers', function() {
264
- result = myp5.unchar(['A', 'B', 'C']);
265
- assert.typeOf(result, 'Array');
266
- assert.deepEqual(result, [65, 66, 67]);
267
- });
268
- });
269
-
270
- suite('p5.prototype.hex', function() {
271
- test('should be a function', function() {
272
- assert.ok(myp5.hex);
273
- assert.typeOf(myp5.hex, 'function');
274
- });
275
-
276
- test('should return the hex representation of the number', function() {
277
- result = myp5.hex(65);
278
- assert.typeOf(result, 'String');
279
- assert.strictEqual(result, '00000041');
280
- });
281
-
282
- test('should return FFFFFFFF for Infinity', function() {
283
- result = myp5.hex(Infinity);
284
- assert.typeOf(result, 'String');
285
- assert.strictEqual(result, 'FFFFFFFF');
286
- });
287
-
288
- test('should return 00000000 for -Infinity', function() {
289
- result = myp5.hex(-Infinity);
290
- assert.typeOf(result, 'String');
291
- assert.strictEqual(result, '00000000');
292
- });
293
-
294
- test('should return array', function() {
295
- result = myp5.hex([65, 66, 67]);
296
- assert.typeOf(result, 'Array');
297
- assert.deepEqual(result, ['00000041', '00000042', '00000043']);
298
- });
299
- });
300
-
301
- suite('p5.prototype.unhex', function() {
302
- test('should be a function', function() {
303
- assert.ok(myp5.unhex);
304
- assert.typeOf(myp5.unchar, 'function');
305
- });
306
-
307
- test('should return the integer representation of hex', function() {
308
- result = myp5.unhex('00000041');
309
- assert.typeOf(result, 'Number');
310
- assert.strictEqual(result, 65);
311
- });
312
-
313
- test('should return the NaN for empty string', function() {
314
- result = myp5.unhex('');
315
- assert.isNaN(result);
316
- });
317
-
318
- test.skip('should return the NaN for invalid hex string', function() {
319
- result = myp5.unhex('cat');
320
- assert.isNaN(result);
321
- });
322
-
323
- test('should return array of numbers', function() {
324
- result = myp5.unhex(['00000041', '00000042', '00000043']);
325
- assert.typeOf(result, 'Array');
326
- assert.deepEqual(result, [65, 66, 67]);
327
- });
328
- });
329
- });
@@ -1,133 +0,0 @@
1
- suite('time and date', 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
- var result;
18
-
19
- suite('p5.prototype.year', function() {
20
- test('should be a function', function() {
21
- assert.ok(myp5.year);
22
- assert.typeOf(myp5.year, 'function');
23
- });
24
-
25
- test('should return this year', function() {
26
- result = myp5.year();
27
- var jsYear = new Date().getFullYear();
28
- assert.equal(result, jsYear);
29
- });
30
- });
31
-
32
- suite('p5.prototype.day', function() {
33
- test('should be a function', function() {
34
- assert.ok(myp5.day);
35
- assert.typeOf(myp5.day, 'function');
36
- });
37
-
38
- test('should return todays day', function() {
39
- var jsDay = new Date().getDate();
40
- result = myp5.day();
41
- assert.equal(result, jsDay);
42
- });
43
- });
44
-
45
- suite('p5.prototype.month', function() {
46
- test('should be a function', function() {
47
- assert.ok(myp5.month);
48
- assert.typeOf(myp5.month, 'function');
49
- });
50
-
51
- test("should return today's month", function() {
52
- result = myp5.month();
53
- var jsMonth = new Date().getMonth() + 1;
54
- assert.equal(result, jsMonth);
55
- });
56
- });
57
-
58
- suite('p5.prototype.hour', function() {
59
- test('should be a function', function() {
60
- assert.ok(myp5.hour);
61
- assert.typeOf(myp5.hour, 'function');
62
- });
63
-
64
- test('should return this hour', function() {
65
- var jsHour = new Date().getHours();
66
- result = myp5.hour();
67
- assert.equal(result, jsHour);
68
- });
69
- });
70
-
71
- suite('p5.prototype.second', function() {
72
- test('should be a function', function() {
73
- assert.ok(myp5.second);
74
- assert.typeOf(myp5.second, 'function');
75
- });
76
-
77
- test('should return this second', function() {
78
- var jsSecond = new Date().getSeconds();
79
- result = myp5.second();
80
- assert.equal(result, jsSecond); //(Math.abs(jsSecond - result), '==', 0, 'everything is ok'); // in my testing, found this might be off by 1 second
81
- });
82
- });
83
-
84
- suite('p5.prototype.minute', function() {
85
- test('should be a function', function() {
86
- assert.ok(myp5.minute);
87
- assert.typeOf(myp5.minute, 'function');
88
- });
89
-
90
- test('should return a number that is this minute', function() {
91
- var jsMinute = new Date().getMinutes();
92
- result = myp5.minute();
93
- assert.isNumber(result);
94
- assert.isNumber(jsMinute);
95
- assert.equal(result, jsMinute);
96
- });
97
- });
98
-
99
- suite('p5.prototype.millis', function() {
100
- test('should be a function', function() {
101
- assert.ok(myp5.millis);
102
- assert.typeOf(myp5.millis, 'function');
103
- });
104
-
105
- test('result should be a number', function() {
106
- assert.isNumber(myp5.millis());
107
- });
108
-
109
- test('result should be greater than running time', function() {
110
- var runningTime = 50;
111
- var init_date = window.performance.now();
112
- // wait :\
113
- while (window.performance.now() - init_date <= runningTime) {
114
- /* no-op */
115
- }
116
- assert.operator(myp5.millis(), '>', runningTime, 'everything is ok');
117
- });
118
-
119
- test('result should be > newResult', function() {
120
- var runningTime = 50;
121
- var init_date = Date.now();
122
- var result = myp5.millis();
123
- // wait :\
124
- while (Date.now() - init_date <= runningTime) {
125
- /* no-op */
126
- }
127
- var newResult = myp5.millis();
128
- assert.operator(newResult, '>', result, 'everything is ok');
129
- });
130
- });
131
-
132
- forceError();
133
- });