-
Notifications
You must be signed in to change notification settings - Fork 12
/
q5.d.ts
2363 lines (2046 loc) · 65.4 KB
/
q5.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* q5.d.ts
*
* TypeScript definitions for q5.js for use with IDEs like VSCode
* for autocompletion, hover over documentation, and type checking.
*/
declare global {
// ⭐️ core
/** ⭐️
* The draw function is run 60 times per second by default.
* @example
function draw() {
background('silver');
circle(frameCount % 200, 100, 80);
}
*/
function draw(): void;
/** ⭐️
* The setup function is run once, when the program starts.
* @example
function setup() {
createCanvas(200, 100);
background('aqua');
}
*/
function setup(): void;
/** ⭐️
* Load assets in the preload function to ensure that they're
* available before the setup and draw functions are run.
* @example
let logo;
function preload() {
logo = loadImage('/q5js_logo.webp');
}
function draw() {
background(logo);
}
*/
function preload(): void;
/** ⭐️
* The number of frames that have been displayed since the program started.
* @example
function draw() {
background(200);
textSize(64);
text(frameCount, 8, 120);
}
*/
var frameCount: number;
/** ⭐️
* Stops the draw loop.
* @example
function draw() {
circle(frameCount * 5, 100, 80);
noLoop();
}
*/
function noLoop(): void;
/** ⭐️
* Redraws the canvas n times. If no input parameter is provided,
* it calls the draw function once.
* @param {number} [n] number of times to redraw the canvas, default is 1
* @example
createCanvas(200, 200);
noLoop();
function draw() {
circle(frameCount * 5, 100, 80);
}
function mousePressed() {
redraw(10);
}
*/
function redraw(n?: number): void;
/** ⭐️
* Starts the draw loop again if it was stopped.
* @example
createCanvas(200, 200);
noLoop();
function draw() {
circle(frameCount * 5, 100, 80);
}
function mousePressed() {
loop();
}
*/
function loop(): void;
/** ⭐️
* Sets the target frame rate or gets an approximation of the
* sketch's current frame rate.
*
* Even when the sketch is running at a consistent frame rate,
* the current frame rate value will fluctuate. Use your web browser's
* developer tools for more accurate performance analysis.
* @param {number} [hertz] target frame rate, default is 60
* @returns {number} current frame rate
* @example
function draw() {
background(200);
if (mouseIsPressed) frameRate(10);
else frameRate(60);
circle(frameCount % 200, 100, 80);
}
* @example
function draw() {
background(200);
textSize(64);
text(round(frameRate()), 65, 120);
}
*/
function frameRate(hertz?: number): number;
/** ⭐️
* The desired frame rate of the sketch.
* @returns {number} target frame rate
* @example
function draw() {
background(200);
textSize(64);
text(getTargetFrameRate(), 65, 120);
}
*/
function getTargetFrameRate(): number;
/** ⭐️
* Gets the current FPS, in terms of how many frames could be generated
* in one second, which can be higher than the target frame rate.
*
* Use your web browser's developer tools for more in-depth
* performance analysis.
* @returns {number} frames per second
* @example
function draw() {
background(200);
frameRate(1);
textSize(64);
text(getFPS(), 8, 120);
}
*/
function getFPS(): number;
/** ⭐️
* Logs a message to the JavaScript console. Alias for the standard
* [`console.log`](https://developer.mozilla.org/en-US/docs/Web/API/console/log_static) function.
*
* You can open web developer tools in most browsers by using the
* keyboard shortcut `Ctrl + Shift + i` or `command + option + i`,
* then click the "Console" tab.
* @param {*} message message to log
*/
function log(message: any): void;
/** ⭐️
* Runs after each `draw` function call and post draw hooks.
*
* Useful for adding post-processing effects when it's not possible
* to do so at the end of the `draw` function, such as when using
* libraries like p5play that draw to the canvas after the `draw`
* function is run.
* @example
function draw() {
background(200);
circle(frameCount % 200, 100, 80);
}
function postProcess() {
filter(INVERT);
}
*/
function postProcess(): void;
/** ⭐️
* The width of the window.
* @example
function draw() {
background(200);
textSize(64);
textAlign(CENTER, CENTER);
text(windowWidth, 100, 100);
}
*/
var windowWidth: number;
/** ⭐️
* The height of the window.
* @example
function draw() {
background(200);
textSize(64);
textAlign(CENTER, CENTER);
text(windowHeight, 100, 100);
}
*/
var windowHeight: number;
/** ⭐️
* The time passed since the last frame was drawn.
*
* With the default frame rate of 60, delta time will be
* approximately 16.6
*
* Can be used to keep movements tied to real time if the sketch
* is often dropping below the target frame rate. Although if frame
* rates are consistently low, consider reducing the target frame
* rate instead.
* @example
function draw() {
background(200);
text(deltaTime, 60, 106);
}
* @example
let x = 0;
function draw() {
background(200);
// simulate frame rate drops
frameRate(random(30, 60));
x += deltaTime * 0.2;
circle(x % 200, 100, 20);
}
*/
var deltaTime: number;
class Q5 {
/** ⭐️
* Creates an instance of Q5.
*
* Running `new Q5()` enables the use of q5 functions and variables
* anywhere in your code. You can also start Q5 in global mode by
* running [`createCanvas`](https://q5js.org/learn/#canvas-createCanvas).
*
* By default q5 uses the CanvasRenderingContext2D based q2d renderer.
*
* To use the q5 WebGPU renderer, run `Q5.webgpu()` after the creation of 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).
* @param {string | Function} [scope]
* - "global": (default) top-level global mode, adds q5 functions
* and variables to the global scope
* - "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
* - "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
* @param {HTMLElement} [parent] element that the canvas will be placed inside
* @example
new Q5();
createCanvas(200, 100);
circle(100, 50, 80);
*/
constructor(scope?: string | Function, parent?: HTMLElement);
/** ⭐️
* Q5 reformats some errors to make them more readable for beginners.
* @default false
*/
static disableFriendlyErrors: boolean;
/** ⭐️
* Sets the default canvas context attributes for all Q5 instances
* and graphics.
* @default { alpha: false, colorSpace: 'display-p3' }
*/
static canvasOptions: {};
/** ⭐️
* True if the device supports HDR (the display-p3 colorspace).
*/
static supportsHDR: boolean;
/** ⭐️
* Modules added to this object will be added to new Q5 instances.
*/
static modules: {};
}
// ⬜️ canvas
/** ⬜️
* Creates a canvas element, a section of the screen your program
* can draw on.
*
* Start using q5 by running this function!
*
* If this function is not run by the user, a 200x200 canvas will be
* created automatically before the draw loop starts. Although in q5
* WebGPU, this function must be run before running other q5 functions.
* @param {number} [w] width of the canvas, default is windowWidth
* @param {number} [h] height of the canvas, default is windowHeight
* @param {Object} [opt] options for the canvas
* @param {boolean} [opt.alpha] whether the canvas should have an alpha channel that allows it to be seen through, default is false
* @param {string} [opt.colorSpace] color space of the canvas, either "srgb" or "display-p3", default is "display-p3" for devices that support HDR colors
* @returns {HTMLCanvasElement} created canvas element
* @example
createCanvas(200, 100);
circle(100, 50, 80);
* @example
createCanvas(200, 200, { alpha: true });
function draw() {
clear();
circle(frameCount % 200, 100, 80);
}
*/
function createCanvas(w?: number, h?: number, options?: CanvasRenderingContext2DSettings): HTMLCanvasElement;
/** ⬜️
* The canvas element associated with the Q5 instance.
*/
var canvas: HTMLCanvasElement;
/** ⬜️
* The width of the canvas.
* Can also be accessed via `canvas.w`/`canvas.width`.
*/
var width: number;
/** ⬜️
* The height of the canvas.
* Can also be accessed via `canvas.h`/`canvas.height`.
*/
var height: number;
/** ⬜️
* Clears the canvas, making every pixel completely transparent.
*
* The canvas can only be seen through if it has an alpha channel though.
*/
function clear(): void;
/** ⬜️
* Sets the fill color for shapes. The default is white.
*
* 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.
* @param {string | Color} color fill color
* @example
function draw() {
background(200);
fill('red');
circle(80, 80, 80);
fill('lime');
square(80, 80, 80);
}
*/
function fill(color: string | Color): void;
/** ⬜️
* Sets the stroke (outline) color for shapes. The default is black.
*
* 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.
* @param {string | Color} color stroke color
* @example
function draw() {
background(200);
fill(36);
stroke('red');
circle(80, 80, 80);
stroke('lime');
square(80, 80, 80);
}
*/
function stroke(color: string | Color): void;
/** ⬜️
* After calling this function, shapes will not be filled.
* @example
function draw() {
background(200);
noFill();
stroke('red');
circle(80, 80, 80);
stroke('lime');
square(80, 80, 80);
}
*/
function noFill(): void;
/** ⬜️
* After calling this function, shapes will not have a stroke (outline).
* @example
function draw() {
background(200);
fill(36);
stroke('red');
circle(80, 80, 80);
noStroke();
square(80, 80, 80);
}
*/
function noStroke(): void;
/** ⬜️
* Sets the size of the stroke used for lines and the border around shapes.
* @param {number} weight size of the stroke in pixels
* @example
function setup() {
createCanvas(200, 200);
background(200);
stroke('red');
circle(50, 100, 80);
strokeWeight(20);
circle(150, 100, 80)
}
*/
function strokeWeight(weight: number): void;
/** ⬜️
* Sets the global opacity, which affects all subsequent drawing operations, except `background`. Default is 1, fully opaque.
* @param {number} alpha opacity level, ranging from 0 to 1
* @example
function draw() {
background(200);
opacity(1);
circle(80, 80, 80);
opacity(0.2);
square(80, 80, 80);
}
*/
function opacity(alpha: number): void;
/** ⬜️
* Sets the shadow color. The default is transparent (no shadow).
*
* Shadows apply to anything drawn to the canvas, including filled
* shapes, strokes, text, and images.
*
* 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.
* @param {string | Color} color shadow color
* @example
function draw() {
background(200);
noFill();
shadow('black');
rect(64, 60, 80, 80);
text('q5', 100, 100);
}
* @example
createCanvas(200, 200);
let logo = loadImage('/assets/p5play_logo.webp');
function setup() {
background(200);
shadow(0);
image(logo, 36, 36, 128, 128);
}
*/
function shadow(color: string | Color): void;
/** ⬜️
* Disables the shadow effect.
* @example
function draw() {
background(200);
noStroke();
shadow('black');
rect(14, 14, 80, 80);
noShadow();
rect(104, 104, 80, 80);
}
*/
function noShadow(): void;
/** ⬜️
* Sets the shadow offset and blur radius.
*
* When q5 starts, shadow offset is (10, 10) with a blur of 10.
* @param {number} offsetX horizontal offset of the shadow
* @param {number} offsetY vertical offset of the shadow, defaults to be the same as offsetX
* @param {number} blur blur radius of the shadow, defaults to 0
* @example
function draw() {
background(200);
noStroke();
shadow('red');
shadowBox(-20, -8, 50);
circle(100, 100, 80, 80);
}
* @example
function draw() {
background(200);
noStroke();
shadow('aqua');
shadowBox(20);
rect(50, 50, 100, 100);
textSize(64);
text('q5', 60, 115);
}
*/
function shadowBox(offsetX: number, offsetY: number, blur: number): void;
/** ⬜️
* Translates the origin of the drawing context.
* @param {number} x translation along the x-axis
* @param {number} y translation along the y-axis
* @example
function draw() {
background(200);
translate(100, 100);
circle(0, 0, 80);
}
*/
function translate(x: number, y: number): void;
/** ⬜️
* Rotates the drawing context.
* @param {number} angle rotation angle in radians
* @example
function draw() {
background(200);
translate(100, 100);
rotate(QUARTER_PI);
// drawn from its top-left corner by default
square(0, 0, 50);
}
*/
function rotate(angle: number): void;
/** ⬜️
* Scales the drawing context.
*
* If only one input parameter is provided,
* the drawing context will be scaled uniformly.
* @param {number} x scaling factor along the x-axis
* @param {number} [y] scaling factor along the y-axis
* @example
function draw() {
background(200);
scale(4);
circle(0, 0, 80);
}
*/
function scale(x: number, y?: number): void;
/** ⬜️
* Shears the drawing context along the x-axis.
* @param {number} angle shear angle in radians
* @example
function draw() {
background(200);
translate(25, 60);
shearX(QUARTER_PI);
square(0, 0, 80);
}
*/
function shearX(angle: number): void;
/** ⬜️
* Shears the drawing context along the y-axis.
* @param {number} angle shear angle in radians
* @example
function draw() {
background(200);
translate(25, 60);
shearY(QUARTER_PI);
square(0, 0, 80);
}
*/
function shearY(angle: number): void;
/** ⬜️
* Applies a transformation matrix.
*
* Accepts a 3x3 or 4x4 matrix as either an array or multiple arguments.
* @param {number} a horizontal scaling
* @param {number} b horizontal skewing
* @param {number} c vertical skewing
* @param {number} d vertical scaling
* @param {number} e horizontal moving
* @param {number} f vertical moving
* @example
function draw() {
background(200);
applyMatrix(2, 1, 1, 1, 100, 100);
circle(0, 0, 80);
}
*/
function applyMatrix(a: number, b: number, c: number, d: number, e: number, f: number): void;
/** ⬜️
* Resets the transformation matrix.
*
* q5 runs this function before every time the `draw` function is run,
* so that transformations don't carry over to the next frame.
* @example
function draw() {
background(200);
translate(100, 100);
circle(0, 0, 80);
resetMatrix();
square(0, 0, 50);
}
*/
function resetMatrix(): void;
/** ⬜️
* Saves the current transformation matrix.
* @example
function draw() {
background(200);
translate(100, 100);
pushMatrix();
rotate(QUARTER_PI);
ellipse(0, 0, 120, 40);
popMatrix();
ellipse(0, 0, 120, 40);
}
*/
function pushMatrix(): void;
/** ⬜️
* Restores the previously saved transformation matrix.
*/
function popMatrix(): void;
/** ⬜️
* Saves the current drawing style settings.
*
* This includes the fill, stroke, stroke weight, tint, image mode,
* rect mode, ellipse mode, text size, text align, text baseline, and
* shadow settings.
* @example
function draw() {
background(200);
pushStyles();
fill('blue');
circle(50, 50, 80);
popStyles();
circle(150, 150, 80);
}
*/
function pushStyles(): void;
/** ⬜️
* Restores the previously saved drawing style settings.
*/
function popStyles(): void;
/** ⬜️
* Saves the current drawing style settings and transformations.
* @example
createCanvas(200, 200);
push();
fill('blue');
translate(100, 100);
circle(0, 0, 80);
pop();
square(0, 0, 50);
*/
function push(): void;
/** ⬜️
* Restores the previously saved drawing style settings and transformations.
*/
function pop(): void;
/** ⬜️
* Resizes the canvas to the specified width and height.
* @param {number} w width of the canvas
* @param {number} h height of the canvas
*/
function resizeCanvas(w: number, h: number): void;
/** ⬜️
* Sets the pixel density of the canvas.
* @param {number} v pixel density value
* @returns {number} pixel density
*/
function pixelDensity(v: number): number;
/** ⬜️
* Returns the current display density.
* @returns {number} display density
*/
function displayDensity(): number;
/** ⬜️
* Enables or disables fullscreen mode.
* @param {boolean} [v] boolean indicating whether to enable or disable fullscreen mode
* @returns {void | boolean} true if fullscreen mode is enabled, false otherwise
*/
function fullscreen(v?: boolean): void | boolean;
/** ⬜️
* Any position coordinates or dimensions you use will be scaled based
* on the unit provided to this function.
* @param {number} unit unit to scale by
* @example
createCanvas(200, 200);
flexibleCanvas(100);
// rect will appear in the middle of the canvas
rect(20, 20, 60, 60);
*/
function flexibleCanvas(unit: number): void;
/** ⬜️
* Creates a graphics buffer.
* @param {number} w width
* @param {number} h height
* @param {Object} [opt] options
* @returns {Q5} a new Q5 graphics buffer
*/
function createGraphics(w: number, h: number, opt?: any): Q5;
/** ⬜️
* The 2D rendering context for the canvas.
*/
var ctx: CanvasRenderingContext2D;
/** ⬜️
* Alias for `ctx`, the 2D rendering context for the canvas.
*/
var drawingContext: CanvasRenderingContext2D;
// 💻 display
/** 💻
* The `displayMode` function lets you customize how your canvas is presented.
* @param {string} mode
* - "normal": (default) no styling to canvas or its parent element
* - "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
* - "maxed": canvas will fill the parent element, same as fullscreen for a canvas inside a `main` element
* - "fullscreen": canvas will fill the screen with letterboxing if necessary to preserve its aspect ratio
* @param {string} renderQuality
* - "smooth": (default) no change to the default render quality
* - "pixelated": runs `pixelDensity(1)` and `noSmooth()` then sets the canvas CSS styles `image-rendering: pixelated` and `font-smooth: never`
* @param {number} scale can also be given as a string (for example "x2")
*/
function displayMode(mode: string, renderQuality: string, scale: string | number): void;
// 🧑🎨 drawing
/** 🧑🎨
* Draws over the entire canvas with a color or image.
* @param {string | number} color color or image to draw
*/
function background(color: string | number): void;
/** 🧑🎨
* Draws a rectangle.
* @param {number} x x-coordinate
* @param {number} y y-coordinate
* @param {number} w width of the rectangle
* @param {number} [h] height of the rectangle
* @param {number} [tl] top-left radius for rounded corners
* @param {number} [tr] top-right radius for rounded corners
* @param {number} [br] bottom-right radius for rounded corners
* @param {number} [bl] bottom-left radius for rounded corners
*/
function rect(x: number, y: number, w: number, h?: number, tl?: number, tr?: number, br?: number, bl?: number): void;
/** 🧑🎨
* Draws a square.
* @param {number} x x-coordinate
* @param {number} y y-coordinate
* @param {number} size size of the sides of the square
* @param {number} [tl] top-left radius for rounded corners
* @param {number} [tr] top-right radius for rounded corners
* @param {number} [br] bottom-right radius for rounded corners
* @param {number} [bl] bottom-left radius for rounded corners
*/
function square(x: number, y: number, size: number, tl?: number, tr?: number, br?: number, bl?: number): void;
/** 🧑🎨
* Draws a circle.
* @param {number} x x-coordinate
* @param {number} y y-coordinate
* @param {number} diameter diameter of the circle
*/
function circle(x: number, y: number, diameter: number): void;
/** 🧑🎨
* Draws an ellipse.
* @param {number} x x-coordinate
* @param {number} y y-coordinate
* @param {number} width width of the ellipse
* @param {number} [height] height of the ellipse
*/
function ellipse(x: number, y: number, width: number, height?: number): void;
/** 🧑🎨
* Draws an arc, which is a section of an ellipse.
*
* `ellipseMode` affects how the arc is drawn.
* @param {number} x x-coordinate
* @param {number} y y-coordinate
* @param {number} w width of the ellipse
* @param {number} h height of the ellipse
* @param {number} start angle to start the arc
* @param {number} stop angle to stop the arc
* @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`
* @example
function draw() {
background(200);
arc(40, 40, 40, 40, 0.8, -0.8);
arc(80, 80, 40, 40, 0.8, -0.8, PIE);
arc(120, 120, 40, 40, 0.8, -0.8, CHORD_OPEN);
arc(160, 160, 40, 40, 0.8, -0.8, CHORD);
}
*/
function arc(x: number, y: number, w: number, h: number, start: number, stop: number, mode?: number): void;
/** 🧑🎨
* Draws a line on the canvas.
* @param {number} x1 x-coordinate of the first point
* @param {number} y1 y-coordinate of the first point
* @param {number} x2 x-coordinate of the second point
* @param {number} y2 y-coordinate of the second point
*/
function line(x1: number, y1: number, x2: number, y2: number): void;
/** 🧑🎨
* Draws a point on the canvas.
* @param {number} x x-coordinate
* @param {number} y y-coordinate
*/
function point(x: number, y: number): void;
/** 🧑🎨
* Sets the global composite operation for the canvas context.
* @param {string} val composite operation to set
*/
function blendMode(val: string): void;
/** 🧑🎨
* Sets the line cap style for the canvas context.
* @param {CanvasLineCap} val line cap style to set ('butt', 'round', 'square')
*/
function strokeCap(val: CanvasLineCap): void;
/** 🧑🎨
* Sets the line join style for the canvas context.
* @param {CanvasLineJoin} val line join style to set ('round', 'bevel', 'miter')
*/
function strokeJoin(val: CanvasLineJoin): void;
/** 🧑🎨
* Sets the ellipse mode.
* @param {string} val ellipse mode to set
*/
function ellipseMode(val: string): void;
/** 🧑🎨
* Sets the rectangle mode.
* @param {string} val rectangle mode to set
*/
function rectMode(val: string): void;
/** 🧑🎨
* Sets the curve detail level.
* @param {number} val curve detail level to set
*/
function curveDetail(val: number): void;
/** 🧑🎨
* Sets the curve alpha value.
* @param {number} val curve alpha value to set
*/
function curveAlpha(val: number): void;
/** 🧑🎨
* Sets the curve tightness value.
* @param {number} val curve tightness value to set
*/
function curveTightness(val: number): void;
/** 🧑🎨
* Starts recording vertices for a shape.
*/
function beginShape(): void;
/** 🧑🎨
* Starts recording vertices for a shape to be used as a contour.
*/
function beginContour(): void;
/** 🧑🎨
* Ends recording vertices for a shape.
*/
function endContour(): void;
/** 🧑🎨
* Specifies a vertex in a shape.
* @param {number} x x-coordinate
* @param {number} y y-coordinate
*/
function vertex(x: number, y: number): void;
/** 🧑🎨
* Specifies a Bezier vertex in a shape.
* @param {number} cp1x x-coordinate of the first control point
* @param {number} cp1y y-coordinate of the first control point
* @param {number} cp2x x-coordinate of the second control point
* @param {number} cp2y y-coordinate of the second control point
* @param {number} x x-coordinate of the anchor point
* @param {number} y y-coordinate of the anchor point
*/
function bezierVertex(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
/** 🧑🎨
* Specifies a quadratic Bezier vertex in a shape.
* @param {number} cp1x x-coordinate of the control point
* @param {number} cp1y y-coordinate of the control point
* @param {number} x x-coordinate of the anchor point
* @param {number} y y-coordinate of the anchor point
*/
function quadraticVertex(cp1x: number, cp1y: number, x: number, y: number): void;
/** 🧑🎨
* Draws a Bezier curve.
* @param {number} x1 x-coordinate of the first anchor point
* @param {number} y1 y-coordinate of the first anchor point
* @param {number} x2 x-coordinate of the first control point
* @param {number} y2 y-coordinate of the first control point
* @param {number} x3 x-coordinate of the second control point
* @param {number} y3 y-coordinate of the second control point
* @param {number} x4 x-coordinate of the second anchor point
* @param {number} y4 y-coordinate of the second anchor point
*/
function bezier(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
/** 🧑🎨
* Draws a triangle.
* @param {number} x1 x-coordinate of the first vertex
* @param {number} y1 y-coordinate of the first vertex
* @param {number} x2 x-coordinate of the second vertex
* @param {number} y2 y-coordinate of the second vertex
* @param {number} x3 x-coordinate of the third vertex
* @param {number} y3 y-coordinate of the third vertex
*/
function triangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void;
/** 🧑🎨
* Draws a quadrilateral.
* @param {number} x1 x-coordinate of the first vertex
* @param {number} y1 y-coordinate of the first vertex
* @param {number} x2 x-coordinate of the second vertex
* @param {number} y2 y-coordinate of the second vertex
* @param {number} x3 x-coordinate of the third vertex
* @param {number} y3 y-coordinate of the third vertex
* @param {number} x4 x-coordinate of the fourth vertex
* @param {number} y4 y-coordinate of the fourth vertex
*/
function quad(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
/** 🧑🎨
* Sets the canvas to erase mode, where shapes will erase what's underneath them instead of drawing over it.
* @param {number} [fillAlpha] opacity level of the fill color from 0 to 255
* @param {number} [strokeAlpha] opacity level of the stroke color from 0 to 255
*/
function erase(fillAlpha?: number, strokeAlpha?: number): void;
/** 🧑🎨
* Resets the canvas from erase mode to normal drawing mode.
*/
function noErase(): void;
/** 🧑🎨
* Checks if a given point is within the current path's fill area.
* @param {number} x x-coordinate of the point
* @param {number} y y-coordinate of the point
* @returns {boolean} true if the point is within the fill area, false otherwise
*/
function inFill(x: number, y: number): boolean;
/** 🧑🎨
* Checks if a given point is within the current path's stroke.
* @param {number} x x-coordinate of the point