q5 2.0.17 → 2.1.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/.vscode/settings.json +3 -0
- package/README.md +8 -5
- package/package.json +5 -4
- package/q5-webgpu.js +3308 -0
- package/q5-webgpu.min.js +8 -0
- package/q5.js +531 -565
- package/q5.min.js +2 -2
- package/src/q5-2d-canvas.js +50 -174
- package/src/q5-2d-drawing.js +8 -39
- package/src/q5-2d-image.js +141 -279
- package/src/q5-2d-soft-filters.js +6 -6
- package/src/q5-2d-text.js +3 -3
- package/src/q5-ai.js +2 -2
- package/src/q5-canvas.js +200 -0
- package/src/q5-color.js +56 -30
- package/src/q5-core.js +41 -33
- package/src/q5-display.js +6 -0
- package/src/q5-input.js +46 -34
- package/src/q5-math.js +3 -3
- package/src/q5-sound.js +10 -3
- package/src/q5-util.js +3 -3
- package/src/q5-vector.js +1 -1
- package/src/q5-webgpu-canvas.js +119 -0
- package/src/q5-webgpu-drawing.js +281 -0
- package/src/q5-webgpu-image.js +1 -0
- package/src/q5-webgpu-text.js +1 -0
- package/src/readme.md +83 -6
package/README.md
CHANGED
|
@@ -314,7 +314,7 @@ Features added by @quinton-ashley:
|
|
|
314
314
|
- `opacity(globalAlpha)`: set the opacity multiplier for anything subsequently drawn to the canvas in a range between 0 (transparent) and 1 (opaque).
|
|
315
315
|
- `textCache(enabled)`: Text image caching is enabled by default. Rotated text is only rendered once, and then cached as an image. This can result in ridiculously high 90x performance boosts for text-heavy sketches. Users don't need to change their code, the `text` function can be used as normal, q5 takes care of everything behind the scenes.
|
|
316
316
|
- `createImage`, `loadImage`, and `createGraphics`: as a last parameter to these functions, `opt` (options) object, users can specify canvas context attributes for an image or graphic. `opt.alpha` is set to true by default.
|
|
317
|
-
- `loadSound(file)`: Returns a Web Audio object with
|
|
317
|
+
- `loadSound(file)`: Returns a Web Audio object with some basic functions added for changing the volume, setting the panning, and checking if the sound is loaded. Good enough in most cases.
|
|
318
318
|
- `ctx`: an instance level alias for `drawingContext`
|
|
319
319
|
|
|
320
320
|
Features added by @LingDong-:
|
|
@@ -325,12 +325,13 @@ Features added by @LingDong-:
|
|
|
325
325
|
|
|
326
326
|
## Porting from p5.js
|
|
327
327
|
|
|
328
|
-
- `createCanvas` must be run before any rendering functions are called.
|
|
329
|
-
- `
|
|
328
|
+
- `createCanvas` must be run before any rendering functions are called. Unlike in p5, it can be run anytime after a `Q5` instance is created, even in `preload`. If `noCanvas` isn't run before the draw loop starts, then q5 will run `createCanvas(100, 100)` automatically.
|
|
329
|
+
- `loadImage` and other loading functions don't support a failure callback. If the image fails to load, q5 will throw an error.
|
|
330
|
+
- `colorMode` supports 'rgb', 'srgb', and 'oklch'. Other color modes, like hsv, are so outdated they're obsolete.
|
|
330
331
|
- `color` function only accepts numeric input, hex, and common named colors. It doesn't parse strings like `color('hsl(160, 100%, 50%)')`.
|
|
331
332
|
- `fill`, `stroke`, and `background` can accept any CSS color string.
|
|
332
|
-
- `colorMode` function only accepts "rgb", "srgb", or "oklch" because other formats that p5 still supports like hsv are obsolete.
|
|
333
333
|
- `noise` function's default noise algorithm is perlin noise. p5's default noise is called "blocky" noise in q5 and using it requires loading the src/q5-noisier.js module.
|
|
334
|
+
- `tint` doesn't change the opacity of an image, instead the tint's alpha value specifies how strong the tint should be using the "multiply" blend mode. To dynamically change the opacity of anything drawn to the canvas, use `opacity(globalAlpha)`.
|
|
334
335
|
|
|
335
336
|
## Size Comparison
|
|
336
337
|
|
|
@@ -385,11 +386,13 @@ Higher FPS (frames per second) is better.
|
|
|
385
386
|
|
|
386
387
|
## Contributing
|
|
387
388
|
|
|
389
|
+
Please comment on issues before attempting to implement them!
|
|
390
|
+
|
|
388
391
|
Check out the [q5 planning board](https://github.com/orgs/q5js/projects/1/views/1).
|
|
389
392
|
|
|
390
393
|
If the q5 project is successful, all contributing developers will be paid for their work. The project will be run as a [worker co-op](https://en.wikipedia.org/wiki/Worker_cooperative).
|
|
391
394
|
|
|
392
|
-
Contributors must agree to the [CODE_OF_CONDUCT.md](
|
|
395
|
+
Contributors must agree to the [code of conduct](CODE_OF_CONDUCT.md) and follow the [q5 code style guide](https://github.com/q5js/q5.js/wiki/q5-Code-Style-Guide).
|
|
393
396
|
|
|
394
397
|
## Licensing
|
|
395
398
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "q5",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A sequel to p5.js that's smaller and faster",
|
|
5
5
|
"author": "quinton-ashley",
|
|
6
6
|
"contributors": [
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
"homepage": "https://q5js.org/home",
|
|
12
12
|
"main": "q5-server.js",
|
|
13
13
|
"scripts": {
|
|
14
|
-
"bundle": "cat src/q5-core.js src/q5-2d-canvas.js src/q5-2d-drawing.js src/q5-2d-image.js src/q5-2d-soft-filters.js src/q5-2d-text.js src/q5-ai.js src/q5-color.js src/q5-display.js src/q5-input.js src/q5-math.js src/q5-sound.js src/q5-util.js src/q5-vector.js > q5.js",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
14
|
+
"bundle": "cat src/q5-core.js src/q5-canvas.js src/q5-2d-canvas.js src/q5-2d-drawing.js src/q5-2d-image.js src/q5-2d-soft-filters.js src/q5-2d-text.js src/q5-ai.js src/q5-color.js src/q5-display.js src/q5-input.js src/q5-math.js src/q5-sound.js src/q5-util.js src/q5-vector.js > q5.js",
|
|
15
|
+
"bundle-webgpu": "cat src/q5-core.js src/q5-canvas.js src/q5-2d-canvas.js src/q5-2d-drawing.js src/q5-2d-image.js src/q5-2d-text.js src/q5-ai.js src/q5-color.js src/q5-display.js src/q5-input.js src/q5-math.js src/q5-sound.js src/q5-util.js src/q5-vector.js src/q5-webgpu-canvas.js src/q5-webgpu-drawing.js src/q5-webgpu-image.js src/q5-webgpu-text.js > q5-webgpu.js",
|
|
16
|
+
"min": "terser q5.js --compress ecma=2024 --mangle > q5.min.js && terser q5-webgpu.js --compress ecma=2024 --mangle > q5-webgpu.min.js",
|
|
17
|
+
"dist": "bun bundle && bun bundle-webgpu && cp q5.js ../../web/p5play-web/v3/q5.js && bun min && cp q5.min.js ../../web/p5play-web/v3/q5.min.js",
|
|
17
18
|
"v": "npm version patch --force",
|
|
18
19
|
"V": "npm version minor --force",
|
|
19
20
|
"version": "git add -A",
|