q5 2.16.4 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/package.json +2 -2
- package/q5.d.ts +436 -178
- package/q5.js +264 -4
- package/q5.min.js +2 -2
package/q5.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ function draw() {
|
|
|
80
80
|
* it calls the draw function once.
|
|
81
81
|
* @param {number} [n] number of times to redraw the canvas, default is 1
|
|
82
82
|
* @example
|
|
83
|
-
createCanvas(200
|
|
83
|
+
createCanvas(200);
|
|
84
84
|
noLoop();
|
|
85
85
|
|
|
86
86
|
function draw() {
|
|
@@ -95,7 +95,7 @@ function mousePressed() {
|
|
|
95
95
|
/** ⭐️
|
|
96
96
|
* Starts the draw loop again if it was stopped.
|
|
97
97
|
* @example
|
|
98
|
-
createCanvas(200
|
|
98
|
+
createCanvas(200);
|
|
99
99
|
noLoop();
|
|
100
100
|
|
|
101
101
|
function draw() {
|
|
@@ -257,7 +257,7 @@ function draw() {
|
|
|
257
257
|
* favor of having load* functions, such as `loadImage`,
|
|
258
258
|
* return promises.
|
|
259
259
|
*
|
|
260
|
-
* In q5 the `load` function can be used to load a file or
|
|
260
|
+
* In q5 the [`load`](https://q5js.org/learn/#load) function can be used to load a file or
|
|
261
261
|
* multiple files, and it returns a promise that resolves
|
|
262
262
|
* when the file(s) are loaded.
|
|
263
263
|
*
|
|
@@ -281,7 +281,7 @@ function draw() {
|
|
|
281
281
|
*
|
|
282
282
|
* Running `new Q5()` enables the use of q5 functions and variables
|
|
283
283
|
* anywhere in your code. You can also start Q5 in global mode by
|
|
284
|
-
* running [`createCanvas`](https://q5js.org/learn/#
|
|
284
|
+
* running [`createCanvas`](https://q5js.org/learn/#createCanvas).
|
|
285
285
|
*
|
|
286
286
|
* By default q5 uses the CanvasRenderingContext2D based c2d renderer.
|
|
287
287
|
*
|
|
@@ -332,10 +332,11 @@ circle(100, 50, 80);
|
|
|
332
332
|
* Start using q5 by running this function!
|
|
333
333
|
*
|
|
334
334
|
* If this function is not run by the user, a 200x200 canvas will be
|
|
335
|
-
* created automatically before the draw loop starts.
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* @param {number} [
|
|
335
|
+
* created automatically before the draw loop starts.
|
|
336
|
+
*
|
|
337
|
+
* In q5 WebGPU, this function must be run before running other q5 functions.
|
|
338
|
+
* @param {number} [w] width or size of the canvas
|
|
339
|
+
* @param {number} [h] height of the canvas
|
|
339
340
|
* @param {Object} [opt] options for the canvas
|
|
340
341
|
* @param {boolean} [opt.alpha] whether the canvas should have an alpha channel that allows it to be seen through, default is false
|
|
341
342
|
* @param {string} [opt.colorSpace] color space of the canvas, either "srgb" or "display-p3", default is "display-p3" for devices that support HDR colors
|
|
@@ -356,96 +357,88 @@ function draw() {
|
|
|
356
357
|
/** ⬜️
|
|
357
358
|
* The canvas element associated with the Q5 instance.
|
|
358
359
|
*
|
|
359
|
-
* @prop {
|
|
360
|
-
* @prop {
|
|
361
|
-
* @prop {
|
|
362
|
-
* @prop {
|
|
363
|
-
* @prop {
|
|
364
|
-
* @prop {
|
|
365
|
-
* @prop {
|
|
360
|
+
* @prop {number} w
|
|
361
|
+
* @prop {number} width
|
|
362
|
+
* @prop {number} h
|
|
363
|
+
* @prop {number} height
|
|
364
|
+
* @prop {number} hw half the width
|
|
365
|
+
* @prop {number} hh half the height
|
|
366
|
+
* @prop {string} renderer either "c2d" (Canvas2D) or "webgpu"
|
|
366
367
|
*/
|
|
367
368
|
var canvas: HTMLCanvasElement;
|
|
368
369
|
|
|
369
|
-
/** ⬜️
|
|
370
|
-
* The width of the canvas.
|
|
371
|
-
*/
|
|
372
|
-
var width: number;
|
|
373
|
-
|
|
374
|
-
/** ⬜️
|
|
375
|
-
* The height of the canvas.
|
|
376
|
-
*/
|
|
377
|
-
var height: number;
|
|
378
|
-
|
|
379
370
|
/** ⬜️
|
|
380
371
|
* Clears the canvas, making every pixel completely transparent.
|
|
381
372
|
*
|
|
382
|
-
*
|
|
373
|
+
* Note that the canvas can only be seen through if it has an alpha channel.
|
|
383
374
|
*/
|
|
384
375
|
function clear(): void;
|
|
385
376
|
|
|
386
377
|
/** ⬜️
|
|
387
378
|
* Sets the fill color for shapes. The default is white.
|
|
388
379
|
*
|
|
389
|
-
* Like the [`color`](https://q5js.org/learn/#color) function, this function
|
|
390
|
-
*
|
|
380
|
+
* Like the [`color`](https://q5js.org/learn/#color) function, this function
|
|
381
|
+
* can accept colors in a wide range of formats: as a CSS color string,
|
|
382
|
+
* a `Color` object, grayscale value, or color component values.
|
|
383
|
+
* @param {Color} color fill color
|
|
391
384
|
* @example
|
|
392
|
-
|
|
393
|
-
|
|
385
|
+
createCanvas(200);
|
|
386
|
+
background(200);
|
|
394
387
|
|
|
395
|
-
|
|
396
|
-
|
|
388
|
+
fill('red');
|
|
389
|
+
circle(80, 80, 80);
|
|
397
390
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
391
|
+
fill('lime');
|
|
392
|
+
square(80, 80, 80);
|
|
401
393
|
*/
|
|
402
|
-
function fill(color:
|
|
394
|
+
function fill(color: Color): void;
|
|
403
395
|
|
|
404
396
|
/** ⬜️
|
|
405
397
|
* Sets the stroke (outline) color for shapes. The default is black.
|
|
406
398
|
*
|
|
407
|
-
* Like the [`color`](https://q5js.org/learn/#color) function, this function
|
|
408
|
-
*
|
|
399
|
+
* Like the [`color`](https://q5js.org/learn/#color) function, this function
|
|
400
|
+
* can accept colors in a wide range of formats: as a CSS color string,
|
|
401
|
+
* a `Color` object, grayscale value, or color component values.
|
|
402
|
+
* @param {Color} color stroke color
|
|
409
403
|
* @example
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
404
|
+
createCanvas(200);
|
|
405
|
+
background(200);
|
|
406
|
+
fill(36);
|
|
413
407
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
408
|
+
stroke('red');
|
|
409
|
+
circle(80, 80, 80);
|
|
410
|
+
|
|
411
|
+
stroke('lime');
|
|
412
|
+
square(80, 80, 80);
|
|
419
413
|
*/
|
|
420
|
-
function stroke(color:
|
|
414
|
+
function stroke(color: Color): void;
|
|
421
415
|
|
|
422
416
|
/** ⬜️
|
|
423
417
|
* After calling this function, shapes will not be filled.
|
|
424
418
|
* @example
|
|
425
|
-
|
|
426
|
-
|
|
419
|
+
createCanvas(200);
|
|
420
|
+
background(200);
|
|
427
421
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
422
|
+
noFill();
|
|
423
|
+
|
|
424
|
+
stroke('red');
|
|
425
|
+
circle(80, 80, 80);
|
|
426
|
+
stroke('lime');
|
|
427
|
+
square(80, 80, 80);
|
|
434
428
|
*/
|
|
435
429
|
function noFill(): void;
|
|
436
430
|
|
|
437
431
|
/** ⬜️
|
|
438
432
|
* After calling this function, shapes will not have a stroke (outline).
|
|
439
433
|
* @example
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
434
|
+
createCanvas(200);
|
|
435
|
+
background(200);
|
|
436
|
+
fill(36);
|
|
437
|
+
stroke('red');
|
|
438
|
+
circle(80, 80, 80);
|
|
445
439
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
}
|
|
440
|
+
noStroke();
|
|
441
|
+
square(80, 80, 80);
|
|
449
442
|
*/
|
|
450
443
|
function noStroke(): void;
|
|
451
444
|
|
|
@@ -453,15 +446,13 @@ function draw() {
|
|
|
453
446
|
* Sets the size of the stroke used for lines and the border around shapes.
|
|
454
447
|
* @param {number} weight size of the stroke in pixels
|
|
455
448
|
* @example
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
circle(50, 100, 80);
|
|
449
|
+
createCanvas(200);
|
|
450
|
+
background(200);
|
|
451
|
+
stroke('red');
|
|
452
|
+
circle(50, 100, 80);
|
|
461
453
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
454
|
+
strokeWeight(20);
|
|
455
|
+
circle(150, 100, 80);
|
|
465
456
|
*/
|
|
466
457
|
function strokeWeight(weight: number): void;
|
|
467
458
|
|
|
@@ -469,15 +460,14 @@ function setup() {
|
|
|
469
460
|
* Sets the global opacity, which affects all subsequent drawing operations, except `background`. Default is 1, fully opaque.
|
|
470
461
|
* @param {number} alpha opacity level, ranging from 0 to 1
|
|
471
462
|
* @example
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
opacity(1);
|
|
476
|
-
circle(80, 80, 80);
|
|
463
|
+
createCanvas(200);
|
|
464
|
+
background(200);
|
|
477
465
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
466
|
+
opacity(1);
|
|
467
|
+
circle(80, 80, 80);
|
|
468
|
+
|
|
469
|
+
opacity(0.2);
|
|
470
|
+
square(80, 80, 80);
|
|
481
471
|
*/
|
|
482
472
|
function opacity(alpha: number): void;
|
|
483
473
|
|
|
@@ -487,19 +477,20 @@ function draw() {
|
|
|
487
477
|
* Shadows apply to anything drawn to the canvas, including filled
|
|
488
478
|
* shapes, strokes, text, and images.
|
|
489
479
|
*
|
|
490
|
-
* Like the [`color`](https://q5js.org/learn/#color) function, this function
|
|
491
|
-
*
|
|
480
|
+
* Like the [`color`](https://q5js.org/learn/#color) function, this function
|
|
481
|
+
* can accept colors in a wide range of formats: as a CSS color string,
|
|
482
|
+
* a `Color` object, grayscale value, or color component values.
|
|
483
|
+
* @param {Color} color shadow color
|
|
492
484
|
* @example
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}
|
|
485
|
+
createCanvas(200);
|
|
486
|
+
background(200);
|
|
487
|
+
|
|
488
|
+
noFill();
|
|
489
|
+
shadow('black');
|
|
490
|
+
rect(64, 60, 80, 80);
|
|
491
|
+
text('q5', 100, 100);
|
|
501
492
|
* @example
|
|
502
|
-
createCanvas(200
|
|
493
|
+
createCanvas(200);
|
|
503
494
|
let logo = loadImage('/assets/p5play_logo.webp');
|
|
504
495
|
|
|
505
496
|
function setup() {
|
|
@@ -513,15 +504,14 @@ function setup() {
|
|
|
513
504
|
/** ⬜️
|
|
514
505
|
* Disables the shadow effect.
|
|
515
506
|
* @example
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
507
|
+
createCanvas(200);
|
|
508
|
+
background(200);
|
|
509
|
+
noStroke();
|
|
510
|
+
shadow('black');
|
|
511
|
+
rect(14, 14, 80, 80);
|
|
521
512
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
}
|
|
513
|
+
noShadow();
|
|
514
|
+
rect(104, 104, 80, 80);
|
|
525
515
|
*/
|
|
526
516
|
function noShadow(): void;
|
|
527
517
|
|
|
@@ -533,27 +523,36 @@ function draw() {
|
|
|
533
523
|
* @param {number} offsetY vertical offset of the shadow, defaults to be the same as offsetX
|
|
534
524
|
* @param {number} blur blur radius of the shadow, defaults to 0
|
|
535
525
|
* @example
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
526
|
+
createCanvas(200);
|
|
527
|
+
background(200);
|
|
528
|
+
noStroke();
|
|
529
|
+
shadow('red');
|
|
540
530
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
531
|
+
shadowBox(-20, -8, 50);
|
|
532
|
+
circle(100, 100, 80, 80);
|
|
544
533
|
* @example
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
534
|
+
createCanvas(200);
|
|
535
|
+
background(200);
|
|
536
|
+
noStroke();
|
|
537
|
+
|
|
538
|
+
shadow('aqua');
|
|
539
|
+
shadowBox(20);
|
|
540
|
+
rect(50, 50, 100, 100);
|
|
541
|
+
textSize(64);
|
|
542
|
+
text('q5', 60, 115);
|
|
554
543
|
*/
|
|
555
544
|
function shadowBox(offsetX: number, offsetY: number, blur: number): void;
|
|
556
545
|
|
|
546
|
+
/** ⬜️
|
|
547
|
+
* The width of the canvas.
|
|
548
|
+
*/
|
|
549
|
+
var width: number;
|
|
550
|
+
|
|
551
|
+
/** ⬜️
|
|
552
|
+
* The height of the canvas.
|
|
553
|
+
*/
|
|
554
|
+
var height: number;
|
|
555
|
+
|
|
557
556
|
/** ⬜️
|
|
558
557
|
* Translates the origin of the drawing context.
|
|
559
558
|
* @param {number} x translation along the x-axis
|
|
@@ -655,35 +654,42 @@ function draw() {
|
|
|
655
654
|
* q5 runs this function before every time the `draw` function is run,
|
|
656
655
|
* so that transformations don't carry over to the next frame.
|
|
657
656
|
* @example
|
|
658
|
-
|
|
659
|
-
|
|
657
|
+
createCanvas(200);
|
|
658
|
+
background(200);
|
|
660
659
|
|
|
661
|
-
|
|
662
|
-
|
|
660
|
+
translate(100, 100);
|
|
661
|
+
circle(0, 0, 80);
|
|
663
662
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
}
|
|
663
|
+
resetMatrix();
|
|
664
|
+
square(0, 0, 50);
|
|
667
665
|
*/
|
|
668
666
|
function resetMatrix(): void;
|
|
669
667
|
|
|
670
668
|
/** ⬜️
|
|
671
669
|
* Saves the current transformation matrix.
|
|
672
670
|
* @example
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
}
|
|
671
|
+
createCanvas(200);
|
|
672
|
+
background(200);
|
|
673
|
+
translate(100, 100);
|
|
674
|
+
pushMatrix();
|
|
675
|
+
rotate(QUARTER_PI);
|
|
676
|
+
ellipse(0, 0, 120, 40);
|
|
677
|
+
popMatrix();
|
|
678
|
+
ellipse(0, 0, 120, 40);
|
|
682
679
|
*/
|
|
683
680
|
function pushMatrix(): void;
|
|
684
681
|
|
|
685
682
|
/** ⬜️
|
|
686
683
|
* Restores the previously saved transformation matrix.
|
|
684
|
+
* @example
|
|
685
|
+
createCanvas(200);
|
|
686
|
+
background(200);
|
|
687
|
+
translate(100, 100);
|
|
688
|
+
pushMatrix();
|
|
689
|
+
rotate(QUARTER_PI);
|
|
690
|
+
ellipse(0, 0, 120, 40);
|
|
691
|
+
popMatrix();
|
|
692
|
+
ellipse(0, 0, 120, 40);
|
|
687
693
|
*/
|
|
688
694
|
function popMatrix(): void;
|
|
689
695
|
|
|
@@ -714,7 +720,7 @@ function draw() {
|
|
|
714
720
|
/** ⬜️
|
|
715
721
|
* Saves the current drawing style settings and transformations.
|
|
716
722
|
* @example
|
|
717
|
-
createCanvas(200
|
|
723
|
+
createCanvas(200);
|
|
718
724
|
|
|
719
725
|
push();
|
|
720
726
|
fill('blue');
|
|
@@ -763,7 +769,7 @@ square(0, 0, 50);
|
|
|
763
769
|
* on the unit provided to this function.
|
|
764
770
|
* @param {number} unit unit to scale by
|
|
765
771
|
* @example
|
|
766
|
-
createCanvas(200
|
|
772
|
+
createCanvas(200);
|
|
767
773
|
flexibleCanvas(100);
|
|
768
774
|
// rect will appear in the middle of the canvas
|
|
769
775
|
rect(20, 20, 60, 60);
|
|
@@ -814,7 +820,11 @@ circle(25, 12.5, 16);
|
|
|
814
820
|
|
|
815
821
|
/** 🧑🎨
|
|
816
822
|
* Draws over the entire canvas with a color or image.
|
|
817
|
-
*
|
|
823
|
+
*
|
|
824
|
+
* Like the [`color`](https://q5js.org/learn/#color) function,
|
|
825
|
+
* this function can accept colors in a wide range of formats:
|
|
826
|
+
* CSS color string, grayscale value, and color component values.
|
|
827
|
+
* @param {Color | Image} filler a color or image to draw
|
|
818
828
|
* @example
|
|
819
829
|
createCanvas(200, 100);
|
|
820
830
|
background('crimson');
|
|
@@ -824,7 +834,7 @@ function draw() {
|
|
|
824
834
|
circle(mouseX, mouseY, 20);
|
|
825
835
|
}
|
|
826
836
|
*/
|
|
827
|
-
function background(
|
|
837
|
+
function background(filler: Color | Image): void;
|
|
828
838
|
|
|
829
839
|
/** 🧑🎨
|
|
830
840
|
* Draws a rectangle or a rounded rectangle.
|
|
@@ -837,7 +847,7 @@ function draw() {
|
|
|
837
847
|
* @param {number} [br] bottom-right radius
|
|
838
848
|
* @param {number} [bl] bottom-left radius
|
|
839
849
|
* @example
|
|
840
|
-
createCanvas(200
|
|
850
|
+
createCanvas(200);
|
|
841
851
|
background(200);
|
|
842
852
|
|
|
843
853
|
rect(30, 20, 40, 60);
|
|
@@ -856,7 +866,7 @@ rect(130, 120, 40, 60, 30, 2, 8, 20);
|
|
|
856
866
|
* @param {number} [br] bottom-right radius
|
|
857
867
|
* @param {number} [bl] bottom-left radius
|
|
858
868
|
* @example
|
|
859
|
-
createCanvas(200
|
|
869
|
+
createCanvas(200);
|
|
860
870
|
background(200);
|
|
861
871
|
|
|
862
872
|
square(30, 30, 40);
|
|
@@ -900,7 +910,7 @@ ellipse(100, 50, 160, 80);
|
|
|
900
910
|
* @param {number} stop angle to stop the arc
|
|
901
911
|
* @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`
|
|
902
912
|
* @example
|
|
903
|
-
createCanvas(200
|
|
913
|
+
createCanvas(200);
|
|
904
914
|
background(200);
|
|
905
915
|
|
|
906
916
|
arc(40, 40, 40, 40, 0.8, -0.8);
|
|
@@ -1096,6 +1106,232 @@ point(125, 50);
|
|
|
1096
1106
|
*/
|
|
1097
1107
|
function inStroke(x: number, y: number): boolean;
|
|
1098
1108
|
|
|
1109
|
+
// 📑 dom
|
|
1110
|
+
|
|
1111
|
+
/** 📑
|
|
1112
|
+
* Creates a new HTML element.
|
|
1113
|
+
*
|
|
1114
|
+
* q5 adds functions like `position` and `size` to the element
|
|
1115
|
+
* that make it easy to position elements above the canvas.
|
|
1116
|
+
*
|
|
1117
|
+
* Modify the element's CSS [`style`](https://developer.mozilla.org/docs/Web/API/HTMLElement/style) to change its appearance.
|
|
1118
|
+
*
|
|
1119
|
+
* `createEl` is an alias for this function.
|
|
1120
|
+
* @param {string} tag tag name of the element
|
|
1121
|
+
* @param {string} [content] content of the element
|
|
1122
|
+
* @returns {HTMLElement} created DOM element
|
|
1123
|
+
* @example
|
|
1124
|
+
createCanvas(200);
|
|
1125
|
+
|
|
1126
|
+
let el = createEl('div', '*');
|
|
1127
|
+
el.position(0, 0);
|
|
1128
|
+
el.size(100, 100);
|
|
1129
|
+
el.style.fontSize = '136px';
|
|
1130
|
+
el.style.textAlign = 'center';
|
|
1131
|
+
el.style.backgroundColor = 'blue';
|
|
1132
|
+
el.style.color = 'white';
|
|
1133
|
+
*/
|
|
1134
|
+
function createElement(tag: string, content?: string): HTMLElement;
|
|
1135
|
+
|
|
1136
|
+
/** 📑
|
|
1137
|
+
* Creates a link element.
|
|
1138
|
+
* @param {string} href url
|
|
1139
|
+
* @param {string} [text] text content
|
|
1140
|
+
* @param {boolean} [newTab] whether to open the link in a new tab
|
|
1141
|
+
* @example
|
|
1142
|
+
createCanvas(200, 100);
|
|
1143
|
+
|
|
1144
|
+
let link = createA('https://q5js.org', 'q5.js');
|
|
1145
|
+
link.position(0, 0);
|
|
1146
|
+
link.style.fontSize = '80px';
|
|
1147
|
+
*/
|
|
1148
|
+
function createA(href: string, text?: string): HTMLAnchorElement;
|
|
1149
|
+
|
|
1150
|
+
/** 📑
|
|
1151
|
+
* Creates a button element.
|
|
1152
|
+
*
|
|
1153
|
+
* Use [`addEventListener`](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) to respond to button click events.
|
|
1154
|
+
* @param {string} [content] text content
|
|
1155
|
+
* @example
|
|
1156
|
+
createCanvas(200, 100);
|
|
1157
|
+
|
|
1158
|
+
let btn = createButton('Click me!');
|
|
1159
|
+
|
|
1160
|
+
btn.addEventListener('click', () => {
|
|
1161
|
+
background(random(100, 255));
|
|
1162
|
+
});
|
|
1163
|
+
*/
|
|
1164
|
+
function createButton(content?: string): HTMLButtonElement;
|
|
1165
|
+
|
|
1166
|
+
/** 📑
|
|
1167
|
+
* Creates a checkbox element.
|
|
1168
|
+
*
|
|
1169
|
+
* Use the `checked` property to get or set the checkbox's state.
|
|
1170
|
+
*
|
|
1171
|
+
* The `label` property is the text label element next to the checkbox.
|
|
1172
|
+
* @param {string} [label] text label placed next to the checkbox
|
|
1173
|
+
* @param {boolean} [checked] initial state
|
|
1174
|
+
* @example
|
|
1175
|
+
createCanvas(200, 100);
|
|
1176
|
+
|
|
1177
|
+
let box = createCheckbox('Check me!');
|
|
1178
|
+
box.label.style.color = 'lime';
|
|
1179
|
+
|
|
1180
|
+
box.addEventListener('change', () => {
|
|
1181
|
+
if (box.checked) background('lime');
|
|
1182
|
+
else background('black');
|
|
1183
|
+
});
|
|
1184
|
+
*/
|
|
1185
|
+
function createCheckbox(label?: string, checked?: boolean): HTMLInputElement;
|
|
1186
|
+
|
|
1187
|
+
/** 📑
|
|
1188
|
+
* Creates a color input element.
|
|
1189
|
+
*
|
|
1190
|
+
* Use the `value` property to get or set the color value.
|
|
1191
|
+
* @param {string} [value] initial color value
|
|
1192
|
+
* @example
|
|
1193
|
+
createCanvas(200, 100);
|
|
1194
|
+
|
|
1195
|
+
let picker = createColorPicker();
|
|
1196
|
+
picker.value = '#fd7575';
|
|
1197
|
+
|
|
1198
|
+
function draw() {
|
|
1199
|
+
background(picker.value);
|
|
1200
|
+
}
|
|
1201
|
+
*/
|
|
1202
|
+
function createColorPicker(value?: string): HTMLInputElement;
|
|
1203
|
+
|
|
1204
|
+
/** 📑
|
|
1205
|
+
* Creates an img element.
|
|
1206
|
+
* @param {string} src url of the image
|
|
1207
|
+
* @example
|
|
1208
|
+
createCanvas(200, 100);
|
|
1209
|
+
|
|
1210
|
+
let img = createImg('/assets/p5play_logo.webp')
|
|
1211
|
+
.position(0, 0)
|
|
1212
|
+
.size(100, 100);
|
|
1213
|
+
*/
|
|
1214
|
+
function createImg(src: string): HTMLImageElement;
|
|
1215
|
+
|
|
1216
|
+
/** 📑
|
|
1217
|
+
* Creates an input element.
|
|
1218
|
+
*
|
|
1219
|
+
* Use the `value` property to get or set the input's value.
|
|
1220
|
+
*
|
|
1221
|
+
* See MDN's [input documentation](https://developer.mozilla.org/docs/Web/HTML/Element/input#input_types) for the full list of input types.
|
|
1222
|
+
* @param {string} [value] initial value
|
|
1223
|
+
* @param {string} [type] text input type, can be 'text', 'password', 'email', 'number', 'range', 'search', 'tel', 'url'
|
|
1224
|
+
* @example
|
|
1225
|
+
createCanvas(200, 100);
|
|
1226
|
+
textSize(64);
|
|
1227
|
+
|
|
1228
|
+
let input = createInput();
|
|
1229
|
+
input.placeholder = 'Type here!';
|
|
1230
|
+
input.size(200, 32);
|
|
1231
|
+
|
|
1232
|
+
input.addEventListener('input', () => {
|
|
1233
|
+
background('orange');
|
|
1234
|
+
text(input.value, 10, 70);
|
|
1235
|
+
});
|
|
1236
|
+
*/
|
|
1237
|
+
function createInput(value?: string, type?: string): HTMLInputElement;
|
|
1238
|
+
|
|
1239
|
+
/** 📑
|
|
1240
|
+
* Creates a paragraph element.
|
|
1241
|
+
* @param {string} [content] text content
|
|
1242
|
+
* @example
|
|
1243
|
+
createCanvas(200, 50);
|
|
1244
|
+
background('coral');
|
|
1245
|
+
|
|
1246
|
+
let p = createP('Hello, world!');
|
|
1247
|
+
p.style.color = 'pink';
|
|
1248
|
+
*/
|
|
1249
|
+
function createP(content?: string): HTMLParagraphElement;
|
|
1250
|
+
|
|
1251
|
+
/** 📑
|
|
1252
|
+
* Creates a radio button group.
|
|
1253
|
+
*
|
|
1254
|
+
* Use the `option(label, value)` function to add new radio buttons
|
|
1255
|
+
* to the group.
|
|
1256
|
+
*
|
|
1257
|
+
* Use the `value` property to get or set the value of the selected radio button.
|
|
1258
|
+
* @param {string} [groupName]
|
|
1259
|
+
* @example
|
|
1260
|
+
createCanvas(200, 100);
|
|
1261
|
+
|
|
1262
|
+
let radio = createRadio()
|
|
1263
|
+
.option('square', '1')
|
|
1264
|
+
.option('circle', '2');
|
|
1265
|
+
radio.style.color = 'aqua';
|
|
1266
|
+
|
|
1267
|
+
function draw() {
|
|
1268
|
+
background(200);
|
|
1269
|
+
if (radio.value == '1') square(75, 25, 50);
|
|
1270
|
+
if (radio.value == '2') circle(100, 50, 50);
|
|
1271
|
+
}
|
|
1272
|
+
*/
|
|
1273
|
+
function createRadio(groupName): HTMLDivElement;
|
|
1274
|
+
|
|
1275
|
+
/** 📑
|
|
1276
|
+
* Creates a select element.
|
|
1277
|
+
*
|
|
1278
|
+
* Use the `option(label, value)` function to add new options to
|
|
1279
|
+
* the select element.
|
|
1280
|
+
*
|
|
1281
|
+
* Set `multiple` to `true` to allow multiple options to be selected.
|
|
1282
|
+
*
|
|
1283
|
+
* Use the `value` property to get or set the selected option.
|
|
1284
|
+
*
|
|
1285
|
+
* Use the `selected` property to get the selected option or options.
|
|
1286
|
+
* @param {boolean} [placeholder] optional placeholder text that appears when no option is selected
|
|
1287
|
+
* @example
|
|
1288
|
+
createCanvas(200, 100);
|
|
1289
|
+
|
|
1290
|
+
let sel = createSelect('Select a color')
|
|
1291
|
+
.option('Red', '#f55')
|
|
1292
|
+
.option('Green', '#5f5');
|
|
1293
|
+
|
|
1294
|
+
sel.addEventListener('change', () => {
|
|
1295
|
+
background(sel.value);
|
|
1296
|
+
});
|
|
1297
|
+
*/
|
|
1298
|
+
function createSelect(placeholder): HTMLSelectElement;
|
|
1299
|
+
|
|
1300
|
+
/** 📑
|
|
1301
|
+
* Creates a slider element.
|
|
1302
|
+
*
|
|
1303
|
+
* Use the `value` property to get or set the slider's value.
|
|
1304
|
+
*
|
|
1305
|
+
* Use the `val` function to get the slider's value as a number.
|
|
1306
|
+
* @param {number} min minimum value
|
|
1307
|
+
* @param {number} max maximum value
|
|
1308
|
+
* @param {number} [value] initial value
|
|
1309
|
+
* @param {number} [step] step size
|
|
1310
|
+
* @example
|
|
1311
|
+
createCanvas(200);
|
|
1312
|
+
|
|
1313
|
+
let slider = createSlider(0, 255)
|
|
1314
|
+
.position(10, 10)
|
|
1315
|
+
.size(180);
|
|
1316
|
+
|
|
1317
|
+
function draw() {
|
|
1318
|
+
background(slider.val());
|
|
1319
|
+
}
|
|
1320
|
+
*/
|
|
1321
|
+
function createSlider(min: number, max: number, value?: number, step?: number): HTMLInputElement;
|
|
1322
|
+
|
|
1323
|
+
/** 📑
|
|
1324
|
+
* Creates a video element.
|
|
1325
|
+
* @param {string} src url of the video
|
|
1326
|
+
* @example
|
|
1327
|
+
createCanvas(200, 100);
|
|
1328
|
+
|
|
1329
|
+
// let vid = createVideo('/assets/q5js_video.mp4');
|
|
1330
|
+
// vid.controls = true;
|
|
1331
|
+
// vid.loop = true;
|
|
1332
|
+
*/
|
|
1333
|
+
function createVideo(src: string): HTMLVideoElement;
|
|
1334
|
+
|
|
1099
1335
|
// 🌆 image
|
|
1100
1336
|
|
|
1101
1337
|
/** 🌆
|
|
@@ -1104,7 +1340,7 @@ point(125, 50);
|
|
|
1104
1340
|
* @param {(img: any) => void} [cb] callback function after the image is loaded
|
|
1105
1341
|
* @param {any} [opt] optional parameters for loading the image
|
|
1106
1342
|
* @example
|
|
1107
|
-
createCanvas(200
|
|
1343
|
+
createCanvas(200);
|
|
1108
1344
|
|
|
1109
1345
|
let logo = loadImage('/q5js_logo.webp');
|
|
1110
1346
|
|
|
@@ -1126,7 +1362,7 @@ function draw() {
|
|
|
1126
1362
|
* @param {number} [sw] width of the subsection of the source image
|
|
1127
1363
|
* @param {number} [sh] height of the subsection of the source image
|
|
1128
1364
|
* @example
|
|
1129
|
-
createCanvas(200
|
|
1365
|
+
createCanvas(200);
|
|
1130
1366
|
|
|
1131
1367
|
let logo = loadImage('/q5js_logo.webp');
|
|
1132
1368
|
|
|
@@ -1143,7 +1379,7 @@ function draw() {
|
|
|
1143
1379
|
* `CENTER`: images will be drawn centered at (dx, dy)
|
|
1144
1380
|
* @param {string} mode
|
|
1145
1381
|
* @example
|
|
1146
|
-
createCanvas(200
|
|
1382
|
+
createCanvas(200);
|
|
1147
1383
|
|
|
1148
1384
|
let logo = loadImage('/q5js_logo.webp');
|
|
1149
1385
|
|
|
@@ -1174,7 +1410,7 @@ function draw() {
|
|
|
1174
1410
|
* @param {number} w new width
|
|
1175
1411
|
* @param {number} h new height
|
|
1176
1412
|
* @example
|
|
1177
|
-
createCanvas(200
|
|
1413
|
+
createCanvas(200);
|
|
1178
1414
|
|
|
1179
1415
|
let logo = loadImage('/q5js_logo.webp');
|
|
1180
1416
|
|
|
@@ -1196,7 +1432,7 @@ function setup() {
|
|
|
1196
1432
|
* their actual size. This is the default setting, so running this
|
|
1197
1433
|
* function only has an effect if `noSmooth` has been called.
|
|
1198
1434
|
* @example
|
|
1199
|
-
createCanvas(200
|
|
1435
|
+
createCanvas(200);
|
|
1200
1436
|
|
|
1201
1437
|
let icon = loadImage('/q5js_icon.png');
|
|
1202
1438
|
|
|
@@ -1209,7 +1445,7 @@ function setup() {
|
|
|
1209
1445
|
/** 🌆
|
|
1210
1446
|
* Disables smooth image rendering for a pixelated look.
|
|
1211
1447
|
* @example
|
|
1212
|
-
createCanvas(200
|
|
1448
|
+
createCanvas(200);
|
|
1213
1449
|
|
|
1214
1450
|
let icon = loadImage('/q5js_icon.png');
|
|
1215
1451
|
|
|
@@ -1240,7 +1476,7 @@ function setup() {
|
|
|
1240
1476
|
* each copy separately.
|
|
1241
1477
|
* @param {string | number} color tint color
|
|
1242
1478
|
* @example
|
|
1243
|
-
createCanvas(200
|
|
1479
|
+
createCanvas(200);
|
|
1244
1480
|
|
|
1245
1481
|
let logo = loadImage('/q5js_logo.webp');
|
|
1246
1482
|
|
|
@@ -1279,7 +1515,7 @@ function setup() {
|
|
|
1279
1515
|
* @param {number} [h] height of the area
|
|
1280
1516
|
* @returns {Image | number[]}
|
|
1281
1517
|
* @example
|
|
1282
|
-
createCanvas(200
|
|
1518
|
+
createCanvas(200);
|
|
1283
1519
|
|
|
1284
1520
|
let logo = loadImage('/q5js_logo.webp');
|
|
1285
1521
|
|
|
@@ -1301,7 +1537,7 @@ function setup() {
|
|
|
1301
1537
|
* @param {number} y
|
|
1302
1538
|
* @param {any} c color, canvas, or image
|
|
1303
1539
|
* @example
|
|
1304
|
-
createCanvas(200
|
|
1540
|
+
createCanvas(200);
|
|
1305
1541
|
let c = color('lime');
|
|
1306
1542
|
|
|
1307
1543
|
function draw() {
|
|
@@ -1329,7 +1565,7 @@ function draw() {
|
|
|
1329
1565
|
* @param {number} dw width of the destination region
|
|
1330
1566
|
* @param {number} dh height of the destination region
|
|
1331
1567
|
* @example
|
|
1332
|
-
createCanvas(200
|
|
1568
|
+
createCanvas(200);
|
|
1333
1569
|
|
|
1334
1570
|
let logo = loadImage('/q5js_logo.webp');
|
|
1335
1571
|
|
|
@@ -1348,7 +1584,7 @@ function setup() {
|
|
|
1348
1584
|
/** 🌆
|
|
1349
1585
|
* Loads pixel data into the canvas' or image's `pixels` array.
|
|
1350
1586
|
* @example
|
|
1351
|
-
createCanvas(200
|
|
1587
|
+
createCanvas(200);
|
|
1352
1588
|
let icon = loadImage('/q5js_icon.png');
|
|
1353
1589
|
|
|
1354
1590
|
function setup() {
|
|
@@ -1363,7 +1599,7 @@ function setup() {
|
|
|
1363
1599
|
/** 🌆
|
|
1364
1600
|
* Applies changes in the `pixels` array to the canvas or image.
|
|
1365
1601
|
* @example
|
|
1366
|
-
createCanvas(200
|
|
1602
|
+
createCanvas(200);
|
|
1367
1603
|
function setup() {
|
|
1368
1604
|
for (let x = 0; x < 200; x += 5) {
|
|
1369
1605
|
for (let y = 0; y < 200; y += 5) {
|
|
@@ -1391,7 +1627,7 @@ function setup() {
|
|
|
1391
1627
|
* @param {string} type filter type or a CSS filter string
|
|
1392
1628
|
* @param {number} [value] optional value, depends on filter type
|
|
1393
1629
|
* @example
|
|
1394
|
-
createCanvas(200
|
|
1630
|
+
createCanvas(200);
|
|
1395
1631
|
let logo = loadImage('/q5js_logo.webp');
|
|
1396
1632
|
|
|
1397
1633
|
function setup() {
|
|
@@ -1461,13 +1697,13 @@ function setup() {
|
|
|
1461
1697
|
* @param {number} [wrapWidth] maximum line width in characters
|
|
1462
1698
|
* @param {number} [lineLimit] maximum number of lines
|
|
1463
1699
|
* @example
|
|
1464
|
-
createCanvas(200
|
|
1700
|
+
createCanvas(200);
|
|
1465
1701
|
background('silver');
|
|
1466
1702
|
|
|
1467
1703
|
textSize(32);
|
|
1468
1704
|
text('Hello, world!', 12, 106);
|
|
1469
1705
|
* @example
|
|
1470
|
-
createCanvas(200
|
|
1706
|
+
createCanvas(200);
|
|
1471
1707
|
background(200);
|
|
1472
1708
|
textSize(20);
|
|
1473
1709
|
|
|
@@ -1497,7 +1733,7 @@ text(info, 12, 30, 20, 6);
|
|
|
1497
1733
|
* @param {(font: FontFace) => void} [cb] optional callback function that receives the font name as an argument once the font is loaded
|
|
1498
1734
|
* @returns {FontFace} font
|
|
1499
1735
|
* @example
|
|
1500
|
-
createCanvas(200
|
|
1736
|
+
createCanvas(200);
|
|
1501
1737
|
|
|
1502
1738
|
loadFont('/assets/Robotica.ttf');
|
|
1503
1739
|
|
|
@@ -1520,7 +1756,7 @@ function setup() {
|
|
|
1520
1756
|
* https://developer.mozilla.org/docs/Web/CSS/font-family
|
|
1521
1757
|
* @param {string} fontName name of the font family or a FontFace object
|
|
1522
1758
|
* @example
|
|
1523
|
-
createCanvas(200
|
|
1759
|
+
createCanvas(200);
|
|
1524
1760
|
background(200);
|
|
1525
1761
|
|
|
1526
1762
|
textFont('serif');
|
|
@@ -1563,7 +1799,7 @@ function draw() {
|
|
|
1563
1799
|
* Sets the current text style.
|
|
1564
1800
|
* @param {'normal' | 'italic' | 'bold' | 'bolditalic'} style font style
|
|
1565
1801
|
* @example
|
|
1566
|
-
createCanvas(200
|
|
1802
|
+
createCanvas(200);
|
|
1567
1803
|
background(200);
|
|
1568
1804
|
|
|
1569
1805
|
textStyle(ITALIC);
|
|
@@ -1578,7 +1814,7 @@ text('Hello, world!', 12, 106);
|
|
|
1578
1814
|
* @param {'left' | 'center' | 'right'} horiz horizontal alignment
|
|
1579
1815
|
* @param {'top' | 'middle' | 'bottom' | 'alphabetic'} [vert] vertical alignment
|
|
1580
1816
|
* @example
|
|
1581
|
-
createCanvas(200
|
|
1817
|
+
createCanvas(200);
|
|
1582
1818
|
background(200);
|
|
1583
1819
|
|
|
1584
1820
|
textAlign(CENTER, MIDDLE);
|
|
@@ -1623,7 +1859,7 @@ function draw() {
|
|
|
1623
1859
|
* @param {string} str string to measure
|
|
1624
1860
|
* @returns {number} descent of the text in pixels
|
|
1625
1861
|
* @example
|
|
1626
|
-
createCanvas(200
|
|
1862
|
+
createCanvas(200);
|
|
1627
1863
|
background(200);
|
|
1628
1864
|
textSize(64);
|
|
1629
1865
|
|
|
@@ -1723,25 +1959,47 @@ createCanvas(200, 200);
|
|
|
1723
1959
|
// 🎨 color
|
|
1724
1960
|
|
|
1725
1961
|
/** 🎨
|
|
1726
|
-
* Creates a new `Color` object
|
|
1727
|
-
* color
|
|
1962
|
+
* Creates a new `Color` object, which is primarily useful for storing
|
|
1963
|
+
* a color that your sketch will reuse or modify later.
|
|
1728
1964
|
*
|
|
1729
|
-
* RGB colors have components
|
|
1730
|
-
* and `a`/`alpha`.
|
|
1965
|
+
* With the default RGB color mode, colors have these components:
|
|
1731
1966
|
*
|
|
1732
|
-
*
|
|
1733
|
-
* as a grayscale value. If only two numeric inputs are provided,
|
|
1734
|
-
* they will be used as grayscale and alpha values.
|
|
1967
|
+
* `r`/`red`, `g`/`green`, `b`/`blue`, and `a`/`alpha`.
|
|
1735
1968
|
*
|
|
1736
|
-
*
|
|
1737
|
-
*
|
|
1738
|
-
*
|
|
1969
|
+
* The default color format is integer, so set color components
|
|
1970
|
+
* to values between 0 and 255.
|
|
1971
|
+
*
|
|
1972
|
+
* In q5 WebGPU, the default color mode is RGB in float format, so
|
|
1973
|
+
* set color components to values between 0 and 1.
|
|
1974
|
+
*
|
|
1975
|
+
* The [`fill`](https://q5js.org/learn/#fill), [`stroke`](https://q5js.org/learn/#stroke), and [`background`](https://q5js.org/learn/#background) functions
|
|
1976
|
+
* accept the same wide range of color representations as this function.
|
|
1977
|
+
*
|
|
1978
|
+
* Here are some examples of valid use:
|
|
1979
|
+
*
|
|
1980
|
+
* - `color(255)` (grayscale)
|
|
1981
|
+
* - `color(255, 200)` (grayscale, alpha)
|
|
1982
|
+
* - `color(255, 0, 0)` (r, g, b)
|
|
1983
|
+
* - `color(255, 0, 0, 10)` (r, g, b, a)
|
|
1984
|
+
* - `color('red')` (colorName)
|
|
1985
|
+
* - `color('#ff0000')` (hexColor)
|
|
1986
|
+
* - `color([255, 0, 0])` (colorComponents)
|
|
1987
|
+
* @param {string | number | Color | number[]} c0 color or first color component
|
|
1739
1988
|
* @param {number} [c1] second color component
|
|
1740
1989
|
* @param {number} [c2] third color component
|
|
1741
1990
|
* @param {number} [c3] fourth color component (alpha)
|
|
1742
1991
|
* @returns {Color} a new `Color` object
|
|
1743
1992
|
* @example
|
|
1744
|
-
createCanvas(200
|
|
1993
|
+
createCanvas(200);
|
|
1994
|
+
// (gray, alpha)
|
|
1995
|
+
let darkGray = color(55, 100);
|
|
1996
|
+
background(darkGray);
|
|
1997
|
+
// (r, g, b, a)
|
|
1998
|
+
let blueBottle = color(0, 0, 200, 20);
|
|
1999
|
+
fill(blueBottle);
|
|
2000
|
+
circle(100, 50, 50);
|
|
2001
|
+
* @example
|
|
2002
|
+
createCanvas(200);
|
|
1745
2003
|
|
|
1746
2004
|
let c = color('gray');
|
|
1747
2005
|
|
|
@@ -1763,7 +2021,7 @@ function draw() {
|
|
|
1763
2021
|
* @param {'rgb' | 'srgb' | 'oklch'} mode color mode
|
|
1764
2022
|
* @param {1 | 255} format color format (1 for float, 255 for integer)
|
|
1765
2023
|
* @example
|
|
1766
|
-
createCanvas(200
|
|
2024
|
+
createCanvas(200);
|
|
1767
2025
|
|
|
1768
2026
|
colorMode(RGB, 1);
|
|
1769
2027
|
fill(1, 0, 0);
|
|
@@ -1773,7 +2031,7 @@ rect(66, 0, 67, 200);
|
|
|
1773
2031
|
fill(0, 0, 1);
|
|
1774
2032
|
rect(133, 0, 67, 200);
|
|
1775
2033
|
* @example
|
|
1776
|
-
createCanvas(200
|
|
2034
|
+
createCanvas(200);
|
|
1777
2035
|
|
|
1778
2036
|
colorMode(OKLCH);
|
|
1779
2037
|
|
|
@@ -1794,7 +2052,7 @@ rect(100, 0, 100, 200);
|
|
|
1794
2052
|
* rgb colors are mapped to the full P3 gamut, even when they use the
|
|
1795
2053
|
* legacy integer format.
|
|
1796
2054
|
* @example
|
|
1797
|
-
createCanvas(200
|
|
2055
|
+
createCanvas(200);
|
|
1798
2056
|
|
|
1799
2057
|
function setup() {
|
|
1800
2058
|
background(255, 0, 0);
|
|
@@ -1809,7 +2067,7 @@ function setup() {
|
|
|
1809
2067
|
* example, note that full red appears less saturated, as it would
|
|
1810
2068
|
* on an SDR display.
|
|
1811
2069
|
* @example
|
|
1812
|
-
createCanvas(200
|
|
2070
|
+
createCanvas(200);
|
|
1813
2071
|
|
|
1814
2072
|
colorMode(SRGB, 255);
|
|
1815
2073
|
|
|
@@ -1843,7 +2101,7 @@ function setup() {
|
|
|
1843
2101
|
*
|
|
1844
2102
|
* Note how seamless the hue transitions are in the following example.
|
|
1845
2103
|
* @example
|
|
1846
|
-
createCanvas(200
|
|
2104
|
+
createCanvas(200);
|
|
1847
2105
|
colorMode(OKLCH);
|
|
1848
2106
|
|
|
1849
2107
|
function draw() {
|
|
@@ -1963,7 +2221,7 @@ function draw() {
|
|
|
1963
2221
|
/** 🖲️
|
|
1964
2222
|
* Hides the cursor within the bounds of the canvas.
|
|
1965
2223
|
* @example
|
|
1966
|
-
createCanvas(200
|
|
2224
|
+
createCanvas(200);
|
|
1967
2225
|
noCursor();
|
|
1968
2226
|
*/
|
|
1969
2227
|
function noCursor(): void;
|
|
@@ -2169,7 +2427,7 @@ noCursor();
|
|
|
2169
2427
|
* @param {string} url sound file
|
|
2170
2428
|
* @returns {Sound} a new `Sound` object
|
|
2171
2429
|
* @example
|
|
2172
|
-
createCanvas(200
|
|
2430
|
+
createCanvas(200);
|
|
2173
2431
|
|
|
2174
2432
|
let sound = loadSound('/assets/jump.wav');
|
|
2175
2433
|
sound.volume = 0.3;
|
|
@@ -2190,7 +2448,7 @@ function mousePressed() {
|
|
|
2190
2448
|
* @param url audio file
|
|
2191
2449
|
* @returns {HTMLAudioElement} an HTMLAudioElement
|
|
2192
2450
|
* @example
|
|
2193
|
-
createCanvas(200
|
|
2451
|
+
createCanvas(200);
|
|
2194
2452
|
|
|
2195
2453
|
let audio = loadAudio('/assets/retro.flac');
|
|
2196
2454
|
audio.volume = 0.4;
|
|
@@ -2299,7 +2557,7 @@ function draw() {
|
|
|
2299
2557
|
}
|
|
2300
2558
|
* @example
|
|
2301
2559
|
new Q5();
|
|
2302
|
-
createCanvas(200
|
|
2560
|
+
createCanvas(200);
|
|
2303
2561
|
|
|
2304
2562
|
// use with top level await in a module
|
|
2305
2563
|
await load('/assets/Robotica.ttf');
|
|
@@ -2308,7 +2566,7 @@ background(255);
|
|
|
2308
2566
|
text('Hello, world!', 20, 100);
|
|
2309
2567
|
* @example
|
|
2310
2568
|
let q = new Q5();
|
|
2311
|
-
createCanvas(200
|
|
2569
|
+
createCanvas(200);
|
|
2312
2570
|
|
|
2313
2571
|
let [jump, retro] = await load(
|
|
2314
2572
|
'/assets/jump.wav', '/assets/retro.flac'
|