q5 2.4.5 → 2.5.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/README.md +5 -2
- package/package.json +1 -1
- package/q5.d.ts +27 -4
- package/q5.js +939 -275
- package/q5.min.js +1 -1
- package/src/q5-2d-canvas.js +10 -19
- package/src/q5-2d-text.js +162 -127
- package/src/q5-canvas.js +11 -7
- package/src/q5-core.js +2 -2
- package/src/q5-util.js +17 -1
- package/src/q5-webgpu-canvas.js +81 -64
- package/src/q5-webgpu-drawing.js +21 -13
- package/src/q5-webgpu-image.js +33 -16
- package/src/q5-webgpu-text.js +601 -25
- package/src/readme.md +76 -9
package/README.md
CHANGED
|
@@ -339,13 +339,13 @@ Unminified:
|
|
|
339
339
|
|
|
340
340
|
- p5.js **5112kb** ⚠️
|
|
341
341
|
- p5.sound.js 488kb
|
|
342
|
-
- q5.js
|
|
342
|
+
- q5.js 110kb
|
|
343
343
|
|
|
344
344
|
Minified:
|
|
345
345
|
|
|
346
346
|
- p5.min.js 1034kb ⚠️
|
|
347
347
|
- p5.sound.min.js 200kb
|
|
348
|
-
- q5.min.js **
|
|
348
|
+
- q5.min.js **70kb** 🎉
|
|
349
349
|
|
|
350
350
|
## Benchmarks
|
|
351
351
|
|
|
@@ -404,6 +404,9 @@ p5.js is licensed under the LGPLv2, the two small sections of p5' code directly
|
|
|
404
404
|
|
|
405
405
|
## Credits
|
|
406
406
|
|
|
407
|
+
q5-webgpu msdf text rendering:
|
|
408
|
+
https://webgpu.github.io/webgpu-samples/?sample=textRenderingMsdf
|
|
409
|
+
|
|
407
410
|
q5-webgpu blendMode:
|
|
408
411
|
https://webgpufundamentals.org/webgpu/lessons/webgpu-transparency.html
|
|
409
412
|
|
package/package.json
CHANGED
package/q5.d.ts
CHANGED
|
@@ -86,6 +86,22 @@ declare global {
|
|
|
86
86
|
*/
|
|
87
87
|
var deviceOrientation: string | null;
|
|
88
88
|
|
|
89
|
+
/** ⭐️
|
|
90
|
+
* Use preload to load assets before the sketch starts and the
|
|
91
|
+
* setup function is run.
|
|
92
|
+
*/
|
|
93
|
+
function preload(): void;
|
|
94
|
+
|
|
95
|
+
/** ⭐️
|
|
96
|
+
* The setup function is called once when the program starts.
|
|
97
|
+
*/
|
|
98
|
+
function setup(): void;
|
|
99
|
+
|
|
100
|
+
/** ⭐️
|
|
101
|
+
* The draw function is run 60 times per second by default.
|
|
102
|
+
*/
|
|
103
|
+
function draw(): void;
|
|
104
|
+
|
|
89
105
|
/** ⭐️
|
|
90
106
|
* Stops the draw loop.
|
|
91
107
|
*/
|
|
@@ -312,6 +328,8 @@ declare global {
|
|
|
312
328
|
|
|
313
329
|
/** ⬜️
|
|
314
330
|
* Saves the current drawing style settings.
|
|
331
|
+
*
|
|
332
|
+
* This includes the fill, stroke, stroke weight, tint, image mode, rect mode, ellipse mode, text size, text align, and text baseline.
|
|
315
333
|
*/
|
|
316
334
|
function pushStyles(): void;
|
|
317
335
|
|
|
@@ -775,6 +793,11 @@ declare global {
|
|
|
775
793
|
|
|
776
794
|
/** ✍️
|
|
777
795
|
* Loads a font from a URL and optionally runs a callback function with the font name once it's loaded
|
|
796
|
+
*
|
|
797
|
+
* WebGPU: Fonts must be in MSDF format with the file ending
|
|
798
|
+
* "-msdf.json". If no font is loaded before `text` is run, then
|
|
799
|
+
* the default font is loaded:
|
|
800
|
+
* https://q5js.org/fonts/YaHei-msdf.json
|
|
778
801
|
* @param url - URL of the font to load
|
|
779
802
|
* @param cb - Optional callback function that receives the font name as an argument once the font is loaded
|
|
780
803
|
* @returns name of the loaded font
|
|
@@ -782,7 +805,7 @@ declare global {
|
|
|
782
805
|
function loadFont(url: string, cb?: (fontName: string) => void): string;
|
|
783
806
|
|
|
784
807
|
/** ✍️
|
|
785
|
-
* Sets the current font to be used for text
|
|
808
|
+
* Sets the current font to be used for rendering text
|
|
786
809
|
* @param fontName - name of the font
|
|
787
810
|
*/
|
|
788
811
|
function textFont(fontName: string): void;
|
|
@@ -812,7 +835,7 @@ declare global {
|
|
|
812
835
|
* @param horiz - horizontal alignment ('left', 'center', 'right')
|
|
813
836
|
* @param vert - vertical alignment ('top', 'middle', 'bottom', 'alphabetic')
|
|
814
837
|
*/
|
|
815
|
-
function textAlign(horiz: 'left' | 'center' | 'right', vert?: 'top' | '
|
|
838
|
+
function textAlign(horiz: 'left' | 'center' | 'right', vert?: 'top' | 'center' | 'bottom' | 'alphabetic'): void;
|
|
816
839
|
|
|
817
840
|
/** ✍️
|
|
818
841
|
* Calculates and returns the width of a given string of text
|
|
@@ -894,7 +917,7 @@ declare global {
|
|
|
894
917
|
|
|
895
918
|
/** 🎨
|
|
896
919
|
* Sets the color mode for the sketch. Changes the type of color object created by color functions.
|
|
897
|
-
*
|
|
920
|
+
*
|
|
898
921
|
* In WebGPU, the default color mode is 'rgb' in float format.
|
|
899
922
|
* @param mode - color mode ('rgb', 'srgb', or 'oklch')
|
|
900
923
|
* @param format - color format (1 or 255) for floating point or legacy 8-bit integer representation
|
|
@@ -1145,7 +1168,7 @@ declare global {
|
|
|
1145
1168
|
*/
|
|
1146
1169
|
function noiseDetail(lod: number, falloff: number): void;
|
|
1147
1170
|
|
|
1148
|
-
// 🔊
|
|
1171
|
+
// 🔊 sound
|
|
1149
1172
|
|
|
1150
1173
|
/** 🔊
|
|
1151
1174
|
* Represents a sound object, extending the native `Audio` to
|