q5 2.24.4 → 2.25.1

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 CHANGED
@@ -6,7 +6,7 @@
6
6
  - performance optimized for interactive art 🚀
7
7
  - lightning fast [WebGPU renderer](https://github.com/q5js/q5.js/wiki/q5-WebGPU-renderer) ⚡️
8
8
  - beginner friendly [documentation](https://q5js.org/learn) 📚
9
- - compatible with popular addons, including [p5.sound][] and [p5play][] 🎮
9
+ - compatible with popular addons, including [p5.sound][], [ml5.js][], and [p5play][] 🎮
10
10
  - no dependencies, ~100kb minified 📦
11
11
  - free to use under the LGPL (just like p5.js) 🆓
12
12
 
@@ -19,8 +19,6 @@ createCanvas(100, 100);
19
19
  circle(50, 50, 50);
20
20
  ```
21
21
 
22
- q5 doesn't replicate all of p5's functionality, but it's a superior alternative for many use cases. 🛠️
23
-
24
22
  ## Documentation
25
23
 
26
24
  Browse the [q5 reference pages](https://q5js.org/learn) to learn how to use q5.js.
@@ -34,7 +32,9 @@ Use the [q5.d.ts](q5.d.ts) file in Visual Studio Code to get autocompletion and
34
32
  "compilerOptions": {
35
33
  "target": "ESNext"
36
34
  },
37
- "include": ["*.js", "*/*.js", "node_modules/q5/q5.d.ts"]
35
+ "typeAcquisition": {
36
+ "include": ["node_modules/q5"]
37
+ }
38
38
  }
39
39
  ```
40
40
 
@@ -42,7 +42,7 @@ Use the [q5.d.ts](q5.d.ts) file in Visual Studio Code to get autocompletion and
42
42
 
43
43
  q5 is open source and anyone can use it for free under the terms of the LGPL (just like p5.js). 🎉
44
44
 
45
- We need your support though! If you enjoy using q5.js, please donate via [GitHub Sponsors](https://github.com/sponsors/quinton-ashley) or [Patreon](https://www.patreon.com/p5play).
45
+ We need your support though! If you enjoy using q5.js, please donate via [GitHub Sponsors](https://github.com/sponsors/quinton-ashley), [ko-fi](https://ko-fi.com/q5play), or [Patreon](https://www.patreon.com/p5play).
46
46
 
47
47
  ## Contributing
48
48
 
@@ -91,4 +91,5 @@ https://github.com/processing/p5.js/blob/1.1.9/src/math/noise.js
91
91
  [p5.js]: https://p5js.org
92
92
  [Processing Java]: https://processing.org
93
93
  [p5.sound]: https://archive.p5js.org/reference/#/libraries/p5.sound
94
+ [ml5.js]: https://ml5js.org
94
95
  [p5play]: https://p5play.org
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q5/q5",
3
- "version": "2.24.1",
3
+ "version": "2.25.0",
4
4
  "license": "LGPL-3.0",
5
5
  "description": "Beginner friendly graphics powered by WebGPU and optimized for interactive art!",
6
6
  "author": "quinton-ashley",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q5",
3
- "version": "2.24.4",
3
+ "version": "2.25.1",
4
4
  "description": "Beginner friendly graphics powered by WebGPU and optimized for interactive art!",
5
5
  "author": "quinton-ashley",
6
6
  "contributors": [
package/q5.d.ts CHANGED
@@ -840,13 +840,6 @@ square(0, 0, 50);
840
840
  */
841
841
  function displayDensity(): number;
842
842
 
843
- /** ⬜️
844
- * Enables or disables fullscreen mode.
845
- * @param {boolean} [v] boolean indicating whether to enable or disable fullscreen mode
846
- * @returns {void | boolean} true if fullscreen mode is enabled, false otherwise
847
- */
848
- function fullscreen(v?: boolean): void | boolean;
849
-
850
843
  /** ⬜️
851
844
  * Any position coordinates or dimensions you use will be scaled based
852
845
  * on the unit provided to this function.
@@ -1178,23 +1171,51 @@ background(255, 0, 0);
1178
1171
 
1179
1172
  /** 💻
1180
1173
  * Customize how your canvas is presented.
1181
- * @param {string} mode
1182
- * - "normal": (default) canvas is not repositioned
1183
- * - "centered": canvas is moved to the center of its parent
1184
- * - "maxed": canvas will be scaled to fill the parent element, with letterboxing if necessary to preserve its aspect ratio
1185
- * @param {string} renderQuality
1186
- * - "smooth": (default) smooth upscaling if the canvas is scaled
1187
- * - "pixelated": pixels rendered as sharp squares
1174
+ * @param {string} mode Display modes:
1175
+ * - NORMAL: (default) canvas is not repositioned
1176
+ * - CENTER: canvas is moved to the center of its parent
1177
+ * - MAXED: canvas will be scaled to fill the parent element, with letterboxing if necessary to preserve its aspect ratio
1178
+ * @param {string} renderQuality Render quality settings:
1179
+ * - SMOOTH: (default) smooth upscaling if the canvas is scaled
1180
+ * - PIXELATED: pixels rendered as sharp squares
1188
1181
  * @param {number} scale can also be given as a string (for example "x2")
1189
1182
  * @example
1190
1183
  createCanvas(50, 25);
1191
1184
 
1192
- displayMode('centered', 'pixelated', 4);
1185
+ displayMode(CENTER, PIXELATED, 4);
1193
1186
 
1194
1187
  circle(25, 12.5, 16);
1195
1188
  */
1196
1189
  function displayMode(mode: string, renderQuality: string, scale: string | number): void;
1197
1190
 
1191
+ /** 💻
1192
+ * Enables or disables fullscreen mode.
1193
+ * @param {boolean} [v] boolean indicating whether to enable or disable fullscreen mode
1194
+ */
1195
+ function fullscreen(v?: boolean): void;
1196
+
1197
+ /** 💻
1198
+ * A `displayMode` setting.
1199
+ *
1200
+ * The canvas will be scaled to fill the parent element,
1201
+ * with letterboxing if necessary to preserve its aspect ratio.
1202
+ */
1203
+ const MAXED: 'maxed';
1204
+
1205
+ /** 💻
1206
+ * A `displayMode` render quality.
1207
+ *
1208
+ * Smooth upscaling is used if the canvas is scaled.
1209
+ */
1210
+ const SMOOTH: 'smooth';
1211
+
1212
+ /** 💻
1213
+ * A `displayMode` render quality.
1214
+ *
1215
+ * Pixels are rendered as sharp squares if the canvas is scaled.
1216
+ */
1217
+ const PIXELATED: 'pixelated';
1218
+
1198
1219
  // 🧑‍🎨 shapes
1199
1220
 
1200
1221
  /** 🧑‍🎨
@@ -2242,7 +2263,7 @@ function draw() {
2242
2263
  *
2243
2264
  * Useful for playing sounds.
2244
2265
  * @example
2245
- createCanvas(200, 100);
2266
+ createCanvas(200);
2246
2267
 
2247
2268
  let gray = 100;
2248
2269
  function mousePressed() {
@@ -2404,8 +2425,9 @@ function draw() {
2404
2425
  /**
2405
2426
  * ___Experimental! May be renamed or removed in the future.___
2406
2427
  *
2407
- * Generates a random number within a symmetric
2408
- * [jitter](https://en.wikipedia.org/wiki/Jitter) range around zero.
2428
+ * Generates a random number within a symmetric range around zero.
2429
+ *
2430
+ * Can be used to create a jitter effect (random displacement).
2409
2431
  *
2410
2432
  * Equivalent to `random(-amount, amount)`.
2411
2433
  * @param {number} amount absolute maximum amount of jitter, default is 1
@@ -2424,6 +2446,58 @@ q.draw = () => {
2424
2446
  */
2425
2447
  function jit(amount: number): number;
2426
2448
 
2449
+ /** 🧮
2450
+ * Generates a noise value based on the x, y, and z inputs.
2451
+ *
2452
+ * Uses [Perlin Noise](https://en.wikipedia.org/wiki/Perlin_noise) by default.
2453
+ * @param {number} [x] x-coordinate input
2454
+ * @param {number} [y] y-coordinate input
2455
+ * @param {number} [z] z-coordinate input
2456
+ * @returns {number} a noise value
2457
+ * @example
2458
+ function draw() {
2459
+ background(200);
2460
+ let n = noise(frameCount * 0.01);
2461
+ circle(100, 100, n * 200);
2462
+ }
2463
+ * @example
2464
+ function draw() {
2465
+ background(200);
2466
+ let t = (frameCount + mouseX) * 0.02;
2467
+ for (let x = -5; x < 220; x += 10) {
2468
+ let n = noise(t, x * 0.1);
2469
+ circle(x, 100, n * 40);
2470
+ }
2471
+ }
2472
+ * @example
2473
+ let q = await Q5.WebGPU();
2474
+
2475
+ q.draw = () => {
2476
+ noStroke();
2477
+ let t = millis() * 0.002;
2478
+ for (let x = -100; x < 100; x += 5) {
2479
+ for (let y = -100; y < 100; y += 5) {
2480
+ fill(noise(t, (mouseX + x) * .05, y * .05));
2481
+ square(x, y, 4);
2482
+ }
2483
+ }
2484
+ };
2485
+ * @example
2486
+ let q = await Q5.WebGPU();
2487
+
2488
+ q.draw = () => {
2489
+ let zoom = mouseY / 2000;
2490
+ let t = millis() * 0.002;
2491
+ for (let x = -50; x < 50; x++) {
2492
+ for (let y = -50; y < 50; y++) {
2493
+ stroke(noise(t, x * zoom, y * zoom));
2494
+ point(x, y, 1);
2495
+ }
2496
+ }
2497
+ };
2498
+ */
2499
+ function noise(x?: number, y?: number, z?: number): number;
2500
+
2427
2501
  /** 🧮
2428
2502
  * Calculates the distance between two points.
2429
2503
  *
@@ -2503,6 +2577,89 @@ function draw() {
2503
2577
  */
2504
2578
  function norm(n: number, start: number, stop: number): number;
2505
2579
 
2580
+ /** 🧮
2581
+ * Calculates the fractional part of a number.
2582
+ * @param {number} n a number
2583
+ * @returns {number} fractional part of the number
2584
+ */
2585
+ function fract(n: number): number;
2586
+
2587
+ /** 🧮
2588
+ * Calculates the absolute value of a number.
2589
+ * @param {number} n a number
2590
+ * @returns {number} absolute value of the number
2591
+ */
2592
+ function abs(n: number): number;
2593
+
2594
+ /** 🧮
2595
+ * Rounds a number.
2596
+ * @param {number} n number to round
2597
+ * @param {number} [d] number of decimal places to round to
2598
+ * @returns {number} rounded number
2599
+ * @example
2600
+ createCanvas(200, 100);
2601
+ background(200);
2602
+ textSize(32);
2603
+ text(round(PI, 5), 10, 60);
2604
+ */
2605
+ function round(n: number, d: number): number;
2606
+
2607
+ /** 🧮
2608
+ * Rounds a number up.
2609
+ * @param {number} n a number
2610
+ * @returns {number} rounded number
2611
+ * @example
2612
+ createCanvas(200, 100);
2613
+ background(200);
2614
+ textSize(32);
2615
+ text(ceil(PI), 10, 60);
2616
+ */
2617
+ function ceil(n: number): number;
2618
+
2619
+ /** 🧮
2620
+ * Rounds a number down.
2621
+ * @param {number} n a number
2622
+ * @returns {number} rounded number
2623
+ * @example
2624
+ createCanvas(200, 100);
2625
+ background(200);
2626
+ textSize(32);
2627
+ text(floor(-PI), 10, 60);
2628
+ */
2629
+ function floor(n: number): number;
2630
+
2631
+ /** 🧮
2632
+ * Returns the smallest value in a sequence of numbers.
2633
+ * @param {...number} args numbers to compare
2634
+ * @returns {number} minimum
2635
+ * @example
2636
+ function draw() {
2637
+ background(min(mouseX, 100));
2638
+ }
2639
+ */
2640
+ function min(...args: number[]): number;
2641
+
2642
+ /** 🧮
2643
+ * Returns the largest value in a sequence of numbers.
2644
+ * @param {...number} args numbers to compare
2645
+ * @returns {number} maximum
2646
+ * @example
2647
+ function draw() {
2648
+ background(max(mouseX, 100));
2649
+ }
2650
+ */
2651
+ function max(...args: number[]): number;
2652
+
2653
+ /** 🧮
2654
+ * Calculates the value of a base raised to a power.
2655
+ *
2656
+ * For example, `pow(2, 3)` calculates 2 * 2 * 2 which is 8.
2657
+ * @param {number} base base
2658
+ * @param {number} exponent exponent
2659
+ * @returns {number} base raised to the power of exponent
2660
+ */
2661
+ function pow(base: number, exponent: number): number;
2662
+
2506
2663
  /** 🧮
2507
2664
  * Calculates the square of a number.
2508
2665
  * @param {number} n number to square
@@ -2511,11 +2668,25 @@ function draw() {
2511
2668
  function sq(n: number): number;
2512
2669
 
2513
2670
  /** 🧮
2514
- * Calculates the fractional part of a number.
2515
- * @param {number} n number whose fractional part is to be calculated
2516
- * @returns {number} fractional part of the number
2671
+ * Calculates the square root of a number.
2672
+ * @param {number} n a number
2673
+ * @returns {number} square root of the number
2517
2674
  */
2518
- function fract(n: number): number;
2675
+ function sqrt(n: number): number;
2676
+
2677
+ /** 🧮
2678
+ * Calculates the natural logarithm (base e) of a number.
2679
+ * @param {number} n a number
2680
+ * @returns {number} natural logarithm of the number
2681
+ */
2682
+ function loge(n: number): number;
2683
+
2684
+ /** 🧮
2685
+ * Calculates e raised to the power of a number.
2686
+ * @param {number} exponent power to raise e to
2687
+ * @returns {number} e raised to the power of exponent
2688
+ */
2689
+ function exp(exponent: number): number;
2519
2690
 
2520
2691
  /** 🧮
2521
2692
  * Sets the seed for the random number generator.
@@ -2552,21 +2723,6 @@ function draw() {
2552
2723
  */
2553
2724
  function noiseMode(mode: 'perlin' | 'simplex' | 'blocky'): void;
2554
2725
 
2555
- /** 🧮
2556
- * Generates a noise value based on the x, y, and z inputs.
2557
- * @param {number} [x] x-coordinate input
2558
- * @param {number} [y] y-coordinate input
2559
- * @param {number} [z] z-coordinate input
2560
- * @returns {number} a noise value
2561
- * @example
2562
- function draw() {
2563
- background(200);
2564
- let n = noise(frameCount * 0.01);
2565
- square(100, 100, n * 200);
2566
- }
2567
- */
2568
- function noise(x?: number, y?: number, z?: number): number;
2569
-
2570
2726
  /** 🧮
2571
2727
  * Sets the seed value for noise generation.
2572
2728
  * @param {number} seed seed value