q5 2.10.6 → 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 (72) 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 +20 -11
  6. package/q5.min.js +1 -1
  7. package/src/q5-2d-drawing.js +2 -2
  8. package/src/q5-canvas.js +14 -8
  9. package/src/q5-input.js +1 -1
  10. package/src/q5-webgpu-canvas.js +3 -0
  11. package/test/core.test.js +33 -0
  12. package/test/readme.md +5 -0
  13. package/.vscode/launch.json +0 -26
  14. package/.vscode/settings.json +0 -3
  15. package/bun.lockb +0 -0
  16. package/p5-tests/js/chai_helpers.js +0 -20
  17. package/p5-tests/js/mocha_setup.js +0 -2
  18. package/p5-tests/js/modernizr.js +0 -5
  19. package/p5-tests/js/p5_helpers.js +0 -135
  20. package/p5-tests/js/sinon.js +0 -5949
  21. package/p5-tests/mocha.css +0 -289
  22. package/p5-tests/test.html +0 -71
  23. package/p5-tests/unit/color/color_conversion.js +0 -68
  24. package/p5-tests/unit/color/creating_reading.js +0 -217
  25. package/p5-tests/unit/color/p5.Color.js +0 -1000
  26. package/p5-tests/unit/color/setting.js +0 -289
  27. package/p5-tests/unit/core/2d_primitives.js +0 -490
  28. package/p5-tests/unit/core/attributes.js +0 -115
  29. package/p5-tests/unit/core/curves.js +0 -139
  30. package/p5-tests/unit/core/environment.js +0 -248
  31. package/p5-tests/unit/core/error_helpers.js +0 -1158
  32. package/p5-tests/unit/core/main.js +0 -340
  33. package/p5-tests/unit/core/p5.Element.js +0 -773
  34. package/p5-tests/unit/core/p5.Graphics.js +0 -179
  35. package/p5-tests/unit/core/preload.js +0 -285
  36. package/p5-tests/unit/core/rendering.js +0 -116
  37. package/p5-tests/unit/core/structure.js +0 -293
  38. package/p5-tests/unit/core/transform.js +0 -144
  39. package/p5-tests/unit/core/version.js +0 -28
  40. package/p5-tests/unit/core/vertex.js +0 -137
  41. package/p5-tests/unit/dom/dom.js +0 -2146
  42. package/p5-tests/unit/events/acceleration.js +0 -213
  43. package/p5-tests/unit/events/keyboard.js +0 -179
  44. package/p5-tests/unit/events/mouse.js +0 -487
  45. package/p5-tests/unit/events/touch.js +0 -180
  46. package/p5-tests/unit/image/downloading.js +0 -379
  47. package/p5-tests/unit/image/filters.js +0 -92
  48. package/p5-tests/unit/image/loading.js +0 -413
  49. package/p5-tests/unit/image/p5.Image.js +0 -201
  50. package/p5-tests/unit/image/pixels.js +0 -234
  51. package/p5-tests/unit/io/files.js +0 -378
  52. package/p5-tests/unit/io/loadBytes.js +0 -149
  53. package/p5-tests/unit/io/loadImage.js +0 -123
  54. package/p5-tests/unit/io/loadJSON.js +0 -185
  55. package/p5-tests/unit/io/loadModel.js +0 -215
  56. package/p5-tests/unit/io/loadShader.js +0 -176
  57. package/p5-tests/unit/io/loadStrings.js +0 -140
  58. package/p5-tests/unit/io/loadTable.js +0 -183
  59. package/p5-tests/unit/io/loadXML.js +0 -127
  60. package/p5-tests/unit/io/saveModel.js +0 -113
  61. package/p5-tests/unit/io/saveTable.js +0 -142
  62. package/p5-tests/unit/math/calculation.js +0 -452
  63. package/p5-tests/unit/math/noise.js +0 -66
  64. package/p5-tests/unit/math/p5.Vector.js +0 -1886
  65. package/p5-tests/unit/math/random.js +0 -177
  66. package/p5-tests/unit/math/trigonometry.js +0 -144
  67. package/p5-tests/unit/spec.js +0 -50
  68. package/p5-tests/unit/typography/attributes.js +0 -120
  69. package/p5-tests/unit/typography/loadFont.js +0 -162
  70. package/p5-tests/unit/typography/p5.Font.js +0 -63
  71. package/p5-tests/unit/utilities/conversion.js +0 -329
  72. package/p5-tests/unit/utilities/time_date.js +0 -133
