q5 4.7.0 ā 4.7.2
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/deno.json +3 -1
- package/package.json +1 -1
- package/q5.d.ts +8 -7
- package/q5.js +3 -11
- package/q5.pyi +53 -75
package/deno.json
CHANGED
package/package.json
CHANGED
package/q5.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @module q5 */
|
|
1
2
|
declare global {
|
|
2
3
|
|
|
3
4
|
// ā core
|
|
@@ -1686,7 +1687,7 @@ declare global {
|
|
|
1686
1687
|
* Like the [`color`](https://q5js.org/learn/#color) function,
|
|
1687
1688
|
* this function can accept colors in a wide range of formats:
|
|
1688
1689
|
* CSS color string, grayscale value, and color component values.
|
|
1689
|
-
* @param {Color | Q5.Image} filler
|
|
1690
|
+
* @param {string | Color | Q5.Image} filler color or image
|
|
1690
1691
|
* @example
|
|
1691
1692
|
* await Canvas(200, 100);
|
|
1692
1693
|
* background('crimson');
|
|
@@ -1696,7 +1697,7 @@ declare global {
|
|
|
1696
1697
|
* circle(mouseX, mouseY, 20);
|
|
1697
1698
|
* };
|
|
1698
1699
|
*/
|
|
1699
|
-
function background(
|
|
1700
|
+
function background(c0: number, c1: number, c2: number, c3: number): void;
|
|
1700
1701
|
|
|
1701
1702
|
class Color {
|
|
1702
1703
|
|
|
@@ -1739,7 +1740,7 @@ declare global {
|
|
|
1739
1740
|
* Like the [`color`](https://q5js.org/learn/#color) function, this function
|
|
1740
1741
|
* can accept colors in a wide range of formats: as a CSS color string,
|
|
1741
1742
|
* a `Color` object, grayscale value, or color component values.
|
|
1742
|
-
* @param {Color} color fill color
|
|
1743
|
+
* @param {string | Color} color fill color
|
|
1743
1744
|
* @example
|
|
1744
1745
|
* await Canvas(200);
|
|
1745
1746
|
* background(0.8);
|
|
@@ -1750,7 +1751,7 @@ declare global {
|
|
|
1750
1751
|
* fill('lime');
|
|
1751
1752
|
* square(-20, -20, 80);
|
|
1752
1753
|
*/
|
|
1753
|
-
function fill(
|
|
1754
|
+
function fill(c0: number, c1: number, c2: number, c3: number): void;
|
|
1754
1755
|
|
|
1755
1756
|
/** š
|
|
1756
1757
|
* Sets the stroke (outline) color. The default is black.
|
|
@@ -1758,7 +1759,7 @@ declare global {
|
|
|
1758
1759
|
* Like the [`color`](https://q5js.org/learn/#color) function, this function
|
|
1759
1760
|
* can accept colors in a wide range of formats: as a CSS color string,
|
|
1760
1761
|
* a `Color` object, grayscale value, or color component values.
|
|
1761
|
-
* @param {Color} color stroke color
|
|
1762
|
+
* @param {string | Color} color stroke color
|
|
1762
1763
|
* @example
|
|
1763
1764
|
* await Canvas(200);
|
|
1764
1765
|
* background(0.8);
|
|
@@ -1770,7 +1771,7 @@ declare global {
|
|
|
1770
1771
|
* stroke('lime');
|
|
1771
1772
|
* square(-20, -20, 80);
|
|
1772
1773
|
*/
|
|
1773
|
-
function stroke(
|
|
1774
|
+
function stroke(c0: number, c1: number, c2: number, c3: number): void;
|
|
1774
1775
|
|
|
1775
1776
|
/** š
|
|
1776
1777
|
* After calling this function, drawing will not be filled.
|
|
@@ -1843,7 +1844,7 @@ declare global {
|
|
|
1843
1844
|
* a `Color` object, grayscale value, or color component values.
|
|
1844
1845
|
*
|
|
1845
1846
|
* Not available in q5 WebGPU.
|
|
1846
|
-
* @param {Color} color shadow color
|
|
1847
|
+
* @param {string | Color} color shadow color
|
|
1847
1848
|
*/
|
|
1848
1849
|
function shadow(color: string | Color): void;
|
|
1849
1850
|
|
package/q5.js
CHANGED
|
@@ -6659,7 +6659,7 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
|
|
|
6659
6659
|
if (shapeVertCount === 0) throw new Error('Shape needs a vertex()');
|
|
6660
6660
|
|
|
6661
6661
|
// Get the last vertex as the starting point (Pā)
|
|
6662
|
-
let prevIndex = (shapeVertCount - 1) *
|
|
6662
|
+
let prevIndex = (shapeVertCount - 1) * 3;
|
|
6663
6663
|
let startX = sv[prevIndex];
|
|
6664
6664
|
let startY = sv[prevIndex + 1];
|
|
6665
6665
|
|
|
@@ -6672,7 +6672,7 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
|
|
|
6672
6672
|
y = cy2;
|
|
6673
6673
|
}
|
|
6674
6674
|
|
|
6675
|
-
let end = 1 + step;
|
|
6675
|
+
let end = 1 + step * 0.5;
|
|
6676
6676
|
for (let t = step; t <= end; t += step) {
|
|
6677
6677
|
// Start from 0.1 to avoid duplicating the start point
|
|
6678
6678
|
let t2 = t * t;
|
|
@@ -6801,15 +6801,6 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
|
|
|
6801
6801
|
}
|
|
6802
6802
|
}
|
|
6803
6803
|
} else {
|
|
6804
|
-
let cx = 0,
|
|
6805
|
-
cy = 0;
|
|
6806
|
-
for (let i = 0; i < shapeVertCount - 1; i++) {
|
|
6807
|
-
cx += sv[i * 3];
|
|
6808
|
-
cy += sv[i * 3 + 1];
|
|
6809
|
-
}
|
|
6810
|
-
cx /= Math.max(1, shapeVertCount - 1);
|
|
6811
|
-
cy /= Math.max(1, shapeVertCount - 1);
|
|
6812
|
-
|
|
6813
6804
|
let signedArea = 0,
|
|
6814
6805
|
sign = 1;
|
|
6815
6806
|
for (let i = 0; i < shapeVertCount - 1; i++) {
|
|
@@ -9665,6 +9656,7 @@ const runPython = async function () {
|
|
|
9665
9656
|
|
|
9666
9657
|
const useWebGPU = !code.slice(0, code.indexOf('\n')).includes('C2D'),
|
|
9667
9658
|
q = useWebGPU ? await Q5.WebGPU() : new Q5();
|
|
9659
|
+
q._py = true;
|
|
9668
9660
|
await q.ready;
|
|
9669
9661
|
|
|
9670
9662
|
let pyReady;
|
package/q5.pyi
CHANGED
|
@@ -1662,7 +1662,7 @@ Example::
|
|
|
1662
1662
|
background(1, 0, 0)
|
|
1663
1663
|
"""
|
|
1664
1664
|
|
|
1665
|
-
def background(filler: Color | Image) -> None:
|
|
1665
|
+
def background(filler: str | Color | Image) -> None:
|
|
1666
1666
|
"""šØ
|
|
1667
1667
|
Draws over the entire canvas with a color or image.
|
|
1668
1668
|
|
|
@@ -1670,7 +1670,7 @@ def background(filler: Color | Image) -> None:
|
|
|
1670
1670
|
this function can accept colors in a wide range of formats:
|
|
1671
1671
|
CSS color string, grayscale value, and color component values.
|
|
1672
1672
|
|
|
1673
|
-
:param filler:
|
|
1673
|
+
:param filler: color or image
|
|
1674
1674
|
|
|
1675
1675
|
Example::
|
|
1676
1676
|
|
|
@@ -1689,26 +1689,25 @@ class Color:
|
|
|
1689
1689
|
"""
|
|
1690
1690
|
|
|
1691
1691
|
|
|
1692
|
-
def equals(self) ->
|
|
1692
|
+
def equals(self) -> bool:
|
|
1693
1693
|
"""šØ Checks if this color is exactly equal to another color."""
|
|
1694
1694
|
...
|
|
1695
1695
|
|
|
1696
|
-
def isSameColor(self) ->
|
|
1696
|
+
def isSameColor(self) -> bool:
|
|
1697
1697
|
"""šØ Checks if the color is the same as another color,
|
|
1698
1698
|
disregarding their alpha values."""
|
|
1699
1699
|
...
|
|
1700
1700
|
|
|
1701
|
-
def toString(self) ->
|
|
1701
|
+
def toString(self) -> str:
|
|
1702
1702
|
"""šØ Produces a CSS color string representation."""
|
|
1703
1703
|
...
|
|
1704
1704
|
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
...
|
|
1705
|
+
levels: list[float]
|
|
1706
|
+
"""šØ An array of the color's components."""
|
|
1708
1707
|
|
|
1709
1708
|
# š
styles
|
|
1710
1709
|
|
|
1711
|
-
def fill(color: Color) -> None:
|
|
1710
|
+
def fill(color: str | Color) -> None:
|
|
1712
1711
|
"""š
|
|
1713
1712
|
Sets the fill color. The default is white.
|
|
1714
1713
|
|
|
@@ -1731,7 +1730,7 @@ def fill(color: Color) -> None:
|
|
|
1731
1730
|
"""
|
|
1732
1731
|
...
|
|
1733
1732
|
|
|
1734
|
-
def stroke(color: Color) -> None:
|
|
1733
|
+
def stroke(color: str | Color) -> None:
|
|
1735
1734
|
"""š
|
|
1736
1735
|
Sets the stroke (outline) color. The default is black.
|
|
1737
1736
|
|
|
@@ -1829,7 +1828,7 @@ def opacity(alpha: float) -> None:
|
|
|
1829
1828
|
"""
|
|
1830
1829
|
...
|
|
1831
1830
|
|
|
1832
|
-
def shadow(color: Color) -> None:
|
|
1831
|
+
def shadow(color: str | Color) -> None:
|
|
1833
1832
|
"""š
|
|
1834
1833
|
Sets the shadow color. The default is transparent (no shadow).
|
|
1835
1834
|
|
|
@@ -3057,30 +3056,24 @@ class Sound:
|
|
|
3057
3056
|
"""
|
|
3058
3057
|
|
|
3059
3058
|
|
|
3060
|
-
|
|
3061
|
-
|
|
3059
|
+
volume: float
|
|
3060
|
+
"""š Set the sound's volume to a value between
|
|
3062
3061
|
0 (silent) and 1 (full volume)."""
|
|
3063
|
-
...
|
|
3064
3062
|
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
...
|
|
3063
|
+
pan: float
|
|
3064
|
+
"""š Set the sound's stereo position between -1 (left) and 1 (right)."""
|
|
3068
3065
|
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
...
|
|
3066
|
+
loop: bool
|
|
3067
|
+
"""š Set to true to make the sound loop continuously."""
|
|
3072
3068
|
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
...
|
|
3069
|
+
loaded: bool
|
|
3070
|
+
"""š True if the sound data has finished loading."""
|
|
3076
3071
|
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
...
|
|
3072
|
+
paused: bool
|
|
3073
|
+
"""š True if the sound is currently paused."""
|
|
3080
3074
|
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
...
|
|
3075
|
+
ended: bool
|
|
3076
|
+
"""š True if the sound has finished playing."""
|
|
3084
3077
|
|
|
3085
3078
|
def play(self) -> object:
|
|
3086
3079
|
"""š Plays the sound.
|
|
@@ -3768,17 +3761,14 @@ class Vector:
|
|
|
3768
3761
|
"""
|
|
3769
3762
|
|
|
3770
3763
|
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
...
|
|
3764
|
+
x: float
|
|
3765
|
+
"""ā The x component of the vector."""
|
|
3774
3766
|
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
...
|
|
3767
|
+
y: float
|
|
3768
|
+
"""ā The y component of the vector."""
|
|
3778
3769
|
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
...
|
|
3770
|
+
z: float
|
|
3771
|
+
"""ā The z component of the vector, if applicable."""
|
|
3782
3772
|
|
|
3783
3773
|
def add(self, v: Vector) -> Vector:
|
|
3784
3774
|
"""ā Adds a vector to this vector."""
|
|
@@ -4330,74 +4320,63 @@ class Q5:
|
|
|
4330
4320
|
"""
|
|
4331
4321
|
|
|
4332
4322
|
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
...
|
|
4323
|
+
version: str
|
|
4324
|
+
"""ā The current minor version of q5."""
|
|
4336
4325
|
|
|
4337
|
-
|
|
4338
|
-
|
|
4326
|
+
lang: str
|
|
4327
|
+
"""ā Set to a language code other than 'en' (English) to use q5 in an additional language.
|
|
4339
4328
|
|
|
4340
4329
|
Currently supported languages:
|
|
4341
4330
|
|
|
4342
4331
|
- 'es' (Spanish)"""
|
|
4343
|
-
...
|
|
4344
4332
|
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
...
|
|
4333
|
+
disableFriendlyErrors: bool
|
|
4334
|
+
"""ā Turn off q5's friendly error messages."""
|
|
4348
4335
|
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
...
|
|
4336
|
+
errorTolerant: bool
|
|
4337
|
+
"""ā Set to true to keep draw looping after an error."""
|
|
4352
4338
|
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
...
|
|
4339
|
+
supportsHDR: bool
|
|
4340
|
+
"""ā True if the device supports HDR (the display-p3 colorspace)."""
|
|
4356
4341
|
|
|
4357
|
-
|
|
4358
|
-
|
|
4342
|
+
canvasOptions: dict
|
|
4343
|
+
"""ā Sets the default canvas context attributes used for newly created
|
|
4359
4344
|
canvases and internal graphics. These options are overwritten by any
|
|
4360
4345
|
per-canvas options you pass to Canvas."""
|
|
4361
|
-
...
|
|
4362
4346
|
|
|
4363
|
-
|
|
4364
|
-
|
|
4347
|
+
MAX_TRANSFORMS: float
|
|
4348
|
+
"""ā A WebGPU memory allocation limit.
|
|
4365
4349
|
|
|
4366
4350
|
The maximum number of transformation matrixes
|
|
4367
4351
|
that can be used per frame."""
|
|
4368
|
-
...
|
|
4369
4352
|
|
|
4370
|
-
|
|
4371
|
-
|
|
4353
|
+
MAX_RECTS: float
|
|
4354
|
+
"""ā A WebGPU memory allocation limit.
|
|
4372
4355
|
|
|
4373
4356
|
The maximum number of rectangles
|
|
4374
4357
|
(calls to rect, square, capsule)
|
|
4375
4358
|
that can be drawn per frame."""
|
|
4376
|
-
...
|
|
4377
4359
|
|
|
4378
|
-
|
|
4379
|
-
|
|
4360
|
+
MAX_ELLIPSES: float
|
|
4361
|
+
"""ā A WebGPU memory allocation limit.
|
|
4380
4362
|
|
|
4381
4363
|
The maximum number of ellipses
|
|
4382
4364
|
(calls to ellipse, circle, and arc)
|
|
4383
4365
|
that can be drawn per frame."""
|
|
4384
|
-
...
|
|
4385
4366
|
|
|
4386
|
-
|
|
4387
|
-
|
|
4367
|
+
MAX_CHARS: float
|
|
4368
|
+
"""ā A WebGPU memory allocation limit.
|
|
4388
4369
|
|
|
4389
4370
|
The maximum number of text characters
|
|
4390
4371
|
that can be drawn per frame."""
|
|
4391
|
-
...
|
|
4392
4372
|
|
|
4393
|
-
|
|
4394
|
-
|
|
4373
|
+
MAX_TEXTS: float
|
|
4374
|
+
"""ā A WebGPU memory allocation limit.
|
|
4395
4375
|
|
|
4396
4376
|
The maximum number of separate calls to text
|
|
4397
4377
|
that can be drawn per frame."""
|
|
4398
|
-
...
|
|
4399
4378
|
|
|
4400
|
-
def WebGPU(self) ->
|
|
4379
|
+
def WebGPU(self) -> Q5:
|
|
4401
4380
|
"""ā Creates a new Q5 instance that uses q5's WebGPU renderer."""
|
|
4402
4381
|
...
|
|
4403
4382
|
|
|
@@ -4412,14 +4391,13 @@ Inside the function, this refers to the Q5 instance."""
|
|
|
4412
4391
|
"""ā p5.js v2 compatible way to register an addon with q5."""
|
|
4413
4392
|
...
|
|
4414
4393
|
|
|
4415
|
-
|
|
4416
|
-
|
|
4394
|
+
modules: dict
|
|
4395
|
+
"""ā An object containing q5's modules, functions that run when q5 loads.
|
|
4417
4396
|
|
|
4418
4397
|
Each function receives two input parameters:
|
|
4419
4398
|
|
|
4420
4399
|
- the q5 instance
|
|
4421
4400
|
- a proxy for editing the q5 instance and corresponding properties of the global scope"""
|
|
4422
|
-
...
|
|
4423
4401
|
|
|
4424
4402
|
def draw(self) -> None:
|
|
4425
4403
|
"""ā The q5 draw function is run 60 times per second by default."""
|