q5 2.24.4 → 2.25.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 +6 -5
- package/deno.json +1 -1
- package/package.json +1 -1
- package/q5.d.ts +157 -22
- package/q5.js +111 -69
- package/q5.min.js +2 -2
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
|
-
"
|
|
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
package/package.json
CHANGED
package/q5.d.ts
CHANGED
|
@@ -2242,7 +2242,7 @@ function draw() {
|
|
|
2242
2242
|
*
|
|
2243
2243
|
* Useful for playing sounds.
|
|
2244
2244
|
* @example
|
|
2245
|
-
createCanvas(200
|
|
2245
|
+
createCanvas(200);
|
|
2246
2246
|
|
|
2247
2247
|
let gray = 100;
|
|
2248
2248
|
function mousePressed() {
|
|
@@ -2404,8 +2404,9 @@ function draw() {
|
|
|
2404
2404
|
/**
|
|
2405
2405
|
* ___Experimental! May be renamed or removed in the future.___
|
|
2406
2406
|
*
|
|
2407
|
-
* Generates a random number within a symmetric
|
|
2408
|
-
*
|
|
2407
|
+
* Generates a random number within a symmetric range around zero.
|
|
2408
|
+
*
|
|
2409
|
+
* Can be used to create a jitter effect (random displacement).
|
|
2409
2410
|
*
|
|
2410
2411
|
* Equivalent to `random(-amount, amount)`.
|
|
2411
2412
|
* @param {number} amount absolute maximum amount of jitter, default is 1
|
|
@@ -2424,6 +2425,58 @@ q.draw = () => {
|
|
|
2424
2425
|
*/
|
|
2425
2426
|
function jit(amount: number): number;
|
|
2426
2427
|
|
|
2428
|
+
/** 🧮
|
|
2429
|
+
* Generates a noise value based on the x, y, and z inputs.
|
|
2430
|
+
*
|
|
2431
|
+
* Uses [Perlin Noise](https://en.wikipedia.org/wiki/Perlin_noise) by default.
|
|
2432
|
+
* @param {number} [x] x-coordinate input
|
|
2433
|
+
* @param {number} [y] y-coordinate input
|
|
2434
|
+
* @param {number} [z] z-coordinate input
|
|
2435
|
+
* @returns {number} a noise value
|
|
2436
|
+
* @example
|
|
2437
|
+
function draw() {
|
|
2438
|
+
background(200);
|
|
2439
|
+
let n = noise(frameCount * 0.01);
|
|
2440
|
+
circle(100, 100, n * 200);
|
|
2441
|
+
}
|
|
2442
|
+
* @example
|
|
2443
|
+
function draw() {
|
|
2444
|
+
background(200);
|
|
2445
|
+
let t = (frameCount + mouseX) * 0.02;
|
|
2446
|
+
for (let x = -5; x < 220; x += 10) {
|
|
2447
|
+
let n = noise(t, x * 0.1);
|
|
2448
|
+
circle(x, 100, n * 40);
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
* @example
|
|
2452
|
+
let q = await Q5.WebGPU();
|
|
2453
|
+
|
|
2454
|
+
q.draw = () => {
|
|
2455
|
+
let t = millis() * 0.002;
|
|
2456
|
+
for (let x = -100; x < 100; x += 5) {
|
|
2457
|
+
for (let y = -100; y < 100; y += 5) {
|
|
2458
|
+
fill(noise(t, (mouseX + x) * .05, y * .05));
|
|
2459
|
+
square(x, y, 5);
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
};
|
|
2463
|
+
* @example
|
|
2464
|
+
let q = await Q5.WebGPU();
|
|
2465
|
+
|
|
2466
|
+
q.draw = () => {
|
|
2467
|
+
let zoom = mouseY / 2000;
|
|
2468
|
+
let t = millis() * 0.002;
|
|
2469
|
+
noStroke();
|
|
2470
|
+
for (let x = -100; x < 100; x++) {
|
|
2471
|
+
for (let y = -100; y < 100; y++) {
|
|
2472
|
+
fill(noise(t, x * zoom, y * zoom));
|
|
2473
|
+
square(x, y, 1);
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
};
|
|
2477
|
+
*/
|
|
2478
|
+
function noise(x?: number, y?: number, z?: number): number;
|
|
2479
|
+
|
|
2427
2480
|
/** 🧮
|
|
2428
2481
|
* Calculates the distance between two points.
|
|
2429
2482
|
*
|
|
@@ -2503,6 +2556,89 @@ function draw() {
|
|
|
2503
2556
|
*/
|
|
2504
2557
|
function norm(n: number, start: number, stop: number): number;
|
|
2505
2558
|
|
|
2559
|
+
/** 🧮
|
|
2560
|
+
* Calculates the fractional part of a number.
|
|
2561
|
+
* @param {number} n a number
|
|
2562
|
+
* @returns {number} fractional part of the number
|
|
2563
|
+
*/
|
|
2564
|
+
function fract(n: number): number;
|
|
2565
|
+
|
|
2566
|
+
/** 🧮
|
|
2567
|
+
* Calculates the absolute value of a number.
|
|
2568
|
+
* @param {number} n a number
|
|
2569
|
+
* @returns {number} absolute value of the number
|
|
2570
|
+
*/
|
|
2571
|
+
function abs(n: number): number;
|
|
2572
|
+
|
|
2573
|
+
/** 🧮
|
|
2574
|
+
* Rounds a number.
|
|
2575
|
+
* @param {number} n number to round
|
|
2576
|
+
* @param {number} [d] number of decimal places to round to
|
|
2577
|
+
* @returns {number} rounded number
|
|
2578
|
+
* @example
|
|
2579
|
+
createCanvas(200, 100);
|
|
2580
|
+
background(200);
|
|
2581
|
+
textSize(32);
|
|
2582
|
+
text(round(PI, 5), 10, 60);
|
|
2583
|
+
*/
|
|
2584
|
+
function round(n: number, d: number): number;
|
|
2585
|
+
|
|
2586
|
+
/** 🧮
|
|
2587
|
+
* Rounds a number up.
|
|
2588
|
+
* @param {number} n a number
|
|
2589
|
+
* @returns {number} rounded number
|
|
2590
|
+
* @example
|
|
2591
|
+
createCanvas(200, 100);
|
|
2592
|
+
background(200);
|
|
2593
|
+
textSize(32);
|
|
2594
|
+
text(ceil(PI), 10, 60);
|
|
2595
|
+
*/
|
|
2596
|
+
function ceil(n: number): number;
|
|
2597
|
+
|
|
2598
|
+
/** 🧮
|
|
2599
|
+
* Rounds a number down.
|
|
2600
|
+
* @param {number} n a number
|
|
2601
|
+
* @returns {number} rounded number
|
|
2602
|
+
* @example
|
|
2603
|
+
createCanvas(200, 100);
|
|
2604
|
+
background(200);
|
|
2605
|
+
textSize(32);
|
|
2606
|
+
text(floor(-PI), 10, 60);
|
|
2607
|
+
*/
|
|
2608
|
+
function floor(n: number): number;
|
|
2609
|
+
|
|
2610
|
+
/** 🧮
|
|
2611
|
+
* Returns the smallest value in a sequence of numbers.
|
|
2612
|
+
* @param {...number} args numbers to compare
|
|
2613
|
+
* @returns {number} minimum
|
|
2614
|
+
* @example
|
|
2615
|
+
function draw() {
|
|
2616
|
+
background(min(mouseX, 100));
|
|
2617
|
+
}
|
|
2618
|
+
*/
|
|
2619
|
+
function min(...args: number[]): number;
|
|
2620
|
+
|
|
2621
|
+
/** 🧮
|
|
2622
|
+
* Returns the largest value in a sequence of numbers.
|
|
2623
|
+
* @param {...number} args numbers to compare
|
|
2624
|
+
* @returns {number} maximum
|
|
2625
|
+
* @example
|
|
2626
|
+
function draw() {
|
|
2627
|
+
background(max(mouseX, 100));
|
|
2628
|
+
}
|
|
2629
|
+
*/
|
|
2630
|
+
function max(...args: number[]): number;
|
|
2631
|
+
|
|
2632
|
+
/** 🧮
|
|
2633
|
+
* Calculates the value of a base raised to a power.
|
|
2634
|
+
*
|
|
2635
|
+
* For example, `pow(2, 3)` calculates 2 * 2 * 2 which is 8.
|
|
2636
|
+
* @param {number} base base
|
|
2637
|
+
* @param {number} exponent exponent
|
|
2638
|
+
* @returns {number} base raised to the power of exponent
|
|
2639
|
+
*/
|
|
2640
|
+
function pow(base: number, exponent: number): number;
|
|
2641
|
+
|
|
2506
2642
|
/** 🧮
|
|
2507
2643
|
* Calculates the square of a number.
|
|
2508
2644
|
* @param {number} n number to square
|
|
@@ -2511,11 +2647,25 @@ function draw() {
|
|
|
2511
2647
|
function sq(n: number): number;
|
|
2512
2648
|
|
|
2513
2649
|
/** 🧮
|
|
2514
|
-
* Calculates the
|
|
2515
|
-
* @param {number} n number
|
|
2516
|
-
* @returns {number}
|
|
2650
|
+
* Calculates the square root of a number.
|
|
2651
|
+
* @param {number} n a number
|
|
2652
|
+
* @returns {number} square root of the number
|
|
2517
2653
|
*/
|
|
2518
|
-
function
|
|
2654
|
+
function sqrt(n: number): number;
|
|
2655
|
+
|
|
2656
|
+
/** 🧮
|
|
2657
|
+
* Calculates the natural logarithm (base e) of a number.
|
|
2658
|
+
* @param {number} n a number
|
|
2659
|
+
* @returns {number} natural logarithm of the number
|
|
2660
|
+
*/
|
|
2661
|
+
function loge(n: number): number;
|
|
2662
|
+
|
|
2663
|
+
/** 🧮
|
|
2664
|
+
* Calculates e raised to the power of a number.
|
|
2665
|
+
* @param {number} exponent power to raise e to
|
|
2666
|
+
* @returns {number} e raised to the power of exponent
|
|
2667
|
+
*/
|
|
2668
|
+
function exp(exponent: number): number;
|
|
2519
2669
|
|
|
2520
2670
|
/** 🧮
|
|
2521
2671
|
* Sets the seed for the random number generator.
|
|
@@ -2552,21 +2702,6 @@ function draw() {
|
|
|
2552
2702
|
*/
|
|
2553
2703
|
function noiseMode(mode: 'perlin' | 'simplex' | 'blocky'): void;
|
|
2554
2704
|
|
|
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
2705
|
/** 🧮
|
|
2571
2706
|
* Sets the seed value for noise generation.
|
|
2572
2707
|
* @param {number} seed seed value
|