q5 3.4.0 → 3.5.0

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 (5) hide show
  1. package/deno.json +1 -1
  2. package/package.json +3 -3
  3. package/q5.d.ts +434 -334
  4. package/q5.js +18 -7
  5. package/q5.min.js +2 -2
package/q5.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * q5.d.ts
3
- *
3
+ *
4
4
  * TypeScript definitions for q5.js to use with IDEs like VSCode
5
5
  * for autocompletion, hover over documentation, and type checking.
6
6
  */
@@ -9,27 +9,76 @@ declare global {
9
9
 
10
10
  /** ⭐️
11
11
  * Welcome to q5's documentation! 🤩
12
- *
12
+ *
13
13
  * First time coding? Check out the [q5 Beginner's Brief](https://github.com/q5js/q5.js/wiki/q5-Beginner's-Brief).
14
- *
15
- * On these Learn pages, you can experiment with editing the
14
+ *
15
+ * On these Learn pages, you can experiment with editing the
16
16
  * interactive mini examples. Have fun! 😎
17
17
  */
18
18
 
19
19
  /** ⭐️
20
20
  * The draw function is run 60 times per second by default.
21
21
  * @example
22
- Q5.draw = function () {
22
+ function draw() {
23
23
  background('silver');
24
24
  circle(frameCount % 200, 100, 80);
25
25
  }
26
26
  */
27
27
  function draw(): void;
28
28
 
29
+ /** ⭐️
30
+ * The setup function is run once, when the program starts.
31
+ *
32
+ * It can also be defined as an async function and used to load assets.
33
+ * @example
34
+ function setup() {
35
+ createCanvas(200, 100);
36
+ background('aqua');
37
+ }
38
+ * @example
39
+ let logo;
40
+
41
+ async function setup() {
42
+ logo = await loadImage('/q5js_logo.avif');
43
+ }
44
+
45
+ function draw() {
46
+ background(logo);
47
+ }
48
+ */
49
+ function setup(): void;
50
+
51
+ /** ⭐️
52
+ * Load assets in the preload function to ensure that they'll be
53
+ * ready to use in the setup and draw functions.
54
+ *
55
+ * q5's preload system can also be used without a preload function
56
+ * if you create a canvas first, as shown in the second example.
57
+ * @example
58
+ let logo;
59
+
60
+ function preload() {
61
+ logo = loadImage('/q5js_logo.avif');
62
+ }
63
+
64
+ function draw() {
65
+ background(logo);
66
+ }
67
+ * @example
68
+ createCanvas(200, 100);
69
+
70
+ let logo = loadImage('/q5js_logo.avif');
71
+
72
+ function draw() {
73
+ background(logo);
74
+ }
75
+ */
76
+ function preload(): void;
77
+
29
78
  /** ⭐️
30
79
  * The number of frames that have been displayed since the program started.
31
80
  * @example
32
- Q5.draw = function () {
81
+ function draw() {
33
82
  background(200);
34
83
  textSize(64);
35
84
  text(frameCount, 8, 120);
@@ -40,7 +89,7 @@ Q5.draw = function () {
40
89
  /** ⭐️
41
90
  * Stops the draw loop.
42
91
  * @example
43
- Q5.draw = function () {
92
+ function draw() {
44
93
  circle(frameCount * 5, 100, 80);
45
94
  noLoop();
46
95
  }
@@ -54,13 +103,13 @@ Q5.draw = function () {
54
103
  * This is an async function.
55
104
  * @param {number} [n] number of times to redraw the canvas, default is 1
56
105
  * @example
57
- await createCanvas(200);
106
+ createCanvas(200);
58
107
  noLoop();
59
108
 
60
- Q5.draw = function () {
109
+ function draw() {
61
110
  circle(frameCount * 5, 100, 80);
62
111
  }
63
- Q5.mousePressed = function () {
112
+ function mousePressed() {
64
113
  redraw(10);
65
114
  }
66
115
  */
@@ -69,13 +118,13 @@ Q5.mousePressed = function () {
69
118
  /** ⭐️
70
119
  * Starts the draw loop again if it was stopped.
71
120
  * @example
72
- await createCanvas(200);
121
+ createCanvas(200);
73
122
  noLoop();
74
123
 
75
- Q5.draw = function () {
124
+ function draw() {
76
125
  circle(frameCount * 5, 100, 80);
77
126
  }
78
- Q5.mousePressed = function () {
127
+ function mousePressed() {
79
128
  loop();
80
129
  }
81
130
  */
@@ -91,7 +140,7 @@ Q5.mousePressed = function () {
91
140
  * @param {number} [hertz] target frame rate, default is 60
92
141
  * @returns {number} current frame rate
93
142
  * @example
94
- Q5.draw = function () {
143
+ function draw() {
95
144
  background(200);
96
145
 
97
146
  if (mouseIsPressed) frameRate(10);
@@ -100,7 +149,7 @@ Q5.draw = function () {
100
149
  circle(frameCount % 200, 100, 80);
101
150
  }
102
151
  * @example
103
- Q5.draw = function () {
152
+ function draw() {
104
153
  background(200);
105
154
  textSize(64);
106
155
  text(round(frameRate()), 65, 120);
@@ -112,7 +161,7 @@ Q5.draw = function () {
112
161
  * The desired frame rate of the sketch.
113
162
  * @returns {number} target frame rate
114
163
  * @example
115
- Q5.draw = function () {
164
+ function draw() {
116
165
  background(200);
117
166
  textSize(64);
118
167
 
@@ -129,7 +178,7 @@ Q5.draw = function () {
129
178
  * performance analysis.
130
179
  * @returns {number} frames per second
131
180
  * @example
132
- Q5.draw = function () {
181
+ function draw() {
133
182
  background(200);
134
183
  frameRate(1);
135
184
  textSize(64);
@@ -142,8 +191,8 @@ Q5.draw = function () {
142
191
  /** ⭐️
143
192
  * Logs a message to the JavaScript console. Alias for the standard
144
193
  * [`console.log`](https://developer.mozilla.org/docs/Web/API/console/log_static) function.
145
- *
146
- * You can open web developer tools in most browsers by using the
194
+ *
195
+ * You can open web developer tools in most browsers by using the
147
196
  * keyboard shortcut `Ctrl + Shift + i` or `command + option + i`,
148
197
  * then click the "Console" tab.
149
198
  * @param {*} message message to log
@@ -158,12 +207,12 @@ Q5.draw = function () {
158
207
  * addons like p5play that auto-draw to the canvas after the `draw`
159
208
  * function is run.
160
209
  * @example
161
- Q5.draw = function () {
210
+ function draw() {
162
211
  background(200);
163
212
  circle(frameCount % 200, 100, 80);
164
213
  }
165
214
 
166
- Q5.postProcess = function () {
215
+ function postProcess() {
167
216
  filter(INVERT);
168
217
  }
169
218
  */
@@ -172,7 +221,7 @@ Q5.postProcess = function () {
172
221
  /** ⭐️
173
222
  * The width of the window.
174
223
  * @example
175
- Q5.draw = function () {
224
+ function draw() {
176
225
  background(200);
177
226
  textSize(64);
178
227
  textAlign(CENTER, CENTER);
@@ -184,7 +233,7 @@ Q5.draw = function () {
184
233
  /** ⭐️
185
234
  * The height of the window.
186
235
  * @example
187
- Q5.draw = function () {
236
+ function draw() {
188
237
  background(200);
189
238
  textSize(64);
190
239
  textAlign(CENTER, CENTER);
@@ -204,13 +253,13 @@ Q5.draw = function () {
204
253
  * rates are consistently low, consider reducing the target frame
205
254
  * rate instead.
206
255
  * @example
207
- Q5.draw = function () {
256
+ function draw() {
208
257
  background(200);
209
258
  text(deltaTime, 60, 106);
210
259
  }
211
260
  * @example
212
261
  let x = 0;
213
- Q5.draw = function () {
262
+ function draw() {
214
263
  background(200);
215
264
  // simulate frame rate drops
216
265
  frameRate(random(30, 60));
@@ -238,7 +287,7 @@ Q5.draw = function () {
238
287
  *
239
288
  * @param {boolean} [val] Whether load* functions should return promises or not. If this parameter is undefined the value is set to true.
240
289
  * @example
241
- await createCanvas(200);
290
+ createCanvas(200);
242
291
 
243
292
  usePromiseLoading();
244
293
 
@@ -316,8 +365,20 @@ q.circle(100, 50, 20);
316
365
  static modules: {};
317
366
 
318
367
  static Image: {
319
- new(w: number, h: number, opt?: any): Q5.Image;
320
- }
368
+ new (w: number, h: number, opt?: any): Q5.Image;
369
+ };
370
+
371
+ /** ⭐️
372
+ * Creates a new Q5 instance that uses [q5's WebGPU renderer](https://github.com/q5js/q5.js/wiki/q5-WebGPU-renderer).
373
+ * @example
374
+ let q = await Q5.WebGPU('instance');
375
+
376
+ q.draw = () => {
377
+ q.background(0.8);
378
+ q.circle(q.mouseX, 0, 80);
379
+ }
380
+ */
381
+ static WebGPU(): Q5;
321
382
 
322
383
  /** ⭐️
323
384
  * ___Experimental! Might be changed.___
@@ -338,7 +399,7 @@ Q5.registerAddon((Q5, proto, lifecycles) => {
338
399
  });
339
400
 
340
401
  // sketch.js
341
- await createCanvas(200);
402
+ createCanvas(200);
342
403
  */
343
404
  static registerAddon(addon: Function): void; //-
344
405
 
@@ -355,14 +416,14 @@ await createCanvas(200);
355
416
  /** ⭐️
356
417
  * Load assets in the preload function to ensure that they'll be
357
418
  * ready to use in the setup and draw functions.
358
- *
419
+ *
359
420
  * q5's preload system can also be used without a preload function
360
421
  * if you create a canvas first.
361
422
  */
362
423
  preload(): void; //-
363
424
 
364
425
  /** ⭐️
365
- * The number of frames that have been displayed since the program
426
+ * The number of frames that have been displayed since the program
366
427
  * started.
367
428
  */
368
429
  postProcess(): void; //-
@@ -385,26 +446,25 @@ await createCanvas(200);
385
446
  * by the user, a 200x200 canvas will be created automatically before
386
447
  * the draw loop starts.
387
448
  *
388
- * You should create a canvas before using any other q5 functions
389
- * in top level global mode.
390
- *
391
- * Note! The origin (0, 0) point on a WebGPU canvas is at its center!
449
+ * When using q5 WebGPU, create a canvas before using any other
450
+ * q5 functions. The origin of a WebGPU canvas is at its center.
392
451
  * @param {number} [w] width or size of the canvas
393
452
  * @param {number} [h] height of the canvas
394
453
  * @param {object} [opt] options for the canvas
395
454
  * @param {boolean} [opt.alpha] whether the canvas should have an alpha channel that allows it to be seen through, default is false
396
455
  * @param {string} [opt.colorSpace] color space of the canvas, either "srgb" or "display-p3", default is "display-p3" for devices that support HDR colors
397
- * @returns {Promise<HTMLCanvasElement>} created canvas element
456
+ * @returns {HTMLCanvasElement} created canvas element
398
457
  * @example
399
- await createCanvas(200, 100);
458
+ createCanvas(200, 100);
400
459
  circle(100, 50, 80);
401
460
  * @example
402
- await createCanvas(200, 100, GPU);
461
+ await Q5.WebGPU();
462
+ createCanvas(200, 100);
403
463
  circle(0, 0, 80);
404
464
  * @example
405
- await createCanvas(200, 200, { alpha: true });
465
+ createCanvas(200, 200, { alpha: true });
406
466
 
407
- Q5.draw = function () {
467
+ function draw() {
408
468
  clear();
409
469
  circle(frameCount % 200, 100, 80);
410
470
  }
@@ -413,10 +473,10 @@ Q5.draw = function () {
413
473
 
414
474
  /** ⬜️
415
475
  * The canvas element associated with the Q5 instance.
416
- *
417
- * @prop {number} w width
476
+ *
477
+ * @prop {number} w
418
478
  * @prop {number} width
419
- * @prop {number} h height
479
+ * @prop {number} h
420
480
  * @prop {number} height
421
481
  * @prop {number} hw half the width
422
482
  * @prop {number} hh half the height
@@ -439,7 +499,7 @@ Q5.draw = function () {
439
499
  * a `Color` object, grayscale value, or color component values.
440
500
  * @param {Color} color fill color
441
501
  * @example
442
- await createCanvas(200);
502
+ createCanvas(200);
443
503
  background(200);
444
504
 
445
505
  fill('red');
@@ -458,7 +518,7 @@ square(80, 80, 80);
458
518
  * a `Color` object, grayscale value, or color component values.
459
519
  * @param {Color} color stroke color
460
520
  * @example
461
- await createCanvas(200);
521
+ createCanvas(200);
462
522
  background(200);
463
523
  fill(36);
464
524
 
@@ -473,7 +533,7 @@ square(80, 80, 80);
473
533
  /** ⬜️
474
534
  * After calling this function, shapes will not be filled.
475
535
  * @example
476
- await createCanvas(200);
536
+ createCanvas(200);
477
537
  background(200);
478
538
 
479
539
  noFill();
@@ -488,7 +548,7 @@ square(80, 80, 80);
488
548
  /** ⬜️
489
549
  * After calling this function, shapes will not have a stroke (outline).
490
550
  * @example
491
- await createCanvas(200);
551
+ createCanvas(200);
492
552
  background(200);
493
553
  fill(36);
494
554
  stroke('red');
@@ -503,7 +563,7 @@ square(80, 80, 80);
503
563
  * Sets the size of the stroke used for lines and the border around shapes.
504
564
  * @param {number} weight size of the stroke in pixels
505
565
  * @example
506
- await createCanvas(200);
566
+ createCanvas(200);
507
567
  background(200);
508
568
  stroke('red');
509
569
  circle(50, 100, 80);
@@ -519,7 +579,7 @@ circle(150, 100, 80);
519
579
  * In q5 WebGPU this function only affects images.
520
580
  * @param {number} alpha opacity level, ranging from 0 to 1
521
581
  * @example
522
- await createCanvas(200);
582
+ createCanvas(200);
523
583
  background(200);
524
584
 
525
585
  opacity(1);
@@ -543,19 +603,21 @@ square(80, 80, 80);
543
603
  * Not available in q5 WebGPU.
544
604
  * @param {Color} color shadow color
545
605
  * @example
546
- await createCanvas(200);
606
+ createCanvas(200);
547
607
  background(200);
548
608
 
549
609
  noFill();
550
610
  shadow('black');
551
611
  rect(64, 60, 80, 80);
552
612
  * @example
553
- await createCanvas(200);
554
- let logo = await load('/assets/p5play_logo.webp');
613
+ createCanvas(200);
614
+ let logo = loadImage('/assets/p5play_logo.webp');
555
615
 
556
- background(200);
557
- shadow(0);
558
- image(logo, 36, 36, 128, 128);
616
+ function setup() {
617
+ background(200);
618
+ shadow(0);
619
+ image(logo, 36, 36, 128, 128);
620
+ }
559
621
  */
560
622
  function shadow(color: string | Color): void;
561
623
 
@@ -564,7 +626,7 @@ image(logo, 36, 36, 128, 128);
564
626
  *
565
627
  * Not available in q5 WebGPU.
566
628
  * @example
567
- await createCanvas(200);
629
+ createCanvas(200);
568
630
  background(200);
569
631
  noStroke();
570
632
  shadow('black');
@@ -586,17 +648,17 @@ rect(104, 104, 80, 80);
586
648
  * @param {number} offsetY vertical offset of the shadow, defaults to be the same as offsetX
587
649
  * @param {number} blur blur radius of the shadow, defaults to 0
588
650
  * @example
589
- await createCanvas(200);
651
+ createCanvas(200);
590
652
  noStroke();
591
653
  shadow(50);
592
654
 
593
- Q5.draw = function () {
655
+ function draw() {
594
656
  background(200);
595
657
  shadowBox(-20, mouseY, 10);
596
658
  circle(100, 100, 80, 80);
597
659
  }
598
660
  * @example
599
- await createCanvas(200);
661
+ createCanvas(200);
600
662
  background(200);
601
663
  noStroke();
602
664
 
@@ -633,7 +695,7 @@ text('q5', 60, 115);
633
695
  * @param {number} x translation along the x-axis
634
696
  * @param {number} y translation along the y-axis
635
697
  * @example
636
- Q5.draw = function () {
698
+ function draw() {
637
699
  background(200);
638
700
 
639
701
  translate(100, 100);
@@ -646,7 +708,7 @@ Q5.draw = function () {
646
708
  * Rotates the drawing context.
647
709
  * @param {number} angle rotation angle in radians
648
710
  * @example
649
- Q5.draw = function () {
711
+ function draw() {
650
712
  background(200);
651
713
 
652
714
  translate(100, 100);
@@ -666,7 +728,7 @@ Q5.draw = function () {
666
728
  * @param {number} x scaling factor along the x-axis
667
729
  * @param {number} [y] scaling factor along the y-axis
668
730
  * @example
669
- Q5.draw = function () {
731
+ function draw() {
670
732
  background(200);
671
733
 
672
734
  scale(4);
@@ -679,7 +741,7 @@ Q5.draw = function () {
679
741
  * Shears the drawing context along the x-axis.
680
742
  * @param {number} angle shear angle in radians
681
743
  * @example
682
- Q5.draw = function () {
744
+ function draw() {
683
745
  background(200);
684
746
 
685
747
  translate(25, 60);
@@ -693,7 +755,7 @@ Q5.draw = function () {
693
755
  * Shears the drawing context along the y-axis.
694
756
  * @param {number} angle shear angle in radians
695
757
  * @example
696
- Q5.draw = function () {
758
+ function draw() {
697
759
  background(200);
698
760
 
699
761
  translate(25, 60);
@@ -718,7 +780,7 @@ Q5.draw = function () {
718
780
  * @param {number} e horizontal moving
719
781
  * @param {number} f vertical moving
720
782
  * @example
721
- Q5.draw = function () {
783
+ function draw() {
722
784
  background(200);
723
785
 
724
786
  applyMatrix(2, 1, 1, 1, 100, 100);
@@ -733,7 +795,7 @@ Q5.draw = function () {
733
795
  * q5 runs this function before every time the `draw` function is run,
734
796
  * so that transformations don't carry over to the next frame.
735
797
  * @example
736
- await createCanvas(200);
798
+ createCanvas(200);
737
799
  background(200);
738
800
 
739
801
  translate(100, 100);
@@ -747,7 +809,7 @@ square(0, 0, 50);
747
809
  /** ⬜️
748
810
  * Saves the current transformation matrix.
749
811
  * @example
750
- await createCanvas(200);
812
+ createCanvas(200);
751
813
  background(200);
752
814
  translate(100, 100);
753
815
  pushMatrix();
@@ -761,7 +823,7 @@ ellipse(0, 0, 120, 40);
761
823
  /** ⬜️
762
824
  * Restores the previously saved transformation matrix.
763
825
  * @example
764
- await createCanvas(200);
826
+ createCanvas(200);
765
827
  background(200);
766
828
  translate(100, 100);
767
829
  pushMatrix();
@@ -779,7 +841,7 @@ ellipse(0, 0, 120, 40);
779
841
  * rect mode, ellipse mode, text size, text align, text baseline, and
780
842
  * shadow settings.
781
843
  * @example
782
- Q5.draw = function () {
844
+ function draw() {
783
845
  background(200);
784
846
 
785
847
  pushStyles();
@@ -799,7 +861,7 @@ Q5.draw = function () {
799
861
  /** ⬜️
800
862
  * Saves the current drawing style settings and transformations.
801
863
  * @example
802
- await createCanvas(200);
864
+ createCanvas(200);
803
865
 
804
866
  push();
805
867
  fill('blue');
@@ -838,7 +900,7 @@ square(0, 0, 50);
838
900
 
839
901
  /** ⬜️
840
902
  * Creates a graphics buffer.
841
- *
903
+ *
842
904
  * Disabled by default in q5 WebGPU.
843
905
  * See issue [#104](https://github.com/q5js/q5.js/issues/104) for details.
844
906
  * @param {number} w width
@@ -889,7 +951,7 @@ square(0, 0, 50);
889
951
  * @param {number} [c3] fourth color component (alpha)
890
952
  * @returns {Color} a new `Color` object
891
953
  * @example
892
- await createCanvas(200);
954
+ createCanvas(200);
893
955
  rect(0, 0, 100, 200);
894
956
 
895
957
  // ( r, g, b, a)
@@ -899,22 +961,22 @@ stroke(bottle);
899
961
  strokeWeight(30);
900
962
  circle(100, 100, 155);
901
963
  * @example
902
- await createCanvas(200);
964
+ createCanvas(200);
903
965
  // (gray, alpha)
904
966
  let c = color(200, 50);
905
967
 
906
- Q5.draw = function () {
968
+ function draw() {
907
969
  background(c);
908
970
  circle(mouseX, mouseY, 50);
909
971
  c.g = (c.g + 1) % 256;
910
972
  }
911
973
  * @example
912
- await createCanvas(200, GPU);
974
+ let q = await Q5.WebGPU();
913
975
 
914
976
  // (r, g, b, a)
915
977
  let c = color(0, 1, 1, 0.2);
916
978
 
917
- Q5.draw = function () {
979
+ q.draw = () => {
918
980
  fill(c);
919
981
  circle(mouseX, mouseY, 50);
920
982
  };
@@ -935,7 +997,7 @@ Q5.draw = function () {
935
997
  * @param {1 | 255} format color format (1 for float, 255 for integer)
936
998
  * @param {'srgb' | 'display-p3'} [gamut] color gamut
937
999
  * @example
938
- await createCanvas(200);
1000
+ createCanvas(200);
939
1001
 
940
1002
  colorMode(RGB, 1);
941
1003
  fill(1, 0, 0);
@@ -945,7 +1007,7 @@ rect(66, 0, 67, 200);
945
1007
  fill(0, 0, 1);
946
1008
  rect(133, 0, 67, 200);
947
1009
  * @example
948
- await createCanvas(200);
1010
+ createCanvas(200);
949
1011
 
950
1012
  colorMode(OKLCH);
951
1013
 
@@ -965,7 +1027,7 @@ rect(100, 0, 100, 200);
965
1027
  * rgb colors are mapped to the full P3 gamut, even when they use the
966
1028
  * legacy integer 0-255 format.
967
1029
  * @example
968
- await createCanvas(200, 100);
1030
+ createCanvas(200, 100);
969
1031
 
970
1032
  colorMode(RGB);
971
1033
 
@@ -997,16 +1059,16 @@ background(255, 0, 0);
997
1059
  * - `hue`: 0 to 360
998
1060
  * - `alpha`: 0 to 1
999
1061
  * @example
1000
- await createCanvas(200, 100);
1062
+ createCanvas(200, 100);
1001
1063
 
1002
1064
  colorMode(OKLCH);
1003
1065
 
1004
1066
  background(0.64, 0.3, 30);
1005
1067
  * @example
1006
- await createCanvas(200);
1068
+ createCanvas(200);
1007
1069
  colorMode(OKLCH);
1008
1070
 
1009
- Q5.draw = function () {
1071
+ function draw() {
1010
1072
  background(0.7, 0.16, frameCount % 360);
1011
1073
  }
1012
1074
  */
@@ -1032,13 +1094,13 @@ Q5.draw = function () {
1032
1094
  * - `lightness`: 0 to 100
1033
1095
  * - `alpha`: 0 to 1
1034
1096
  * @example
1035
- await createCanvas(200, 100);
1097
+ createCanvas(200, 100);
1036
1098
 
1037
1099
  colorMode(HSL);
1038
1100
 
1039
1101
  background(0, 100, 50);
1040
1102
  * @example
1041
- await createCanvas(200, 220);
1103
+ createCanvas(200, 220);
1042
1104
  noStroke();
1043
1105
 
1044
1106
  colorMode(HSL);
@@ -1065,13 +1127,13 @@ for (let h = 0; h < 360; h += 10) {
1065
1127
  * - `brightness`: 0 to 100
1066
1128
  * - `alpha`: 0 to 1
1067
1129
  * @example
1068
- await createCanvas(200, 100);
1130
+ createCanvas(200, 100);
1069
1131
 
1070
1132
  colorMode(HSB);
1071
1133
 
1072
1134
  background(0, 100, 100);
1073
1135
  * @example
1074
- await createCanvas(200, 220);
1136
+ createCanvas(200, 220);
1075
1137
  noStroke();
1076
1138
 
1077
1139
  colorMode(HSB);
@@ -1091,7 +1153,7 @@ for (let h = 0; h < 360; h += 10) {
1091
1153
  * less saturated and darker in this example, as it would on
1092
1154
  * an SDR display.
1093
1155
  * @example
1094
- await createCanvas(200, 100);
1156
+ createCanvas(200, 100);
1095
1157
 
1096
1158
  colorMode(RGB, 255, SRGB);
1097
1159
 
@@ -1107,7 +1169,7 @@ background(255, 0, 0);
1107
1169
  * If your display is HDR capable, note that full red appears
1108
1170
  * fully saturated and bright in the following example.
1109
1171
  * @example
1110
- await createCanvas(200, 100);
1172
+ createCanvas(200, 100);
1111
1173
 
1112
1174
  colorMode(RGB, 255, DISPLAY_P3);
1113
1175
 
@@ -1117,12 +1179,12 @@ background(255, 0, 0);
1117
1179
 
1118
1180
  class Color {
1119
1181
  /** 🎨
1120
- * This constructor strictly accepts 4 numbers, which are the color
1182
+ * This constructor strictly accepts 4 numbers, which are the color
1121
1183
  * components.
1122
- *
1184
+ *
1123
1185
  * Use the `color` function for greater flexibility, it runs
1124
1186
  * this constructor internally.
1125
- *
1187
+ *
1126
1188
  * `Color` is not actually a class itself, it's a reference to a
1127
1189
  * Q5 color class based on the color mode, format, and gamut.
1128
1190
  */
@@ -1163,7 +1225,7 @@ background(255, 0, 0);
1163
1225
  * - PIXELATED: pixels rendered as sharp squares
1164
1226
  * @param {number} scale can also be given as a string (for example "x2")
1165
1227
  * @example
1166
- await createCanvas(50, 25);
1228
+ createCanvas(50, 25);
1167
1229
 
1168
1230
  displayMode(CENTER, PIXELATED, 4);
1169
1231
 
@@ -1179,7 +1241,7 @@ circle(25, 12.5, 16);
1179
1241
 
1180
1242
  /** 💻
1181
1243
  * A `displayMode` setting.
1182
- *
1244
+ *
1183
1245
  * The canvas will be scaled to fill the parent element,
1184
1246
  * with letterboxing if necessary to preserve its aspect ratio.
1185
1247
  */
@@ -1187,14 +1249,14 @@ circle(25, 12.5, 16);
1187
1249
 
1188
1250
  /** 💻
1189
1251
  * A `displayMode` render quality.
1190
- *
1252
+ *
1191
1253
  * Smooth upscaling is used if the canvas is scaled.
1192
1254
  */
1193
1255
  const SMOOTH: 'smooth';
1194
1256
 
1195
1257
  /** 💻
1196
1258
  * A `displayMode` render quality.
1197
- *
1259
+ *
1198
1260
  * Pixels are rendered as sharp squares if the canvas is scaled.
1199
1261
  */
1200
1262
  const PIXELATED: 'pixelated';
@@ -1209,12 +1271,12 @@ circle(25, 12.5, 16);
1209
1271
  * CSS color string, grayscale value, and color component values.
1210
1272
  * @param {Color | Q5.Image} filler a color or image to draw
1211
1273
  * @example
1212
- await createCanvas(200, 100);
1274
+ createCanvas(200, 100);
1213
1275
  background('crimson');
1214
1276
  * @example
1215
- await createCanvas(200, GPU);
1277
+ let q = await Q5.WebGPU();
1216
1278
 
1217
- Q5.draw = function () {
1279
+ q.draw = () => {
1218
1280
  background(0.5, 0.4);
1219
1281
  circle(mouseX, mouseY, 20);
1220
1282
  };
@@ -1232,7 +1294,7 @@ Q5.draw = function () {
1232
1294
  * @param {number} [br] bottom-right radius
1233
1295
  * @param {number} [bl] bottom-left radius
1234
1296
  * @example
1235
- await createCanvas(200);
1297
+ createCanvas(200);
1236
1298
  background(200);
1237
1299
 
1238
1300
  rect(30, 20, 40, 60);
@@ -1251,7 +1313,7 @@ rect(130, 120, 40, 60, 30, 2, 8, 20);
1251
1313
  * @param {number} [br] bottom-right radius
1252
1314
  * @param {number} [bl] bottom-left radius
1253
1315
  * @example
1254
- await createCanvas(200);
1316
+ createCanvas(200);
1255
1317
  background(200);
1256
1318
 
1257
1319
  square(30, 30, 40);
@@ -1266,7 +1328,7 @@ square(130, 130, 40, 30, 2, 8, 20);
1266
1328
  * @param {number} y y-coordinate
1267
1329
  * @param {number} diameter diameter of the circle
1268
1330
  * @example
1269
- await createCanvas(200, 100);
1331
+ createCanvas(200, 100);
1270
1332
  circle(100, 50, 80);
1271
1333
  */
1272
1334
  function circle(x: number, y: number, diameter: number): void;
@@ -1278,7 +1340,7 @@ circle(100, 50, 80);
1278
1340
  * @param {number} width width of the ellipse
1279
1341
  * @param {number} [height] height of the ellipse
1280
1342
  * @example
1281
- await createCanvas(200, 100);
1343
+ createCanvas(200, 100);
1282
1344
  ellipse(100, 50, 160, 80);
1283
1345
  */
1284
1346
  function ellipse(x: number, y: number, width: number, height?: number): void;
@@ -1297,7 +1359,7 @@ ellipse(100, 50, 160, 80);
1297
1359
  * @param {number} stop angle to stop the arc
1298
1360
  * @param {number} [mode] shape and stroke style setting, default is `PIE_OPEN` for a pie shape with an unclosed stroke, can be `PIE`, `CHORD`, or `CHORD_OPEN`
1299
1361
  * @example
1300
- await createCanvas(200);
1362
+ createCanvas(200);
1301
1363
  background(200);
1302
1364
 
1303
1365
  arc(40, 40, 40, 40, 0.8, -0.8);
@@ -1314,7 +1376,7 @@ arc(160, 160, 40, 40, 0.8, -0.8, CHORD);
1314
1376
  * @param {number} x2 x-coordinate of the second point
1315
1377
  * @param {number} y2 y-coordinate of the second point
1316
1378
  * @example
1317
- await createCanvas(200, 100);
1379
+ createCanvas(200, 100);
1318
1380
  stroke('lime');
1319
1381
  line(20, 20, 180, 80);
1320
1382
  */
@@ -1328,14 +1390,14 @@ line(20, 20, 180, 80);
1328
1390
  * @param {number} y2 y-coordinate of the second point
1329
1391
  * @param {number} r radius of the capsule semi-circle ends
1330
1392
  * @example
1331
- await createCanvas(200, 100);
1393
+ createCanvas(200, 100);
1332
1394
  background(200);
1333
1395
  strokeWeight(5);
1334
1396
  capsule(40, 40, 160, 60, 10);
1335
1397
  * @example
1336
- await createCanvas(200, GPU);
1398
+ let q = await Q5.WebGPU();
1337
1399
 
1338
- Q5.draw = function () {
1400
+ q.draw = () => {
1339
1401
  background(0.8);
1340
1402
  strokeWeight(10);
1341
1403
  capsule(0, 0, mouseX, mouseY, 20);
@@ -1348,7 +1410,7 @@ Q5.draw = function () {
1348
1410
  * @param {number} x x-coordinate
1349
1411
  * @param {number} y y-coordinate
1350
1412
  * @example
1351
- await createCanvas(200, 100);
1413
+ createCanvas(200, 100);
1352
1414
  stroke('white');
1353
1415
  point(75, 50);
1354
1416
 
@@ -1359,7 +1421,7 @@ point(125, 50);
1359
1421
 
1360
1422
  /** 🧑‍🎨
1361
1423
  * Set the global composite operation for the canvas context.
1362
- *
1424
+ *
1363
1425
  * Not available in q5 WebGPU.
1364
1426
  * @param {string} val composite operation
1365
1427
  */
@@ -1371,7 +1433,7 @@ point(125, 50);
1371
1433
  * Not available in q5 WebGPU.
1372
1434
  * @param {CanvasLineCap} val line cap style
1373
1435
  * @example
1374
- await createCanvas(200);
1436
+ createCanvas(200);
1375
1437
  background(200);
1376
1438
  strokeWeight(20);
1377
1439
 
@@ -1392,7 +1454,7 @@ line(50, 150, 150, 150);
1392
1454
  * Not available in q5 WebGPU.
1393
1455
  * @param {CanvasLineJoin} val line join style
1394
1456
  * @example
1395
- await createCanvas(200);
1457
+ createCanvas(200);
1396
1458
  background(200);
1397
1459
  strokeWeight(10);
1398
1460
 
@@ -1414,28 +1476,28 @@ triangle(50, 130, 150, 180, 50, 180);
1414
1476
  * `rect` and `square` are interpreted.
1415
1477
  * @param {string} mode
1416
1478
  * @example
1417
- await createCanvas(200, 100);
1479
+ createCanvas(200, 100);
1418
1480
  background(200);
1419
1481
  rectMode(CORNER);
1420
1482
 
1421
1483
  // ( x, y, w, h)
1422
1484
  rect(50, 25, 100, 50);
1423
1485
  * @example
1424
- await createCanvas(200, 100);
1486
+ createCanvas(200, 100);
1425
1487
  background(200);
1426
1488
  rectMode(CENTER);
1427
1489
 
1428
1490
  // ( cX, cY, w, h)
1429
1491
  rect(100, 50, 100, 50);
1430
1492
  * @example
1431
- await createCanvas(200, 100);
1493
+ createCanvas(200, 100);
1432
1494
  background(200);
1433
1495
  rectMode(RADIUS);
1434
1496
 
1435
1497
  // ( cX, cY, rX, rY)
1436
1498
  rect(100, 50, 50, 25);
1437
1499
  * @example
1438
- await createCanvas(200, 100);
1500
+ createCanvas(200, 100);
1439
1501
  background(200);
1440
1502
  rectMode(CORNERS);
1441
1503
 
@@ -1444,35 +1506,35 @@ rect(50, 25, 150, 75);
1444
1506
  */
1445
1507
  function rectMode(mode: string): void;
1446
1508
 
1447
- /** 🧑‍🎨
1509
+ /** 🧑‍🎨
1448
1510
  * Set to `CENTER` (default), `RADIUS`, `CORNER`, or `CORNERS`.
1449
1511
  *
1450
1512
  * Changes how the first four inputs to
1451
1513
  * `ellipse`, `circle`, and `arc` are interpreted.
1452
1514
  * @param {string} mode
1453
1515
  * @example
1454
- await createCanvas(200, 100);
1516
+ createCanvas(200, 100);
1455
1517
  background(200);
1456
1518
  ellipseMode(CENTER);
1457
1519
 
1458
1520
  // ( x, y, w, h)
1459
1521
  ellipse(100, 50, 100, 50);
1460
1522
  * @example
1461
- await createCanvas(200, 100);
1523
+ createCanvas(200, 100);
1462
1524
  background(200);
1463
1525
  ellipseMode(RADIUS);
1464
1526
 
1465
1527
  // ( x, y, rX, rY)
1466
1528
  ellipse(100, 50, 50, 25);
1467
1529
  * @example
1468
- await createCanvas(200, 100);
1530
+ createCanvas(200, 100);
1469
1531
  background(200);
1470
1532
  ellipseMode(CORNER);
1471
1533
 
1472
1534
  // (lX, tY, w, h)
1473
1535
  ellipse(50, 25, 100, 50);
1474
1536
  * @example
1475
- await createCanvas(200, 100);
1537
+ createCanvas(200, 100);
1476
1538
  background(200);
1477
1539
  ellipseMode(CORNERS);
1478
1540
 
@@ -1481,11 +1543,10 @@ ellipse(50, 25, 150, 75);
1481
1543
  */
1482
1544
  function ellipseMode(mode: string): void;
1483
1545
 
1484
-
1485
1546
  /** 🧑‍🎨
1486
1547
  * Draws a curve.
1487
1548
  */
1488
- function curve( x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
1549
+ function curve(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
1489
1550
 
1490
1551
  /** 🧑‍🎨
1491
1552
  * Sets the amount of straight line segments used to make a curve.
@@ -1516,14 +1577,14 @@ curve(-100, -200, -50, 0, 50, 0, 100, -200);
1516
1577
 
1517
1578
  /** 🧑‍🎨
1518
1579
  * Starts storing vertices for a contour.
1519
- *
1580
+ *
1520
1581
  * Not available in q5 WebGPU.
1521
1582
  */
1522
1583
  function beginContour(): void;
1523
1584
 
1524
1585
  /** 🧑‍🎨
1525
1586
  * Ends storing vertices for a contour.
1526
- *
1587
+ *
1527
1588
  * Not available in q5 WebGPU.
1528
1589
  */
1529
1590
  function endContour(): void;
@@ -1593,9 +1654,9 @@ curve(-100, -200, -50, 0, 50, 0, 100, -200);
1593
1654
  function quad(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
1594
1655
 
1595
1656
  /** 🧑‍🎨
1596
- * Sets the canvas to erase mode, where shapes will erase what's
1657
+ * Sets the canvas to erase mode, where shapes will erase what's
1597
1658
  * underneath them instead of drawing over it.
1598
- *
1659
+ *
1599
1660
  * Not available in q5 WebGPU.
1600
1661
  * @param {number} [fillAlpha] opacity level of the fill color
1601
1662
  * @param {number} [strokeAlpha] opacity level of the stroke color
@@ -1604,14 +1665,14 @@ curve(-100, -200, -50, 0, 50, 0, 100, -200);
1604
1665
 
1605
1666
  /** 🧑‍🎨
1606
1667
  * Resets the canvas from erase mode to normal drawing mode.
1607
- *
1668
+ *
1608
1669
  * Not available in q5 WebGPU.
1609
1670
  */
1610
1671
  function noErase(): void;
1611
1672
 
1612
1673
  /** 🧑‍🎨
1613
1674
  * Checks if a given point is within the current path's fill area.
1614
- *
1675
+ *
1615
1676
  * Not available in q5 WebGPU.
1616
1677
  * @param {number} x x-coordinate of the point
1617
1678
  * @param {number} y y-coordinate of the point
@@ -1621,7 +1682,7 @@ curve(-100, -200, -50, 0, 50, 0, 100, -200);
1621
1682
 
1622
1683
  /** 🧑‍🎨
1623
1684
  * Checks if a given point is within the current path's stroke.
1624
- *
1685
+ *
1625
1686
  * Not available in q5 WebGPU.
1626
1687
  * @param {number} x x-coordinate of the point
1627
1688
  * @param {number} y y-coordinate of the point
@@ -1651,20 +1712,20 @@ curve(-100, -200, -50, 0, 50, 0, 100, -200);
1651
1712
  * @param {string} url url of the image to load
1652
1713
  * @returns {Q5.Image | Promise<Q5.Image>} image or promise
1653
1714
  * @example
1654
- await createCanvas(200);
1715
+ createCanvas(200);
1655
1716
 
1656
1717
  let logo = loadImage('/q5js_logo.avif');
1657
1718
 
1658
- Q5.draw = function () {
1719
+ function draw() {
1659
1720
  background(logo);
1660
1721
  }
1661
1722
  * @example
1662
- await createCanvas(200, GPU);
1663
- await createCanvas(200);
1723
+ let q = await Q5.WebGPU();
1724
+ createCanvas(200);
1664
1725
 
1665
1726
  let logo = loadImage('/q5js_logo.avif');
1666
1727
 
1667
- Q5.draw = function () {
1728
+ q.draw = () => {
1668
1729
  background(logo);
1669
1730
  };
1670
1731
  */
@@ -1682,23 +1743,33 @@ Q5.draw = function () {
1682
1743
  * @param {number} [sw] width of the subsection of the source image
1683
1744
  * @param {number} [sh] height of the subsection of the source image
1684
1745
  * @example
1685
- await createCanvas(200);
1746
+ createCanvas(200);
1686
1747
 
1687
1748
  let logo = loadImage('/q5js_logo.avif');
1688
1749
 
1689
- Q5.draw = function () {
1750
+ function draw() {
1690
1751
  image(logo, 0, 0, 200, 200);
1691
1752
  }
1692
1753
  * @example
1693
- await createCanvas(200);
1754
+ createCanvas(200);
1694
1755
 
1695
1756
  let logo = loadImage('/q5js_logo.avif');
1696
1757
 
1697
- Q5.draw = function () {
1758
+ function draw() {
1698
1759
  image(logo, 0, 0, 200, 200, 256, 256, 512, 512);
1699
1760
  }
1700
1761
  */
1701
- function image(img: Q5.Image | HTMLVideoElement, dx: number, dy: number, dw?: number, dh?: number, sx?: number, sy?: number, sw?: number, sh?: number): void;
1762
+ function image(
1763
+ img: Q5.Image | HTMLVideoElement,
1764
+ dx: number,
1765
+ dy: number,
1766
+ dw?: number,
1767
+ dh?: number,
1768
+ sx?: number,
1769
+ sy?: number,
1770
+ sw?: number,
1771
+ sh?: number
1772
+ ): void;
1702
1773
 
1703
1774
  /** 🌆
1704
1775
  * Set to `CORNER` (default), `CORNERS`, or `CENTER`.
@@ -1706,30 +1777,30 @@ Q5.draw = function () {
1706
1777
  * Changes how inputs to `image` are interpreted.
1707
1778
  * @param {string} mode
1708
1779
  * @example
1709
- await createCanvas(200);
1780
+ createCanvas(200);
1710
1781
  let logo = loadImage('/q5js_logo.avif');
1711
1782
 
1712
- Q5.draw = function () {
1783
+ function draw() {
1713
1784
  imageMode(CORNER);
1714
1785
 
1715
1786
  // ( img, x, y, w, h)
1716
1787
  image(logo, 50, 50, 100, 100);
1717
1788
  }
1718
1789
  * @example
1719
- await createCanvas(200);
1790
+ createCanvas(200);
1720
1791
  let logo = loadImage('/q5js_logo.avif');
1721
1792
 
1722
- Q5.draw = function () {
1793
+ function draw() {
1723
1794
  imageMode(CENTER);
1724
1795
 
1725
1796
  // ( img, cX, cY, w, h)
1726
1797
  image(logo, 100, 100, 100, 100);
1727
1798
  }
1728
1799
  * @example
1729
- await createCanvas(200);
1800
+ createCanvas(200);
1730
1801
  let logo = loadImage('/q5js_logo.avif');
1731
1802
 
1732
- Q5.draw = function () {
1803
+ function draw() {
1733
1804
  imageMode(CORNERS);
1734
1805
 
1735
1806
  // ( img, x1, y1, x2, y2)
@@ -1741,11 +1812,11 @@ Q5.draw = function () {
1741
1812
  /** 🌆
1742
1813
  * Sets the default image scale, which is applied to images when
1743
1814
  * they are drawn without a specified width or height.
1744
- *
1815
+ *
1745
1816
  * By default it is 0.5 so images appear at their actual size
1746
1817
  * when pixel density is 2. Images will be drawn at a consistent
1747
1818
  * default size relative to the canvas regardless of pixel density.
1748
- *
1819
+ *
1749
1820
  * This function must be called before images are loaded to
1750
1821
  * have an effect.
1751
1822
  * @param {number} scale
@@ -1758,12 +1829,14 @@ Q5.draw = function () {
1758
1829
  * @param {number} w new width
1759
1830
  * @param {number} h new height
1760
1831
  * @example
1761
- await createCanvas(200);
1832
+ createCanvas(200);
1762
1833
 
1763
- let logo = await load('/q5js_logo.avif');
1834
+ let logo = loadImage('/q5js_logo.avif');
1764
1835
 
1765
- logo.resize(128, 128);
1766
- image(logo, 0, 0, 200, 200);
1836
+ function setup() {
1837
+ logo.resize(128, 128);
1838
+ image(logo, 0, 0, 200, 200);
1839
+ }
1767
1840
  */
1768
1841
  function resize(w: number, h: number): void;
1769
1842
 
@@ -1778,21 +1851,27 @@ image(logo, 0, 0, 200, 200);
1778
1851
  * their actual size. This is the default setting, so running this
1779
1852
  * function only has an effect if `noSmooth` has been called.
1780
1853
  * @example
1781
- await createCanvas(200);
1782
- let icon = await load('/q5js_icon.png');
1783
- image(icon, 0, 0, 200, 200);
1854
+ createCanvas(200);
1855
+
1856
+ let icon = loadImage('/q5js_icon.png');
1857
+
1858
+ function setup() {
1859
+ image(icon, 0, 0, 200, 200);
1860
+ }
1784
1861
  */
1785
1862
  function smooth(): void;
1786
1863
 
1787
1864
  /** 🌆
1788
1865
  * Disables smooth image rendering for a pixelated look.
1789
1866
  * @example
1790
- await createCanvas(200);
1867
+ createCanvas(200);
1791
1868
 
1792
- let icon = await load('/q5js_icon.png');
1869
+ let icon = loadImage('/q5js_icon.png');
1793
1870
 
1794
- noSmooth();
1795
- image(icon, 0, 0, 200, 200);
1871
+ function setup() {
1872
+ noSmooth();
1873
+ image(icon, 0, 0, 200, 200);
1874
+ }
1796
1875
  */
1797
1876
  function noSmooth(): void;
1798
1877
 
@@ -1816,12 +1895,14 @@ image(icon, 0, 0, 200, 200);
1816
1895
  * each copy separately.
1817
1896
  * @param {string | number} color tint color
1818
1897
  * @example
1819
- await createCanvas(200);
1898
+ createCanvas(200);
1820
1899
 
1821
- let logo = await load('/q5js_logo.avif');
1900
+ let logo = loadImage('/q5js_logo.avif');
1822
1901
 
1823
- tint(255, 0, 0, 128);
1824
- image(logo, 0, 0, 200, 200);
1902
+ function setup() {
1903
+ tint(255, 0, 0, 128);
1904
+ image(logo, 0, 0, 200, 200);
1905
+ }
1825
1906
  */
1826
1907
  function tint(color: string | number): void;
1827
1908
 
@@ -1854,12 +1935,14 @@ image(logo, 0, 0, 200, 200);
1854
1935
  * @param {number} dw width of the destination region
1855
1936
  * @param {number} dh height of the destination region
1856
1937
  * @example
1857
- await createCanvas(200);
1938
+ createCanvas(200);
1858
1939
 
1859
- let logo = await load('/q5js_logo.avif');
1940
+ let logo = loadImage('/q5js_logo.avif');
1860
1941
 
1861
- logo.inset(256, 256, 512, 512, 0, 0, 256, 256);
1862
- image(logo, 0, 0, 200, 200);
1942
+ function setup() {
1943
+ logo.inset(256, 256, 512, 512, 0, 0, 256, 256);
1944
+ image(logo, 0, 0, 200, 200);
1945
+ }
1863
1946
  */
1864
1947
  function inset(sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void;
1865
1948
 
@@ -1879,7 +1962,7 @@ image(logo, 0, 0, 200, 200);
1879
1962
  * @param {number} [h] height of the area, default is 1
1880
1963
  * @returns {Q5.Image | number[]}
1881
1964
  * @example
1882
- Q5.draw = function () {
1965
+ function draw() {
1883
1966
  background(200);
1884
1967
  noStroke();
1885
1968
  circle(100, 100, frameCount % 200);
@@ -1889,12 +1972,14 @@ Q5.draw = function () {
1889
1972
  text(col, mouseX, mouseY);
1890
1973
  }
1891
1974
  * @example
1892
- await createCanvas(200);
1975
+ createCanvas(200);
1893
1976
 
1894
- let logo = await load('/q5js_logo.avif');
1977
+ let logo = loadImage('/q5js_logo.avif');
1895
1978
 
1896
- let cropped = logo.get(256, 256, 512, 512);
1897
- image(cropped, 0, 0, 200, 200);
1979
+ function setup() {
1980
+ let cropped = logo.get(256, 256, 512, 512);
1981
+ image(cropped, 0, 0, 200, 200);
1982
+ }
1898
1983
  */
1899
1984
  function get(x: number, y: number, w?: number, h?: number): Q5.Image | number[];
1900
1985
 
@@ -1909,10 +1994,10 @@ image(cropped, 0, 0, 200, 200);
1909
1994
  * @param {number} y
1910
1995
  * @param {any} val color, canvas, or image
1911
1996
  * @example
1912
- await createCanvas(200);
1997
+ createCanvas(200);
1913
1998
  let c = color('lime');
1914
1999
 
1915
- Q5.draw = function () {
2000
+ function draw() {
1916
2001
  set(random(200), random(200), c);
1917
2002
  updatePixels();
1918
2003
  }
@@ -1921,14 +2006,14 @@ Q5.draw = function () {
1921
2006
 
1922
2007
  /** 🌆
1923
2008
  * Array of pixel color data from a canvas or image.
1924
- *
2009
+ *
1925
2010
  * Each pixel is represented by four consecutive values in the array,
1926
2011
  * corresponding to its red, green, blue, and alpha channels.
1927
- *
2012
+ *
1928
2013
  * The top left pixel's data is at the beginning of the array
1929
2014
  * and the bottom right pixel's data is at the end, going from
1930
2015
  * left to right and top to bottom.
1931
- *
2016
+ *
1932
2017
  * Use `loadPixels` to load current pixel data from a canvas or image.
1933
2018
  */
1934
2019
  var pixels: number[];
@@ -1942,7 +2027,7 @@ Q5.draw = function () {
1942
2027
  frameRate(5);
1943
2028
  let icon = loadImage('/q5js_icon.png');
1944
2029
 
1945
- Q5.draw = function () {
2030
+ function draw() {
1946
2031
  icon.loadPixels();
1947
2032
  for (let i = 0; i < icon.pixels.length; i += 16) {
1948
2033
  icon.pixels[i + 1] = random(255);
@@ -1956,7 +2041,7 @@ Q5.draw = function () {
1956
2041
  /** 🌆
1957
2042
  * Applies changes in the `pixels` array to the canvas or image.
1958
2043
  * @example
1959
- await createCanvas(200);
2044
+ createCanvas(200);
1960
2045
 
1961
2046
  for (let x = 0; x < 200; x += 5) {
1962
2047
  for (let y = 0; y < 200; y += 5) {
@@ -1977,10 +2062,13 @@ updatePixels();
1977
2062
  * @param {string} type filter type or a CSS filter string
1978
2063
  * @param {number} [value] optional value, depends on filter type
1979
2064
  * @example
1980
- await createCanvas(200);
1981
- let logo = await load('/q5js_logo.avif');
1982
- logo.filter(INVERT);
1983
- image(logo, 0, 0, 200, 200);
2065
+ createCanvas(200);
2066
+ let logo = loadImage('/q5js_logo.avif');
2067
+
2068
+ function setup() {
2069
+ logo.filter(INVERT);
2070
+ image(logo, 0, 0, 200, 200);
2071
+ }
1984
2072
  */
1985
2073
  function filter(type: string, value?: number): void;
1986
2074
 
@@ -2044,13 +2132,13 @@ image(logo, 0, 0, 200, 200);
2044
2132
  * @param {number} [wrapWidth] maximum line width in characters
2045
2133
  * @param {number} [lineLimit] maximum number of lines
2046
2134
  * @example
2047
- await createCanvas(200, 100);
2135
+ createCanvas(200, 100);
2048
2136
  background('silver');
2049
2137
 
2050
2138
  textSize(32);
2051
2139
  text('Hello, world!', 12, 60);
2052
2140
  * @example
2053
- await createCanvas(200);
2141
+ createCanvas(200);
2054
2142
  background(200);
2055
2143
  textSize(20);
2056
2144
 
@@ -2085,7 +2173,7 @@ text(info, 12, 30, 20, 6);
2085
2173
  * @param {string} url URL of the font to load
2086
2174
  * @returns {FontFace | Promise<FontFace>} font or promise
2087
2175
  * @example
2088
- await createCanvas(200, 56);
2176
+ createCanvas(200, 56);
2089
2177
 
2090
2178
  loadFont('/assets/Robotica.ttf');
2091
2179
 
@@ -2095,7 +2183,7 @@ function setup() {
2095
2183
  text('Hello!', 2, 54);
2096
2184
  }
2097
2185
  * @example
2098
- await createCanvas(200, 74);
2186
+ createCanvas(200, 74);
2099
2187
 
2100
2188
  loadFont(
2101
2189
  'fonts.googleapis.com/css2?family=Pacifico'
@@ -2107,7 +2195,7 @@ function setup() {
2107
2195
  text('Hello!', 2, 68);
2108
2196
  }
2109
2197
  */
2110
- function loadFont(url: string): FontFace | Promise<FontFace>
2198
+ function loadFont(url: string): FontFace | Promise<FontFace>;
2111
2199
 
2112
2200
  /** ✍️
2113
2201
  * Sets the current font to be used for rendering text.
@@ -2116,7 +2204,7 @@ function setup() {
2116
2204
  * "sans-serif" or the last font loaded.
2117
2205
  * @param {string} fontName name of the font family or a FontFace object
2118
2206
  * @example
2119
- await createCanvas(200, 160);
2207
+ createCanvas(200, 160);
2120
2208
  background(200);
2121
2209
 
2122
2210
  textFont('serif');
@@ -2124,13 +2212,13 @@ textFont('serif');
2124
2212
  textSize(32);
2125
2213
  text('Hello, world!', 15, 90);
2126
2214
  * @example
2127
- await createCanvas(200, GPU);
2128
- await createCanvas(200);
2215
+ let q = await Q5.WebGPU();
2216
+ createCanvas(200);
2129
2217
  background(0.8);
2130
2218
 
2131
2219
  textFont('monospace');
2132
2220
 
2133
- Q5.setup = function () {
2221
+ q.setup = () => {
2134
2222
  text('Hello, world!', -65, 0);
2135
2223
  }
2136
2224
  */
@@ -2141,7 +2229,7 @@ Q5.setup = function () {
2141
2229
  * @param {number} [size] size of the font in pixels
2142
2230
  * @returns {number | void} current font size when no argument is provided
2143
2231
  * @example
2144
- Q5.draw = function () {
2232
+ function draw() {
2145
2233
  background(200);
2146
2234
 
2147
2235
  textSize(abs(mouseX));
@@ -2155,7 +2243,7 @@ Q5.draw = function () {
2155
2243
  * @param {number} [leading] line height in pixels
2156
2244
  * @returns {number | void} current line height when no argument is provided
2157
2245
  * @example
2158
- Q5.draw = function () {
2246
+ function draw() {
2159
2247
  background(200);
2160
2248
 
2161
2249
  textSize(abs(mouseX));
@@ -2169,7 +2257,7 @@ Q5.draw = function () {
2169
2257
  * Sets the current text style.
2170
2258
  * @param {'normal' | 'italic' | 'bold' | 'bolditalic'} style font style
2171
2259
  * @example
2172
- await createCanvas(200);
2260
+ createCanvas(200);
2173
2261
  background(200);
2174
2262
 
2175
2263
  textStyle(ITALIC);
@@ -2184,7 +2272,7 @@ text('Hello, world!', 12, 106);
2184
2272
  * @param {'left' | 'center' | 'right'} horiz horizontal alignment
2185
2273
  * @param {'top' | 'middle' | 'bottom' | 'alphabetic'} [vert] vertical alignment
2186
2274
  * @example
2187
- await createCanvas(200);
2275
+ createCanvas(200);
2188
2276
  background(200);
2189
2277
  textSize(32);
2190
2278
 
@@ -2207,7 +2295,7 @@ text('Hello, world!', 100, 100);
2207
2295
  * - 900: black/heavy
2208
2296
  * @param {number | string} weight font weight
2209
2297
  * @example
2210
- await createCanvas(200);
2298
+ createCanvas(200);
2211
2299
  background(200);
2212
2300
  textSize(32);
2213
2301
  textAlign(CENTER, MIDDLE);
@@ -2222,7 +2310,7 @@ text('Hello, world!', 100, 100);
2222
2310
  * @param {string} str string to measure
2223
2311
  * @returns {number} width of the text in pixels
2224
2312
  * @example
2225
- Q5.draw = function () {
2313
+ function draw() {
2226
2314
  background(200);
2227
2315
 
2228
2316
  textSize(abs(mouseX));
@@ -2237,7 +2325,7 @@ Q5.draw = function () {
2237
2325
  * @param {string} str string to measure
2238
2326
  * @returns {number} ascent of the text in pixels
2239
2327
  * @example
2240
- Q5.draw = function () {
2328
+ function draw() {
2241
2329
  background(200);
2242
2330
 
2243
2331
  textSize(abs(mouseX));
@@ -2252,7 +2340,7 @@ Q5.draw = function () {
2252
2340
  * @param {string} str string to measure
2253
2341
  * @returns {number} descent of the text in pixels
2254
2342
  * @example
2255
- await createCanvas(200);
2343
+ createCanvas(200);
2256
2344
  background(200);
2257
2345
  textSize(64);
2258
2346
 
@@ -2268,13 +2356,13 @@ await createCanvas(200);
2268
2356
  * @param {number} [lineLimit] maximum number of lines
2269
2357
  * @returns {Q5.Image} an image object representing the rendered text
2270
2358
  * @example
2271
- await createCanvas(200);
2359
+ createCanvas(200);
2272
2360
  textSize(96);
2273
2361
 
2274
2362
  let img = createTextImage('🐶');
2275
2363
  img.filter(INVERT);
2276
2364
 
2277
- Q5.draw = function () {
2365
+ function draw() {
2278
2366
  image(img, 55, 10);
2279
2367
  }
2280
2368
  */
@@ -2297,18 +2385,20 @@ Q5.draw = function () {
2297
2385
  * @param {number} x x-coordinate where the image should be placed
2298
2386
  * @param {number} y y-coordinate where the image should be placed
2299
2387
  * @example
2300
- await createCanvas(200, GPU);
2388
+ let q = await Q5.WebGPU();
2389
+ createCanvas(200);
2301
2390
  background(0.8);
2302
2391
  textSize(96);
2303
2392
  textAlign(CENTER, CENTER);
2304
2393
 
2305
2394
  textImage('🐶', 0, 0);
2306
2395
  * @example
2307
- await createCanvas(200, GPU);
2396
+ let q = await Q5.WebGPU();
2397
+ createCanvas(200);
2308
2398
 
2309
2399
  loadFont('/assets/Robotica.ttf');
2310
2400
 
2311
- Q5.setup = function () {
2401
+ q.setup = () => {
2312
2402
  background(0.8);
2313
2403
  textSize(66);
2314
2404
  textImage('Hello!', -100, 100);
@@ -2325,7 +2415,7 @@ Q5.setup = function () {
2325
2415
  * @param {number} r number of digits to appear after the decimal point
2326
2416
  * @returns {string} a string representation of the number, formatted accordingly
2327
2417
  * @example
2328
- await createCanvas(200, 100);
2418
+ createCanvas(200, 100);
2329
2419
  background(200);
2330
2420
 
2331
2421
  textSize(32);
@@ -2387,9 +2477,9 @@ text(nf(PI, 4, 5), 10, 60);
2387
2477
 
2388
2478
  /** 🖲️
2389
2479
  * Note that input responses inside `draw` can be delayed by
2390
- * up to one frame cycle: from the exact moment an input event occurs
2480
+ * up to one frame cycle: from the exact moment an input event occurs
2391
2481
  * to the next time a frame is drawn.
2392
- *
2482
+ *
2393
2483
  * Play sounds or trigger other non-visual feedback immediately
2394
2484
  * by responding to input events inside functions like
2395
2485
  * `mousePressed` and `keyPressed`.
@@ -2398,7 +2488,7 @@ text(nf(PI, 4, 5), 10, 60);
2398
2488
  /** 🖲️
2399
2489
  * Current X position of the mouse.
2400
2490
  * @example
2401
- Q5.draw = function () {
2491
+ function draw() {
2402
2492
  background(200);
2403
2493
  textSize(64);
2404
2494
  text(round(mouseX), 50, 120);
@@ -2409,7 +2499,7 @@ Q5.draw = function () {
2409
2499
  /** 🖲️
2410
2500
  * Current Y position of the mouse.
2411
2501
  * @example
2412
- Q5.draw = function () {
2502
+ function draw() {
2413
2503
  background(200);
2414
2504
  circle(100, mouseY, 100);
2415
2505
  }
@@ -2431,7 +2521,7 @@ Q5.draw = function () {
2431
2521
  *
2432
2522
  * The default value is an empty string.
2433
2523
  * @example
2434
- Q5.draw = function () {
2524
+ function draw() {
2435
2525
  background(200);
2436
2526
  textSize(64);
2437
2527
  text(mouseButton, 20, 120);
@@ -2442,7 +2532,7 @@ Q5.draw = function () {
2442
2532
  /** 🖲️
2443
2533
  * True if the mouse is currently pressed, false otherwise.
2444
2534
  * @example
2445
- Q5.draw = function () {
2535
+ function draw() {
2446
2536
  if (mouseIsPressed) background(100);
2447
2537
  else background(200);
2448
2538
  }
@@ -2452,10 +2542,10 @@ Q5.draw = function () {
2452
2542
  /** 🖲️
2453
2543
  * Define this function to respond to mouse down events.
2454
2544
  * @example
2455
- await createCanvas(200);
2545
+ createCanvas(200);
2456
2546
  let gray = 95;
2457
2547
 
2458
- Q5.mousePressed = function () {
2548
+ function mousePressed() {
2459
2549
  background(gray % 256);
2460
2550
  gray += 40;
2461
2551
  }
@@ -2465,7 +2555,7 @@ Q5.mousePressed = function () {
2465
2555
  /** 🖲️
2466
2556
  * Define this function to respond to mouse up events.
2467
2557
  * @example
2468
- await createCanvas(200);
2558
+ createCanvas(200);
2469
2559
  let gray = 95;
2470
2560
 
2471
2561
  function mouseReleased() {
@@ -2481,7 +2571,7 @@ function mouseReleased() {
2481
2571
  * On touchscreen devices this function is not called
2482
2572
  * when the user drags their finger on the screen.
2483
2573
  * @example
2484
- await createCanvas(200);
2574
+ createCanvas(200);
2485
2575
  let gray = 95;
2486
2576
 
2487
2577
  function mouseMoved() {
@@ -2497,7 +2587,7 @@ function mouseMoved() {
2497
2587
  * Dragging the mouse is defined as moving the mouse
2498
2588
  * while a mouse button is pressed.
2499
2589
  * @example
2500
- await createCanvas(200);
2590
+ createCanvas(200);
2501
2591
  let gray = 95;
2502
2592
 
2503
2593
  function mouseDragged() {
@@ -2510,7 +2600,7 @@ function mouseDragged() {
2510
2600
  /** 🖲️
2511
2601
  * Define this function to respond to mouse double click events.
2512
2602
  * @example
2513
- await createCanvas(200);
2603
+ createCanvas(200);
2514
2604
  let gray = 95;
2515
2605
 
2516
2606
  function doubleClicked() {
@@ -2523,7 +2613,7 @@ function doubleClicked() {
2523
2613
  /** 🖲️
2524
2614
  * The name of the last key pressed.
2525
2615
  * @example
2526
- Q5.draw = function () {
2616
+ function draw() {
2527
2617
  background(200);
2528
2618
  textSize(64);
2529
2619
  text(key, 20, 120);
@@ -2534,7 +2624,7 @@ Q5.draw = function () {
2534
2624
  /** 🖲️
2535
2625
  * True if a key is currently pressed, false otherwise.
2536
2626
  * @example
2537
- Q5.draw = function () {
2627
+ function draw() {
2538
2628
  if (keyIsPressed) background(100);
2539
2629
  else background(200);
2540
2630
  }
@@ -2547,7 +2637,7 @@ Q5.draw = function () {
2547
2637
  * @param {string} key key to check
2548
2638
  * @returns {boolean} true if the key is pressed, false otherwise
2549
2639
  * @example
2550
- Q5.draw = function () {
2640
+ function draw() {
2551
2641
  background(200);
2552
2642
 
2553
2643
  if (keyIsDown('f') && keyIsDown('j')) {
@@ -2560,7 +2650,7 @@ Q5.draw = function () {
2560
2650
  /** 🖲️
2561
2651
  * Define this function to respond to key down events.
2562
2652
  * @example
2563
- await createCanvas(200);
2653
+ createCanvas(200);
2564
2654
 
2565
2655
  let gray = 95;
2566
2656
  function keyPressed() {
@@ -2573,7 +2663,7 @@ function keyPressed() {
2573
2663
  /** 🖲️
2574
2664
  * Define this function to respond to key up events.
2575
2665
  * @example
2576
- await createCanvas(200);
2666
+ createCanvas(200);
2577
2667
 
2578
2668
  let gray = 95;
2579
2669
  function keyReleased() {
@@ -2588,7 +2678,7 @@ function keyReleased() {
2588
2678
  * browser window. Each touch being an object with
2589
2679
  * `id`, `x`, and `y` properties.
2590
2680
  * @example
2591
- Q5.draw = function () {
2681
+ function draw() {
2592
2682
  background(200);
2593
2683
  for (let touch of touches) {
2594
2684
  circle(touch.x, touch.y, 100);
@@ -2604,7 +2694,7 @@ Q5.draw = function () {
2604
2694
  * Return true to enable touch gestures like pinch-to-zoom
2605
2695
  * and scroll, which q5 disables on the canvas by default.
2606
2696
  * @example
2607
- await createCanvas(200);
2697
+ createCanvas(200);
2608
2698
 
2609
2699
  let gray = 95;
2610
2700
  function touchStarted() {
@@ -2621,7 +2711,7 @@ function touchStarted() {
2621
2711
  * Return true to enable touch gestures like pinch-to-zoom
2622
2712
  * and scroll, which q5 disables on the canvas by default.
2623
2713
  * @example
2624
- await createCanvas(200);
2714
+ createCanvas(200);
2625
2715
 
2626
2716
  let gray = 95;
2627
2717
  function touchEnded() {
@@ -2638,7 +2728,7 @@ function touchEnded() {
2638
2728
  * Return true to enable touch gestures like pinch-to-zoom
2639
2729
  * and scroll, which q5 disables on the canvas by default.
2640
2730
  * @example
2641
- await createCanvas(200);
2731
+ createCanvas(200);
2642
2732
  let gray = 95;
2643
2733
 
2644
2734
  function touchMoved() {
@@ -2659,7 +2749,7 @@ function touchMoved() {
2659
2749
  * The `event` property contains the original
2660
2750
  * [PointerEvent](https://developer.mozilla.org/docs/Web/API/PointerEvent).
2661
2751
  * @example
2662
- Q5.draw = function () {
2752
+ function draw() {
2663
2753
  background(200);
2664
2754
  for (let pointerID in pointers) {
2665
2755
  let pointer = pointers[pointerID];
@@ -2677,7 +2767,7 @@ Q5.draw = function () {
2677
2767
  * @param {number} [x] x-coordinate of the cursor's point
2678
2768
  * @param {number} [y] y-coordinate of the cursor's point
2679
2769
  * @example
2680
- await createCanvas(200, 100);
2770
+ createCanvas(200, 100);
2681
2771
  cursor('pointer');
2682
2772
  */
2683
2773
  function cursor(name: string, x?: number, y?: number): void;
@@ -2685,7 +2775,7 @@ cursor('pointer');
2685
2775
  /** 🖲️
2686
2776
  * Hides the cursor within the bounds of the canvas.
2687
2777
  * @example
2688
- await createCanvas(200, 100);
2778
+ createCanvas(200, 100);
2689
2779
  noCursor();
2690
2780
  */
2691
2781
  function noCursor(): void;
@@ -2699,7 +2789,7 @@ noCursor();
2699
2789
  * Return true to allow the default behavior of scrolling the page.
2700
2790
  * @example
2701
2791
  let x = y = 100;
2702
- Q5.draw = function () {
2792
+ function draw() {
2703
2793
  circle(x, y, 10);
2704
2794
  }
2705
2795
  function mouseWheel(e) {
@@ -2720,7 +2810,7 @@ function mouseWheel(e) {
2720
2810
  *
2721
2811
  * @param {boolean} unadjustedMovement set to true to disable OS-level mouse acceleration and access raw mouse input
2722
2812
  * @example
2723
- Q5.draw = function () {
2813
+ function draw() {
2724
2814
  circle(mouseX / 10, mouseY / 10, 10);
2725
2815
  }
2726
2816
 
@@ -2747,15 +2837,15 @@ function doubleClicked() {
2747
2837
  * @param {number} [high] upper bound (exclusive)
2748
2838
  * @returns {number | any} a random number or element
2749
2839
  * @example
2750
- await createCanvas(200);
2840
+ createCanvas(200);
2751
2841
  background(200);
2752
2842
  frameRate(5);
2753
2843
 
2754
- Q5.draw = function () {
2844
+ function draw() {
2755
2845
  circle(100, 100, random(20, 200));
2756
2846
  }
2757
2847
  * @example
2758
- Q5.draw = function () {
2848
+ function draw() {
2759
2849
  circle(random(200), random(200), 10);
2760
2850
  }
2761
2851
  */
@@ -2770,13 +2860,14 @@ Q5.draw = function () {
2770
2860
  * @param {number} amount absolute maximum amount of jitter, default is 1
2771
2861
  * @returns {number} random number between -val and val
2772
2862
  * @example
2773
- Q5.draw = function () {
2863
+ function draw() {
2774
2864
  circle(mouseX + jit(3), mouseY + jit(3), 5);
2775
2865
  }
2776
2866
  * @example
2777
- await createCanvas(200, GPU);
2867
+ let q = await Q5.WebGPU();
2868
+ createCanvas(200, 100);
2778
2869
 
2779
- Q5.draw = function () {
2870
+ q.draw = () => {
2780
2871
  circle(jit(50), 0, random(50));
2781
2872
  };
2782
2873
  */
@@ -2791,13 +2882,13 @@ Q5.draw = function () {
2791
2882
  * @param {number} [z] z-coordinate input
2792
2883
  * @returns {number} a noise value
2793
2884
  * @example
2794
- Q5.draw = function () {
2885
+ function draw() {
2795
2886
  background(200);
2796
2887
  let n = noise(frameCount * 0.01);
2797
2888
  circle(100, 100, n * 200);
2798
2889
  }
2799
2890
  * @example
2800
- Q5.draw = function () {
2891
+ function draw() {
2801
2892
  background(200);
2802
2893
  let t = (frameCount + mouseX) * 0.02;
2803
2894
  for (let x = -5; x < 220; x += 10) {
@@ -2806,9 +2897,9 @@ Q5.draw = function () {
2806
2897
  }
2807
2898
  }
2808
2899
  * @example
2809
- await createCanvas(200);
2900
+ let q = await Q5.WebGPU();
2810
2901
 
2811
- Q5.draw = () => {
2902
+ q.draw = () => {
2812
2903
  noStroke();
2813
2904
  let t = millis() * 0.002;
2814
2905
  for (let x = -100; x < 100; x += 5) {
@@ -2831,7 +2922,7 @@ Q5.draw = () => {
2831
2922
  * @param {number} y2 y-coordinate of the second point
2832
2923
  * @returns {number} distance between the points
2833
2924
  * @example
2834
- Q5.draw = function () {
2925
+ function draw() {
2835
2926
  background(200);
2836
2927
  circle(100, 100, 20);
2837
2928
  circle(mouseX, mouseY, 20);
@@ -2920,7 +3011,7 @@ Q5.draw = function () {
2920
3011
  * @param {number} [d] number of decimal places to round to
2921
3012
  * @returns {number} rounded number
2922
3013
  * @example
2923
- await createCanvas(200, 100);
3014
+ createCanvas(200, 100);
2924
3015
  background(200);
2925
3016
  textSize(32);
2926
3017
  text(round(PI, 5), 10, 60);
@@ -2932,7 +3023,7 @@ text(round(PI, 5), 10, 60);
2932
3023
  * @param {number} n a number
2933
3024
  * @returns {number} rounded number
2934
3025
  * @example
2935
- await createCanvas(200, 100);
3026
+ createCanvas(200, 100);
2936
3027
  background(200);
2937
3028
  textSize(32);
2938
3029
  text(ceil(PI), 10, 60);
@@ -2944,7 +3035,7 @@ text(ceil(PI), 10, 60);
2944
3035
  * @param {number} n a number
2945
3036
  * @returns {number} rounded number
2946
3037
  * @example
2947
- await createCanvas(200, 100);
3038
+ createCanvas(200, 100);
2948
3039
  background(200);
2949
3040
  textSize(32);
2950
3041
  text(floor(-PI), 10, 60);
@@ -2956,7 +3047,7 @@ text(floor(-PI), 10, 60);
2956
3047
  * @param {...number} args numbers to compare
2957
3048
  * @returns {number} minimum
2958
3049
  * @example
2959
- Q5.draw = function () {
3050
+ function draw() {
2960
3051
  background(min(mouseX, 100));
2961
3052
  }
2962
3053
  */
@@ -2967,7 +3058,7 @@ Q5.draw = function () {
2967
3058
  * @param {...number} args numbers to compare
2968
3059
  * @returns {number} maximum
2969
3060
  * @example
2970
- Q5.draw = function () {
3061
+ function draw() {
2971
3062
  background(max(mouseX, 100));
2972
3063
  }
2973
3064
  */
@@ -2975,7 +3066,7 @@ Q5.draw = function () {
2975
3066
 
2976
3067
  /** 🧮
2977
3068
  * Calculates the value of a base raised to a power.
2978
- *
3069
+ *
2979
3070
  * For example, `pow(2, 3)` calculates 2 * 2 * 2 which is 8.
2980
3071
  * @param {number} base base
2981
3072
  * @param {number} exponent exponent
@@ -3039,8 +3130,8 @@ Q5.draw = function () {
3039
3130
 
3040
3131
  /** 🧮
3041
3132
  * Sets the noise generation mode.
3042
- *
3043
- * Only the default mode, "perlin", is included in q5.js. Use of the
3133
+ *
3134
+ * Only the default mode, "perlin", is included in q5.js. Use of the
3044
3135
  * other modes requires the q5-noiser module.
3045
3136
  * @param {'perlin' | 'simplex' | 'blocky'} mode noise generation mode
3046
3137
  */
@@ -3094,7 +3185,7 @@ Q5.draw = function () {
3094
3185
  /** 🔊
3095
3186
  * q5.js includes low latency sound playback and basic mixing powered
3096
3187
  * by WebAudio.
3097
- *
3188
+ *
3098
3189
  * For audio filtering, synthesis, and analysis, consider using
3099
3190
  * [p5.sound](https://p5js.org/reference/p5.sound/).
3100
3191
  */
@@ -3124,12 +3215,12 @@ Q5.draw = function () {
3124
3215
  * @param {string} url sound file
3125
3216
  * @returns {Sound | Promise<Sound>} a new `Sound` object or promise
3126
3217
  * @example
3127
- await createCanvas(200);
3218
+ createCanvas(200);
3128
3219
 
3129
3220
  let sound = loadSound('/assets/jump.wav');
3130
3221
  sound.volume = 0.3;
3131
3222
 
3132
- Q5.mousePressed = function () {
3223
+ function mousePressed() {
3133
3224
  sound.play();
3134
3225
  }
3135
3226
  */
@@ -3148,12 +3239,12 @@ Q5.mousePressed = function () {
3148
3239
  * @param url audio file
3149
3240
  * @returns {HTMLAudioElement | Promise<HTMLAudioElement>} an HTMLAudioElement or promise
3150
3241
  * @example
3151
- await createCanvas(200);
3242
+ createCanvas(200);
3152
3243
 
3153
3244
  let audio = loadAudio('/assets/retro.flac');
3154
3245
  audio.volume = 0.4;
3155
3246
 
3156
- Q5.mousePressed = function () {
3247
+ function mousePressed() {
3157
3248
  audio.play();
3158
3249
  }
3159
3250
  */
@@ -3210,10 +3301,10 @@ Q5.mousePressed = function () {
3210
3301
 
3211
3302
  /** 🔊
3212
3303
  * Plays the sound.
3213
- *
3304
+ *
3214
3305
  * If this function is run when the sound is already playing,
3215
3306
  * a new playback will start, causing a layering effect.
3216
- *
3307
+ *
3217
3308
  * If this function is run when the sound is paused,
3218
3309
  * all playback instances will be resumed.
3219
3310
  */
@@ -3227,7 +3318,7 @@ Q5.mousePressed = function () {
3227
3318
  /** 🔊
3228
3319
  * Stops the sound, resetting its playback position
3229
3320
  * to the beginning.
3230
- *
3321
+ *
3231
3322
  * Removes all playback instances.
3232
3323
  */
3233
3324
  stop(): void;
@@ -3262,7 +3353,7 @@ Q5.mousePressed = function () {
3262
3353
  * @param {string} [content] content of the element
3263
3354
  * @returns {HTMLElement} element
3264
3355
  * @example
3265
- await createCanvas(200);
3356
+ createCanvas(200);
3266
3357
 
3267
3358
  let el = createEl('div', '*');
3268
3359
  el.position(50, 50);
@@ -3280,7 +3371,7 @@ el.style.color = 'white';
3280
3371
  * @param {string} [text] text content
3281
3372
  * @param {boolean} [newTab] whether to open the link in a new tab
3282
3373
  * @example
3283
- await createCanvas(200);
3374
+ createCanvas(200);
3284
3375
 
3285
3376
  let link = createA('https://q5js.org', 'q5.js');
3286
3377
  link.position(16, 42);
@@ -3296,7 +3387,7 @@ link.addEventListener('mouseover', () => {
3296
3387
  * Creates a button element.
3297
3388
  * @param {string} [content] text content
3298
3389
  * @example
3299
- await createCanvas(200, 100);
3390
+ createCanvas(200, 100);
3300
3391
 
3301
3392
  let btn = createButton('Click me!');
3302
3393
 
@@ -3315,7 +3406,7 @@ btn.addEventListener('click', () => {
3315
3406
  * @param {string} [label] text label placed next to the checkbox
3316
3407
  * @param {boolean} [checked] initial state
3317
3408
  * @example
3318
- await createCanvas(200, 100);
3409
+ createCanvas(200, 100);
3319
3410
 
3320
3411
  let box = createCheckbox('Check me!');
3321
3412
  box.label.style.color = 'lime';
@@ -3333,12 +3424,12 @@ box.addEventListener('input', () => {
3333
3424
  * Use the `value` property to get or set the color value.
3334
3425
  * @param {string} [value] initial color value
3335
3426
  * @example
3336
- await createCanvas(200, 100);
3427
+ createCanvas(200, 100);
3337
3428
 
3338
3429
  let picker = createColorPicker();
3339
3430
  picker.value = '#fd7575';
3340
3431
 
3341
- Q5.draw = function () {
3432
+ function draw() {
3342
3433
  background(picker.value);
3343
3434
  }
3344
3435
  */
@@ -3348,7 +3439,7 @@ Q5.draw = function () {
3348
3439
  * Creates an image element.
3349
3440
  * @param {string} src url of the image
3350
3441
  * @example
3351
- await createCanvas(200, 100);
3442
+ createCanvas(200, 100);
3352
3443
 
3353
3444
  let img = createImg('/assets/p5play_logo.webp')
3354
3445
  .position(0, 0)
@@ -3368,7 +3459,7 @@ let img = createImg('/assets/p5play_logo.webp')
3368
3459
  * @param {string} [value] initial value
3369
3460
  * @param {string} [type] text input type, can be 'text', 'password', 'email', 'number', 'range', 'search', 'tel', 'url'
3370
3461
  * @example
3371
- await createCanvas(200, 100);
3462
+ createCanvas(200, 100);
3372
3463
  textSize(64);
3373
3464
 
3374
3465
  let input = createInput();
@@ -3386,7 +3477,7 @@ input.addEventListener('input', () => {
3386
3477
  * Creates a paragraph element.
3387
3478
  * @param {string} [content] text content
3388
3479
  * @example
3389
- await createCanvas(200, 50);
3480
+ createCanvas(200, 50);
3390
3481
  background('coral');
3391
3482
 
3392
3483
  let p = createP('Hello, world!');
@@ -3403,19 +3494,19 @@ p.style.color = 'pink';
3403
3494
  * Use the `value` property to get or set the value of the selected radio button.
3404
3495
  * @param {string} [groupName]
3405
3496
  * @example
3406
- await createCanvas(200, 100);
3497
+ createCanvas(200, 100);
3407
3498
 
3408
3499
  let radio = createRadio()
3409
3500
  .option('square', '1')
3410
3501
  .option('circle', '2');
3411
3502
 
3412
- Q5.draw = function () {
3503
+ function draw() {
3413
3504
  background(200);
3414
3505
  if (radio.value == '1') square(75, 25, 50);
3415
3506
  if (radio.value == '2') circle(100, 50, 50);
3416
3507
  }
3417
3508
  */
3418
- function createRadio(groupName): HTMLDivElement;
3509
+ function createRadio(groupName?: string): HTMLDivElement;
3419
3510
 
3420
3511
  /** 📑
3421
3512
  * Creates a select element.
@@ -3432,7 +3523,7 @@ Q5.draw = function () {
3432
3523
  * string or an array of strings.
3433
3524
  * @param {string} [placeholder] optional placeholder text that appears before an option is selected
3434
3525
  * @example
3435
- await createCanvas(200, 100);
3526
+ createCanvas(200, 100);
3436
3527
 
3437
3528
  let sel = createSelect('Select a color')
3438
3529
  .option('Red', '#f55')
@@ -3442,7 +3533,7 @@ sel.addEventListener('change', () => {
3442
3533
  background(sel.value);
3443
3534
  });
3444
3535
  */
3445
- function createSelect(placeholder): HTMLSelectElement;
3536
+ function createSelect(placeholder?: string): HTMLSelectElement;
3446
3537
 
3447
3538
  /** 📑
3448
3539
  * Creates a slider element.
@@ -3455,13 +3546,13 @@ sel.addEventListener('change', () => {
3455
3546
  * @param {number} [value] initial value
3456
3547
  * @param {number} [step] step size
3457
3548
  * @example
3458
- await createCanvas(200);
3549
+ createCanvas(200);
3459
3550
 
3460
3551
  let slider = createSlider(0, 255)
3461
3552
  .position(10, 10)
3462
3553
  .size(180);
3463
3554
 
3464
- Q5.draw = function () {
3555
+ function draw() {
3465
3556
  background(slider.val());
3466
3557
  }
3467
3558
  */
@@ -3481,7 +3572,7 @@ Q5.draw = function () {
3481
3572
  * @param {string} src url of the video
3482
3573
  * @returns {HTMLVideoElement | Promise<HTMLVideoElement>} a new video element or promise
3483
3574
  * @example
3484
- await createCanvas(0);
3575
+ createCanvas(0);
3485
3576
 
3486
3577
  let vid = createVideo('/assets/apollo4.mp4');
3487
3578
  vid.size(200, 150);
@@ -3489,15 +3580,15 @@ vid.autoplay = vid.muted = vid.loop = true;
3489
3580
  vid.controls = true;
3490
3581
 
3491
3582
  * @example
3492
- await createCanvas(200, 150);
3583
+ createCanvas(200, 150);
3493
3584
  let vid = createVideo('/assets/apollo4.mp4');
3494
3585
  vid.hide();
3495
3586
 
3496
- Q5.mousePressed = function () {
3587
+ function mousePressed() {
3497
3588
  vid.currentTime = 0;
3498
3589
  vid.play();
3499
3590
  }
3500
- Q5.draw = function () {
3591
+ function draw() {
3501
3592
  image(vid, 0, 0, 200, 150);
3502
3593
  filter(HUE_ROTATE, 90);
3503
3594
  }
@@ -3524,30 +3615,30 @@ Q5.draw = function () {
3524
3615
  * @param {boolean} [flipped] whether to mirror the video vertically, true by default
3525
3616
  * @returns {HTMLVideoElement | Promise<HTMLVideoElement>} a new video element or promise
3526
3617
  * @example
3527
- await createCanvas(200);
3618
+ createCanvas(200);
3528
3619
 
3529
- Q5.mousePressed = function () {
3620
+ function mousePressed() {
3530
3621
  let cap = createCapture(VIDEO);
3531
3622
  cap.size(200, 112.5);
3532
3623
  canvas.remove();
3533
3624
  }
3534
3625
  * @example
3535
- await createCanvas(200);
3626
+ createCanvas(200);
3536
3627
 
3537
3628
  let cap;
3538
- Q5.mousePressed = function () {
3629
+ function mousePressed() {
3539
3630
  cap = createCapture(VIDEO);
3540
3631
  cap.hide();
3541
3632
  }
3542
3633
 
3543
- Q5.draw = function () {
3634
+ function draw() {
3544
3635
  let y = frameCount % height;
3545
3636
  image(cap, 0, y, 200, 200);
3546
3637
  }
3547
3638
  * @example
3548
- await createCanvas(200);
3639
+ createCanvas(200);
3549
3640
 
3550
- Q5.mousePressed = function () {
3641
+ function mousePressed() {
3551
3642
  let cap = createCapture({
3552
3643
  video: { width: 640, height: 480 }
3553
3644
  });
@@ -3594,12 +3685,12 @@ Q5.mousePressed = function () {
3594
3685
  *
3595
3686
  * @returns {HTMLElement} a recorder, q5 DOM element
3596
3687
  * @example
3597
- await createCanvas(200);
3688
+ createCanvas(200);
3598
3689
 
3599
3690
  let rec = createRecorder();
3600
3691
  rec.bitrate = 10;
3601
3692
 
3602
- Q5.draw = function () {
3693
+ function draw() {
3603
3694
  circle(mouseX, random(height), 10);
3604
3695
  }
3605
3696
  */
@@ -3607,7 +3698,7 @@ Q5.draw = function () {
3607
3698
 
3608
3699
  /** 🎞️
3609
3700
  * Starts recording the canvas or resumes recording if it was paused.
3610
- *
3701
+ *
3611
3702
  * If no recorder exists, one is created but not displayed.
3612
3703
  */
3613
3704
  function record(): void;
@@ -3626,16 +3717,16 @@ Q5.draw = function () {
3626
3717
  * Saves the current recording as a video file.
3627
3718
  * @param {string} fileName
3628
3719
  * @example
3629
- Q5.draw = function () {
3720
+ function draw() {
3630
3721
  square(mouseX, random(200), 10);
3631
3722
  }
3632
3723
 
3633
- Q5.mousePressed = function () {
3724
+ function mousePressed() {
3634
3725
  if (!recording) record();
3635
3726
  else saveRecording('squares');
3636
3727
  }
3637
3728
  */
3638
- function saveRecording(fileName): void;
3729
+ function saveRecording(fileName: string): void;
3639
3730
 
3640
3731
  /** 🎞️
3641
3732
  * True if the canvas is currently being recorded.
@@ -3655,15 +3746,17 @@ Q5.mousePressed = function () {
3655
3746
  * @param {...string} urls
3656
3747
  * @returns {Promise<any[]>} a promise that resolves with objects
3657
3748
  * @example
3658
- await createCanvas(200);
3749
+ let logo;
3659
3750
 
3660
- let logo = await load('/q5js_logo.avif');
3751
+ async function setup() {
3752
+ logo = await load('/q5js_logo.avif');
3753
+ }
3661
3754
 
3662
- Q5.draw = function () {
3755
+ function draw() {
3663
3756
  image(logo, 0, 0, 200, 200);
3664
3757
  }
3665
3758
  * @example
3666
- await createCanvas(200);
3759
+ createCanvas(200);
3667
3760
 
3668
3761
  // use with top level await in a module
3669
3762
  await load('/assets/Robotica.ttf');
@@ -3672,26 +3765,16 @@ background(255);
3672
3765
  textSize(24);
3673
3766
  text('Hello, world!', 16, 100);
3674
3767
  * @example
3675
- await createCanvas(200);
3768
+ let q = await Q5.WebGPU();
3769
+ createCanvas(200);
3676
3770
 
3677
3771
  let [jump, retro] = await load(
3678
3772
  '/assets/jump.wav', '/assets/retro.flac'
3679
3773
  );
3680
3774
 
3681
- Q5.mousePressed = () => {
3775
+ q.mousePressed = () => {
3682
3776
  mouseButton == 'left' ? jump.play() : retro.play();
3683
3777
  };
3684
- * @example
3685
- await createCanvas(200);
3686
- background(200);
3687
- textSize(32);
3688
-
3689
- let myXML = await load('/assets/animals.xml');
3690
- let mammals = myXML.getElementsByTagName('mammal');
3691
- let y = 64;
3692
- for (let mammal of mammals) {
3693
- text(mammal.textContent, 20, (y += 32));
3694
- }
3695
3778
  */
3696
3779
  function load(...urls: string[]): Promise<any[]>;
3697
3780
 
@@ -3705,21 +3788,21 @@ for (let mammal of mammals) {
3705
3788
  * @param {object} [data] canvas, image, or JS object
3706
3789
  * @param {string} [fileName] filename to save as
3707
3790
  * @example
3708
- await createCanvas(200);
3791
+ createCanvas(200);
3709
3792
  background(200);
3710
3793
  circle(100, 100, 50);
3711
3794
 
3712
- Q5.mousePressed = function () {
3795
+ function mousePressed() {
3713
3796
  save('circle.png');
3714
3797
  }
3715
3798
  * @example
3716
- await createCanvas(200);
3799
+ createCanvas(200);
3717
3800
 
3718
3801
  textSize(180);
3719
3802
  let bolt = createTextImage('⚡️');
3720
3803
  image(bolt, 16, -56);
3721
3804
 
3722
- Q5.mousePressed = function () {
3805
+ function mousePressed() {
3723
3806
  save(bolt, 'bolt.png');
3724
3807
  }
3725
3808
  */
@@ -3727,9 +3810,9 @@ Q5.mousePressed = function () {
3727
3810
 
3728
3811
  /** 🛠️
3729
3812
  * Loads a text file from the specified url.
3730
- *
3813
+ *
3731
3814
  * Returns a promise if used in async `setup`.
3732
- *
3815
+ *
3733
3816
  * @param {string} url text file
3734
3817
  * @returns {object | Promise} an object containing the loaded text in the property `obj.text` or a promise
3735
3818
  */
@@ -3737,9 +3820,9 @@ Q5.mousePressed = function () {
3737
3820
 
3738
3821
  /** 🛠️
3739
3822
  * Loads a JSON file from the specified url.
3740
- *
3823
+ *
3741
3824
  * Returns a promise if used in async `setup`.
3742
- *
3825
+ *
3743
3826
  * @param {string} url JSON file
3744
3827
  * @returns {any | Promise} an object or array containing the loaded JSON or a promise
3745
3828
  */
@@ -3747,9 +3830,9 @@ Q5.mousePressed = function () {
3747
3830
 
3748
3831
  /** 🛠️
3749
3832
  * Loads a CSV file from the specified url.
3750
- *
3833
+ *
3751
3834
  * Returns a promise if used in async `setup`.
3752
- *
3835
+ *
3753
3836
  * @param {string} url CSV file
3754
3837
  * @returns {object[] | Promise<object[]>} an array of objects containing the loaded CSV or a promise
3755
3838
  */
@@ -3762,6 +3845,20 @@ Q5.mousePressed = function () {
3762
3845
  *
3763
3846
  * @param {string} url xml file
3764
3847
  * @returns {Element | Promise<Element>} an object containing the loaded XML in a property called `obj.DOM` or a promise
3848
+ * @example
3849
+ async function setup() {
3850
+ createCanvas(200);
3851
+ background(200);
3852
+ textSize(32);
3853
+
3854
+ let myXML = await loadXML('/assets/animals.xml');
3855
+
3856
+ let mammals = myXML.getElementsByTagName('mammal');
3857
+ let y = 64;
3858
+ for (let mammal of mammals) {
3859
+ text(mammal.textContent, 20, (y += 32));
3860
+ }
3861
+ }
3765
3862
  */
3766
3863
  function loadXML(url: string): object | Promise<Element>;
3767
3864
 
@@ -3776,7 +3873,7 @@ Q5.mousePressed = function () {
3776
3873
 
3777
3874
  /** 🛠
3778
3875
  * Shuffles the elements of an array.
3779
- *
3876
+ *
3780
3877
  * @param {any[]} arr array to shuffle
3781
3878
  * @param {boolean} [modify] whether to modify the original array, false by default which copies the array before shuffling
3782
3879
  * @returns {any[]} shuffled array
@@ -4028,7 +4125,7 @@ Q5.mousePressed = function () {
4028
4125
  * @param {string} code WGSL shader code excerpt
4029
4126
  * @returns {GPUShaderModule} a shader program
4030
4127
  * @example
4031
- await createCanvas(200, GPU);
4128
+ let q = await Q5.WebGPU();
4032
4129
 
4033
4130
  let wobble = createShader(`
4034
4131
  @vertex
@@ -4044,13 +4141,13 @@ fn vertexMain(v: VertexParams) -> FragParams {
4044
4141
  return f;
4045
4142
  }`);
4046
4143
 
4047
- Q5.draw = function () {
4144
+ q.draw = () => {
4048
4145
  clear();
4049
4146
  shader(wobble);
4050
4147
  plane(0, 0, 100);
4051
4148
  };
4052
4149
  * @example
4053
- await createCanvas(200, GPU);
4150
+ let q = await Q5.WebGPU();
4054
4151
 
4055
4152
  let stripes = createShader(`
4056
4153
  @fragment
@@ -4059,7 +4156,7 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
4059
4156
  return vec4(r, 0.0, 1, 1);
4060
4157
  }`);
4061
4158
 
4062
- Q5.draw = function () {
4159
+ q.draw = () => {
4063
4160
  shader(stripes);
4064
4161
  triangle(-50, -50, 0, 50, 50, -50);
4065
4162
  };
@@ -4073,7 +4170,8 @@ Q5.draw = function () {
4073
4170
  * @param {number} w width or side length
4074
4171
  * @param {number} [h] height
4075
4172
  * @example
4076
- await createCanvas(200, GPU);
4173
+ let q = await Q5.WebGPU();
4174
+ createCanvas(200);
4077
4175
  plane(0, 0, 100);
4078
4176
  */
4079
4177
  function plane(x: number, y: number, w: number, h?: number): void;
@@ -4087,7 +4185,7 @@ plane(0, 0, 100);
4087
4185
  /** ⚡️
4088
4186
  * Make q5 use the default shapes shader.
4089
4187
  * @example
4090
- await createCanvas(200, GPU);
4188
+ let q = await Q5.WebGPU();
4091
4189
 
4092
4190
  let stripes = createShader(`
4093
4191
  @fragment
@@ -4096,7 +4194,7 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
4096
4194
  return vec4(1, g, 0, 1);
4097
4195
  }`);
4098
4196
 
4099
- Q5.draw = function () {
4197
+ q.draw = () => {
4100
4198
  shader(stripes);
4101
4199
  background(0);
4102
4200
 
@@ -4139,7 +4237,8 @@ Q5.draw = function () {
4139
4237
  * Use this function to customize a copy of the
4140
4238
  * [default frame shader](https://github.com/q5js/q5.js/blob/main/src/shaders/frame.wgsl).
4141
4239
  * @example
4142
- await createCanvas(200, GPU);
4240
+ let q = await Q5.WebGPU();
4241
+ createCanvas(200);
4143
4242
 
4144
4243
  let boxy = createFrameShader(`
4145
4244
  @fragment
@@ -4150,7 +4249,7 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
4150
4249
  return textureSample(tex, samp, uv);
4151
4250
  }`);
4152
4251
 
4153
- Q5.draw = function () {
4252
+ q.draw = () => {
4154
4253
  stroke(1);
4155
4254
  strokeWeight(8);
4156
4255
  line(mouseX, mouseY, pmouseX, pmouseY);
@@ -4167,7 +4266,7 @@ Q5.draw = function () {
4167
4266
  * @param {string} code WGSL shader code excerpt
4168
4267
  * @returns {GPUShaderModule} a shader program
4169
4268
  * @example
4170
- await createCanvas(200, GPU);
4269
+ let q = await Q5.WebGPU();
4171
4270
  imageMode(CENTER);
4172
4271
 
4173
4272
  let logo = loadImage('/q5js_logo.avif');
@@ -4180,7 +4279,7 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
4180
4279
  return texColor;
4181
4280
  }`);
4182
4281
 
4183
- Q5.draw = function () {
4282
+ q.draw = () => {
4184
4283
  background(0.7);
4185
4284
  shader(grate);
4186
4285
  image(logo, 0, 0, 180, 180);
@@ -4196,7 +4295,8 @@ Q5.draw = function () {
4196
4295
  * @param {string} code WGSL shader code excerpt
4197
4296
  * @returns {GPUShaderModule} a shader program
4198
4297
  * @example
4199
- await createCanvas(200, 600, GPU);
4298
+ let q = await Q5.WebGPU();
4299
+ createCanvas(200, 600);
4200
4300
 
4201
4301
  let vid = createVideo('/assets/apollo4.mp4');
4202
4302
  vid.hide();
@@ -4224,7 +4324,7 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
4224
4324
  return texColor;
4225
4325
  }`);
4226
4326
 
4227
- Q5.draw = function () {
4327
+ q.draw = () => {
4228
4328
  clear();
4229
4329
  if (mouseIsPressed) vid.play();
4230
4330
  shader(flipper);
@@ -4241,7 +4341,7 @@ Q5.draw = function () {
4241
4341
  * @param {string} code WGSL shader code excerpt
4242
4342
  * @returns {GPUShaderModule} a shader program
4243
4343
  * @example
4244
- await createCanvas(200, GPU);
4344
+ let q = await Q5.WebGPU();
4245
4345
  textAlign(CENTER, CENTER);
4246
4346
 
4247
4347
  let spin = createTextShader(`
@@ -4267,7 +4367,7 @@ fn vertexMain(v : VertexParams) -> FragParams {
4267
4367
  return f;
4268
4368
  }`);
4269
4369
 
4270
- Q5.draw = function () {
4370
+ q.draw = () => {
4271
4371
  clear();
4272
4372
  shader(spin);
4273
4373
  fill(1, 0, 1);