q5 3.6.4 → 3.6.8
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/defs/q5-c2d.d.ts +52 -40
- package/deno.json +1 -1
- package/package.json +1 -1
- package/q5.d.ts +52 -40
- package/q5.js +57 -32
- package/q5.min.js +1 -1
package/defs/q5-c2d.d.ts
CHANGED
|
@@ -259,7 +259,9 @@ declare global {
|
|
|
259
259
|
// 🌆 image
|
|
260
260
|
|
|
261
261
|
/** 🌆
|
|
262
|
-
* Loads an image from a URL
|
|
262
|
+
* Loads an image from a URL.
|
|
263
|
+
*
|
|
264
|
+
* By default, assets are loaded in parallel before q5 runs `draw`. Use `await` to wait for an image to load.
|
|
263
265
|
* @param {string} url url of the image to load
|
|
264
266
|
* @returns {Q5.Image & PromiseLike<Q5.Image>} image
|
|
265
267
|
* @example
|
|
@@ -488,6 +490,8 @@ declare global {
|
|
|
488
490
|
*
|
|
489
491
|
* If you make changes to the canvas or image, you must call `loadPixels`
|
|
490
492
|
* before using this function to get current color data.
|
|
493
|
+
*
|
|
494
|
+
* Not applicable to WebGPU canvases.
|
|
491
495
|
* @param {number} x
|
|
492
496
|
* @param {number} y
|
|
493
497
|
* @param {number} [w] width of the area, default is 1
|
|
@@ -516,12 +520,14 @@ declare global {
|
|
|
516
520
|
function get(x: number, y: number, w?: number, h?: number): Q5.Image | number[];
|
|
517
521
|
|
|
518
522
|
/** 🌆
|
|
519
|
-
* Sets a pixel's color in the image or canvas.
|
|
523
|
+
* Sets a pixel's color in the image or canvas. Color mode must be RGB.
|
|
520
524
|
*
|
|
521
525
|
* Or if a canvas or image is provided, it's drawn on top of the
|
|
522
526
|
* destination image or canvas, ignoring its tint setting.
|
|
523
527
|
*
|
|
524
528
|
* Run `updatePixels` to apply the changes.
|
|
529
|
+
*
|
|
530
|
+
* Not applicable to WebGPU canvases.
|
|
525
531
|
* @param {number} x
|
|
526
532
|
* @param {number} y
|
|
527
533
|
* @param {any} val color, canvas, or image
|
|
@@ -539,14 +545,14 @@ declare global {
|
|
|
539
545
|
/** 🌆
|
|
540
546
|
* Array of pixel color data from a canvas or image.
|
|
541
547
|
*
|
|
548
|
+
* Empty by default, populate by running `loadPixels`.
|
|
549
|
+
*
|
|
542
550
|
* Each pixel is represented by four consecutive values in the array,
|
|
543
551
|
* corresponding to its red, green, blue, and alpha channels.
|
|
544
552
|
*
|
|
545
553
|
* The top left pixel's data is at the beginning of the array
|
|
546
554
|
* and the bottom right pixel's data is at the end, going from
|
|
547
555
|
* left to right and top to bottom.
|
|
548
|
-
*
|
|
549
|
-
* Use `loadPixels` to load current pixel data from a canvas or image.
|
|
550
556
|
*/
|
|
551
557
|
var pixels: number[];
|
|
552
558
|
|
|
@@ -554,7 +560,9 @@ declare global {
|
|
|
554
560
|
* Loads pixel data into `pixels` from the canvas or image.
|
|
555
561
|
*
|
|
556
562
|
* The example below sets some pixels' green channel
|
|
557
|
-
* to a random
|
|
563
|
+
* to a random value.
|
|
564
|
+
*
|
|
565
|
+
* Not applicable to WebGPU canvases.
|
|
558
566
|
* @example
|
|
559
567
|
* frameRate(5);
|
|
560
568
|
* let icon = loadImage('/q5js_icon.png');
|
|
@@ -572,6 +580,8 @@ declare global {
|
|
|
572
580
|
|
|
573
581
|
/** 🌆
|
|
574
582
|
* Applies changes in the `pixels` array to the canvas or image.
|
|
583
|
+
*
|
|
584
|
+
* Not applicable to WebGPU canvases.
|
|
575
585
|
* @example
|
|
576
586
|
* createCanvas(200);
|
|
577
587
|
*
|
|
@@ -591,6 +601,8 @@ declare global {
|
|
|
591
601
|
*
|
|
592
602
|
* A CSS filter string can also be used.
|
|
593
603
|
* https://developer.mozilla.org/docs/Web/CSS/filter
|
|
604
|
+
*
|
|
605
|
+
* Not applicable to WebGPU canvases.
|
|
594
606
|
* @param {string} type filter type or a CSS filter string
|
|
595
607
|
* @param {number} [value] optional value, depends on filter type
|
|
596
608
|
* @example
|
|
@@ -675,7 +687,9 @@ declare global {
|
|
|
675
687
|
// 📘 text
|
|
676
688
|
|
|
677
689
|
/** 📘
|
|
678
|
-
* Renders text
|
|
690
|
+
* Renders text on the canvas.
|
|
691
|
+
*
|
|
692
|
+
* Text can be positioned with the x and y
|
|
679
693
|
* parameters and can optionally be constrained.
|
|
680
694
|
* @param {string} str string of text to display
|
|
681
695
|
* @param {number} x x-coordinate of the text's position
|
|
@@ -715,10 +729,10 @@ declare global {
|
|
|
715
729
|
*
|
|
716
730
|
* If no fonts are loaded, the default sans-serif font is used.
|
|
717
731
|
*
|
|
718
|
-
* In q5 WebGPU,
|
|
719
|
-
* with the file ending "-msdf.json" can be used
|
|
720
|
-
*
|
|
721
|
-
*
|
|
732
|
+
* In q5 WebGPU, fonts in [MSDF format](https://github.com/q5js/q5.js/wiki/q5-WebGPU-renderer#text-rendering)
|
|
733
|
+
* with the file ending "-msdf.json" can be used for high performance text rendering. Make your own using the [MSDF font converter](https://msdf-bmfont.donmccurdy.com/).
|
|
734
|
+
*
|
|
735
|
+
* By default, assets are loaded in parallel before q5 runs `draw`. Use `await` to wait for a font to load.
|
|
722
736
|
* @param {string} url URL of the font to load
|
|
723
737
|
* @returns {FontFace & PromiseLike<FontFace>} font
|
|
724
738
|
* @example
|
|
@@ -1019,6 +1033,10 @@ declare global {
|
|
|
1019
1033
|
// 🖲 input
|
|
1020
1034
|
|
|
1021
1035
|
/**
|
|
1036
|
+
* q5's input handling is very basic.
|
|
1037
|
+
*
|
|
1038
|
+
* For better input handling, including game controller support, consider using the [p5play](https://p5play.org/) addon with q5.
|
|
1039
|
+
*
|
|
1022
1040
|
* Note that input responses inside `draw` can be delayed by
|
|
1023
1041
|
* up to one frame cycle: from the exact moment an input event occurs
|
|
1024
1042
|
* to the next time a frame is drawn.
|
|
@@ -2832,15 +2850,15 @@ declare global {
|
|
|
2832
2850
|
// 🔊 sound
|
|
2833
2851
|
|
|
2834
2852
|
/**
|
|
2835
|
-
* q5
|
|
2836
|
-
* by WebAudio.
|
|
2853
|
+
* q5 includes low latency sound playback and basic mixing capabilities
|
|
2854
|
+
* powered by WebAudio.
|
|
2837
2855
|
*
|
|
2838
|
-
* For audio filtering, synthesis, and analysis, consider using
|
|
2839
|
-
* [p5.sound](https://p5js.org/reference/p5.sound/).
|
|
2856
|
+
* For audio filtering, synthesis, and analysis, consider using the
|
|
2857
|
+
* [p5.sound](https://p5js.org/reference/p5.sound/) addon with q5.
|
|
2840
2858
|
*/
|
|
2841
2859
|
|
|
2842
2860
|
/** 🔊
|
|
2843
|
-
* Loads audio data from a file and returns a `
|
|
2861
|
+
* Loads audio data from a file and returns a `Sound` object.
|
|
2844
2862
|
*
|
|
2845
2863
|
* Use functions like `play`, `pause`, and `stop` to
|
|
2846
2864
|
* control playback. Note that sounds can only be played after the
|
|
@@ -2852,14 +2870,9 @@ declare global {
|
|
|
2852
2870
|
*
|
|
2853
2871
|
* Use `loaded`, `paused`, and `ended` to check the sound's status.
|
|
2854
2872
|
*
|
|
2855
|
-
* The entire sound file must be loaded before playback can start,
|
|
2856
|
-
* to stream larger audio files use the `loadAudio` function instead.
|
|
2857
|
-
*
|
|
2858
|
-
* For backwards compatibility with the p5.sound API, the functions
|
|
2859
|
-
* `setVolume`, `setLoop`, `setPan`, `isLoaded`, and `isPlaying`
|
|
2860
|
-
* are also implemented, but their use is deprecated.
|
|
2873
|
+
* The entire sound file must be loaded before playback can start, use `await` to wait for a sound to load. To stream larger audio files use the `loadAudio` function instead.
|
|
2861
2874
|
* @param {string} url sound file
|
|
2862
|
-
* @returns {Sound & PromiseLike<Sound>}
|
|
2875
|
+
* @returns {Sound & PromiseLike<Sound>} sound
|
|
2863
2876
|
* @example
|
|
2864
2877
|
* createCanvas(200);
|
|
2865
2878
|
*
|
|
@@ -2949,6 +2962,9 @@ declare global {
|
|
|
2949
2962
|
*
|
|
2950
2963
|
* If this function is run when the sound is paused,
|
|
2951
2964
|
* all playback instances will be resumed.
|
|
2965
|
+
*
|
|
2966
|
+
* Use `await` to wait for the sound to finish playing.
|
|
2967
|
+
* @returns {Promise<void>} a promise that resolves when the sound finishes playing
|
|
2952
2968
|
*/
|
|
2953
2969
|
play(): void;
|
|
2954
2970
|
|
|
@@ -3365,6 +3381,8 @@ declare global {
|
|
|
3365
3381
|
*
|
|
3366
3382
|
* File type is determined by file extension. q5 supports loading
|
|
3367
3383
|
* text, json, csv, font, audio, and image files.
|
|
3384
|
+
*
|
|
3385
|
+
* By default, assets are loaded in parallel before q5 runs `draw`. Use `await` to wait for assets to load.
|
|
3368
3386
|
* @param {...string} urls
|
|
3369
3387
|
* @returns {Promise<any[]>} a promise that resolves with objects
|
|
3370
3388
|
* @example
|
|
@@ -3409,43 +3427,37 @@ declare global {
|
|
|
3409
3427
|
|
|
3410
3428
|
/** 🛠
|
|
3411
3429
|
* Loads a text file from the specified url.
|
|
3430
|
+
*
|
|
3431
|
+
* Using `await` to get the loaded text as a string is recommended.
|
|
3412
3432
|
* @param {string} url text file
|
|
3413
|
-
* @returns {object & PromiseLike<string>} an object containing the loaded text in the property `obj.text` or
|
|
3433
|
+
* @returns {object & PromiseLike<string>} an object containing the loaded text in the property `obj.text` or use `await` to get the text string directly
|
|
3414
3434
|
*/
|
|
3415
3435
|
function loadText(url: string): object & PromiseLike<string>;
|
|
3416
3436
|
|
|
3417
3437
|
/** 🛠
|
|
3418
3438
|
* Loads a JSON file from the specified url.
|
|
3439
|
+
*
|
|
3440
|
+
* Using `await` to get the loaded JSON object or array is recommended.
|
|
3419
3441
|
* @param {string} url JSON file
|
|
3420
|
-
* @returns {any & PromiseLike<any>} an object or array containing the loaded JSON
|
|
3442
|
+
* @returns {any & PromiseLike<any>} an object or array containing the loaded JSON
|
|
3421
3443
|
*/
|
|
3422
3444
|
function loadJSON(url: string): any & PromiseLike<any>;
|
|
3423
3445
|
|
|
3424
3446
|
/** 🛠
|
|
3425
3447
|
* Loads a CSV file from the specified url.
|
|
3448
|
+
*
|
|
3449
|
+
* Using `await` to get the loaded CSV as an array of objects is recommended.
|
|
3426
3450
|
* @param {string} url CSV file
|
|
3427
|
-
* @returns {object[] & PromiseLike<object[]>} an array of objects containing the loaded CSV
|
|
3451
|
+
* @returns {object[] & PromiseLike<object[]>} an array of objects containing the loaded CSV
|
|
3428
3452
|
*/
|
|
3429
3453
|
function loadCSV(url: string): object[] & PromiseLike<object[]>;
|
|
3430
3454
|
|
|
3431
3455
|
/** 🛠
|
|
3432
3456
|
* Loads an xml file from the specified url.
|
|
3433
|
-
* @param {string} url xml file
|
|
3434
|
-
* @returns {Element & PromiseLike<Element>} an object containing the loaded XML in a property called `obj.DOM` or a promise
|
|
3435
|
-
* @example
|
|
3436
|
-
* async function setup() {
|
|
3437
|
-
* createCanvas(200);
|
|
3438
|
-
* background(200);
|
|
3439
|
-
* textSize(32);
|
|
3440
|
-
*
|
|
3441
|
-
* let myXML = await loadXML('/assets/animals.xml');
|
|
3442
3457
|
*
|
|
3443
|
-
*
|
|
3444
|
-
*
|
|
3445
|
-
*
|
|
3446
|
-
* text(mammal.textContent, 20, (y += 32));
|
|
3447
|
-
* }
|
|
3448
|
-
* }
|
|
3458
|
+
* Using `await` to get the loaded XML Element is recommended.
|
|
3459
|
+
* @param {string} url xml file
|
|
3460
|
+
* @returns {Element & PromiseLike<Element>} an object containing the loaded XML Element in a property called `obj.DOM` or use await to get the XML Element directly
|
|
3449
3461
|
*/
|
|
3450
3462
|
function loadXML(url: string): object & PromiseLike<Element>;
|
|
3451
3463
|
|
package/deno.json
CHANGED
package/package.json
CHANGED
package/q5.d.ts
CHANGED
|
@@ -259,7 +259,9 @@ declare global {
|
|
|
259
259
|
// 🌆 image
|
|
260
260
|
|
|
261
261
|
/** 🌆
|
|
262
|
-
* Loads an image from a URL
|
|
262
|
+
* Loads an image from a URL.
|
|
263
|
+
*
|
|
264
|
+
* By default, assets are loaded in parallel before q5 runs `draw`. Use `await` to wait for an image to load.
|
|
263
265
|
* @param {string} url url of the image to load
|
|
264
266
|
* @returns {Q5.Image & PromiseLike<Q5.Image>} image
|
|
265
267
|
* @example
|
|
@@ -488,6 +490,8 @@ declare global {
|
|
|
488
490
|
*
|
|
489
491
|
* If you make changes to the canvas or image, you must call `loadPixels`
|
|
490
492
|
* before using this function to get current color data.
|
|
493
|
+
*
|
|
494
|
+
* Not applicable to WebGPU canvases.
|
|
491
495
|
* @param {number} x
|
|
492
496
|
* @param {number} y
|
|
493
497
|
* @param {number} [w] width of the area, default is 1
|
|
@@ -516,12 +520,14 @@ declare global {
|
|
|
516
520
|
function get(x: number, y: number, w?: number, h?: number): Q5.Image | number[];
|
|
517
521
|
|
|
518
522
|
/** 🌆
|
|
519
|
-
* Sets a pixel's color in the image or canvas.
|
|
523
|
+
* Sets a pixel's color in the image or canvas. Color mode must be RGB.
|
|
520
524
|
*
|
|
521
525
|
* Or if a canvas or image is provided, it's drawn on top of the
|
|
522
526
|
* destination image or canvas, ignoring its tint setting.
|
|
523
527
|
*
|
|
524
528
|
* Run `updatePixels` to apply the changes.
|
|
529
|
+
*
|
|
530
|
+
* Not applicable to WebGPU canvases.
|
|
525
531
|
* @param {number} x
|
|
526
532
|
* @param {number} y
|
|
527
533
|
* @param {any} val color, canvas, or image
|
|
@@ -539,14 +545,14 @@ declare global {
|
|
|
539
545
|
/** 🌆
|
|
540
546
|
* Array of pixel color data from a canvas or image.
|
|
541
547
|
*
|
|
548
|
+
* Empty by default, populate by running `loadPixels`.
|
|
549
|
+
*
|
|
542
550
|
* Each pixel is represented by four consecutive values in the array,
|
|
543
551
|
* corresponding to its red, green, blue, and alpha channels.
|
|
544
552
|
*
|
|
545
553
|
* The top left pixel's data is at the beginning of the array
|
|
546
554
|
* and the bottom right pixel's data is at the end, going from
|
|
547
555
|
* left to right and top to bottom.
|
|
548
|
-
*
|
|
549
|
-
* Use `loadPixels` to load current pixel data from a canvas or image.
|
|
550
556
|
*/
|
|
551
557
|
var pixels: number[];
|
|
552
558
|
|
|
@@ -554,7 +560,9 @@ declare global {
|
|
|
554
560
|
* Loads pixel data into `pixels` from the canvas or image.
|
|
555
561
|
*
|
|
556
562
|
* The example below sets some pixels' green channel
|
|
557
|
-
* to a random
|
|
563
|
+
* to a random value.
|
|
564
|
+
*
|
|
565
|
+
* Not applicable to WebGPU canvases.
|
|
558
566
|
* @example
|
|
559
567
|
* frameRate(5);
|
|
560
568
|
* let icon = loadImage('/q5js_icon.png');
|
|
@@ -572,6 +580,8 @@ declare global {
|
|
|
572
580
|
|
|
573
581
|
/** 🌆
|
|
574
582
|
* Applies changes in the `pixels` array to the canvas or image.
|
|
583
|
+
*
|
|
584
|
+
* Not applicable to WebGPU canvases.
|
|
575
585
|
* @example
|
|
576
586
|
* createCanvas(200);
|
|
577
587
|
*
|
|
@@ -591,6 +601,8 @@ declare global {
|
|
|
591
601
|
*
|
|
592
602
|
* A CSS filter string can also be used.
|
|
593
603
|
* https://developer.mozilla.org/docs/Web/CSS/filter
|
|
604
|
+
*
|
|
605
|
+
* Not applicable to WebGPU canvases.
|
|
594
606
|
* @param {string} type filter type or a CSS filter string
|
|
595
607
|
* @param {number} [value] optional value, depends on filter type
|
|
596
608
|
* @example
|
|
@@ -675,7 +687,9 @@ declare global {
|
|
|
675
687
|
// 📘 text
|
|
676
688
|
|
|
677
689
|
/** 📘
|
|
678
|
-
* Renders text
|
|
690
|
+
* Renders text on the canvas.
|
|
691
|
+
*
|
|
692
|
+
* Text can be positioned with the x and y
|
|
679
693
|
* parameters and can optionally be constrained.
|
|
680
694
|
* @param {string} str string of text to display
|
|
681
695
|
* @param {number} x x-coordinate of the text's position
|
|
@@ -715,10 +729,10 @@ declare global {
|
|
|
715
729
|
*
|
|
716
730
|
* If no fonts are loaded, the default sans-serif font is used.
|
|
717
731
|
*
|
|
718
|
-
* In q5 WebGPU,
|
|
719
|
-
* with the file ending "-msdf.json" can be used
|
|
720
|
-
*
|
|
721
|
-
*
|
|
732
|
+
* In q5 WebGPU, fonts in [MSDF format](https://github.com/q5js/q5.js/wiki/q5-WebGPU-renderer#text-rendering)
|
|
733
|
+
* with the file ending "-msdf.json" can be used for high performance text rendering. Make your own using the [MSDF font converter](https://msdf-bmfont.donmccurdy.com/).
|
|
734
|
+
*
|
|
735
|
+
* By default, assets are loaded in parallel before q5 runs `draw`. Use `await` to wait for a font to load.
|
|
722
736
|
* @param {string} url URL of the font to load
|
|
723
737
|
* @returns {FontFace & PromiseLike<FontFace>} font
|
|
724
738
|
* @example
|
|
@@ -1019,6 +1033,10 @@ declare global {
|
|
|
1019
1033
|
// 🖲 input
|
|
1020
1034
|
|
|
1021
1035
|
/**
|
|
1036
|
+
* q5's input handling is very basic.
|
|
1037
|
+
*
|
|
1038
|
+
* For better input handling, including game controller support, consider using the [p5play](https://p5play.org/) addon with q5.
|
|
1039
|
+
*
|
|
1022
1040
|
* Note that input responses inside `draw` can be delayed by
|
|
1023
1041
|
* up to one frame cycle: from the exact moment an input event occurs
|
|
1024
1042
|
* to the next time a frame is drawn.
|
|
@@ -2832,15 +2850,15 @@ declare global {
|
|
|
2832
2850
|
// 🔊 sound
|
|
2833
2851
|
|
|
2834
2852
|
/**
|
|
2835
|
-
* q5
|
|
2836
|
-
* by WebAudio.
|
|
2853
|
+
* q5 includes low latency sound playback and basic mixing capabilities
|
|
2854
|
+
* powered by WebAudio.
|
|
2837
2855
|
*
|
|
2838
|
-
* For audio filtering, synthesis, and analysis, consider using
|
|
2839
|
-
* [p5.sound](https://p5js.org/reference/p5.sound/).
|
|
2856
|
+
* For audio filtering, synthesis, and analysis, consider using the
|
|
2857
|
+
* [p5.sound](https://p5js.org/reference/p5.sound/) addon with q5.
|
|
2840
2858
|
*/
|
|
2841
2859
|
|
|
2842
2860
|
/** 🔊
|
|
2843
|
-
* Loads audio data from a file and returns a `
|
|
2861
|
+
* Loads audio data from a file and returns a `Sound` object.
|
|
2844
2862
|
*
|
|
2845
2863
|
* Use functions like `play`, `pause`, and `stop` to
|
|
2846
2864
|
* control playback. Note that sounds can only be played after the
|
|
@@ -2852,14 +2870,9 @@ declare global {
|
|
|
2852
2870
|
*
|
|
2853
2871
|
* Use `loaded`, `paused`, and `ended` to check the sound's status.
|
|
2854
2872
|
*
|
|
2855
|
-
* The entire sound file must be loaded before playback can start,
|
|
2856
|
-
* to stream larger audio files use the `loadAudio` function instead.
|
|
2857
|
-
*
|
|
2858
|
-
* For backwards compatibility with the p5.sound API, the functions
|
|
2859
|
-
* `setVolume`, `setLoop`, `setPan`, `isLoaded`, and `isPlaying`
|
|
2860
|
-
* are also implemented, but their use is deprecated.
|
|
2873
|
+
* The entire sound file must be loaded before playback can start, use `await` to wait for a sound to load. To stream larger audio files use the `loadAudio` function instead.
|
|
2861
2874
|
* @param {string} url sound file
|
|
2862
|
-
* @returns {Sound & PromiseLike<Sound>}
|
|
2875
|
+
* @returns {Sound & PromiseLike<Sound>} sound
|
|
2863
2876
|
* @example
|
|
2864
2877
|
* createCanvas(200);
|
|
2865
2878
|
*
|
|
@@ -2949,6 +2962,9 @@ declare global {
|
|
|
2949
2962
|
*
|
|
2950
2963
|
* If this function is run when the sound is paused,
|
|
2951
2964
|
* all playback instances will be resumed.
|
|
2965
|
+
*
|
|
2966
|
+
* Use `await` to wait for the sound to finish playing.
|
|
2967
|
+
* @returns {Promise<void>} a promise that resolves when the sound finishes playing
|
|
2952
2968
|
*/
|
|
2953
2969
|
play(): void;
|
|
2954
2970
|
|
|
@@ -3365,6 +3381,8 @@ declare global {
|
|
|
3365
3381
|
*
|
|
3366
3382
|
* File type is determined by file extension. q5 supports loading
|
|
3367
3383
|
* text, json, csv, font, audio, and image files.
|
|
3384
|
+
*
|
|
3385
|
+
* By default, assets are loaded in parallel before q5 runs `draw`. Use `await` to wait for assets to load.
|
|
3368
3386
|
* @param {...string} urls
|
|
3369
3387
|
* @returns {Promise<any[]>} a promise that resolves with objects
|
|
3370
3388
|
* @example
|
|
@@ -3409,43 +3427,37 @@ declare global {
|
|
|
3409
3427
|
|
|
3410
3428
|
/** 🛠
|
|
3411
3429
|
* Loads a text file from the specified url.
|
|
3430
|
+
*
|
|
3431
|
+
* Using `await` to get the loaded text as a string is recommended.
|
|
3412
3432
|
* @param {string} url text file
|
|
3413
|
-
* @returns {object & PromiseLike<string>} an object containing the loaded text in the property `obj.text` or
|
|
3433
|
+
* @returns {object & PromiseLike<string>} an object containing the loaded text in the property `obj.text` or use `await` to get the text string directly
|
|
3414
3434
|
*/
|
|
3415
3435
|
function loadText(url: string): object & PromiseLike<string>;
|
|
3416
3436
|
|
|
3417
3437
|
/** 🛠
|
|
3418
3438
|
* Loads a JSON file from the specified url.
|
|
3439
|
+
*
|
|
3440
|
+
* Using `await` to get the loaded JSON object or array is recommended.
|
|
3419
3441
|
* @param {string} url JSON file
|
|
3420
|
-
* @returns {any & PromiseLike<any>} an object or array containing the loaded JSON
|
|
3442
|
+
* @returns {any & PromiseLike<any>} an object or array containing the loaded JSON
|
|
3421
3443
|
*/
|
|
3422
3444
|
function loadJSON(url: string): any & PromiseLike<any>;
|
|
3423
3445
|
|
|
3424
3446
|
/** 🛠
|
|
3425
3447
|
* Loads a CSV file from the specified url.
|
|
3448
|
+
*
|
|
3449
|
+
* Using `await` to get the loaded CSV as an array of objects is recommended.
|
|
3426
3450
|
* @param {string} url CSV file
|
|
3427
|
-
* @returns {object[] & PromiseLike<object[]>} an array of objects containing the loaded CSV
|
|
3451
|
+
* @returns {object[] & PromiseLike<object[]>} an array of objects containing the loaded CSV
|
|
3428
3452
|
*/
|
|
3429
3453
|
function loadCSV(url: string): object[] & PromiseLike<object[]>;
|
|
3430
3454
|
|
|
3431
3455
|
/** 🛠
|
|
3432
3456
|
* Loads an xml file from the specified url.
|
|
3433
|
-
* @param {string} url xml file
|
|
3434
|
-
* @returns {Element & PromiseLike<Element>} an object containing the loaded XML in a property called `obj.DOM` or a promise
|
|
3435
|
-
* @example
|
|
3436
|
-
* async function setup() {
|
|
3437
|
-
* createCanvas(200);
|
|
3438
|
-
* background(200);
|
|
3439
|
-
* textSize(32);
|
|
3440
|
-
*
|
|
3441
|
-
* let myXML = await loadXML('/assets/animals.xml');
|
|
3442
3457
|
*
|
|
3443
|
-
*
|
|
3444
|
-
*
|
|
3445
|
-
*
|
|
3446
|
-
* text(mammal.textContent, 20, (y += 32));
|
|
3447
|
-
* }
|
|
3448
|
-
* }
|
|
3458
|
+
* Using `await` to get the loaded XML Element is recommended.
|
|
3459
|
+
* @param {string} url xml file
|
|
3460
|
+
* @returns {Element & PromiseLike<Element>} an object containing the loaded XML Element in a property called `obj.DOM` or use await to get the XML Element directly
|
|
3449
3461
|
*/
|
|
3450
3462
|
function loadXML(url: string): object & PromiseLike<Element>;
|
|
3451
3463
|
|