q5 2.4.4 → 2.4.5

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 ADDED
@@ -0,0 +1,1425 @@
1
+ /**
2
+ * q5.d.ts
3
+ *
4
+ * TypeScript definitions for q5.js for use with IDEs like VSCode
5
+ * for autocompletion, hover over documentation, and type checking.
6
+ */
7
+ declare global {
8
+ class Q5 {
9
+ // ⭐️ core
10
+
11
+ /** ⭐️
12
+ * Creates an instance of Q5.
13
+ *
14
+ * Scopes:
15
+ * - "global": the default if scope is undefined, which enables top level global use Q5 functions and variables
16
+ * - "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
17
+ * - "namespace": enables users to assign a Q5 instance to a variable
18
+ *
19
+ * The first param can also be a function, called when the instance is created, replicating p5's instance mode. Use of the "namespace" scope is recommended.
20
+ * @param scope
21
+ * @param parent - element that the canvas will be placed inside
22
+ */
23
+ constructor(scope?: string | Function, parent?: HTMLElement);
24
+
25
+ /** ⭐️
26
+ * Sets the default canvas context attributes for all Q5 instances and graphics.
27
+ */
28
+ static canvasOptions: {
29
+ alpha: boolean;
30
+ colorSpace: 'display-p3' | 'srgb';
31
+ };
32
+
33
+ /** ⭐️
34
+ * True if the device supports HDR (the display-p3 colorspace).
35
+ */
36
+ static supportsHDR: boolean;
37
+
38
+ /** ⭐️
39
+ * Modules added to this object will be added to new Q5 instances.
40
+ */
41
+ static modules: {};
42
+ }
43
+
44
+ /** ⭐️
45
+ * The canvas element created by Q5.
46
+ */
47
+ var canvas: HTMLCanvasElement | null;
48
+
49
+ /** ⭐️
50
+ * The 2D rendering context for the canvas.
51
+ */
52
+ var ctx: CanvasRenderingContext2D | null;
53
+
54
+ /** ⭐️
55
+ * Alias for `ctx`, the 2D rendering context for the canvas.
56
+ */
57
+ var drawingContext: CanvasRenderingContext2D | null;
58
+
59
+ /** ⭐️
60
+ * Array of pixels in the canvas.
61
+ */
62
+ var pixels: number[];
63
+
64
+ /** ⭐️
65
+ * The number of frames that have been displayed since the program started.
66
+ */
67
+ var frameCount: number;
68
+
69
+ /** ⭐️
70
+ * The time passed since the last frame was drawn.
71
+ */
72
+ var deltaTime: number;
73
+
74
+ /** ⭐️
75
+ * The width of the window.
76
+ */
77
+ var windowWidth: number;
78
+
79
+ /** ⭐️
80
+ * The height of the window.
81
+ */
82
+ var windowHeight: number;
83
+
84
+ /** ⭐️
85
+ * The current orientation of the device.
86
+ */
87
+ var deviceOrientation: string | null;
88
+
89
+ /** ⭐️
90
+ * Stops the draw loop.
91
+ */
92
+ function noLoop(): void;
93
+
94
+ /** ⭐️
95
+ * Starts the draw loop, which calls the `draw` function at the target frame rate.
96
+ */
97
+ function loop(): void;
98
+
99
+ /** ⭐️
100
+ * Redraws the canvas n times.
101
+ * @param n - number of times to redraw the canvas
102
+ */
103
+ function redraw(n?: number): void;
104
+
105
+ /** ⭐️
106
+ * Sets the target frame rate or gets the sketch's current frame rate.
107
+ * @param hz - desired frame rate
108
+ * @returns current frame rate
109
+ */
110
+ function frameRate(hz?: number): number;
111
+
112
+ /** ⭐️
113
+ * The desired frame rate of the sketch.
114
+ * @returns target frame rate.
115
+ */
116
+ function getTargetFrameRate(): number;
117
+
118
+ /** ⭐️
119
+ * @returns frames per second.
120
+ */
121
+ function getFPS(): number;
122
+
123
+ /** ⭐️
124
+ * Logs a message to the JavaScript console. Alias for the standard `console.log` function.
125
+ * @param message
126
+ */
127
+ function log(message: any): void;
128
+
129
+ /** ⭐️
130
+ * Prints a message to the JavaScript console.
131
+ * @param message The message to print.
132
+ */
133
+ function print(message: any): void;
134
+
135
+ /** ⭐️
136
+ * The constant for TWO_PI (2*PI).
137
+ */
138
+ const TWO_PI: number;
139
+
140
+ /** ⭐️
141
+ * The constant for TAU (2*PI).
142
+ */
143
+ const TAU: number;
144
+
145
+ // ⬜️ canvas
146
+
147
+ /** ⬜️
148
+ * The canvas element associated with the Q5 instance.
149
+ */
150
+ var canvas: HTMLCanvasElement;
151
+
152
+ /** ⬜️
153
+ * The width of the canvas.
154
+ */
155
+ var width: number;
156
+
157
+ /** ⬜️
158
+ * The height of the canvas.
159
+ */
160
+ var height: number;
161
+
162
+ /** ⬜️
163
+ * Creates a canvas element.
164
+ * @param w - width of the canvas
165
+ * @param h - height of the canvas
166
+ * @param options - options for the canvas.
167
+ */
168
+ function createCanvas(w: number, h: number, options?: CanvasRenderingContext2DSettings): HTMLCanvasElement;
169
+
170
+ /** ⬜️
171
+ * Any position coordinates or dimensions you use will be scaled based on the unit
172
+ * provided to this function.
173
+ * @param unit
174
+ * @example
175
+ * new Q5();
176
+ * createCanvas(1000, 1000);
177
+ *
178
+ * flexibleCanvas(400);
179
+ * // rect will appear in the middle of the canvas
180
+ * rect(100, 100, 200, 200);
181
+ */
182
+ function flexibleCanvas(unit: number): void;
183
+
184
+ /** ⬜️
185
+ * Resizes the canvas to the specified width and height.
186
+ * @param w - width of the canvas
187
+ * @param h - height of the canvas
188
+ */
189
+ function resizeCanvas(w: number, h: number): void;
190
+
191
+ /** ⬜️
192
+ * Sets the pixel density of the canvas.
193
+ * @param v - pixel density value
194
+ */
195
+ function pixelDensity(v: number): number;
196
+
197
+ /** ⬜️
198
+ * Returns the current display density.
199
+ */
200
+ function displayDensity(): number;
201
+
202
+ /** ⬜️
203
+ * Enables or disables fullscreen mode.
204
+ * @param v - boolean indicating whether to enable or disable fullscreen mode
205
+ * @returns true if fullscreen mode is enabled, false otherwise
206
+ */
207
+ function fullscreen(v?: boolean): void | boolean;
208
+
209
+ /** ⬜️
210
+ * Creates a graphics buffer.
211
+ * @param w - width
212
+ * @param h - height
213
+ * @param opt - options
214
+ */
215
+ function createGraphics(w: number, h: number, opt?: CanvasRenderingContext2DSettings): Q5;
216
+
217
+ /** ⬜️
218
+ * Sets the fill color for shapes.
219
+ * @param color
220
+ */
221
+ function fill(color: string | number): void;
222
+
223
+ /** ⬜️
224
+ * Sets the stroke (outline) color for shapes.
225
+ * @param color
226
+ */
227
+ function stroke(color: string | number): void;
228
+
229
+ /** ⬜️
230
+ * After calling this function, shapes will not be filled.
231
+ */
232
+ function noFill(): void;
233
+
234
+ /** ⬜️
235
+ * After calling this function, shapes will not have a stroke (outline).
236
+ */
237
+ function noStroke(): void;
238
+
239
+ /** ⬜️
240
+ * Sets the size of the stroke used for lines and the border around shapes.
241
+ * @param weight - size of the stroke in pixels
242
+ */
243
+ function strokeWeight(weight: number): void;
244
+
245
+ /** ⬜️
246
+ * Sets the global opacity, `ctx.globalAlpha`, which
247
+ * affects all subsequent drawing operations.
248
+ * 0 is completely transparent, 255 is completely opaque.
249
+ * @param alpha - opacity level
250
+ */
251
+ function opacity(alpha: number): void;
252
+
253
+ /** ⬜️
254
+ * Translates the origin of the drawing context.
255
+ * @param x
256
+ * @param y
257
+ */
258
+ function translate(x: number, y: number): void;
259
+
260
+ /** ⬜️
261
+ * Rotates the drawing context.
262
+ * @param angle
263
+ */
264
+ function rotate(angle: number): void;
265
+
266
+ /** ⬜️
267
+ * Scales the drawing context.
268
+ * @param x - scaling factor along the x-axis
269
+ * @param y - scaling factor along the y-axis
270
+ */
271
+ function scale(x: number, y?: number): void;
272
+
273
+ /** ⬜️
274
+ * Shears the drawing context along the x-axis.
275
+ * @param angle
276
+ */
277
+ function shearX(angle: number): void;
278
+
279
+ /** ⬜️
280
+ * Shears the drawing context along the y-axis.
281
+ * @param angle
282
+ */
283
+ function shearY(angle: number): void;
284
+
285
+ /** ⬜️
286
+ * Applies a transformation matrix.
287
+ *
288
+ * Accepts a 3x3 or 4x4 matrix as either an array or multiple arguments.
289
+ * @param a - Horizontal scaling
290
+ * @param b - Horizontal skewing
291
+ * @param c - Vertical skewing
292
+ * @param d - Vertical scaling
293
+ * @param e - Horizontal moving
294
+ * @param f - Vertical moving
295
+ */
296
+ function applyMatrix(a: number, b: number, c: number, d: number, e: number, f: number): void;
297
+
298
+ /** ⬜️
299
+ * Resets the transformation matrix.
300
+ */
301
+ function resetMatrix(): void;
302
+
303
+ /** ⬜️
304
+ * Saves the current transformation matrix.
305
+ */
306
+ function pushMatrix(): void;
307
+
308
+ /** ⬜️
309
+ * Restores the previously saved transformation matrix.
310
+ */
311
+ function popMatrix(): void;
312
+
313
+ /** ⬜️
314
+ * Saves the current drawing style settings.
315
+ */
316
+ function pushStyles(): void;
317
+
318
+ /** ⬜️
319
+ * Restores the previously saved drawing style settings.
320
+ */
321
+ function popStyles(): void;
322
+
323
+ /** ⬜️
324
+ * Saves the current drawing style settings and transformations.
325
+ */
326
+ function push(): void;
327
+
328
+ /** ⬜️
329
+ * Restores the previously saved drawing style settings and transformations.
330
+ */
331
+ function pop(): void;
332
+
333
+ /** ⬜️
334
+ * The 2D drawing context for the canvas.
335
+ */
336
+ var ctx: CanvasRenderingContext2D;
337
+
338
+ // 💻 display
339
+
340
+ /** 💻
341
+ * The `displayMode` function lets you customize how your canvas is presented.
342
+ *
343
+ * Display modes:
344
+ * - "normal": no styling to canvas or its parent element
345
+ * - "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
346
+ * - "maxed": canvas will fill the parent element, same as fullscreen for a global mode canvas inside a `main` element
347
+ * - "fullscreen": canvas will fill the screen with letterboxing if necessary to persevere its aspect ratio, like css object-fit contain
348
+ *
349
+ * Render qualities:
350
+ * - "default": pixelDensity set to displayDensity
351
+ * - "pixelated": pixelDensity set to 1 and various css styles are applied to the canvas to make it render without image smoothing
352
+ *
353
+ * Display scale can be set to make small canvases appear larger.
354
+ * @param displayMode
355
+ * @param renderQuality
356
+ * @param displayScale - can be given as a string (ex. "x2") or a number
357
+ */
358
+ function displayMode(displayMode: string, renderQuality: string, displayScale: string | number): void;
359
+
360
+ // 🧑‍🎨 drawing
361
+
362
+ /** 🧑‍🎨
363
+ * Draws over the entire canvas with a color or image.
364
+ * @param color
365
+ */
366
+ function background(color: string | number): void;
367
+
368
+ /** 🧑‍🎨
369
+ * Draws a rectangle.
370
+ * @param x
371
+ * @param y
372
+ * @param w - width
373
+ * @param h - height
374
+ * @param tl - top-left radius for rounded corners
375
+ * @param tr - top-right radius for rounded corners
376
+ * @param br - bottom-right radius for rounded corners
377
+ * @param bl - bottom-left radius for rounded corners
378
+ */
379
+ function rect(x: number, y: number, w: number, h?: number, tl?: number, tr?: number, br?: number, bl?: number): void;
380
+
381
+ /** 🧑‍🎨
382
+ * Draws a square.
383
+ * @param x
384
+ * @param y
385
+ * @param size - size of the sides of the square
386
+ * @param tl - top-left radius for rounded corners
387
+ * @param tr - top-right radius for rounded corners
388
+ * @param br - bottom-right radius for rounded corners
389
+ * @param bl - bottom-left radius for rounded corners
390
+ */
391
+ function square(x: number, y: number, size: number, tl?: number, tr?: number, br?: number, bl?: number): void;
392
+
393
+ /** 🧑‍🎨
394
+ * Draws a circle.
395
+ * @param x
396
+ * @param y
397
+ * @param diameter
398
+ */
399
+ function circle(x: number, y: number, diameter: number): void;
400
+
401
+ /** 🧑‍🎨
402
+ * Draws an ellipse.
403
+ * @param x
404
+ * @param y
405
+ * @param width
406
+ * @param height
407
+ */
408
+ function ellipse(x: number, y: number, width: number, height?: number): void;
409
+
410
+ /** 🧑‍🎨
411
+ * Draws an arc.
412
+ * @param x
413
+ * @param y
414
+ * @param w - width
415
+ * @param h - height
416
+ * @param start - angle to start the arc
417
+ * @param stop - angle to stop the arc
418
+ * @param mode - drawing mode, can be `PIE`, `CHORD`, or `OPEN`
419
+ * @param detail - resolution of the arc
420
+ */
421
+ function arc(
422
+ x: number,
423
+ y: number,
424
+ w: number,
425
+ h: number,
426
+ start: number,
427
+ stop: number,
428
+ mode?: number,
429
+ detail?: number
430
+ ): void;
431
+
432
+ /** 🧑‍🎨
433
+ * Draws a line on the canvas.
434
+ * @param x1 - x-coordinate of the first point
435
+ * @param y1 - y-coordinate of the first point
436
+ * @param x2 - x-coordinate of the second point
437
+ * @param y2 - y-coordinate of the second point
438
+ */
439
+ function line(x1: number, y1: number, x2: number, y2: number): void;
440
+
441
+ /** 🧑‍🎨
442
+ * Draws a point on the canvas.
443
+ * @param x
444
+ * @param y
445
+ */
446
+ function point(x: number, y: number): void;
447
+
448
+ /** 🧑‍🎨
449
+ * Starts recording vertices for a shape.
450
+ */
451
+ function beginShape(): void;
452
+
453
+ /** 🧑‍🎨
454
+ * Starts recording vertices for a shape to be used as a contour.
455
+ */
456
+ function beginContour(): void;
457
+
458
+ /** 🧑‍🎨
459
+ * Ends recording vertices for a shape.
460
+ */
461
+ function endContour(): void;
462
+
463
+ /** 🧑‍🎨
464
+ * Specifies a vertex in a shape.
465
+ * @param x
466
+ * @param y
467
+ */
468
+ function vertex(x: number, y: number): void;
469
+
470
+ /** 🧑‍🎨
471
+ * Specifies a Bezier vertex in a shape.
472
+ * @param cp1x - x-coordinate of the first control point
473
+ * @param cp1y - y-coordinate of the first control point
474
+ * @param cp2x - x-coordinate of the second control point
475
+ * @param cp2y - y-coordinate of the second control point
476
+ * @param x - x-coordinate of the anchor point
477
+ * @param y - y-coordinate of the anchor point
478
+ */
479
+ function bezierVertex(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
480
+
481
+ /** 🧑‍🎨
482
+ * Specifies a quadratic Bezier vertex in a shape.
483
+ * @param cp1x - x-coordinate of the control point
484
+ * @param cp1y - y-coordinate of the control point
485
+ * @param x - x-coordinate of the anchor point
486
+ * @param y - y-coordinate of the anchor point
487
+ */
488
+ function quadraticVertex(cp1x: number, cp1y: number, x: number, y: number): void;
489
+
490
+ /** 🧑‍🎨
491
+ * Draws a Bezier curve.
492
+ * @param x1 - x-coordinate of the first anchor point
493
+ * @param y1 - y-coordinate of the first anchor point
494
+ * @param x2 - x-coordinate of the first control point
495
+ * @param y2 - y-coordinate of the first control point
496
+ * @param x3 - x-coordinate of the second control point
497
+ * @param y3 - y-coordinate of the second control point
498
+ * @param x4 - x-coordinate of the second anchor point
499
+ * @param y4 - y-coordinate of the second anchor point
500
+ */
501
+ function bezier(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
502
+
503
+ /** 🧑‍🎨
504
+ * Draws a triangle.
505
+ * @param x1 - x-coordinate of the first vertex
506
+ * @param y1 - y-coordinate of the first vertex
507
+ * @param x2 - x-coordinate of the second vertex
508
+ * @param y2 - y-coordinate of the second vertex
509
+ * @param x3 - x-coordinate of the third vertex
510
+ * @param y3 - y-coordinate of the third vertex
511
+ */
512
+ function triangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void;
513
+
514
+ /** 🧑‍🎨
515
+ * Draws a quadrilateral.
516
+ * @param x1 - x-coordinate of the first vertex
517
+ * @param y1 - y-coordinate of the first vertex
518
+ * @param x2 - x-coordinate of the second vertex
519
+ * @param y2 - y-coordinate of the second vertex
520
+ * @param x3 - x-coordinate of the third vertex
521
+ * @param y3 - y-coordinate of the third vertex
522
+ * @param x4 - x-coordinate of the fourth vertex
523
+ * @param y4 - y-coordinate of the fourth vertex
524
+ */
525
+ function quad(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4): void;
526
+
527
+ /** 🧑‍🎨
528
+ * Sets the canvas to erase mode, where shapes will erase what's underneath them instead of drawing over it.
529
+ * @param fillAlpha - opacity level of the fill color from 0 to 255, where 0 is completely transparent and 255 is completely opaque
530
+ * @param strokeAlpha - opacity level of the stroke color from 0 to 255, where 0 is completely transparent and 255 is completely opaque
531
+ */
532
+ function erase(fillAlpha?: number, strokeAlpha?: number): void;
533
+
534
+ /** 🧑‍🎨
535
+ * Resets the canvas from erase mode to normal drawing mode.
536
+ */
537
+ function noErase(): void;
538
+
539
+ /** 🧑‍🎨
540
+ * Checks if a given point is within the current path's fill area.
541
+ * @returns {boolean} True if the point is within the fill area, false otherwise
542
+ */
543
+ function inFill(x: number, y: number): boolean;
544
+
545
+ /** 🧑‍🎨
546
+ * Checks if a given point is within the current path's stroke.
547
+ * @returns {boolean} True if the point is within the stroke, false otherwise
548
+ */
549
+ function inStroke(x: number, y: number): boolean;
550
+
551
+ // 🌆 image
552
+
553
+ /** 🌆
554
+ * Applies a filter to the image
555
+ * @param typ - the type of filter
556
+ * @param x - optional parameter, depending on filter type
557
+ */
558
+ function filter(typ: string, x?: number): void;
559
+
560
+ /** 🌆
561
+ * Resizes the image
562
+ * @param w - new width
563
+ * @param h - new height
564
+ */
565
+ function resize(w: number, h: number): void;
566
+
567
+ /** 🌆
568
+ * Trims the image, cropping out transparent pixels from the edges.
569
+ */
570
+ function trim(): void;
571
+
572
+ /** 🌆
573
+ * Masks the image with another image
574
+ * @param img - the image to use as a mask
575
+ */
576
+ function mask(img: Image): void;
577
+
578
+ /** 🌆
579
+ * Saves the image
580
+ * @param a - filename or path
581
+ * @param b - file extension
582
+ * @param c - quality of the saved image
583
+ */
584
+ function save(a: string, b: string, c?: number): void;
585
+
586
+ /** 🌆
587
+ * Retrieves pixel data from an image.
588
+ * @param x
589
+ * @param y
590
+ * @param w - width of the area
591
+ * @param h - height of the area
592
+ */
593
+ function get(x: number, y: number, w?: number, h?: number): any;
594
+
595
+ /** 🌆
596
+ * Sets pixel data in the image.
597
+ * @param x
598
+ * @param y
599
+ * @param c - color or pixel data
600
+ */
601
+ function set(x: number, y: number, c: any): void;
602
+
603
+ /** 🌆
604
+ * Loads pixel data into the image's pixel array.
605
+ */
606
+ function loadPixels(): void;
607
+
608
+ /** 🌆
609
+ * Updates the image's pixels array to the canvas.
610
+ */
611
+ function updatePixels(): void;
612
+
613
+ /** 🌆
614
+ * Enables smooth image rendering
615
+ */
616
+ function smooth(): void;
617
+
618
+ /** 🌆
619
+ * Disables smooth image rendering for a pixelated look.
620
+ */
621
+ function noSmooth(): void;
622
+
623
+ /** 🌆
624
+ * Applies a tint (color overlay) to the drawing.
625
+ * Tinting affects all subsequent images drawn.
626
+ * @param c - tint color
627
+ */
628
+ function tint(c: string | number): void;
629
+
630
+ /** 🌆
631
+ * Images drawn after this function is run will not be tinted.
632
+ */
633
+ function noTint(): void;
634
+
635
+ /** 🌆
636
+ * Creates a new image.
637
+ * @param w - width
638
+ * @param h - height
639
+ * @param opt - optional settings for the image
640
+ */
641
+ function createImage(w: number, h: number, opt?: any): Image;
642
+
643
+ /** 🌆
644
+ * Sets the image mode, which determines the position and alignment of images drawn on the canvas.
645
+ * - 'CORNER': by default images will be drawn from the top-left corner (set dx, dy)
646
+ * - 'CORNERS': images will be drawn from top-left corner (set dx, dy) and bottom-right corner (set dWidth, dHeight) to draw the image, enabling easy scaling
647
+ * - 'CENTER': draws the image centered at (dx, dy)
648
+ * @param mode
649
+ */
650
+ var imageMode: (mode: 'corner' | 'corners' | 'center') => void;
651
+
652
+ /** 🌆
653
+ * Draws an image to the canvas
654
+ * @param img - image to draw
655
+ * @param dx - x-coordinate of the destination corner
656
+ * @param dy - y-coordinate of the destination corner
657
+ * @param dWidth - width of the destination image
658
+ * @param dHeight - height of the destination image
659
+ * @param sx - x-coordinate of the source corner; defaults to 0
660
+ * @param sy - y-coordinate of the source corner; defaults to 0
661
+ * @param sWidth - width of the source image
662
+ * @param sHeight - height of the source image
663
+ */
664
+ function image(
665
+ img: any,
666
+ dx: number,
667
+ dy: number,
668
+ dWidth: number,
669
+ dHeight: number,
670
+ sx?: number,
671
+ sy?: number,
672
+ sWidth?: number,
673
+ sHeight?: number
674
+ ): void;
675
+
676
+ /** 🌆
677
+ * Loads an image from a URL and optionally runs a callback function
678
+ * @param url - URL of the image to load
679
+ * @param cb - callback function to run after the image is loaded
680
+ * @param opt - optional parameters for loading the image
681
+ */
682
+ function loadImage(url: string, cb?: (img: any) => void, opt?: any): void;
683
+
684
+ /** 🌆
685
+ * Converts the image to black and white pixels depending if they are above or below a certain threshold.
686
+ */
687
+ const THRESHOLD: 1;
688
+
689
+ /** 🌆
690
+ * Converts the image to grayscale by setting each pixel to its luminance.
691
+ */
692
+ const GRAY: 2;
693
+
694
+ /** 🌆
695
+ * Sets the alpha channel to fully opaque.
696
+ */
697
+ const OPAQUE: 3;
698
+
699
+ /** 🌆
700
+ * Inverts the color of each pixel.
701
+ */
702
+ const INVERT: 4;
703
+
704
+ /** 🌆
705
+ * Limits each channel of the image to the number of colors specified as an argument.
706
+ */
707
+ const POSTERIZE: 5;
708
+
709
+ /** 🌆
710
+ * Increases the size of bright areas.
711
+ */
712
+ const DILATE: 6;
713
+
714
+ /** 🌆
715
+ * Increases the size of dark areas.
716
+ */
717
+ const ERODE: 7;
718
+
719
+ /** 🌆
720
+ * Applies a Gaussian blur to the image.
721
+ */
722
+ const BLUR: 8;
723
+
724
+ // ✍️ text
725
+
726
+ /** ✍️
727
+ * Normal font weight.
728
+ */
729
+ const NORMAL: 'normal';
730
+
731
+ /** ✍️
732
+ * Italic font style.
733
+ */
734
+ const ITALIC: 'italic';
735
+
736
+ /** ✍️
737
+ * Bold font weight.
738
+ */
739
+ const BOLD: 'bold';
740
+
741
+ /** ✍️
742
+ * Bold and italic font style.
743
+ */
744
+ const BOLDITALIC: 'italic bold';
745
+
746
+ /** ✍️
747
+ * Align text to the center.
748
+ */
749
+ const CENTER: 'center';
750
+
751
+ /** ✍️
752
+ * Align text to the left.
753
+ */
754
+ const LEFT: 'left';
755
+
756
+ /** ✍️
757
+ * Align text to the right.
758
+ */
759
+ const RIGHT: 'right';
760
+
761
+ /** ✍️
762
+ * Align text to the top.
763
+ */
764
+ const TOP: 'top';
765
+
766
+ /** ✍️
767
+ * Align text to the bottom.
768
+ */
769
+ const BOTTOM: 'bottom';
770
+
771
+ /** ✍️
772
+ * Align text to the baseline (alphabetic).
773
+ */
774
+ const BASELINE: 'alphabetic';
775
+
776
+ /** ✍️
777
+ * Loads a font from a URL and optionally runs a callback function with the font name once it's loaded
778
+ * @param url - URL of the font to load
779
+ * @param cb - Optional callback function that receives the font name as an argument once the font is loaded
780
+ * @returns name of the loaded font
781
+ */
782
+ function loadFont(url: string, cb?: (fontName: string) => void): string;
783
+
784
+ /** ✍️
785
+ * Sets the current font to be used for text elements
786
+ * @param fontName - name of the font
787
+ */
788
+ function textFont(fontName: string): void;
789
+
790
+ /** ✍️
791
+ * Sets or gets the current font size. If no argument is provided, returns the current font size
792
+ * @param size - size of the font in pixels
793
+ * @returns current font size when no argument is provided
794
+ */
795
+ function textSize(size?: number): number | void;
796
+
797
+ /** ✍️
798
+ * Sets or gets the current line height. If no argument is provided, returns the current line height
799
+ * @param leading - line height in pixels
800
+ * @returns current line height when no argument is provided
801
+ */
802
+ function textLeading(leading?: number): number | void;
803
+
804
+ /** ✍️
805
+ * Sets the current text style
806
+ * @param style - font style ('normal', 'italic', 'bold', 'bolditalic')
807
+ */
808
+ function textStyle(style: 'normal' | 'italic' | 'bold' | 'bolditalic'): void;
809
+
810
+ /** ✍️
811
+ * Sets the horizontal and vertical alignment of text
812
+ * @param horiz - horizontal alignment ('left', 'center', 'right')
813
+ * @param vert - vertical alignment ('top', 'middle', 'bottom', 'alphabetic')
814
+ */
815
+ function textAlign(horiz: 'left' | 'center' | 'right', vert?: 'top' | 'middle' | 'bottom' | 'alphabetic'): void;
816
+
817
+ /** ✍️
818
+ * Calculates and returns the width of a given string of text
819
+ * @param str - string to measure
820
+ * @returns width of the text in pixels
821
+ */
822
+ function textWidth(str: string): number;
823
+
824
+ /** ✍️
825
+ * Calculates and returns the ascent (the distance from the baseline to the top of the highest character) of the current font
826
+ * @param str - string to measure
827
+ * @returns ascent of the text in pixels
828
+ */
829
+ function textAscent(str: string): number;
830
+
831
+ /** ✍️
832
+ * Calculates and returns the descent (the distance from the baseline to the bottom of the lowest character) of the current font
833
+ * @param str - string to measure
834
+ * @returns descent of the text in pixels
835
+ */
836
+ function textDescent(str: string): number;
837
+
838
+ /** ✍️
839
+ * Creates an image from a string of text. Width and height
840
+ * will not be the width and height of the text image, but of
841
+ * the bounding box that the text will be constrained within.
842
+ * @param str - string of text
843
+ * @param w - width of the bounding box
844
+ * @param h - height of the bounding box
845
+ * @returns An image object representing the rendered text.
846
+ */
847
+ function createTextImage(str: string, w: number, h: number): Q5;
848
+
849
+ /** ✍️
850
+ * Renders text to the screen. Text can be positioned with the x and y
851
+ * parameters and can optionally be constrained within a bounding box.
852
+ * @param str - string of text to display
853
+ * @param x - x-coordinate of the text's position
854
+ * @param y - y-coordinate of the text's position
855
+ * @param w - width of the bounding box
856
+ * @param h - height of the bounding box
857
+ */
858
+ function text(str: string, x: number, y: number, w?: number, h?: number): void;
859
+
860
+ /** ✍️
861
+ * Renders an image generated from text onto the canvas. The
862
+ * positioning of the image can be affected by the current text
863
+ * alignment and baseline settings.
864
+ * @param img - image object to render, typically generated from text
865
+ * @param x - x-coordinate where the image should be placed
866
+ * @param y - y-coordinate where the image should be placed
867
+ */
868
+ function textImage(img: HTMLImageElement, x: number, y: number): void;
869
+
870
+ /** ✍️
871
+ * Number formatter, can be used to display number as a string with
872
+ * a specified number of digits before and after the decimal point,
873
+ * optionally adding padding with zeros.
874
+ * @param n - number to format
875
+ * @param l - minimum number of digits to appear before the decimal point, the number is padded with zeros if necessary.
876
+ * @param r - number of digits to appear after the decimal point
877
+ * @returns A string representation of the number, formatted according to the specified conditions.
878
+ */
879
+ function nf(n: number, l: number, r: number): string;
880
+
881
+ // ✨ ai
882
+
883
+ /** ✨
884
+ * Run this function before a line of code that isn't working as expected.
885
+ * @example
886
+ * function draw() {
887
+ * askAI();
888
+ * text('Hello!');
889
+ * }
890
+ */
891
+ function askAI(): void;
892
+
893
+ // 🎨 color
894
+
895
+ /** 🎨
896
+ * Sets the color mode for the sketch. Changes the type of color object created by color functions.
897
+ *
898
+ * In WebGPU, the default color mode is 'rgb' in float format.
899
+ * @param mode - color mode ('rgb', 'srgb', or 'oklch')
900
+ * @param format - color format (1 or 255) for floating point or legacy 8-bit integer representation
901
+ */
902
+ function colorMode(mode: 'rgb' | 'srgb' | 'oklch', format: 1 | 255): void;
903
+
904
+ /** 🎨
905
+ * A function to create a new `Color` object. It can parse different
906
+ * color representations depending on the current `colorMode`.
907
+ * @param c0 - first color component, or a string representing the color, or a `Color` object, or an array of components.
908
+ * @param c1 - second color component
909
+ * @param c2 - third color component
910
+ * @param c3 - fourth color component (alpha)
911
+ * @returns A new `Color` object.
912
+ */
913
+ function color(c0: string | number | Color | number[], c1?: number, c2?: number, c3?: number): Color;
914
+
915
+ // 🖲️ input
916
+
917
+ /** 🖲️
918
+ * Current X position of the mouse.
919
+ */
920
+ let mouseX: number;
921
+
922
+ /** 🖲️
923
+ * Current Y position of the mouse.
924
+ */
925
+ let mouseY: number;
926
+
927
+ /** 🖲️
928
+ * Previous X position of the mouse.
929
+ */
930
+ let pmouseX: number;
931
+
932
+ /** 🖲️
933
+ * Previous Y position of the mouse.
934
+ */
935
+ let pmouseY: number;
936
+
937
+ /** 🖲️
938
+ * Array of current touches, each touch being an object with x, y, id, etc.
939
+ */
940
+ let touches: any[];
941
+
942
+ /** 🖲️
943
+ * The current button being pressed ('left', 'right', 'center'), or null if no button is pressed.
944
+ */
945
+ let mouseButton: string | null;
946
+
947
+ /** 🖲️
948
+ * True if a key is currently pressed, false otherwise.
949
+ */
950
+ let keyIsPressed: boolean;
951
+
952
+ /** 🖲️
953
+ * True if the mouse is currently pressed, false otherwise.
954
+ */
955
+ let mouseIsPressed: boolean;
956
+
957
+ /** 🖲️
958
+ * The value of the last key pressed, or null if no key is pressed.
959
+ */
960
+ let key: string | null;
961
+
962
+ /** 🖲️
963
+ * The keyCode of the last key pressed, or null if no key is pressed.
964
+ */
965
+ let keyCode: number | null;
966
+
967
+ /** 🖲️
968
+ * Sets the cursor to a specified type or image path.
969
+ * If an image is provided, optional x and y coordinates can
970
+ * specify the active point of the cursor.
971
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
972
+ * @param name - name of the cursor or the path to an image
973
+ * @param x - x-coordinate of the cursor's hot spot
974
+ * @param y - y-coordinate of the cursor's hot spot
975
+ */
976
+ function cursor(name: string, x?: number, y?: number): void;
977
+
978
+ /** 🖲️
979
+ * Hides the cursor.
980
+ */
981
+ function noCursor(): void;
982
+
983
+ /** 🖲️
984
+ * Requests that the pointer be locked to the document body, hiding the cursor and allowing for unlimited movement.
985
+ */
986
+ function requestPointerLock(): void;
987
+
988
+ /** 🖲️
989
+ * Exits pointer lock, showing the cursor again and stopping the unlimited movement.
990
+ */
991
+ function exitPointerLock(): void;
992
+
993
+ /** 🖲️
994
+ * Returns true if the key is the user is pressing the key, false otherwise. Accepts case-insensitive key names.
995
+ * @param key
996
+ */
997
+ function keyIsDown(key: string): boolean;
998
+
999
+ // 🧮 math
1000
+
1001
+ /** 🧮
1002
+ * Calculates the distance between two points.
1003
+ * @param x1 - x-coordinate of the first point
1004
+ * @param y1 - y-coordinate of the first point
1005
+ * @param x2 - x-coordinate of the second point
1006
+ * @param y2 - y-coordinate of the second point
1007
+ * @returns - distance between the points
1008
+ */
1009
+ function dist(x1: number, y1: number, x2: number, y2: number): number;
1010
+
1011
+ /** 🧮
1012
+ * Maps a number from one range to another.
1013
+ * @param value - incoming value to be converted
1014
+ * @param start1 - Lower bound of the value's current range
1015
+ * @param stop1 - Upper bound of the value's current range
1016
+ * @param start2 - Lower bound of the value's target range
1017
+ * @param stop2 - Upper bound of the value's target range
1018
+ * @returns mapped value
1019
+ */
1020
+ function map(value: number, start1: number, stop1: number, start2: number, stop2: number): number;
1021
+
1022
+ /** 🧮
1023
+ * Sets the mode for interpreting and drawing angles. Can be either 'degrees' or 'radians'.
1024
+ * @param mode - The mode to set for angle interpretation ('degrees' or 'radians').
1025
+ */
1026
+ function angleMode(mode: 'degrees' | 'radians'): void;
1027
+
1028
+ /** 🧮
1029
+ * Converts degrees to radians.
1030
+ * @param degrees - The angle in degrees.
1031
+ * @returns The angle in radians.
1032
+ */
1033
+ function radians(degrees: number): number;
1034
+
1035
+ /** 🧮
1036
+ * Converts radians to degrees.
1037
+ * @param radians - The angle in radians.
1038
+ * @returns The angle in degrees.
1039
+ */
1040
+ function degrees(radians: number): number;
1041
+
1042
+ /** 🧮
1043
+ * Calculates a number between two numbers at a specific increment.
1044
+ * @param start - The first number.
1045
+ * @param stop - The second number.
1046
+ * @param amt - The amount to interpolate between the two values.
1047
+ * @returns The interpolated number.
1048
+ */
1049
+ function lerp(start: number, stop: number, amt: number): number;
1050
+
1051
+ /** 🧮
1052
+ * Constrains a value between a minimum and maximum value.
1053
+ * @param n - The number to constrain.
1054
+ * @param low - The lower bound.
1055
+ * @param high - The upper bound.
1056
+ * @returns The constrained value.
1057
+ */
1058
+ function constrain(n: number, low: number, high: number): number;
1059
+
1060
+ /** 🧮
1061
+ * Normalizes a number from another range into a value between 0 and 1.
1062
+ * @param n - The number to normalize.
1063
+ * @param start - Lower bound of the range.
1064
+ * @param stop - Upper bound of the range.
1065
+ * @returns The normalized number.
1066
+ */
1067
+ function norm(n: number, start: number, stop: number): number;
1068
+
1069
+ /** 🧮
1070
+ * Calculates the square of a number.
1071
+ * @param n - The number to square.
1072
+ * @returns The square of the number.
1073
+ */
1074
+ function sq(n: number): number;
1075
+
1076
+ /** 🧮
1077
+ * Calculates the fractional part of a number.
1078
+ * @param n - The number whose fractional part is to be calculated.
1079
+ * @returns The fractional part of the number.
1080
+ */
1081
+ function fract(n: number): number;
1082
+
1083
+ /** 🧮
1084
+ * Sets the seed for the random number generator.
1085
+ * @param seed - The seed value.
1086
+ */
1087
+ function randomSeed(seed: number): void;
1088
+
1089
+ /** 🧮
1090
+ * Generates random numbers. If no arguments are provided, returns a random number between 0 and 1.
1091
+ * If one number argument is provided, returns a random number between 0 and the provided value.
1092
+ * If two number arguments are provided, returns a random number between the two values.
1093
+ * If an array is provided, returns a random element from the array.
1094
+ * @param a - lower bound (inclusive) or an array.
1095
+ * @param b - upper bound (exclusive).
1096
+ * @returns A random number or element.
1097
+ */
1098
+ function random(a?: number | any[], b?: number): number | any;
1099
+
1100
+ /** 🧮
1101
+ * Sets the random number generation method.
1102
+ * @param method - method to use for random number generation.
1103
+ */
1104
+ function randomGenerator(method: any): void;
1105
+
1106
+ /** 🧮
1107
+ * Generates a random number following a Gaussian (normal) distribution.
1108
+ * @param mean - mean (center) of the distribution.
1109
+ * @param std - standard deviation (spread or "width") of the distribution.
1110
+ * @returns A random number following a Gaussian distribution.
1111
+ */
1112
+ function randomGaussian(mean: number, std: number): number;
1113
+
1114
+ /** 🧮
1115
+ * Generates a random number following an exponential distribution.
1116
+ * @returns A random number following an exponential distribution.
1117
+ */
1118
+ function randomExponential(): number;
1119
+
1120
+ /** 🧮
1121
+ * Sets the noise generation mode.
1122
+ * @param mode - noise generation mode ('perlin', 'simplex', or 'blocky').
1123
+ */
1124
+ function noiseMode(mode: 'perlin' | 'simplex' | 'blocky'): void;
1125
+
1126
+ /** 🧮
1127
+ * Sets the seed value for noise generation.
1128
+ * @param seed
1129
+ */
1130
+ function noiseSeed(seed: number): void;
1131
+
1132
+ /** 🧮
1133
+ * Generates a noise value based on the x, y, and z inputs.
1134
+ * @param x
1135
+ * @param y
1136
+ * @param z
1137
+ * @returns a noise value
1138
+ */
1139
+ function noise(x?: number, y?: number, z?: number): number;
1140
+
1141
+ /** 🧮
1142
+ * Sets the level of detail for noise generation.
1143
+ * @param lod - level of detail (number of octaves)
1144
+ * @param falloff - falloff rate for each octave
1145
+ */
1146
+ function noiseDetail(lod: number, falloff: number): void;
1147
+
1148
+ // 🔊 q5-sound
1149
+
1150
+ /** 🔊
1151
+ * Represents a sound object, extending the native `Audio` to
1152
+ * add panning and for deprecated p5.sound v1 compatibility.
1153
+ */
1154
+ class Sound extends Audio {
1155
+ /** 🔊
1156
+ * Creates a new `Sound` object.
1157
+ * @param path - path to the sound file
1158
+ */
1159
+ constructor(path: string);
1160
+
1161
+ /** 🔊
1162
+ * Sets the volume of the sound.
1163
+ * @param level - volume level, between 0.0 and 1.0
1164
+ * @deprecated Set the `.volume` property instead.
1165
+ */
1166
+ setVolume(level: number): void;
1167
+
1168
+ /** 🔊
1169
+ * Sets whether the sound should loop.
1170
+ * @param loop - A boolean indicating whether to loop the sound.
1171
+ * @deprecated Set the `.loop` property instead.
1172
+ */
1173
+ setLoop(loop: boolean): void;
1174
+
1175
+ /** 🔊
1176
+ * Sets the stereo panning of the sound.
1177
+ * @param value - The panning value, between -1 (full left) and 1 (full right).
1178
+ * @deprecated Set the `.pan` property instead.
1179
+ */
1180
+ setPan(value: number): void;
1181
+ }
1182
+
1183
+ /** 🔊
1184
+ * Loads a sound file and returns an enhanced Audio object with additional methods.
1185
+ * @param path - The path to the sound file.
1186
+ * @param cb - An optional callback function that is called when the sound is ready to play.
1187
+ * @returns An enhanced Audio object with additional methods for volume, looping, and panning.
1188
+ */
1189
+ function loadSound(path: string, cb?: (a: Sound) => void): Sound;
1190
+
1191
+ /** 🔊
1192
+ * Returns the AudioContext used by the library. Creates a new one if it doesn't exist.
1193
+ * @returns The AudioContext instance.
1194
+ */
1195
+ function getAudioContext(): AudioContext;
1196
+
1197
+ /** 🔊
1198
+ * Resumes the AudioContext if it has been suspended.
1199
+ */
1200
+ function userStartAudio(): Promise<void>;
1201
+
1202
+ // 🛠️ utilities
1203
+
1204
+ /** 🛠️
1205
+ * Loads a text file from the specified path and returns an array of strings.
1206
+ * @param path - The path to the text file.
1207
+ * @param cb - A callback function that is called when the file is loaded.
1208
+ */
1209
+ function loadStrings(path: string, cb: (result: string[]) => void): void;
1210
+
1211
+ /** 🛠️
1212
+ * Loads a JSON file from the specified path.
1213
+ * @param path - The path to the JSON file.
1214
+ * @param cb - A callback function that is called when the file is loaded.
1215
+ */
1216
+ function loadJSON(path: string, cb: (result: object) => void): void;
1217
+
1218
+ /** 🛠️
1219
+ * Stores an item in localStorage.
1220
+ * @param key - The key under which to store the item.
1221
+ * @param value - The value to store.
1222
+ */
1223
+ function storeItem(key: string, value: string): void;
1224
+
1225
+ /** 🛠️
1226
+ * Retrieves an item from localStorage.
1227
+ * @param key - The key of the item to retrieve.
1228
+ * @returns The value of the retrieved item.
1229
+ */
1230
+ function getItem(key: string): string | null;
1231
+
1232
+ /** 🛠️
1233
+ * Removes an item from localStorage.
1234
+ * @param key - The key of the item to remove.
1235
+ */
1236
+ function removeItem(key: string): void;
1237
+
1238
+ /** 🛠️
1239
+ * Clears all items from localStorage.
1240
+ */
1241
+ function clearStorage(): void;
1242
+
1243
+ /** 🛠️
1244
+ * Returns the current year.
1245
+ * @returns The current year.
1246
+ */
1247
+ function year(): number;
1248
+
1249
+ /** 🛠️
1250
+ * Returns the current day of the week.
1251
+ * @returns The current day of the week.
1252
+ */
1253
+ function day(): number;
1254
+
1255
+ /** 🛠️
1256
+ * Returns the current hour.
1257
+ * @returns The current hour.
1258
+ */
1259
+ function hour(): number;
1260
+
1261
+ /** 🛠️
1262
+ * Returns the current minute.
1263
+ * @returns The current minute.
1264
+ */
1265
+ function minute(): number;
1266
+
1267
+ /** 🛠️
1268
+ * Returns the current second.
1269
+ * @returns The current second.
1270
+ */
1271
+ function second(): number;
1272
+
1273
+ // ↗️ vector
1274
+
1275
+ /** ↗️
1276
+ * Represents a 2D or 3D vector. This class offers a variety of operations for vector math.
1277
+ */
1278
+ class Vector {
1279
+ /** ↗️
1280
+ * The x component of the vector.
1281
+ */
1282
+ x: number;
1283
+
1284
+ /** ↗️
1285
+ * The y component of the vector.
1286
+ */
1287
+ y: number;
1288
+
1289
+ /** ↗️
1290
+ * The z component of the vector, if applicable.
1291
+ */
1292
+ z?: number;
1293
+
1294
+ /** ↗️
1295
+ * Constructs a new Vector object.
1296
+ * @param x - The x component of the vector.
1297
+ * @param y - The y component of the vector.
1298
+ * @param z - Optional. The z component of the vector.
1299
+ */
1300
+ constructor(x: number, y: number, z?: number);
1301
+
1302
+ /** ↗️
1303
+ * Adds a vector to this vector.
1304
+ * @param v - The vector to add.
1305
+ */
1306
+ add(v: Vector): Vector;
1307
+
1308
+ /** ↗️
1309
+ * Subtracts a vector from this vector.
1310
+ * @param v - The vector to subtract.
1311
+ */
1312
+ sub(v: Vector): Vector;
1313
+
1314
+ /** ↗️
1315
+ * Multiplies this vector by a scalar or element-wise by another vector.
1316
+ * @param n - The scalar to multiply by, or a vector for element-wise multiplication.
1317
+ */
1318
+ mult(n: number | Vector): Vector;
1319
+
1320
+ /** ↗️
1321
+ * Divides this vector by a scalar or element-wise by another vector.
1322
+ * @param n - The scalar to divide by, or a vector for element-wise division.
1323
+ */
1324
+ div(n: number | Vector): Vector;
1325
+
1326
+ /** ↗️
1327
+ * Calculates the magnitude (length) of the vector.
1328
+ * @returns The magnitude of the vector.
1329
+ */
1330
+ mag(): number;
1331
+
1332
+ /** ↗️
1333
+ * Normalizes the vector to a length of 1 (making it a unit vector).
1334
+ */
1335
+ normalize(): Vector;
1336
+
1337
+ /** ↗️
1338
+ * Sets the magnitude of the vector to the specified length.
1339
+ * @param len - The new length of the vector.
1340
+ */
1341
+ setMag(len: number): Vector;
1342
+
1343
+ /** ↗️
1344
+ * Calculates the dot product of this vector and another vector.
1345
+ * @param v - The other vector.
1346
+ * @returns The dot product.
1347
+ */
1348
+ dot(v: Vector): number;
1349
+
1350
+ /** ↗️
1351
+ * Calculates the cross product of this vector and another vector.
1352
+ * @param v - The other vector.
1353
+ * @returns A new vector that is the cross product of this vector and the given vector.
1354
+ */
1355
+ cross(v: Vector): Vector;
1356
+
1357
+ /** ↗️
1358
+ * Calculates the distance between this vector and another vector.
1359
+ * @param v - The other vector.
1360
+ * @returns The distance.
1361
+ */
1362
+ dist(v: Vector): number;
1363
+
1364
+ /** ↗️
1365
+ * Copies this vector.
1366
+ * @returns A new vector with the same components as this one.
1367
+ */
1368
+ copy(): Vector;
1369
+
1370
+ /** ↗️
1371
+ * Sets the components of the vector.
1372
+ * @param x - The x component.
1373
+ * @param y - The y component.
1374
+ * @param z - Optional. The z component.
1375
+ */
1376
+ set(x: number, y: number, z?: number): void;
1377
+
1378
+ /** ↗️
1379
+ * Limits the magnitude of the vector to the value used for the max parameter.
1380
+ * @param max - The maximum magnitude for the vector.
1381
+ */
1382
+ limit(max: number): Vector;
1383
+
1384
+ /** ↗️
1385
+ * Calculates the angle of rotation for this vector (only 2D vectors).
1386
+ * @returns The angle of rotation.
1387
+ */
1388
+ heading(): number;
1389
+
1390
+ /** ↗️
1391
+ * Rotates the vector to a specific angle without changing its magnitude.
1392
+ */
1393
+ setHeading(angle: number): Vector;
1394
+
1395
+ /** ↗️
1396
+ * Rotates the vector by the given angle (only 2D vectors).
1397
+ * @param angle - The angle of rotation in radians.
1398
+ */
1399
+ rotate(angle: number): Vector;
1400
+
1401
+ /** ↗️
1402
+ * Linearly interpolates between this vector and another vector.
1403
+ * @param v - The vector to interpolate towards.
1404
+ * @param amt - The amount of interpolation; a number between 0.0 (close to the current vector) and 1.0 (close to the target vector).
1405
+ */
1406
+ lerp(v: Vector, amt: number): Vector;
1407
+
1408
+ /** ↗️
1409
+ * Linearly interpolates between this vector and another vector, including the magnitude.
1410
+ * @param v - The vector to interpolate towards.
1411
+ * @param amt - The amount of interpolation; a number between 0.0 (close to the current vector) and 1.0 (close to the target vector).
1412
+ */
1413
+ slerp(v: Vector, amt: number): Vector;
1414
+
1415
+ /** ↗️
1416
+ * Static method to create a new 2D vector from an angle.
1417
+ * @param angle - The angle in radians.
1418
+ * @param length - Optional. The length of the vector. The default is 1.
1419
+ * @returns A new 2D vector pointing in the direction of the given angle.
1420
+ */
1421
+ static fromAngle(angle: number, length?: number): Vector;
1422
+ }
1423
+ }
1424
+
1425
+ export {};