-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathq5.d.ts
3239 lines (2812 loc) · 86.2 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
/** ⭐️
* Welcome to q5's documentation! ☺️
*
* First time coding? Check out the [q5 Beginner's Guide to JavaScript](https://github.com/q5js/q5.js/wiki/q5-Beginner's-Guide-to-JavaScript).
*
* On these Learn pages you'll find concise descriptions for
* q5's functions and variables. Scroll through entire topics without
* needing to click between separate pages.
*
* Experiment with editing the code in the interactive mini examples,
* which are often only 8 lines or less. They automatically
* update as you type, so you can see results right away.
*/
/** ⭐️
* 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'll be
* ready to use in the setup and draw functions.
*
* q5's preload system can also be used without a preload function
* if you create a canvas first, as shown in the second example.
* @example
let logo;
function preload() {
logo = loadImage('/q5js_logo.webp');
}
function draw() {
background(logo);
}
* @example
createCanvas(200, 100);
let 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);
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);
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/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;
/** ⭐️
* q5 uses the same preload system as p5.js v1
* to load assets asynchronously, before the setup and draw
* functions are run. It makes it very easy for users to
* load many images, sounds, and other assets at the same time.
*
* In p5.js v2, the preload system was entirely removed in
* favor of having load* functions, such as `loadImage`,
* return promises.
*
* In q5 the [`load`](https://q5js.org/learn/#load) function can be used to load a file or
* multiple files, and it returns a promise that resolves
* when the file(s) are loaded.
*
* Disable the preload system in q5 to make load* functions
* return promises, to match p5.js v2 behavior.
* @example
new Q5();
disablePreloadSystem();
logo = await loadImage('/q5js_logo.webp');
function draw() {
background(logo);
}
*/
function disablePreloadSystem(): void;
class Q5 {
/** ⭐️
* Creates an instance of Q5.
*
* Running `new Q5()` starts q5 in top-level global mode,
* enabling use of q5 functions and variables on the file level,
* outside of `setup` and `draw`. You can also start Q5 in this mode
* by running [`createCanvas`](https://q5js.org/learn/#createCanvas)
* on the file level.
*
* If users don't create a new instance of Q5 themselves, an
* instance will be created automatically, replicating
* p5's limited global mode. p5's instance mode is supported by
* this constructor as well but its use is deprecated, use
* [q5's namespaced instance mode](https://github.com/q5js/q5.js/wiki/Instance-Mode) instead.
*
* Run [`Q5.webgpu()`](https://github.com/q5js/q5.js/wiki/q5-WebGPU-renderer) instead of this constructor to use
* q5's WebGPU renderer.
* @param {string | Function} [scope]
* - "global": (default) adds q5 functions and variables to the global scope
* - "instance": does not add q5 functions or variables 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);
* @example
let q = new Q5('instance');
q.createCanvas(200, 100);
q.circle(100, 50, 20);
*/
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: {};
static Image: {
new(w: number, h: number, opt?: any): Q5.Image;
}
}
namespace Q5 {
interface Image {
width: number;
height: number;
}
}
// ⬜️ canvas
/** ⬜️
* Creates a canvas element, a section of the screen your program
* can draw on.
*
* Run this function to start using q5. If this function is not run
* by the user, a 200x200 canvas will be created automatically before
* the draw loop starts.
*
* In q5 WebGPU, this function must be run before running other
* q5 functions.
* @param {number} [w] width or size of the canvas
* @param {number} [h] height of the canvas
* @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.
*
* @prop {number} w
* @prop {number} width
* @prop {number} h
* @prop {number} height
* @prop {number} hw half the width
* @prop {number} hh half the height
* @prop {string} renderer either "c2d" (Canvas2D) or "webgpu"
*/
var canvas: HTMLCanvasElement;
/** ⬜️
* Clears the canvas, making every pixel completely transparent.
*
* Note that the canvas can only be seen through if it has an alpha channel.
*/
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: as a CSS color string,
* a `Color` object, grayscale value, or color component values.
* @param {Color} color fill color
* @example
createCanvas(200);
background(200);
fill('red');
circle(80, 80, 80);
fill('lime');
square(80, 80, 80);
*/
function fill(color: 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: as a CSS color string,
* a `Color` object, grayscale value, or color component values.
* @param {Color} color stroke color
* @example
createCanvas(200);
background(200);
fill(36);
stroke('red');
circle(80, 80, 80);
stroke('lime');
square(80, 80, 80);
*/
function stroke(color: Color): void;
/** ⬜️
* After calling this function, shapes will not be filled.
* @example
createCanvas(200);
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
createCanvas(200);
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
createCanvas(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
createCanvas(200);
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: as a CSS color string,
* a `Color` object, grayscale value, or color component values.
*
* Not available in q5 WebGPU.
* @param {Color} color shadow color
* @example
createCanvas(200);
background(200);
noFill();
shadow('black');
rect(64, 60, 80, 80);
text('q5', 100, 100);
* @example
createCanvas(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
createCanvas(200);
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
createCanvas(200);
noStroke();
shadow(50);
function draw() {
background(200);
shadowBox(-20, mouseY, 10);
circle(100, 100, 80, 80);
}
* @example
createCanvas(200);
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;
/** ⬜️
* The width of the canvas.
*/
var width: number;
/** ⬜️
* The height of the canvas.
*/
var height: number;
/** ⬜️
* Half the width of the canvas.
*/
var halfWidth: number;
/** ⬜️
* Half the height of the canvas.
*/
var halfHeight: number;
/** ⬜️
* 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
createCanvas(200);
background(200);
translate(100, 100);
circle(0, 0, 80);
resetMatrix();
square(0, 0, 50);
*/
function resetMatrix(): void;
/** ⬜️
* Saves the current transformation matrix.
* @example
createCanvas(200);
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.
* @example
createCanvas(200);
background(200);
translate(100, 100);
pushMatrix();
rotate(QUARTER_PI);
ellipse(0, 0, 120, 40);
popMatrix();
ellipse(0, 0, 120, 40);
*/
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);
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.
*
* Not available in q5 WebGPU.
* @param {number} unit unit to scale by
* @example
createCanvas(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.
*
* Not available in q5 WebGPU.
* @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, if using the Canvas2D
* renderer.
*/
var ctx: CanvasRenderingContext2D;
/** ⬜️
* Alias for `ctx`, the 2D rendering context for the canvas.
*/
var drawingContext: CanvasRenderingContext2D;
// 💻 display
/** 💻
* Customize how your canvas is presented.
* @param {string} mode
* - "normal": (default) canvas is not repositioned
* - "centered": canvas is moved to the center of its parent
* - "maxed": canvas will be scaled to fill the parent element, with letterboxing if necessary to preserve its aspect ratio
* @param {string} renderQuality
* - "smooth": (default) smooth upscaling if the canvas is scaled
* - "pixelated": pixels rendered as sharp squares
* @param {number} scale can also be given as a string (for example "x2")
* @example
createCanvas(50, 25);
displayMode('centered', 'pixelated', 4);
circle(25, 12.5, 16);
*/
function displayMode(mode: string, renderQuality: string, scale: string | number): void;
// 🧑🎨 drawing
/** 🧑🎨
* Draws over the entire canvas with a color or image.
*
* Like the [`color`](https://q5js.org/learn/#color) function,
* this function can accept colors in a wide range of formats:
* CSS color string, grayscale value, and color component values.
* @param {Color | Q5.Image} filler a color or image to draw
* @example
createCanvas(200, 100);
background('crimson');
* @example
function draw() {
background(128, 100);
circle(mouseX, mouseY, 20);
}
*/
function background(filler: Color | Q5.Image): void;
/** 🧑🎨
* Draws a rectangle or a rounded 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
* @param {number} [tr] top-right radius
* @param {number} [br] bottom-right radius
* @param {number} [bl] bottom-left radius
* @example
createCanvas(200);
background(200);
rect(30, 20, 40, 60);
rect(80, 70, 40, 60, 10);
rect(130, 120, 40, 60, 30, 2, 8, 20);
*/
function rect(x: number, y: number, w: number, h?: number, tl?: number, tr?: number, br?: number, bl?: number): void;
/** 🧑🎨
* Draws a square or a rounded 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
* @param {number} [tr] top-right radius
* @param {number} [br] bottom-right radius
* @param {number} [bl] bottom-left radius
* @example
createCanvas(200);
background(200);
square(30, 30, 40);
square(80, 80, 40, 10);
square(130, 130, 40, 30, 2, 8, 20);
*/
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
* @example
createCanvas(200, 100);
circle(100, 50, 80);
*/
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
* @example
createCanvas(200, 100);
ellipse(100, 50, 160, 80);
*/
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
createCanvas(200);
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
* @example
createCanvas(200, 100);
stroke('lime');
line(20, 20, 180, 80);
*/
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
* @example
createCanvas(200, 100);
stroke('white');
point(75, 50);
strokeWeight(10);
point(125, 50);
*/