@@ -1,289 +0,0 @@
1
- suite('color/Setting', function() {
2
- let myp5; // sketch without WEBGL Mode
3
- let my3D; // sketch with WEBGL mode
4
- setup(function(done) {
5
- new p5(function(p) {
6
- p.setup = function() {
7
- myp5 = p;
8
- };
9
- });
10
- new p5(function(p) {
11
- p.setup = function() {
12
- p.createCanvas(100, 100, p.WEBGL);
13
- my3D = p;
14
- };
15
- });
16
- done();
17
- });
18
-
19
- teardown(function() {
20
- myp5.remove();
21
- my3D.remove();
22
- });
23
-
24
- suite('p5.prototype.erase', function() {
25
- test('should be a function', function() {
26
- assert.ok(myp5.erase);
27
- });
28
-
29
- test('should set renderer to erasing state', function() {
30
- myp5.erase();
31
- assert.isTrue(myp5._renderer._isErasing);
32
- });
33
-
34
- test('should cache renderer fill', function() {
35
- myp5.fill(255, 0, 0);
36
- const fillStyle = myp5.drawingContext.fillStyle;
37
- myp5.erase();
38
- assert.deepEqual(myp5._renderer._cachedFillStyle, fillStyle);
39
- });
40
-
41
- test('should cache renderer stroke', function() {
42
- myp5.stroke(255, 0, 0);
43
- const strokeStyle = myp5.drawingContext.strokeStyle;
44
- myp5.erase();
45
- assert.deepEqual(myp5._renderer._cachedStrokeStyle, strokeStyle);
46
- });
47
-
48
- test('should cache renderer blend', function() {
49
- myp5.blendMode(myp5.SCREEN);
50
- myp5.erase();
51
- assert.deepEqual(myp5._renderer._cachedBlendMode, myp5.SCREEN);
52
- });
53
-
54
- test('should set fill strength', function() {
55
- myp5.erase(125);
56
- assert.equal(
57
- myp5.color(myp5.drawingContext.fillStyle).array,
58
- myp5.color(255, 125).array
59
- );
60
- });
61
-
62
- test('should set stroke strength', function() {
63
- myp5.erase(255, 50);
64
- assert.equal(
65
- myp5.color(myp5.drawingContext.strokeStyle).array,
66
- myp5.color(255, 50).array
67
- );
68
- });
69
- });
70
-
71
- suite('p5.RendererGL.prototype.erase', function() {
72
- test('should set renderer to erasing state', function() {
73
- my3D.erase();
74
- assert.isTrue(my3D._renderer._isErasing);
75
- });
76
-
77
- test('should cache renderer fill', function() {
78
- my3D.fill(255, 0, 0);
79
- const curFillColor = my3D._renderer.curFillColor;
80
- my3D.erase();
81
- assert.deepEqual(my3D._renderer._cachedFillStyle, curFillColor);
82
- });
83
-
84
- test('should cache renderer stroke', function() {
85
- my3D.stroke(255, 0, 0);
86
- const strokeStyle = my3D._renderer.curStrokeColor;
87
- my3D.erase();
88
- assert.deepEqual(my3D._renderer._cachedStrokeStyle, strokeStyle);
89
- });
90
-
91
- test('should cache renderer blend', function() {
92
- my3D.blendMode(my3D.SCREEN);
93
- my3D.erase();
94
- assert.deepEqual(my3D._renderer.preEraseBlend, my3D.SCREEN);
95
- });
96
-
97
- test('should set fill strength', function() {
98
- my3D.erase(125);
99
- assert.deepEqual(my3D._renderer.curFillColor, [1, 1, 1, 125 / 255]);
100
- });
101
-
102
- test('should set stroke strength', function() {
103
- my3D.erase(255, 50);
104
- assert.deepEqual(my3D._renderer.curStrokeColor, [1, 1, 1, 50 / 255]);
105
- });
106
-
107
- test('should set default values when no arguments', function() {
108
- my3D.erase();
109
- assert.deepEqual(my3D._renderer.curFillColor, [1, 1, 1, 1]);
110
- assert.deepEqual(my3D._renderer.curStrokeColor, [1, 1, 1, 1]);
111
- });
112
- });
113
-
114
- suite('p5.prototype.noErase', function() {
115
- test('should be a function', function() {
116
- assert.ok(myp5.noErase);
117
- });
118
-
119
- test('should turn off renderer erasing state', function() {
120
- myp5.erase();
121
- myp5.noErase();
122
- assert.isFalse(myp5._renderer._isErasing);
123
- });
124
-
125
- test('should restore cached renderer fill', function() {
126
- myp5.fill(255, 0, 0);
127
- const fillStyle = myp5.drawingContext.fillStyle;
128
- myp5.erase();
129
- myp5.noErase();
130
- assert.deepEqual(myp5.drawingContext.fillStyle, fillStyle);
131
- });
132
-
133
- test('should restore cached renderer stroke', function() {
134
- myp5.stroke(255, 0, 0);
135
- const strokeStyle = myp5.drawingContext.strokeStyle;
136
- myp5.erase();
137
- myp5.noErase();
138
- assert.deepEqual(myp5.drawingContext.strokeStyle, strokeStyle);
139
- });
140
- });
141
-
142
- suite('p5.RendererGL.prototype.noErase', function() {
143
- test('should turn off renderer erasing state', function() {
144
- my3D.erase();
145
- my3D.noErase();
146
- assert.isFalse(my3D._renderer._isErasing);
147
- });
148
-
149
- test('should restore cached renderer fill', function() {
150
- my3D.fill(255, 0, 0);
151
- const fillStyle = my3D._renderer.curFillColor.slice();
152
- my3D.erase();
153
- my3D.noErase();
154
- assert.deepEqual([1, 0, 0, 1], fillStyle);
155
- });
156
-
157
- test('should restore cached renderer stroke', function() {
158
- my3D.stroke(255, 0, 0);
159
- const strokeStyle = my3D._renderer.curStrokeColor.slice();
160
- my3D.erase();
161
- my3D.noErase();
162
- assert.deepEqual([1, 0, 0, 1], strokeStyle);
163
- });
164
- });
165
-
166
- suite('p5.prototype.colorMode', function() {
167
- test('should be a function', function() {
168
- assert.ok(myp5.colorMode);
169
- });
170
-
171
- test('should set mode to RGB', function() {
172
- myp5.colorMode(myp5.RGB);
173
- assert.equal(myp5._colorMode, myp5.RGB);
174
- });
175
-
176
- test('should correctly set color RGB maxes', function() {
177
- assert.deepEqual(myp5._colorMaxes[myp5.RGB], [255, 255, 255, 255]);
178
- myp5.colorMode(myp5.RGB, 1, 1, 1);
179
- assert.deepEqual(myp5._colorMaxes[myp5.RGB], [1, 1, 1, 255]);
180
- myp5.colorMode(myp5.RGB, 1);
181
- assert.deepEqual(myp5._colorMaxes[myp5.RGB], [1, 1, 1, 1]);
182
- myp5.colorMode(myp5.RGB, 255, 255, 255, 1);
183
- assert.deepEqual(myp5._colorMaxes[myp5.RGB], [255, 255, 255, 1]);
184
- myp5.colorMode(myp5.RGB, 255);
185
- });
186
-
187
- test('should set mode to HSL', function() {
188
- myp5.colorMode(myp5.HSL);
189
- assert.equal(myp5._colorMode, myp5.HSL);
190
- });
191
-
192
- test('should correctly set color HSL maxes', function() {
193
- assert.deepEqual(myp5._colorMaxes[myp5.HSL], [360, 100, 100, 1]);
194
- myp5.colorMode(myp5.HSL, 255, 255, 255);
195
- assert.deepEqual(myp5._colorMaxes[myp5.HSL], [255, 255, 255, 1]);
196
- myp5.colorMode(myp5.HSL, 360);
197
- assert.deepEqual(myp5._colorMaxes[myp5.HSL], [360, 360, 360, 360]);
198
- myp5.colorMode(myp5.HSL, 360, 100, 100, 1);
199
- assert.deepEqual(myp5._colorMaxes[myp5.HSL], [360, 100, 100, 1]);
200
- });
201
-
202
- test('should set mode to HSB', function() {
203
- myp5.colorMode(myp5.HSB);
204
- assert.equal(myp5._colorMode, myp5.HSB);
205
- });
206
-
207
- test('should correctly set color HSB maxes', function() {
208
- assert.deepEqual(myp5._colorMaxes[myp5.HSB], [360, 100, 100, 1]);
209
- myp5.colorMode(myp5.HSB, 255, 255, 255);
210
- assert.deepEqual(myp5._colorMaxes[myp5.HSB], [255, 255, 255, 1]);
211
- myp5.colorMode(myp5.HSB, 360);
212
- assert.deepEqual(myp5._colorMaxes[myp5.HSB], [360, 360, 360, 360]);
213
- myp5.colorMode(myp5.HSB, 360, 100, 100, 1);
214
- assert.deepEqual(myp5._colorMaxes[myp5.HSB], [360, 100, 100, 1]);
215
- });
216
- });
217
-
218
- suite('p5.Color components', function() {
219
- test('setRed() correctly sets red component', function() {
220
- myp5.colorMode(myp5.RGB, 255);
221
- const c = myp5.color(0, 162, 205, 255);
222
- c.setRed(100);
223
- assert.equal(myp5.red(c), 100);
224
- assert.equal(myp5.green(c), 162);
225
- assert.equal(myp5.blue(c), 205);
226
- assert.equal(myp5.alpha(c), 255);
227
- });
228
-
229
- test('setGreen() correctly sets green component', function() {
230
- myp5.colorMode(myp5.RGB, 255);
231
- const c = myp5.color(0, 162, 205, 255);
232
- c.setGreen(100);
233
- assert.equal(myp5.red(c), 0);
234
- assert.equal(myp5.green(c), 100);
235
- assert.equal(myp5.blue(c), 205);
236
- assert.equal(myp5.alpha(c), 255);
237
- });
238
-
239
- test('setBlue() correctly sets blue component', function() {
240
- myp5.colorMode(myp5.RGB, 255);
241
- const c = myp5.color(0, 162, 205, 255);
242
- c.setBlue(100);
243
- assert.equal(myp5.red(c), 0);
244
- assert.equal(myp5.green(c), 162);
245
- assert.equal(myp5.blue(c), 100);
246
- assert.equal(myp5.alpha(c), 255);
247
- });
248
-
249
- test('setAlpha correctly sets alpha component', function() {
250
- myp5.colorMode(myp5.RGB, 255);
251
- const c = myp5.color(0, 162, 205, 255);
252
- c.setAlpha(100);
253
- assert.equal(myp5.red(c), 0);
254
- assert.equal(myp5.green(c), 162);
255
- assert.equal(myp5.blue(c), 205);
256
- assert.equal(myp5.alpha(c), 100);
257
- });
258
-
259
- test('changing the red/green/blue/alpha components should clear the cached HSL/HSB values', function() {
260
- myp5.colorMode(myp5.RGB, 255);
261
- const c = myp5.color(0, 162, 205, 255);
262
-
263
- // create HSL/HSB values
264
- myp5.lightness(c);
265
- myp5.brightness(c);
266
- c.setRed(100);
267
- assert(!c.hsba);
268
- assert(!c.hsla);
269
-
270
- myp5.lightness(c);
271
- myp5.brightness(c);
272
- c.setGreen(100);
273
- assert(!c.hsba);
274
- assert(!c.hsla);
275
-
276
- myp5.lightness(c);
277
- myp5.brightness(c);
278
- c.setBlue(100);
279
- assert(!c.hsba);
280
- assert(!c.hsla);
281
-
282
- myp5.lightness(c);
283
- myp5.brightness(c);
284
- c.setAlpha(100);
285
- assert(!c.hsba);
286
- assert(!c.hsla);
287
- });
288
- });
289
- });