q5 2.11.7 → 2.12.4

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.
package/q5.d.ts CHANGED
@@ -7,57 +7,11 @@
7
7
  declare global {
8
8
  // ⭐️ core
9
9
 
10
- class Q5 {
11
- /** ⭐️
12
- * Creates an instance of Q5.
13
- *
14
- * Running `new Q5()` enables the use of q5 functions and variables
15
- * anywhere in your code. You can also start Q5 in global mode by
16
- * running [`createCanvas`](https://q5js.org/learn/#canvas-createCanvas). q5 uses the q2d renderer, based on the CanvasRenderingContext2D, by default.
17
- *
18
- * To use the q5 WebGPU renderer, run `Q5.webgpu()` after the creation of any file level variables. For more information read the [q5-webgpu modules documentation](https://github.com/q5js/q5.js/blob/main/src/readme.md#webgpu-canvas).
19
- * @param {string | Function} [scope] -
20
- * - "global": (default) top-level global mode, adds q5 functions
21
- * and variables to the global scope
22
- * - "auto": if users don't create a new instance of Q5 themselves, an instance will be created automatically with this scope, which replicates p5's global mode
23
- * - "instance": enables users to [assign a Q5 instance to a variable](https://github.com/q5js/q5.js/wiki/Instance-Mode), not to the global scope
24
- * @param {HTMLElement} [parent] - element that the canvas will be placed inside
25
- * @example
26
- new Q5();
27
- createCanvas(200, 100);
28
- circle(100, 50, 80);
29
- */
30
- constructor(scope?: string | Function, parent?: HTMLElement);
31
-
32
- /** ⭐️
33
- * Q5 reformats some errors to make them more readable for beginners.
34
- * @default false
35
- */
36
- static disableFriendlyErrors: boolean;
37
-
38
- /** ⭐️
39
- * Sets the default canvas context attributes for all Q5 instances
40
- * and graphics.
41
- * @default { alpha: false, colorSpace: 'display-p3' }
42
- */
43
- static canvasOptions: {};
44
-
45
- /** ⭐️
46
- * True if the device supports HDR (the display-p3 colorspace).
47
- */
48
- static supportsHDR: boolean;
49
-
50
- /** ⭐️
51
- * Modules added to this object will be added to new Q5 instances.
52
- */
53
- static modules: {};
54
- }
55
-
56
10
  /** ⭐️
57
11
  * The draw function is run 60 times per second by default.
58
12
  * @example
59
13
  function draw() {
60
- background('lightgray');
14
+ background('silver');
61
15
  circle(frameCount % 200, 100, 80);
62
16
  }
63
17
  */
@@ -74,13 +28,15 @@ function setup() {
74
28
  function setup(): void;
75
29
 
76
30
  /** ⭐️
77
- * Use preload to load assets before the sketch starts and the
78
- * setup and draw functions are run.
31
+ * Load assets in the preload function to ensure that they're
32
+ * available before the setup and draw functions are run.
79
33
  * @example
80
34
  let logo;
35
+
81
36
  function preload() {
82
37
  logo = loadImage('/q5js_logo.webp');
83
38
  }
39
+
84
40
  function draw() {
85
41
  background(logo);
86
42
  }
@@ -111,7 +67,7 @@ function draw() {
111
67
  /** ⭐️
112
68
  * Redraws the canvas n times. If no input parameter is provided,
113
69
  * it calls the draw function once.
114
- * @param {number} [n] - number of times to redraw the canvas, default is 1
70
+ * @param {number} [n] number of times to redraw the canvas, default is 1
115
71
  * @example
116
72
  createCanvas(200, 200);
117
73
  noLoop();
@@ -119,7 +75,7 @@ noLoop();
119
75
  function draw() {
120
76
  circle(frameCount * 5, 100, 80);
121
77
  }
122
- function mouseClicked() {
78
+ function mousePressed() {
123
79
  redraw();
124
80
  }
125
81
  */
@@ -134,7 +90,7 @@ noLoop();
134
90
  function draw() {
135
91
  circle(frameCount * 5, 100, 80);
136
92
  }
137
- function mouseClicked() {
93
+ function mousePressed() {
138
94
  loop();
139
95
  }
140
96
  */
@@ -142,7 +98,7 @@ function mouseClicked() {
142
98
 
143
99
  /** ⭐️
144
100
  * Sets the target frame rate or gets the sketch's current frame rate.
145
- * @param {number} [hertz] - target frame rate, default is 60
101
+ * @param {number} [hertz] target frame rate, default is 60
146
102
  * @returns {number} current frame rate
147
103
  * @example
148
104
  function draw() {
@@ -169,6 +125,7 @@ function draw() {
169
125
  function draw() {
170
126
  background(200);
171
127
  textSize(64);
128
+
172
129
  text(getTargetFrameRate(), 65, 120);
173
130
  }
174
131
  */
@@ -184,6 +141,7 @@ function draw() {
184
141
  background(200);
185
142
  frameRate(1);
186
143
  textSize(64);
144
+
187
145
  text(getFPS(), 8, 120);
188
146
  }
189
147
  */
@@ -192,7 +150,11 @@ function draw() {
192
150
  /** ⭐️
193
151
  * Logs a message to the JavaScript console. Alias for the standard
194
152
  * [`console.log`](https://developer.mozilla.org/en-US/docs/Web/API/console/log_static) function.
195
- * @param {*} message - message to log
153
+ *
154
+ * You can open web developer tools in most browsers by using the
155
+ * keyboard shortcut `Ctrl + Shift + i` or `command + option + i`,
156
+ * then click the "Console" tab.
157
+ * @param {*} message message to log
196
158
  */
197
159
  function log(message: any): void;
198
160
 
@@ -248,22 +210,70 @@ function draw() {
248
210
  */
249
211
  var deltaTime: number;
250
212
 
213
+ class Q5 {
214
+ /** ⭐️
215
+ * Creates an instance of Q5.
216
+ *
217
+ * Running `new Q5()` enables the use of q5 functions and variables
218
+ * anywhere in your code. You can also start Q5 in global mode by
219
+ * running [`createCanvas`](https://q5js.org/learn/#canvas-createCanvas).
220
+ *
221
+ * By default q5 uses the CanvasRenderingContext2D based q2d renderer.
222
+ *
223
+ * To use the q5 WebGPU renderer, run `Q5.webgpu()` after the creation of any file level variables. For more information read the [q5-webgpu modules documentation](https://github.com/q5js/q5.js/blob/main/src/readme.md#webgpu-canvas).
224
+ * @param {string | Function} [scope]
225
+ * - "global": (default) top-level global mode, adds q5 functions
226
+ * and variables to the global scope
227
+ * - "auto": if users don't create a new instance of Q5 themselves, an instance will be created automatically with this scope, which replicates p5's global mode
228
+ * - "instance": enables users to [assign a Q5 instance to a variable](https://github.com/q5js/q5.js/wiki/Instance-Mode), not to the global scope
229
+ * @param {HTMLElement} [parent] element that the canvas will be placed inside
230
+ * @example
231
+ new Q5();
232
+ createCanvas(200, 100);
233
+ circle(100, 50, 80);
234
+ */
235
+ constructor(scope?: string | Function, parent?: HTMLElement);
236
+
237
+ /** ⭐️
238
+ * Q5 reformats some errors to make them more readable for beginners.
239
+ * @default false
240
+ */
241
+ static disableFriendlyErrors: boolean;
242
+
243
+ /** ⭐️
244
+ * Sets the default canvas context attributes for all Q5 instances
245
+ * and graphics.
246
+ * @default { alpha: false, colorSpace: 'display-p3' }
247
+ */
248
+ static canvasOptions: {};
249
+
250
+ /** ⭐️
251
+ * True if the device supports HDR (the display-p3 colorspace).
252
+ */
253
+ static supportsHDR: boolean;
254
+
255
+ /** ⭐️
256
+ * Modules added to this object will be added to new Q5 instances.
257
+ */
258
+ static modules: {};
259
+ }
260
+
251
261
  // ⬜️ canvas
252
262
 
253
263
  /** ⬜️
254
- * Creates a canvas element. If no input parameters are provided, the
255
- * canvas will be the size of the window.
264
+ * Creates a canvas element, a section of the screen your program
265
+ * can draw on.
256
266
  *
257
- * You can start q5 in top level global mode by running this function
258
- * before the rest of your code.
267
+ * Start using q5 by running this function!
259
268
  *
260
269
  * If this function is not run by the user, a 200x200 canvas will be
261
- * created automatically.
262
- * @param {number} [w] - width of the canvas
263
- * @param {number} [h] - height of the canvas
264
- * @param {Object} [options] - options for the canvas
265
- * @param {boolean} [options.alpha] - whether the canvas should have an alpha channel that allows it to be seen through, default is false
266
- * @param {string} [options.colorSpace] - color space of the canvas, either "srgb" or "display-p3", default is "display-p3" for devices that support HDR colors
270
+ * created automatically before the draw loop starts. Although in q5
271
+ * WebGPU, this function must be run before running other q5 functions.
272
+ * @param {number} [w] width of the canvas, default is windowWidth
273
+ * @param {number} [h] height of the canvas, default is windowHeight
274
+ * @param {Object} [opt] options for the canvas
275
+ * @param {boolean} [opt.alpha] whether the canvas should have an alpha channel that allows it to be seen through, default is false
276
+ * @param {string} [opt.colorSpace] color space of the canvas, either "srgb" or "display-p3", default is "display-p3" for devices that support HDR colors
267
277
  * @returns {HTMLCanvasElement} created canvas element
268
278
  * @example
269
279
  createCanvas(200, 100);
@@ -306,7 +316,7 @@ function draw() {
306
316
  * Sets the fill color for shapes. The default is white.
307
317
  *
308
318
  * Like the [`color`](https://q5js.org/learn/#color) function, this function can accept colors in a wide range of formats: CSS color string, hex string, grayscale value, and color component values.
309
- * @param {string | Color} color - fill color
319
+ * @param {string | Color} color fill color
310
320
  * @example
311
321
  function draw() {
312
322
  background(200);
@@ -324,7 +334,7 @@ function draw() {
324
334
  * Sets the stroke (outline) color for shapes. The default is black.
325
335
  *
326
336
  * Like the [`color`](https://q5js.org/learn/#color) function, this function can accept colors in a wide range of formats: CSS color string, hex string, grayscale value, and color component values.
327
- * @param {string | Color} color - stroke color
337
+ * @param {string | Color} color stroke color
328
338
  * @example
329
339
  function draw() {
330
340
  background(200);
@@ -370,7 +380,7 @@ function draw() {
370
380
 
371
381
  /** ⬜️
372
382
  * Sets the size of the stroke used for lines and the border around shapes.
373
- * @param {number} weight - size of the stroke in pixels
383
+ * @param {number} weight size of the stroke in pixels
374
384
  * @example
375
385
  function setup() {
376
386
  createCanvas(200, 200);
@@ -386,7 +396,7 @@ function setup() {
386
396
 
387
397
  /** ⬜️
388
398
  * Sets the global opacity, which affects all subsequent drawing operations, except `background`. Default is 1, fully opaque.
389
- * @param {number} alpha - opacity level, ranging from 0 to 1
399
+ * @param {number} alpha opacity level, ranging from 0 to 1
390
400
  * @example
391
401
  function draw() {
392
402
  background(200);
@@ -407,7 +417,7 @@ function draw() {
407
417
  * shapes, strokes, text, and images.
408
418
  *
409
419
  * Like the [`color`](https://q5js.org/learn/#color) function, this function can accept colors in a wide range of formats: CSS color string, hex string, grayscale value, and color component values.
410
- * @param {string | Color} color - shadow color
420
+ * @param {string | Color} color shadow color
411
421
  * @example
412
422
  function draw() {
413
423
  background(200);
@@ -418,13 +428,13 @@ function draw() {
418
428
  text('q5', 100, 100);
419
429
  }
420
430
  * @example
421
- createCanvas(256, 256);
422
- let logo = loadImage('https://p5play.org/assets/p5play_logo.webp');
431
+ createCanvas(200, 200);
432
+ let logo = loadImage('/assets/p5play_logo.webp');
423
433
 
424
434
  function setup() {
425
435
  background(200);
426
436
  shadow(0);
427
- image(logo, 27, 27, 200, 200);
437
+ image(logo, 36, 36, 128, 128);
428
438
  }
429
439
  */
430
440
  function shadow(color: string | Color): void;
@@ -448,9 +458,9 @@ function draw() {
448
458
  * Sets the shadow offset and blur radius.
449
459
  *
450
460
  * When q5 starts, shadow offset is (10, 10) with a blur of 10.
451
- * @param {number} offsetX - horizontal offset of the shadow
452
- * @param {number} offsetY - vertical offset of the shadow, defaults to be the same as offsetX
453
- * @param {number} blur - blur radius of the shadow, defaults to 0
461
+ * @param {number} offsetX horizontal offset of the shadow
462
+ * @param {number} offsetY vertical offset of the shadow, defaults to be the same as offsetX
463
+ * @param {number} blur blur radius of the shadow, defaults to 0
454
464
  * @example
455
465
  function draw() {
456
466
  background(200);
@@ -475,8 +485,8 @@ function draw() {
475
485
 
476
486
  /** ⬜️
477
487
  * Translates the origin of the drawing context.
478
- * @param {number} x - translation along the x-axis
479
- * @param {number} y - translation along the y-axis
488
+ * @param {number} x translation along the x-axis
489
+ * @param {number} y translation along the y-axis
480
490
  * @example
481
491
  function draw() {
482
492
  background(200);
@@ -489,7 +499,7 @@ function draw() {
489
499
 
490
500
  /** ⬜️
491
501
  * Rotates the drawing context.
492
- * @param {number} angle - rotation angle in radians
502
+ * @param {number} angle rotation angle in radians
493
503
  * @example
494
504
  function draw() {
495
505
  background(200);
@@ -508,8 +518,8 @@ function draw() {
508
518
  *
509
519
  * If only one input parameter is provided,
510
520
  * the drawing context will be scaled uniformly.
511
- * @param {number} x - scaling factor along the x-axis
512
- * @param {number} [y] - scaling factor along the y-axis
521
+ * @param {number} x scaling factor along the x-axis
522
+ * @param {number} [y] scaling factor along the y-axis
513
523
  * @example
514
524
  function draw() {
515
525
  background(200);
@@ -522,7 +532,7 @@ function draw() {
522
532
 
523
533
  /** ⬜️
524
534
  * Shears the drawing context along the x-axis.
525
- * @param {number} angle - shear angle in radians
535
+ * @param {number} angle shear angle in radians
526
536
  * @example
527
537
  function draw() {
528
538
  background(200);
@@ -536,7 +546,7 @@ function draw() {
536
546
 
537
547
  /** ⬜️
538
548
  * Shears the drawing context along the y-axis.
539
- * @param {number} angle - shear angle in radians
549
+ * @param {number} angle shear angle in radians
540
550
  * @example
541
551
  function draw() {
542
552
  background(200);
@@ -552,12 +562,12 @@ function draw() {
552
562
  * Applies a transformation matrix.
553
563
  *
554
564
  * Accepts a 3x3 or 4x4 matrix as either an array or multiple arguments.
555
- * @param {number} a - horizontal scaling
556
- * @param {number} b - horizontal skewing
557
- * @param {number} c - vertical skewing
558
- * @param {number} d - vertical scaling
559
- * @param {number} e - horizontal moving
560
- * @param {number} f - vertical moving
565
+ * @param {number} a horizontal scaling
566
+ * @param {number} b horizontal skewing
567
+ * @param {number} c vertical skewing
568
+ * @param {number} d vertical scaling
569
+ * @param {number} e horizontal moving
570
+ * @param {number} f vertical moving
561
571
  * @example
562
572
  function draw() {
563
573
  background(200);
@@ -651,14 +661,14 @@ square(0, 0, 50);
651
661
 
652
662
  /** ⬜️
653
663
  * Resizes the canvas to the specified width and height.
654
- * @param {number} w - width of the canvas
655
- * @param {number} h - height of the canvas
664
+ * @param {number} w width of the canvas
665
+ * @param {number} h height of the canvas
656
666
  */
657
667
  function resizeCanvas(w: number, h: number): void;
658
668
 
659
669
  /** ⬜️
660
670
  * Sets the pixel density of the canvas.
661
- * @param {number} v - pixel density value
671
+ * @param {number} v pixel density value
662
672
  * @returns {number} pixel density
663
673
  */
664
674
  function pixelDensity(v: number): number;
@@ -671,7 +681,7 @@ square(0, 0, 50);
671
681
 
672
682
  /** ⬜️
673
683
  * Enables or disables fullscreen mode.
674
- * @param {boolean} [v] - boolean indicating whether to enable or disable fullscreen mode
684
+ * @param {boolean} [v] boolean indicating whether to enable or disable fullscreen mode
675
685
  * @returns {void | boolean} true if fullscreen mode is enabled, false otherwise
676
686
  */
677
687
  function fullscreen(v?: boolean): void | boolean;
@@ -679,7 +689,7 @@ square(0, 0, 50);
679
689
  /** ⬜️
680
690
  * Any position coordinates or dimensions you use will be scaled based
681
691
  * on the unit provided to this function.
682
- * @param {number} unit - unit to scale by
692
+ * @param {number} unit unit to scale by
683
693
  * @example
684
694
  createCanvas(200, 200);
685
695
  flexibleCanvas(100);
@@ -690,9 +700,9 @@ rect(20, 20, 60, 60);
690
700
 
691
701
  /** ⬜️
692
702
  * Creates a graphics buffer.
693
- * @param {number} w - width
694
- * @param {number} h - height
695
- * @param {Object} [opt] - options
703
+ * @param {number} w width
704
+ * @param {number} h height
705
+ * @param {Object} [opt] options
696
706
  * @returns {Q5} a new Q5 graphics buffer
697
707
  */
698
708
  function createGraphics(w: number, h: number, opt?: any): Q5;
@@ -711,15 +721,15 @@ rect(20, 20, 60, 60);
711
721
 
712
722
  /** 💻
713
723
  * The `displayMode` function lets you customize how your canvas is presented.
714
- * @param {string} mode -
724
+ * @param {string} mode
715
725
  * - "normal": (default) no styling to canvas or its parent element
716
- * - "centered": canvas will be centered horizontally and vertically within its parent and if it's display size is bigger than its parent it will not clip
717
- * - "maxed": canvas will fill the parent element, same as fullscreen for a global mode canvas inside a `main` element
718
- * - "fullscreen": canvas will fill the screen with letterboxing if necessary to preserve its aspect ratio, like css object-fit contain
719
- * @param {string} renderQuality -
720
- * - "smooth": (default) no changes to the default render quality
721
- * - "pixelated": pixelDensity set to 1 and various css styles are applied to the canvas to make it render without image smoothing
722
- * @param {number} scale - can be given as a string (for example "x2") or a number
726
+ * - "centered": canvas will be centered horizontally and vertically within its parent and if the window is smaller than the canvas, the canvas will be resized to avoid clipping
727
+ * - "maxed": canvas will fill the parent element, same as fullscreen for a canvas inside a `main` element
728
+ * - "fullscreen": canvas will fill the screen with letterboxing if necessary to preserve its aspect ratio
729
+ * @param {string} renderQuality
730
+ * - "smooth": (default) no change to the default render quality
731
+ * - "pixelated": runs `pixelDensity(1)` and `noSmooth()` then sets the canvas CSS styles `image-rendering: pixelated` and `font-smooth: never`
732
+ * @param {number} scale can also be given as a string (for example "x2")
723
733
  */
724
734
  function displayMode(mode: string, renderQuality: string, scale: string | number): void;
725
735
 
@@ -727,49 +737,49 @@ rect(20, 20, 60, 60);
727
737
 
728
738
  /** 🧑‍🎨
729
739
  * Draws over the entire canvas with a color or image.
730
- * @param {string | number} color - color or image to draw
740
+ * @param {string | number} color color or image to draw
731
741
  */
732
742
  function background(color: string | number): void;
733
743
 
734
744
  /** 🧑‍🎨
735
745
  * Draws a rectangle.
736
- * @param {number} x - x-coordinate
737
- * @param {number} y - y-coordinate
738
- * @param {number} w - width of the rectangle
739
- * @param {number} [h] - height of the rectangle
740
- * @param {number} [tl] - top-left radius for rounded corners
741
- * @param {number} [tr] - top-right radius for rounded corners
742
- * @param {number} [br] - bottom-right radius for rounded corners
743
- * @param {number} [bl] - bottom-left radius for rounded corners
746
+ * @param {number} x x-coordinate
747
+ * @param {number} y y-coordinate
748
+ * @param {number} w width of the rectangle
749
+ * @param {number} [h] height of the rectangle
750
+ * @param {number} [tl] top-left radius for rounded corners
751
+ * @param {number} [tr] top-right radius for rounded corners
752
+ * @param {number} [br] bottom-right radius for rounded corners
753
+ * @param {number} [bl] bottom-left radius for rounded corners
744
754
  */
745
755
  function rect(x: number, y: number, w: number, h?: number, tl?: number, tr?: number, br?: number, bl?: number): void;
746
756
 
747
757
  /** 🧑‍🎨
748
758
  * Draws a square.
749
- * @param {number} x - x-coordinate
750
- * @param {number} y - y-coordinate
751
- * @param {number} size - size of the sides of the square
752
- * @param {number} [tl] - top-left radius for rounded corners
753
- * @param {number} [tr] - top-right radius for rounded corners
754
- * @param {number} [br] - bottom-right radius for rounded corners
755
- * @param {number} [bl] - bottom-left radius for rounded corners
759
+ * @param {number} x x-coordinate
760
+ * @param {number} y y-coordinate
761
+ * @param {number} size size of the sides of the square
762
+ * @param {number} [tl] top-left radius for rounded corners
763
+ * @param {number} [tr] top-right radius for rounded corners
764
+ * @param {number} [br] bottom-right radius for rounded corners
765
+ * @param {number} [bl] bottom-left radius for rounded corners
756
766
  */
757
767
  function square(x: number, y: number, size: number, tl?: number, tr?: number, br?: number, bl?: number): void;
758
768
 
759
769
  /** 🧑‍🎨
760
770
  * Draws a circle.
761
- * @param {number} x - x-coordinate
762
- * @param {number} y - y-coordinate
763
- * @param {number} diameter - diameter of the circle
771
+ * @param {number} x x-coordinate
772
+ * @param {number} y y-coordinate
773
+ * @param {number} diameter diameter of the circle
764
774
  */
765
775
  function circle(x: number, y: number, diameter: number): void;
766
776
 
767
777
  /** 🧑‍🎨
768
778
  * Draws an ellipse.
769
- * @param {number} x - x-coordinate
770
- * @param {number} y - y-coordinate
771
- * @param {number} width - width of the ellipse
772
- * @param {number} [height] - height of the ellipse
779
+ * @param {number} x x-coordinate
780
+ * @param {number} y y-coordinate
781
+ * @param {number} width width of the ellipse
782
+ * @param {number} [height] height of the ellipse
773
783
  */
774
784
  function ellipse(x: number, y: number, width: number, height?: number): void;
775
785
 
@@ -777,13 +787,13 @@ rect(20, 20, 60, 60);
777
787
  * Draws an arc, which is a section of an ellipse.
778
788
  *
779
789
  * `ellipseMode` affects how the arc is drawn.
780
- * @param {number} x - x-coordinate
781
- * @param {number} y - y-coordinate
782
- * @param {number} w - width of the ellipse
783
- * @param {number} h - height of the ellipse
784
- * @param {number} start - angle to start the arc
785
- * @param {number} stop - angle to stop the arc
786
- * @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`
790
+ * @param {number} x x-coordinate
791
+ * @param {number} y y-coordinate
792
+ * @param {number} w width of the ellipse
793
+ * @param {number} h height of the ellipse
794
+ * @param {number} start angle to start the arc
795
+ * @param {number} stop angle to stop the arc
796
+ * @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`
787
797
  * @example
788
798
  function draw() {
789
799
  background(200);
@@ -798,65 +808,65 @@ function draw() {
798
808
 
799
809
  /** 🧑‍🎨
800
810
  * Draws a line on the canvas.
801
- * @param {number} x1 - x-coordinate of the first point
802
- * @param {number} y1 - y-coordinate of the first point
803
- * @param {number} x2 - x-coordinate of the second point
804
- * @param {number} y2 - y-coordinate of the second point
811
+ * @param {number} x1 x-coordinate of the first point
812
+ * @param {number} y1 y-coordinate of the first point
813
+ * @param {number} x2 x-coordinate of the second point
814
+ * @param {number} y2 y-coordinate of the second point
805
815
  */
806
816
  function line(x1: number, y1: number, x2: number, y2: number): void;
807
817
 
808
818
  /** 🧑‍🎨
809
819
  * Draws a point on the canvas.
810
- * @param {number} x - x-coordinate
811
- * @param {number} y - y-coordinate
820
+ * @param {number} x x-coordinate
821
+ * @param {number} y y-coordinate
812
822
  */
813
823
  function point(x: number, y: number): void;
814
824
 
815
825
  /** 🧑‍🎨
816
826
  * Sets the global composite operation for the canvas context.
817
- * @param {string} val - composite operation to set
827
+ * @param {string} val composite operation to set
818
828
  */
819
829
  function blendMode(val: string): void;
820
830
 
821
831
  /** 🧑‍🎨
822
832
  * Sets the line cap style for the canvas context.
823
- * @param {CanvasLineCap} val - line cap style to set ('butt', 'round', 'square')
833
+ * @param {CanvasLineCap} val line cap style to set ('butt', 'round', 'square')
824
834
  */
825
835
  function strokeCap(val: CanvasLineCap): void;
826
836
 
827
837
  /** 🧑‍🎨
828
838
  * Sets the line join style for the canvas context.
829
- * @param {CanvasLineJoin} val - line join style to set ('round', 'bevel', 'miter')
839
+ * @param {CanvasLineJoin} val line join style to set ('round', 'bevel', 'miter')
830
840
  */
831
841
  function strokeJoin(val: CanvasLineJoin): void;
832
842
 
833
843
  /** 🧑‍🎨
834
844
  * Sets the ellipse mode.
835
- * @param {string} val - ellipse mode to set
845
+ * @param {string} val ellipse mode to set
836
846
  */
837
847
  function ellipseMode(val: string): void;
838
848
 
839
849
  /** 🧑‍🎨
840
850
  * Sets the rectangle mode.
841
- * @param {string} val - rectangle mode to set
851
+ * @param {string} val rectangle mode to set
842
852
  */
843
853
  function rectMode(val: string): void;
844
854
 
845
855
  /** 🧑‍🎨
846
856
  * Sets the curve detail level.
847
- * @param {number} val - curve detail level to set
857
+ * @param {number} val curve detail level to set
848
858
  */
849
859
  function curveDetail(val: number): void;
850
860
 
851
861
  /** 🧑‍🎨
852
862
  * Sets the curve alpha value.
853
- * @param {number} val - curve alpha value to set
863
+ * @param {number} val curve alpha value to set
854
864
  */
855
865
  function curveAlpha(val: number): void;
856
866
 
857
867
  /** 🧑‍🎨
858
868
  * Sets the curve tightness value.
859
- * @param {number} val - curve tightness value to set
869
+ * @param {number} val curve tightness value to set
860
870
  */
861
871
  function curveTightness(val: number): void;
862
872
 
@@ -877,72 +887,72 @@ function draw() {
877
887
 
878
888
  /** 🧑‍🎨
879
889
  * Specifies a vertex in a shape.
880
- * @param {number} x - x-coordinate
881
- * @param {number} y - y-coordinate
890
+ * @param {number} x x-coordinate
891
+ * @param {number} y y-coordinate
882
892
  */
883
893
  function vertex(x: number, y: number): void;
884
894
 
885
895
  /** 🧑‍🎨
886
896
  * Specifies a Bezier vertex in a shape.
887
- * @param {number} cp1x - x-coordinate of the first control point
888
- * @param {number} cp1y - y-coordinate of the first control point
889
- * @param {number} cp2x - x-coordinate of the second control point
890
- * @param {number} cp2y - y-coordinate of the second control point
891
- * @param {number} x - x-coordinate of the anchor point
892
- * @param {number} y - y-coordinate of the anchor point
897
+ * @param {number} cp1x x-coordinate of the first control point
898
+ * @param {number} cp1y y-coordinate of the first control point
899
+ * @param {number} cp2x x-coordinate of the second control point
900
+ * @param {number} cp2y y-coordinate of the second control point
901
+ * @param {number} x x-coordinate of the anchor point
902
+ * @param {number} y y-coordinate of the anchor point
893
903
  */
894
904
  function bezierVertex(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
895
905
 
896
906
  /** 🧑‍🎨
897
907
  * Specifies a quadratic Bezier vertex in a shape.
898
- * @param {number} cp1x - x-coordinate of the control point
899
- * @param {number} cp1y - y-coordinate of the control point
900
- * @param {number} x - x-coordinate of the anchor point
901
- * @param {number} y - y-coordinate of the anchor point
908
+ * @param {number} cp1x x-coordinate of the control point
909
+ * @param {number} cp1y y-coordinate of the control point
910
+ * @param {number} x x-coordinate of the anchor point
911
+ * @param {number} y y-coordinate of the anchor point
902
912
  */
903
913
  function quadraticVertex(cp1x: number, cp1y: number, x: number, y: number): void;
904
914
 
905
915
  /** 🧑‍🎨
906
916
  * Draws a Bezier curve.
907
- * @param {number} x1 - x-coordinate of the first anchor point
908
- * @param {number} y1 - y-coordinate of the first anchor point
909
- * @param {number} x2 - x-coordinate of the first control point
910
- * @param {number} y2 - y-coordinate of the first control point
911
- * @param {number} x3 - x-coordinate of the second control point
912
- * @param {number} y3 - y-coordinate of the second control point
913
- * @param {number} x4 - x-coordinate of the second anchor point
914
- * @param {number} y4 - y-coordinate of the second anchor point
917
+ * @param {number} x1 x-coordinate of the first anchor point
918
+ * @param {number} y1 y-coordinate of the first anchor point
919
+ * @param {number} x2 x-coordinate of the first control point
920
+ * @param {number} y2 y-coordinate of the first control point
921
+ * @param {number} x3 x-coordinate of the second control point
922
+ * @param {number} y3 y-coordinate of the second control point
923
+ * @param {number} x4 x-coordinate of the second anchor point
924
+ * @param {number} y4 y-coordinate of the second anchor point
915
925
  */
916
926
  function bezier(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
917
927
 
918
928
  /** 🧑‍🎨
919
929
  * Draws a triangle.
920
- * @param {number} x1 - x-coordinate of the first vertex
921
- * @param {number} y1 - y-coordinate of the first vertex
922
- * @param {number} x2 - x-coordinate of the second vertex
923
- * @param {number} y2 - y-coordinate of the second vertex
924
- * @param {number} x3 - x-coordinate of the third vertex
925
- * @param {number} y3 - y-coordinate of the third vertex
930
+ * @param {number} x1 x-coordinate of the first vertex
931
+ * @param {number} y1 y-coordinate of the first vertex
932
+ * @param {number} x2 x-coordinate of the second vertex
933
+ * @param {number} y2 y-coordinate of the second vertex
934
+ * @param {number} x3 x-coordinate of the third vertex
935
+ * @param {number} y3 y-coordinate of the third vertex
926
936
  */
927
937
  function triangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void;
928
938
 
929
939
  /** 🧑‍🎨
930
940
  * Draws a quadrilateral.
931
- * @param {number} x1 - x-coordinate of the first vertex
932
- * @param {number} y1 - y-coordinate of the first vertex
933
- * @param {number} x2 - x-coordinate of the second vertex
934
- * @param {number} y2 - y-coordinate of the second vertex
935
- * @param {number} x3 - x-coordinate of the third vertex
936
- * @param {number} y3 - y-coordinate of the third vertex
937
- * @param {number} x4 - x-coordinate of the fourth vertex
938
- * @param {number} y4 - y-coordinate of the fourth vertex
941
+ * @param {number} x1 x-coordinate of the first vertex
942
+ * @param {number} y1 y-coordinate of the first vertex
943
+ * @param {number} x2 x-coordinate of the second vertex
944
+ * @param {number} y2 y-coordinate of the second vertex
945
+ * @param {number} x3 x-coordinate of the third vertex
946
+ * @param {number} y3 y-coordinate of the third vertex
947
+ * @param {number} x4 x-coordinate of the fourth vertex
948
+ * @param {number} y4 y-coordinate of the fourth vertex
939
949
  */
940
950
  function quad(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
941
951
 
942
952
  /** 🧑‍🎨
943
953
  * Sets the canvas to erase mode, where shapes will erase what's underneath them instead of drawing over it.
944
- * @param {number} [fillAlpha] - opacity level of the fill color from 0 to 255
945
- * @param {number} [strokeAlpha] - opacity level of the stroke color from 0 to 255
954
+ * @param {number} [fillAlpha] opacity level of the fill color from 0 to 255
955
+ * @param {number} [strokeAlpha] opacity level of the stroke color from 0 to 255
946
956
  */
947
957
  function erase(fillAlpha?: number, strokeAlpha?: number): void;
948
958
 
@@ -953,16 +963,16 @@ function draw() {
953
963
 
954
964
  /** 🧑‍🎨
955
965
  * Checks if a given point is within the current path's fill area.
956
- * @param {number} x - x-coordinate of the point
957
- * @param {number} y - y-coordinate of the point
966
+ * @param {number} x x-coordinate of the point
967
+ * @param {number} y y-coordinate of the point
958
968
  * @returns {boolean} true if the point is within the fill area, false otherwise
959
969
  */
960
970
  function inFill(x: number, y: number): boolean;
961
971
 
962
972
  /** 🧑‍🎨
963
973
  * Checks if a given point is within the current path's stroke.
964
- * @param {number} x - x-coordinate of the point
965
- * @param {number} y - y-coordinate of the point
974
+ * @param {number} x x-coordinate of the point
975
+ * @param {number} y y-coordinate of the point
966
976
  * @returns {boolean} true if the point is within the stroke, false otherwise
967
977
  */
968
978
  function inStroke(x: number, y: number): boolean;
@@ -971,9 +981,9 @@ function draw() {
971
981
 
972
982
  /** 🌆
973
983
  * Loads an image from a URL and optionally runs a callback function.
974
- * @param {string} url - url of the image to load
975
- * @param {(img: any) => void} [cb] - callback function after the image is loaded
976
- * @param {any} [opt] - optional parameters for loading the image
984
+ * @param {string} url url of the image to load
985
+ * @param {(img: any) => void} [cb] callback function after the image is loaded
986
+ * @param {any} [opt] optional parameters for loading the image
977
987
  * @example
978
988
  createCanvas(200, 200);
979
989
 
@@ -987,15 +997,15 @@ function draw() {
987
997
 
988
998
  /** 🌆
989
999
  * Draws an image to the canvas.
990
- * @param {any} img - image to draw
991
- * @param {number} dx - x position to draw the image at
992
- * @param {number} dy - y position to draw the image at
993
- * @param {number} [dw] - width of the destination image
994
- * @param {number} [dh] - height of the destination image
995
- * @param {number} [sx] - x position in the source to start clipping a subsection from
996
- * @param {number} [sy] - y position in the source to start clipping a subsection from
997
- * @param {number} [sw] - width of the subsection of the source image
998
- * @param {number} [sh] - height of the subsection of the source image
1000
+ * @param {any} img image to draw
1001
+ * @param {number} dx x position to draw the image at
1002
+ * @param {number} dy y position to draw the image at
1003
+ * @param {number} [dw] width of the destination image
1004
+ * @param {number} [dh] height of the destination image
1005
+ * @param {number} [sx] x position in the source to start clipping a subsection from
1006
+ * @param {number} [sy] y position in the source to start clipping a subsection from
1007
+ * @param {number} [sw] width of the subsection of the source image
1008
+ * @param {number} [sh] height of the subsection of the source image
999
1009
  * @example
1000
1010
  createCanvas(200, 200);
1001
1011
 
@@ -1009,9 +1019,9 @@ function draw() {
1009
1019
 
1010
1020
  /** 🌆
1011
1021
  * Sets the image mode, which determines the position and alignment of images drawn on the canvas.
1012
- * - `CORNER`: (default) images will be drawn from the top-left corner
1013
- * - `CORNERS`: images will be drawn from the top-left to the bottom-right corner
1014
- * - `CENTER`: images will be drawn centered at (dx, dy)
1022
+ * `CORNER`: (default) images will be drawn from the top-left corner
1023
+ * `CORNERS`: images will be drawn from the top-left to the bottom-right corner
1024
+ * `CENTER`: images will be drawn centered at (dx, dy)
1015
1025
  * @param {string} mode
1016
1026
  * @example
1017
1027
  createCanvas(200, 200);
@@ -1035,15 +1045,15 @@ function draw() {
1035
1045
  *
1036
1046
  * This function must be called before images are loaded to
1037
1047
  * have an effect.
1038
- * @param {number}
1048
+ * @param {number} scale
1039
1049
  * @returns {number} default image scale
1040
1050
  */
1041
1051
  function defaultImageScale(scale: number): number;
1042
1052
 
1043
1053
  /** 🌆
1044
1054
  * Resizes the image.
1045
- * @param {number} w - new width
1046
- * @param {number} h - new height
1055
+ * @param {number} w new width
1056
+ * @param {number} h new height
1047
1057
  * @example
1048
1058
  createCanvas(200, 200);
1049
1059
 
@@ -1109,7 +1119,7 @@ function setup() {
1109
1119
  * If you need to draw an image multiple times each frame with
1110
1120
  * different tints, consider making copies of the image and tinting
1111
1121
  * each copy separately.
1112
- * @param {string | number} color - tint color
1122
+ * @param {string | number} color tint color
1113
1123
  * @example
1114
1124
  createCanvas(200, 200);
1115
1125
 
@@ -1129,15 +1139,15 @@ function setup() {
1129
1139
 
1130
1140
  /** 🌆
1131
1141
  * Masks the image with another image.
1132
- * @param {Image} img - image to use as a mask
1142
+ * @param {Image} img image to use as a mask
1133
1143
  */
1134
1144
  function mask(img: Image): void;
1135
1145
 
1136
1146
  /** 🌆
1137
1147
  * Saves the image.
1138
- * @param {string} filename - filename or path
1139
- * @param {string} extension - file extension
1140
- * @param {number} [quality] - quality of the saved image
1148
+ * @param {string} filename filename or path
1149
+ * @param {string} extension file extension
1150
+ * @param {number} [quality] quality of the saved image
1141
1151
  */
1142
1152
  function save(filename: string, extension: string, quality?: number): void;
1143
1153
 
@@ -1146,8 +1156,8 @@ function setup() {
1146
1156
  * Or if width and height are both 1, returns the color of the pixel at the given coordinates in `[R, G, B, A]` array format.
1147
1157
  * @param {number} x
1148
1158
  * @param {number} y
1149
- * @param {number} [w] - width of the area
1150
- * @param {number} [h] - height of the area
1159
+ * @param {number} [w] width of the area
1160
+ * @param {number} [h] height of the area
1151
1161
  * @returns {Image | number[]}
1152
1162
  * @example
1153
1163
  createCanvas(200, 200);
@@ -1170,7 +1180,7 @@ function setup() {
1170
1180
  * Run `updatePixels` to apply the changes.
1171
1181
  * @param {number} x
1172
1182
  * @param {number} y
1173
- * @param {any} c - color, canvas, or image
1183
+ * @param {any} c color, canvas, or image
1174
1184
  * @example
1175
1185
  createCanvas(200, 200);
1176
1186
  let c = color('lime');
@@ -1191,14 +1201,14 @@ function draw() {
1191
1201
  /** 🌆
1192
1202
  * Displays a region of the image on another region of the image.
1193
1203
  * Can be used to create a detail inset, aka a magnifying glass effect.
1194
- * @param {number} sx - x-coordinate of the source region
1195
- * @param {number} sy - y-coordinate of the source region
1196
- * @param {number} sw - width of the source region
1197
- * @param {number} sh - height of the source region
1198
- * @param {number} dx - x-coordinate of the destination region
1199
- * @param {number} dy - y-coordinate of the destination region
1200
- * @param {number} dw - width of the destination region
1201
- * @param {number} dh - height of the destination region
1204
+ * @param {number} sx x-coordinate of the source region
1205
+ * @param {number} sy y-coordinate of the source region
1206
+ * @param {number} sw width of the source region
1207
+ * @param {number} sh height of the source region
1208
+ * @param {number} dx x-coordinate of the destination region
1209
+ * @param {number} dy y-coordinate of the destination region
1210
+ * @param {number} dw width of the destination region
1211
+ * @param {number} dh height of the destination region
1202
1212
  * @example
1203
1213
  createCanvas(200, 200);
1204
1214
 
@@ -1248,7 +1258,7 @@ function setup() {
1248
1258
 
1249
1259
  /** 🌆
1250
1260
  * Masks the image with another image.
1251
- * @param {Image} img - image to use as a mask
1261
+ * @param {Image} img image to use as a mask
1252
1262
  */
1253
1263
  function mask(img: Image): void;
1254
1264
 
@@ -1259,8 +1269,8 @@ function setup() {
1259
1269
  *
1260
1270
  * If a CSS filter string is provided, it will be applied to the image.
1261
1271
  * https://developer.mozilla.org/en-US/docs/Web/CSS/filter
1262
- * @param {string} type - type of filter or a CSS filter string
1263
- * @param {number} [value] - optional parameter, depending on filter type
1272
+ * @param {string} type type of filter or a CSS filter string
1273
+ * @param {number} [value] optional parameter, depending on filter type
1264
1274
  * @example
1265
1275
  createCanvas(200, 200);
1266
1276
  let logo = loadImage('/q5js_logo.webp');
@@ -1314,9 +1324,9 @@ function setup() {
1314
1324
 
1315
1325
  /** 🌆
1316
1326
  * Creates a new image.
1317
- * @param {number} [w] - character limit per line
1318
- * @param {number} [h] - line limit
1319
- * @param {any} [opt] - optional settings for the image
1327
+ * @param {number} [w] character limit per line
1328
+ * @param {number} [h] line limit
1329
+ * @param {any} [opt] optional settings for the image
1320
1330
  * @returns {Image}
1321
1331
  */
1322
1332
  function createImage(w: number, h: number, opt?: any): Image;
@@ -1327,11 +1337,11 @@ function setup() {
1327
1337
  * Renders text to the screen. Text can be positioned with the x and y
1328
1338
  * parameters and can optionally be constrained by a character limit
1329
1339
  * per line and a line limit.
1330
- * @param {string} str - string of text to display
1331
- * @param {number} x - x-coordinate of the text's position
1332
- * @param {number} y - y-coordinate of the text's position
1333
- * @param {number} [w] - character limit per line
1334
- * @param {number} [h] - line limit
1340
+ * @param {string} str string of text to display
1341
+ * @param {number} x x-coordinate of the text's position
1342
+ * @param {number} y y-coordinate of the text's position
1343
+ * @param {number} [w] character limit per line
1344
+ * @param {number} [h] line limit
1335
1345
  * @example
1336
1346
  createCanvas(200, 200);
1337
1347
  background('silver');
@@ -1364,8 +1374,8 @@ text(info, 12, 30, 20, 6);
1364
1374
  * the default font, Microsoft YaHei, is loaded:
1365
1375
  * https://q5js.org/fonts/YaHei-msdf.json
1366
1376
  * https://q5js.org/fonts/YaHei.png
1367
- * @param {string} url - uRL of the font to load
1368
- * @param {(fontName: string) => void} [cb] - optional callback function that receives the font name as an argument once the font is loaded
1377
+ * @param {string} url uRL of the font to load
1378
+ * @param {(fontName: string) => void} [cb] optional callback function that receives the font name as an argument once the font is loaded
1369
1379
  * @returns {string} name of the loaded font
1370
1380
  * @example
1371
1381
  createCanvas(200, 200);
@@ -1389,7 +1399,7 @@ function setup() {
1389
1399
  * In q5 q2d, you can set the font to any font accepted in CSS,
1390
1400
  * such as "serif" or "monospace".
1391
1401
  * https://developer.mozilla.org/en-US/docs/Web/CSS/font-family
1392
- * @param {string} fontName - name of the font or font family
1402
+ * @param {string} fontName name of the font or font family
1393
1403
  * @example
1394
1404
  createCanvas(200, 200);
1395
1405
  background(200);
@@ -1403,7 +1413,7 @@ text('Hello, world!', 12, 106);
1403
1413
 
1404
1414
  /** ✍️
1405
1415
  * Sets or gets the current font size. If no argument is provided, returns the current font size.
1406
- * @param {number} [size] - size of the font in pixels
1416
+ * @param {number} [size] size of the font in pixels
1407
1417
  * @returns {number | void} current font size when no argument is provided
1408
1418
  * @example
1409
1419
  function draw() {
@@ -1417,7 +1427,7 @@ function draw() {
1417
1427
 
1418
1428
  /** ✍️
1419
1429
  * Sets or gets the current line height. If no argument is provided, returns the current line height.
1420
- * @param {number} [leading] - line height in pixels
1430
+ * @param {number} [leading] line height in pixels
1421
1431
  * @returns {number | void} current line height when no argument is provided
1422
1432
  * @example
1423
1433
  function draw() {
@@ -1432,7 +1442,7 @@ function draw() {
1432
1442
 
1433
1443
  /** ✍️
1434
1444
  * Sets the current text style.
1435
- * @param {'normal' | 'italic' | 'bold' | 'bolditalic'} style - font style
1445
+ * @param {'normal' | 'italic' | 'bold' | 'bolditalic'} style font style
1436
1446
  * @example
1437
1447
  createCanvas(200, 200);
1438
1448
  background(200);
@@ -1446,8 +1456,8 @@ text('Hello, world!', 12, 106);
1446
1456
 
1447
1457
  /** ✍️
1448
1458
  * Sets the horizontal and vertical alignment of text.
1449
- * @param {'left' | 'center' | 'right'} horiz - horizontal alignment
1450
- * @param {'top' | 'middle' | 'bottom' | 'alphabetic'} [vert] - vertical alignment
1459
+ * @param {'left' | 'center' | 'right'} horiz horizontal alignment
1460
+ * @param {'top' | 'middle' | 'bottom' | 'alphabetic'} [vert] vertical alignment
1451
1461
  * @example
1452
1462
  createCanvas(200, 200);
1453
1463
  background(200);
@@ -1461,7 +1471,7 @@ text('Hello, world!', 100, 100);
1461
1471
 
1462
1472
  /** ✍️
1463
1473
  * Calculates and returns the width of a given string of text.
1464
- * @param {string} str - string to measure
1474
+ * @param {string} str string to measure
1465
1475
  * @returns {number} width of the text in pixels
1466
1476
  * @example
1467
1477
  function draw() {
@@ -1476,7 +1486,7 @@ function draw() {
1476
1486
 
1477
1487
  /** ✍️
1478
1488
  * Calculates and returns the ascent (the distance from the baseline to the top of the highest character) of the current font.
1479
- * @param {string} str - string to measure
1489
+ * @param {string} str string to measure
1480
1490
  * @returns {number} ascent of the text in pixels
1481
1491
  * @example
1482
1492
  function draw() {
@@ -1491,7 +1501,7 @@ function draw() {
1491
1501
 
1492
1502
  /** ✍️
1493
1503
  * Calculates and returns the descent (the distance from the baseline to the bottom of the lowest character) of the current font.
1494
- * @param {string} str - string to measure
1504
+ * @param {string} str string to measure
1495
1505
  * @returns {number} descent of the text in pixels
1496
1506
  * @example
1497
1507
  createCanvas(200, 200);
@@ -1507,9 +1517,9 @@ createCanvas(200, 200);
1507
1517
  * Creates an image from a string of text. Width and height
1508
1518
  * will not be the width and height of the text image, but of
1509
1519
  * the bounding box that the text will be constrained within.
1510
- * @param {string} str - string of text
1511
- * @param {number} w - width of the bounding box
1512
- * @param {number} h - height of the bounding box
1520
+ * @param {string} str string of text
1521
+ * @param {number} w width of the bounding box
1522
+ * @param {number} h height of the bounding box
1513
1523
  * @returns {Q5.Image} an image object representing the rendered text
1514
1524
  */
1515
1525
  function createTextImage(str: string, w: number, h: number): Q5.Image;
@@ -1518,9 +1528,9 @@ createCanvas(200, 200);
1518
1528
  * Renders an image generated from text onto the canvas. The
1519
1529
  * positioning of the image is affected by the current text
1520
1530
  * alignment and baseline settings.
1521
- * @param {HTMLImageElement} img - image object to render, typically generated from text
1522
- * @param {number} x - x-coordinate where the image should be placed
1523
- * @param {number} y - y-coordinate where the image should be placed
1531
+ * @param {HTMLImageElement} img image object to render, typically generated from text
1532
+ * @param {number} x x-coordinate where the image should be placed
1533
+ * @param {number} y y-coordinate where the image should be placed
1524
1534
  */
1525
1535
  function textImage(img: HTMLImageElement, x: number, y: number): void;
1526
1536
 
@@ -1528,9 +1538,9 @@ createCanvas(200, 200);
1528
1538
  * Number formatter, can be used to display a number as a string with
1529
1539
  * a specified number of digits before and after the decimal point,
1530
1540
  * optionally adding padding with zeros.
1531
- * @param {number} n - number to format
1532
- * @param {number} l - minimum number of digits to appear before the decimal point; the number is padded with zeros if necessary
1533
- * @param {number} r - number of digits to appear after the decimal point
1541
+ * @param {number} n number to format
1542
+ * @param {number} l minimum number of digits to appear before the decimal point; the number is padded with zeros if necessary
1543
+ * @param {number} r number of digits to appear after the decimal point
1534
1544
  * @returns {string} a string representation of the number, formatted accordingly
1535
1545
  */
1536
1546
  function nf(n: number, l: number, r: number): string;
@@ -1589,7 +1599,7 @@ createCanvas(200, 200);
1589
1599
 
1590
1600
  /** ✨
1591
1601
  * Run this function before a line of code that isn't working as expected.
1592
- * @param {string} [question] - question to ask the AI
1602
+ * @param {string} [question] question to ask the AI
1593
1603
  */
1594
1604
  function askAI(question?: string): void;
1595
1605
 
@@ -1608,10 +1618,10 @@ createCanvas(200, 200);
1608
1618
  *
1609
1619
  * `fill`, `stroke`, and `background` functions can accept the same
1610
1620
  * wide range of inputs as this function.
1611
- * @param {string | number | Color | number[]} c0 - first color component, a CSS color string, a `Color` object (to make copy), or an array of components
1612
- * @param {number} [c1] - second color component
1613
- * @param {number} [c2] - third color component
1614
- * @param {number} [c3] - fourth color component (alpha)
1621
+ * @param {string | number | Color | number[]} c0 first color component, a CSS color string, a `Color` object (to make copy), or an array of components
1622
+ * @param {number} [c1] second color component
1623
+ * @param {number} [c2] third color component
1624
+ * @param {number} [c3] fourth color component (alpha)
1615
1625
  * @returns {Color} a new `Color` object
1616
1626
  * @example
1617
1627
  createCanvas(200, 200);
@@ -1633,8 +1643,8 @@ function draw() {
1633
1643
  * In WebGPU, the default color mode is RGB in float format.
1634
1644
  *
1635
1645
  * See the documentation for q5's color constants below for more info.
1636
- * @param {'rgb' | 'srgb' | 'oklch'} mode - color mode
1637
- * @param {1 | 255} format - color format (1 for float, 255 for integer)
1646
+ * @param {'rgb' | 'srgb' | 'oklch'} mode color mode
1647
+ * @param {1 | 255} format color format (1 for float, 255 for integer)
1638
1648
  * @example
1639
1649
  createCanvas(200, 200);
1640
1650
 
@@ -1702,7 +1712,7 @@ function setup() {
1702
1712
  * time, they're not perceptually uniform, meaning colors at the same
1703
1713
  * brightness values may appear lighter or darker depending on the hue.
1704
1714
  *
1705
- * The OKLCH format is similar to HSL/HSV but its perceptually
1715
+ * The OKLCH format is similar to HSL/HSV but it's perceptually
1706
1716
  * uniform and supports HDR colors. Use this oklch color picker to
1707
1717
  * explore the color space: https://oklch.com
1708
1718
  *
@@ -1804,7 +1814,7 @@ function draw() {
1804
1814
 
1805
1815
  /** 🖲️
1806
1816
  * Returns true if the user is pressing the specified key, false otherwise. Accepts case-insensitive key names.
1807
- * @param {string} key - key to check
1817
+ * @param {string} key key to check
1808
1818
  * @returns {boolean} true if the key is pressed, false otherwise
1809
1819
  * @example
1810
1820
  function draw() {
@@ -1832,9 +1842,9 @@ function draw() {
1832
1842
  * Sets the cursor to a [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor) or image.
1833
1843
  * If an image is provided, optional x and y coordinates can
1834
1844
  * specify the active point of the cursor.
1835
- * @param {string} name - name of the cursor or the path to an image
1836
- * @param {number} [x] - x-coordinate of the cursor's hot spot
1837
- * @param {number} [y] - y-coordinate of the cursor's hot spot
1845
+ * @param {string} name name of the cursor or the path to an image
1846
+ * @param {number} [x] x-coordinate of the cursor's hot spot
1847
+ * @param {number} [y] y-coordinate of the cursor's hot spot
1838
1848
  */
1839
1849
  function cursor(name: string, x?: number, y?: number): void;
1840
1850
 
@@ -1860,89 +1870,89 @@ noCursor();
1860
1870
 
1861
1871
  /** 🧮
1862
1872
  * Calculates the distance between two points.
1863
- * @param {number} x1 - x-coordinate of the first point
1864
- * @param {number} y1 - y-coordinate of the first point
1865
- * @param {number} x2 - x-coordinate of the second point
1866
- * @param {number} y2 - y-coordinate of the second point
1873
+ * @param {number} x1 x-coordinate of the first point
1874
+ * @param {number} y1 y-coordinate of the first point
1875
+ * @param {number} x2 x-coordinate of the second point
1876
+ * @param {number} y2 y-coordinate of the second point
1867
1877
  * @returns {number} distance between the points
1868
1878
  */
1869
1879
  function dist(x1: number, y1: number, x2: number, y2: number): number;
1870
1880
 
1871
1881
  /** 🧮
1872
1882
  * Maps a number from one range to another.
1873
- * @param {number} value - incoming value to be converted
1874
- * @param {number} start1 - lower bound of the value's current range
1875
- * @param {number} stop1 - upper bound of the value's current range
1876
- * @param {number} start2 - lower bound of the value's target range
1877
- * @param {number} stop2 - upper bound of the value's target range
1883
+ * @param {number} value incoming value to be converted
1884
+ * @param {number} start1 lower bound of the value's current range
1885
+ * @param {number} stop1 upper bound of the value's current range
1886
+ * @param {number} start2 lower bound of the value's target range
1887
+ * @param {number} stop2 upper bound of the value's target range
1878
1888
  * @returns {number} mapped value
1879
1889
  */
1880
1890
  function map(value: number, start1: number, stop1: number, start2: number, stop2: number): number;
1881
1891
 
1882
1892
  /** 🧮
1883
1893
  * Sets the mode for interpreting and drawing angles. Can be either 'degrees' or 'radians'.
1884
- * @param {'degrees' | 'radians'} mode - mode to set for angle interpretation
1894
+ * @param {'degrees' | 'radians'} mode mode to set for angle interpretation
1885
1895
  */
1886
1896
  function angleMode(mode: 'degrees' | 'radians'): void;
1887
1897
 
1888
1898
  /** 🧮
1889
1899
  * Converts degrees to radians.
1890
- * @param {number} degrees - angle in degrees
1900
+ * @param {number} degrees angle in degrees
1891
1901
  * @returns {number} angle in radians
1892
1902
  */
1893
1903
  function radians(degrees: number): number;
1894
1904
 
1895
1905
  /** 🧮
1896
1906
  * Converts radians to degrees.
1897
- * @param {number} radians - angle in radians
1907
+ * @param {number} radians angle in radians
1898
1908
  * @returns {number} angle in degrees
1899
1909
  */
1900
1910
  function degrees(radians: number): number;
1901
1911
 
1902
1912
  /** 🧮
1903
1913
  * Calculates a number between two numbers at a specific increment.
1904
- * @param {number} start - first number
1905
- * @param {number} stop - second number
1906
- * @param {number} amt - amount to interpolate between the two values
1914
+ * @param {number} start first number
1915
+ * @param {number} stop second number
1916
+ * @param {number} amt amount to interpolate between the two values
1907
1917
  * @returns {number} interpolated number
1908
1918
  */
1909
1919
  function lerp(start: number, stop: number, amt: number): number;
1910
1920
 
1911
1921
  /** 🧮
1912
1922
  * Constrains a value between a minimum and maximum value.
1913
- * @param {number} n - number to constrain
1914
- * @param {number} low - lower bound
1915
- * @param {number} high - upper bound
1923
+ * @param {number} n number to constrain
1924
+ * @param {number} low lower bound
1925
+ * @param {number} high upper bound
1916
1926
  * @returns {number} constrained value
1917
1927
  */
1918
1928
  function constrain(n: number, low: number, high: number): number;
1919
1929
 
1920
1930
  /** 🧮
1921
1931
  * Normalizes a number from another range into a value between 0 and 1.
1922
- * @param {number} n - number to normalize
1923
- * @param {number} start - lower bound of the range
1924
- * @param {number} stop - upper bound of the range
1932
+ * @param {number} n number to normalize
1933
+ * @param {number} start lower bound of the range
1934
+ * @param {number} stop upper bound of the range
1925
1935
  * @returns {number} normalized number
1926
1936
  */
1927
1937
  function norm(n: number, start: number, stop: number): number;
1928
1938
 
1929
1939
  /** 🧮
1930
1940
  * Calculates the square of a number.
1931
- * @param {number} n - number to square
1941
+ * @param {number} n number to square
1932
1942
  * @returns {number} square of the number
1933
1943
  */
1934
1944
  function sq(n: number): number;
1935
1945
 
1936
1946
  /** 🧮
1937
1947
  * Calculates the fractional part of a number.
1938
- * @param {number} n - number whose fractional part is to be calculated
1948
+ * @param {number} n number whose fractional part is to be calculated
1939
1949
  * @returns {number} fractional part of the number
1940
1950
  */
1941
1951
  function fract(n: number): number;
1942
1952
 
1943
1953
  /** 🧮
1944
1954
  * Sets the seed for the random number generator.
1945
- * @param {number} seed - seed value
1955
+ * @param {number} seed seed value
1946
1956
  */
1947
1957
  function randomSeed(seed: number): void;
1948
1958
 
@@ -1951,22 +1961,22 @@ noCursor();
1951
1961
  * If one number argument is provided, returns a random number between 0 and the provided value.
1952
1962
  * If two number arguments are provided, returns a random number between the two values.
1953
1963
  * If an array is provided, returns a random element from the array.
1954
- * @param {number | any[]} [a] - lower bound (inclusive) or an array
1955
- * @param {number} [b] - upper bound (exclusive)
1964
+ * @param {number | any[]} [a] lower bound (inclusive) or an array
1965
+ * @param {number} [b] upper bound (exclusive)
1956
1966
  * @returns {number | any} a random number or element
1957
1967
  */
1958
1968
  function random(a?: number | any[], b?: number): number | any;
1959
1969
 
1960
1970
  /** 🧮
1961
1971
  * Sets the random number generation method.
1962
- * @param {any} method - method to use for random number generation
1972
+ * @param {any} method method to use for random number generation
1963
1973
  */
1964
1974
  function randomGenerator(method: any): void;
1965
1975
 
1966
1976
  /** 🧮
1967
1977
  * Generates a random number following a Gaussian (normal) distribution.
1968
- * @param {number} mean - mean (center) of the distribution
1969
- * @param {number} std - standard deviation (spread or "width") of the distribution
1978
+ * @param {number} mean mean (center) of the distribution
1979
+ * @param {number} std standard deviation (spread or "width") of the distribution
1970
1980
  * @returns {number} a random number following a Gaussian distribution
1971
1981
  */
1972
1982
  function randomGaussian(mean: number, std: number): number;
@@ -1979,29 +1989,29 @@ noCursor();
1979
1989
 
1980
1990
  /** 🧮
1981
1991
  * Sets the noise generation mode.
1982
- * @param {'perlin' | 'simplex' | 'blocky'} mode - noise generation mode
1992
+ * @param {'perlin' | 'simplex' | 'blocky'} mode noise generation mode
1983
1993
  */
1984
1994
  function noiseMode(mode: 'perlin' | 'simplex' | 'blocky'): void;
1985
1995
 
1986
1996
  /** 🧮
1987
1997
  * Sets the seed value for noise generation.
1988
- * @param {number} seed - seed value
1998
+ * @param {number} seed seed value
1989
1999
  */
1990
2000
  function noiseSeed(seed: number): void;
1991
2001
 
1992
2002
  /** 🧮
1993
2003
  * Generates a noise value based on the x, y, and z inputs.
1994
- * @param {number} [x] - x-coordinate input
1995
- * @param {number} [y] - y-coordinate input
1996
- * @param {number} [z] - z-coordinate input
2004
+ * @param {number} [x] x-coordinate input
2005
+ * @param {number} [y] y-coordinate input
2006
+ * @param {number} [z] z-coordinate input
1997
2007
  * @returns {number} a noise value
1998
2008
  */
1999
2009
  function noise(x?: number, y?: number, z?: number): number;
2000
2010
 
2001
2011
  /** 🧮
2002
2012
  * Sets the level of detail for noise generation.
2003
- * @param {number} lod - level of detail (number of octaves)
2004
- * @param {number} falloff - falloff rate for each octave
2013
+ * @param {number} lod level of detail (number of octaves)
2014
+ * @param {number} falloff falloff rate for each octave
2005
2015
  */
2006
2016
  function noiseDetail(lod: number, falloff: number): void;
2007
2017
 
@@ -2030,7 +2040,7 @@ noCursor();
2030
2040
  * Creates a new `Sound` object that extends [`Audio`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement/Audio).
2031
2041
  *
2032
2042
  * See the `loadSound` documentation for more info and example usage.
2033
- * @param {string} path - path to the sound file
2043
+ * @param {string} path path to the sound file
2034
2044
  */
2035
2045
  constructor(path: string);
2036
2046
  }
@@ -2051,16 +2061,16 @@ noCursor();
2051
2061
  * For backwards compatibility with the p5.sound v1 API, the functions
2052
2062
  * `setVolume`, `setLoop`, `setPan`, `isLoaded`, and `isPlaying`
2053
2063
  * are also implemented, but their use is deprecated.
2054
- * @param {string} path - path to the sound file
2055
- * @param {(a: Sound) => void} [cb] - an optional callback function that is called when the sound is ready to play
2064
+ * @param {string} path path to the sound file
2065
+ * @param {(a: Sound) => void} [cb] an optional callback function that is called when the sound is ready to play
2056
2066
  * @returns {Sound} a new `Sound` object
2057
2067
  * @example
2058
2068
  createCanvas(200, 200);
2059
2069
 
2060
2070
  let sound = loadSound('/assets/jump.wav');
2071
+ sound.volume = 0.3;
2061
2072
 
2062
2073
  function mousePressed() {
2063
- sound.volume = 0.3;
2064
2074
  sound.play();
2065
2075
  }
2066
2076
  */
@@ -2082,43 +2092,43 @@ function mousePressed() {
2082
2092
 
2083
2093
  /** 🛠️
2084
2094
  * Loads a text file from the specified path. Result is one string.
2085
- * @param {string} path - path to the text file
2086
- * @param {(result: string) => void} cb - a callback function that is run when the file is loaded
2095
+ * @param {string} path path to the text file
2096
+ * @param {(result: string) => void} cb a callback function that is run when the file is loaded
2087
2097
  */
2088
2098
  function loadText(path: string, cb: (result: string) => void): void;
2089
2099
 
2090
2100
  /** 🛠️
2091
2101
  * Loads a JSON file from the specified path. Result depends on the
2092
2102
  * JSON file's contents, but is typically an object or array.
2093
- * @param {string} path - path to the JSON file
2094
- * @param {(result: any) => void} cb - a callback function that is run when the file is loaded
2103
+ * @param {string} path path to the JSON file
2104
+ * @param {(result: any) => void} cb a callback function that is run when the file is loaded
2095
2105
  */
2096
2106
  function loadJSON(path: string, cb: (result: any) => void): void;
2097
2107
 
2098
2108
  /** 🛠️
2099
2109
  * Loads a CSV file from the specified path. Result is an array of objects.
2100
- * @param {string} path - path to the CSV file
2101
- * @param {(result: object[]) => void} cb - a callback function that is run when the file is loaded
2110
+ * @param {string} path path to the CSV file
2111
+ * @param {(result: object[]) => void} cb a callback function that is run when the file is loaded
2102
2112
  */
2103
2113
  function loadCSV(path: string, cb: (result: object[]) => void): void;
2104
2114
 
2105
2115
  /** 🛠️
2106
2116
  * Stores an item in localStorage.
2107
- * @param {string} key - key under which to store the item
2108
- * @param {string} value - value to store
2117
+ * @param {string} key key under which to store the item
2118
+ * @param {string} value value to store
2109
2119
  */
2110
2120
  function storeItem(key: string, value: string): void;
2111
2121
 
2112
2122
  /** 🛠️
2113
2123
  * Retrieves an item from localStorage.
2114
- * @param {string} key - key of the item to retrieve
2124
+ * @param {string} key key of the item to retrieve
2115
2125
  * @returns {string} value of the retrieved item
2116
2126
  */
2117
2127
  function getItem(key: string): string;
2118
2128
 
2119
2129
  /** 🛠️
2120
2130
  * Removes an item from localStorage.
2121
- * @param {string} key - key of the item to remove
2131
+ * @param {string} key key of the item to remove
2122
2132
  */
2123
2133
  function removeItem(key: string): void;
2124
2134
 
@@ -2180,36 +2190,36 @@ function mousePressed() {
2180
2190
 
2181
2191
  /** ↗️
2182
2192
  * Constructs a new Vector object.
2183
- * @param {number} x - x component of the vector
2184
- * @param {number} y - y component of the vector
2185
- * @param {number} [z] - optional. The z component of the vector
2193
+ * @param {number} x x component of the vector
2194
+ * @param {number} y y component of the vector
2195
+ * @param {number} [z] optional. The z component of the vector
2186
2196
  */
2187
2197
  constructor(x: number, y: number, z?: number);
2188
2198
 
2189
2199
  /** ↗️
2190
2200
  * Adds a vector to this vector.
2191
- * @param {Vector} v - vector to add
2201
+ * @param {Vector} v vector to add
2192
2202
  * @returns {Vector} resulting vector after addition
2193
2203
  */
2194
2204
  add(v: Vector): Vector;
2195
2205
 
2196
2206
  /** ↗️
2197
2207
  * Subtracts a vector from this vector.
2198
- * @param {Vector} v - vector to subtract
2208
+ * @param {Vector} v vector to subtract
2199
2209
  * @returns {Vector} resulting vector after subtraction
2200
2210
  */
2201
2211
  sub(v: Vector): Vector;
2202
2212
 
2203
2213
  /** ↗️
2204
2214
  * Multiplies this vector by a scalar or element-wise by another vector.
2205
- * @param {number | Vector} n - scalar to multiply by, or a vector for element-wise multiplication
2215
+ * @param {number | Vector} n scalar to multiply by, or a vector for element-wise multiplication
2206
2216
  * @returns {Vector} resulting vector after multiplication
2207
2217
  */
2208
2218
  mult(n: number | Vector): Vector;
2209
2219
 
2210
2220
  /** ↗️
2211
2221
  * Divides this vector by a scalar or element-wise by another vector.
2212
- * @param {number | Vector} n - scalar to divide by, or a vector for element-wise division
2222
+ * @param {number | Vector} n scalar to divide by, or a vector for element-wise division
2213
2223
  * @returns {Vector} resulting vector after division
2214
2224
  */
2215
2225
  div(n: number | Vector): Vector;
@@ -2228,28 +2238,28 @@ function mousePressed() {
2228
2238
 
2229
2239
  /** ↗️
2230
2240
  * Sets the magnitude of the vector to the specified length.
2231
- * @param {number} len - new length of the vector
2241
+ * @param {number} len new length of the vector
2232
2242
  * @returns {Vector} this vector after setting magnitude
2233
2243
  */
2234
2244
  setMag(len: number): Vector;
2235
2245
 
2236
2246
  /** ↗️
2237
2247
  * Calculates the dot product of this vector and another vector.
2238
- * @param {Vector} v - other vector
2248
+ * @param {Vector} v other vector
2239
2249
  * @returns {number} dot product
2240
2250
  */
2241
2251
  dot(v: Vector): number;
2242
2252
 
2243
2253
  /** ↗️
2244
2254
  * Calculates the cross product of this vector and another vector.
2245
- * @param {Vector} v - other vector
2255
+ * @param {Vector} v other vector
2246
2256
  * @returns {Vector} a new vector that is the cross product of this vector and the given vector
2247
2257
  */
2248
2258
  cross(v: Vector): Vector;
2249
2259
 
2250
2260
  /** ↗️
2251
2261
  * Calculates the distance between this vector and another vector.
2252
- * @param {Vector} v - other vector
2262
+ * @param {Vector} v other vector
2253
2263
  * @returns {number} distance
2254
2264
  */
2255
2265
  dist(v: Vector): number;
@@ -2262,16 +2272,16 @@ function mousePressed() {
2262
2272
 
2263
2273
  /** ↗️
2264
2274
  * Sets the components of the vector.
2265
- * @param {number} x - x component
2266
- * @param {number} y - y component
2267
- * @param {number} [z] - optional. The z component
2275
+ * @param {number} x x component
2276
+ * @param {number} y y component
2277
+ * @param {number} [z] optional. The z component
2268
2278
  * @returns {void}
2269
2279
  */
2270
2280
  set(x: number, y: number, z?: number): void;
2271
2281
 
2272
2282
  /** ↗️
2273
2283
  * Limits the magnitude of the vector to the value used for the max parameter.
2274
- * @param {number} max - maximum magnitude for the vector
2284
+ * @param {number} max maximum magnitude for the vector
2275
2285
  * @returns {Vector} this vector after limiting
2276
2286
  */
2277
2287
  limit(max: number): Vector;
@@ -2284,38 +2294,38 @@ function mousePressed() {
2284
2294
 
2285
2295
  /** ↗️
2286
2296
  * Rotates the vector to a specific angle without changing its magnitude.
2287
- * @param {number} angle - angle in radians to set the heading to
2297
+ * @param {number} angle angle in radians to set the heading to
2288
2298
  * @returns {Vector} this vector after setting the heading
2289
2299
  */
2290
2300
  setHeading(angle: number): Vector;
2291
2301
 
2292
2302
  /** ↗️
2293
2303
  * Rotates the vector by the given angle (only 2D vectors).
2294
- * @param {number} angle - angle of rotation in radians
2304
+ * @param {number} angle angle of rotation in radians
2295
2305
  * @returns {Vector} this vector after rotation
2296
2306
  */
2297
2307
  rotate(angle: number): Vector;
2298
2308
 
2299
2309
  /** ↗️
2300
2310
  * Linearly interpolates between this vector and another vector.
2301
- * @param {Vector} v - vector to interpolate towards
2302
- * @param {number} amt - amount of interpolation; a number between 0.0 (close to the current vector) and 1.0 (close to the target vector)
2311
+ * @param {Vector} v vector to interpolate towards
2312
+ * @param {number} amt amount of interpolation; a number between 0.0 (close to the current vector) and 1.0 (close to the target vector)
2303
2313
  * @returns {Vector} this vector after interpolation
2304
2314
  */
2305
2315
  lerp(v: Vector, amt: number): Vector;
2306
2316
 
2307
2317
  /** ↗️
2308
2318
  * Linearly interpolates between this vector and another vector, including the magnitude.
2309
- * @param {Vector} v - vector to interpolate towards
2310
- * @param {number} amt - amount of interpolation; a number between 0.0 (close to the current vector) and 1.0 (close to the target vector)
2319
+ * @param {Vector} v vector to interpolate towards
2320
+ * @param {number} amt amount of interpolation; a number between 0.0 (close to the current vector) and 1.0 (close to the target vector)
2311
2321
  * @returns {Vector} this vector after spherical interpolation
2312
2322
  */
2313
2323
  slerp(v: Vector, amt: number): Vector;
2314
2324
 
2315
2325
  /** ↗️
2316
2326
  * Static method to create a new 2D vector from an angle.
2317
- * @param {number} angle - angle in radians
2318
- * @param {number} [length] - length of the vector. The default is 1
2327
+ * @param {number} angle angle in radians
2328
+ * @param {number} [length] length of the vector. The default is 1
2319
2329
  * @returns {Vector} a new 2D vector pointing in the direction of the given angle
2320
2330
  */
2321
2331
  static fromAngle(angle: number, length?: number): Vector;