q5 1.9.20 → 1.9.23
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/LICENSE.md +157 -0
- package/README.md +34 -5
- package/package.json +6 -3
- package/q5-server.js +6 -0
- package/q5.js +99 -16
- package/q5.min.js +1 -1
- package/q5js_brand.webp +0 -0
- package/q5js_logo.webp +0 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
|
|
3
|
+
Version 3, 29 June 2007
|
|
4
|
+
|
|
5
|
+
Copyright (C) 2007 Free Software Foundation, Inc.
|
|
6
|
+
<https://fsf.org/>
|
|
7
|
+
|
|
8
|
+
Everyone is permitted to copy and distribute verbatim copies of this
|
|
9
|
+
license document, but changing it is not allowed.
|
|
10
|
+
|
|
11
|
+
This version of the GNU Lesser General Public License incorporates the
|
|
12
|
+
terms and conditions of version 3 of the GNU General Public License,
|
|
13
|
+
supplemented by the additional permissions listed below.
|
|
14
|
+
|
|
15
|
+
## 0. Additional Definitions.
|
|
16
|
+
|
|
17
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
18
|
+
General Public License, and the "GNU GPL" refers to version 3 of the
|
|
19
|
+
GNU General Public License.
|
|
20
|
+
|
|
21
|
+
"The Library" refers to a covered work governed by this License, other
|
|
22
|
+
than an Application or a Combined Work as defined below.
|
|
23
|
+
|
|
24
|
+
An "Application" is any work that makes use of an interface provided
|
|
25
|
+
by the Library, but which is not otherwise based on the Library.
|
|
26
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
27
|
+
of using an interface provided by the Library.
|
|
28
|
+
|
|
29
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
30
|
+
Application with the Library. The particular version of the Library
|
|
31
|
+
with which the Combined Work was made is also called the "Linked
|
|
32
|
+
Version".
|
|
33
|
+
|
|
34
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
35
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
36
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
37
|
+
based on the Application, and not on the Linked Version.
|
|
38
|
+
|
|
39
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
40
|
+
object code and/or source code for the Application, including any data
|
|
41
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
42
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
43
|
+
|
|
44
|
+
## 1. Exception to Section 3 of the GNU GPL.
|
|
45
|
+
|
|
46
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
47
|
+
without being bound by section 3 of the GNU GPL.
|
|
48
|
+
|
|
49
|
+
## 2. Conveying Modified Versions.
|
|
50
|
+
|
|
51
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
52
|
+
facility refers to a function or data to be supplied by an Application
|
|
53
|
+
that uses the facility (other than as an argument passed when the
|
|
54
|
+
facility is invoked), then you may convey a copy of the modified
|
|
55
|
+
version:
|
|
56
|
+
|
|
57
|
+
- a) under this License, provided that you make a good faith effort
|
|
58
|
+
to ensure that, in the event an Application does not supply the
|
|
59
|
+
function or data, the facility still operates, and performs
|
|
60
|
+
whatever part of its purpose remains meaningful, or
|
|
61
|
+
- b) under the GNU GPL, with none of the additional permissions of
|
|
62
|
+
this License applicable to that copy.
|
|
63
|
+
|
|
64
|
+
## 3. Object Code Incorporating Material from Library Header Files.
|
|
65
|
+
|
|
66
|
+
The object code form of an Application may incorporate material from a
|
|
67
|
+
header file that is part of the Library. You may convey such object
|
|
68
|
+
code under terms of your choice, provided that, if the incorporated
|
|
69
|
+
material is not limited to numerical parameters, data structure
|
|
70
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
71
|
+
(ten or fewer lines in length), you do both of the following:
|
|
72
|
+
|
|
73
|
+
- a) Give prominent notice with each copy of the object code that
|
|
74
|
+
the Library is used in it and that the Library and its use are
|
|
75
|
+
covered by this License.
|
|
76
|
+
- b) Accompany the object code with a copy of the GNU GPL and this
|
|
77
|
+
license document.
|
|
78
|
+
|
|
79
|
+
## 4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that, taken
|
|
82
|
+
together, effectively do not restrict modification of the portions of
|
|
83
|
+
the Library contained in the Combined Work and reverse engineering for
|
|
84
|
+
debugging such modifications, if you also do each of the following:
|
|
85
|
+
|
|
86
|
+
- a) Give prominent notice with each copy of the Combined Work that
|
|
87
|
+
the Library is used in it and that the Library and its use are
|
|
88
|
+
covered by this License.
|
|
89
|
+
- b) Accompany the Combined Work with a copy of the GNU GPL and this
|
|
90
|
+
license document.
|
|
91
|
+
- c) For a Combined Work that displays copyright notices during
|
|
92
|
+
execution, include the copyright notice for the Library among
|
|
93
|
+
these notices, as well as a reference directing the user to the
|
|
94
|
+
copies of the GNU GPL and this license document.
|
|
95
|
+
- d) Do one of the following:
|
|
96
|
+
- 0) Convey the Minimal Corresponding Source under the terms of
|
|
97
|
+
this License, and the Corresponding Application Code in a form
|
|
98
|
+
suitable for, and under terms that permit, the user to
|
|
99
|
+
recombine or relink the Application with a modified version of
|
|
100
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
101
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
102
|
+
Corresponding Source.
|
|
103
|
+
- 1) Use a suitable shared library mechanism for linking with
|
|
104
|
+
the Library. A suitable mechanism is one that (a) uses at run
|
|
105
|
+
time a copy of the Library already present on the user's
|
|
106
|
+
computer system, and (b) will operate properly with a modified
|
|
107
|
+
version of the Library that is interface-compatible with the
|
|
108
|
+
Linked Version.
|
|
109
|
+
- e) Provide Installation Information, but only if you would
|
|
110
|
+
otherwise be required to provide such information under section 6
|
|
111
|
+
of the GNU GPL, and only to the extent that such information is
|
|
112
|
+
necessary to install and execute a modified version of the
|
|
113
|
+
Combined Work produced by recombining or relinking the Application
|
|
114
|
+
with a modified version of the Linked Version. (If you use option
|
|
115
|
+
4d0, the Installation Information must accompany the Minimal
|
|
116
|
+
Corresponding Source and Corresponding Application Code. If you
|
|
117
|
+
use option 4d1, you must provide the Installation Information in
|
|
118
|
+
the manner specified by section 6 of the GNU GPL for conveying
|
|
119
|
+
Corresponding Source.)
|
|
120
|
+
|
|
121
|
+
## 5. Combined Libraries.
|
|
122
|
+
|
|
123
|
+
You may place library facilities that are a work based on the Library
|
|
124
|
+
side by side in a single library together with other library
|
|
125
|
+
facilities that are not Applications and are not covered by this
|
|
126
|
+
License, and convey such a combined library under terms of your
|
|
127
|
+
choice, if you do both of the following:
|
|
128
|
+
|
|
129
|
+
- a) Accompany the combined library with a copy of the same work
|
|
130
|
+
based on the Library, uncombined with any other library
|
|
131
|
+
facilities, conveyed under the terms of this License.
|
|
132
|
+
- b) Give prominent notice with the combined library that part of it
|
|
133
|
+
is a work based on the Library, and explaining where to find the
|
|
134
|
+
accompanying uncombined form of the same work.
|
|
135
|
+
|
|
136
|
+
## 6. Revised Versions of the GNU Lesser General Public License.
|
|
137
|
+
|
|
138
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
139
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
140
|
+
versions will be similar in spirit to the present version, but may
|
|
141
|
+
differ in detail to address new problems or concerns.
|
|
142
|
+
|
|
143
|
+
Each version is given a distinguishing version number. If the Library
|
|
144
|
+
as you received it specifies that a certain numbered version of the
|
|
145
|
+
GNU Lesser General Public License "or any later version" applies to
|
|
146
|
+
it, you have the option of following the terms and conditions either
|
|
147
|
+
of that published version or of any later version published by the
|
|
148
|
+
Free Software Foundation. If the Library as you received it does not
|
|
149
|
+
specify a version number of the GNU Lesser General Public License, you
|
|
150
|
+
may choose any version of the GNU Lesser General Public License ever
|
|
151
|
+
published by the Free Software Foundation.
|
|
152
|
+
|
|
153
|
+
If the Library as you received it specifies that a proxy can decide
|
|
154
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
155
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
156
|
+
permanent authorization for you to choose that version for the
|
|
157
|
+
Library.
|
package/README.md
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**q5.js** implements all of [p5][]'s 2D drawing, math, and user input functionality.
|
|
4
4
|
|
|
5
|
-
It's a drop-in replacement that's performance optimized and
|
|
6
|
-
|
|
7
|
-
But q5 doesn't include any friendly error messages, so its mainly for people who are already familiar with p5.js or JS programming in general. If you're a beginner, stick with p5 while developing a sketch, then use q5 to share your work.
|
|
5
|
+
It's a drop-in replacement that's performance optimized and ~20x smaller than p5, while packing a few exclusive new features: top-level global mode, HDR color support, namespace mode, and text image caching.
|
|
8
6
|
|
|
9
7
|
## Usage
|
|
10
8
|
|
|
@@ -43,6 +41,35 @@ To use addons, simply load them after q5.js:
|
|
|
43
41
|
<script src="https://p5play.org/v3/p5play.js"></script>
|
|
44
42
|
```
|
|
45
43
|
|
|
44
|
+
## New Features: Ask AI ✨
|
|
45
|
+
|
|
46
|
+
Why doesn't this code work? `text('Hello!');`
|
|
47
|
+
|
|
48
|
+
JavaScript quietly avoids errors if possible (for example by giving undefined variables default values) and its error messages can be confusing for beginners.
|
|
49
|
+
|
|
50
|
+
p5's error messages are friendlier but often too vague, leaving beginners searching for help. 🙋
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
🌸 p5.js says: [test.js, line 19] text() was expecting at least 3 arguments, but received only 1.
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
q5 creates error reports that can be sent to an AI just by clicking a link! Users can also run the `askAI()` function before a line of code that isn't working as expected. 🤖
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
function draw() {
|
|
60
|
+
askAI();
|
|
61
|
+
text('Hello!');
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Optionally `askAI` can take a question as input, the default question is "What's wrong with this line? short answer".
|
|
66
|
+
|
|
67
|
+
ChatGPT 4o excels at identifying the most common errors that beginners make: typos, missing syntax, incorrect arguments, and more.
|
|
68
|
+
|
|
69
|
+
This feature can be disabled by setting `Q5.disableFriendlyErrors = true;`, though unlike in p5 this doesn't provide a performance boost from disabling argument validation because q5 mostly doesn't have any already.
|
|
70
|
+
|
|
71
|
+
q5 can catch errors in q5 function like `draw` and continue looping if you set `Q5.errorTolerant = true;`.
|
|
72
|
+
|
|
46
73
|
## New Features: Top-Level Global Mode
|
|
47
74
|
|
|
48
75
|
> q5.js includes some exclusive features that aren't available in p5.js. Using them is optional!
|
|
@@ -105,7 +132,7 @@ https://en.wikipedia.org/wiki/HSL_and_HSV#Disadvantages
|
|
|
105
132
|
|
|
106
133
|
## New Features: Customize Canvas Context Attributes
|
|
107
134
|
|
|
108
|
-
In **p5**, you're stuck with the default [canvas context attributes][], which can't be changed. So the canvas must have an alpha layer, even if you don't need one.
|
|
135
|
+
In **p5**, you're stuck with the default [canvas context attributes][], which can't be changed. So the canvas must have an alpha layer, even if you don't need one. HDR color space and [desynchronized rendering][] are not supported.
|
|
109
136
|
|
|
110
137
|
But **q5** has its own defaults:
|
|
111
138
|
|
|
@@ -117,7 +144,9 @@ Q5.canvasOptions = {
|
|
|
117
144
|
};
|
|
118
145
|
```
|
|
119
146
|
|
|
120
|
-
The
|
|
147
|
+
The "display-p3" color space will be used by default on supported devices, falling back to "srgb".
|
|
148
|
+
|
|
149
|
+
The `Q5.canvasOptions` object can be overridden, which will effect all q5 instances. You can also override any of these defaults by passing an options object as the fourth parameter to the `createCanvas()` function:
|
|
121
150
|
|
|
122
151
|
```js
|
|
123
152
|
createCanvas(400, 400, '2d', {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "quinton-ashley",
|
|
3
3
|
"name": "q5",
|
|
4
|
-
"version": "1.9.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "1.9.23",
|
|
5
|
+
"description": "The unofficial sequel to p5.js",
|
|
6
6
|
"main": "q5-server.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"min": "terser q5.js --compress ecma=2024 --mangle > q5.min.js",
|
|
@@ -29,5 +29,8 @@
|
|
|
29
29
|
"bugs": {
|
|
30
30
|
"url": "https://github.com/quinton-ashley/q5.js/issues"
|
|
31
31
|
},
|
|
32
|
-
"homepage": "https://github.com/quinton-ashley/q5.js#readme"
|
|
32
|
+
"homepage": "https://github.com/quinton-ashley/q5.js#readme",
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"jsdom": "^24.0.0"
|
|
35
|
+
}
|
|
33
36
|
}
|
package/q5-server.js
CHANGED
package/q5.js
CHANGED
|
@@ -91,10 +91,10 @@ function Q5(scope, parent) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
$.createCanvas = function (width, height, renderer, options) {
|
|
94
|
-
if (renderer == 'webgl') throw `webgl renderer is not supported in q5, use '2d'
|
|
94
|
+
if (renderer == 'webgl') throw Error(`webgl renderer is not supported in q5, use '2d'`);
|
|
95
95
|
if (typeof renderer == 'object') options = renderer;
|
|
96
|
-
$.width = $.canvas.width = width;
|
|
97
|
-
$.height = $.canvas.height = height;
|
|
96
|
+
$.width = $.canvas.width = width || window.innerWidth;
|
|
97
|
+
$.height = $.canvas.height = height || window.innerHeight;
|
|
98
98
|
$.canvas.renderer = '2d';
|
|
99
99
|
let opt = Object.assign({}, Q5.canvasOptions);
|
|
100
100
|
if (options) Object.assign(opt, options);
|
|
@@ -736,6 +736,8 @@ function Q5(scope, parent) {
|
|
|
736
736
|
}
|
|
737
737
|
|
|
738
738
|
function _resizeCanvas(w, h) {
|
|
739
|
+
w ??= window.innerWidth;
|
|
740
|
+
h ??= window.innerHeight;
|
|
739
741
|
$.width = w;
|
|
740
742
|
$.height = h;
|
|
741
743
|
let c = cloneCtx();
|
|
@@ -922,6 +924,7 @@ function Q5(scope, parent) {
|
|
|
922
924
|
blue: [0, 0, 255],
|
|
923
925
|
brown: [165, 42, 42],
|
|
924
926
|
crimson: [220, 20, 60],
|
|
927
|
+
cyan: [0, 255, 255],
|
|
925
928
|
darkviolet: [148, 0, 211],
|
|
926
929
|
gold: [255, 215, 0],
|
|
927
930
|
green: [0, 128, 0],
|
|
@@ -1024,6 +1027,7 @@ function Q5(scope, parent) {
|
|
|
1024
1027
|
$._doStroke = true;
|
|
1025
1028
|
$._strokeSet = true;
|
|
1026
1029
|
if (!c._q5Color && typeof c != 'string') c = $.color(...arguments);
|
|
1030
|
+
else if (basicColors[c]) c = $.color(...basicColors[c]);
|
|
1027
1031
|
if (c.a <= 0) return ($._doStroke = false);
|
|
1028
1032
|
ctx.strokeStyle = c.toString();
|
|
1029
1033
|
};
|
|
@@ -1032,6 +1036,7 @@ function Q5(scope, parent) {
|
|
|
1032
1036
|
$._doFill = true;
|
|
1033
1037
|
$._fillSet = true;
|
|
1034
1038
|
if (!c._q5Color && typeof c != 'string') c = $.color(...arguments);
|
|
1039
|
+
else if (basicColors[c]) c = $.color(...basicColors[c]);
|
|
1035
1040
|
if (c.a <= 0) return ($._doFill = false);
|
|
1036
1041
|
ctx.fillStyle = c.toString();
|
|
1037
1042
|
};
|
|
@@ -1057,7 +1062,8 @@ function Q5(scope, parent) {
|
|
|
1057
1062
|
if (c._q5) return $.image(c, 0, 0, $.width, $.height);
|
|
1058
1063
|
ctx.save();
|
|
1059
1064
|
ctx.resetTransform();
|
|
1060
|
-
if (!c.
|
|
1065
|
+
if (!c._q5Color && typeof c != 'string') c = $.color(...arguments);
|
|
1066
|
+
else if (basicColors[c]) c = $.color(...basicColors[c]);
|
|
1061
1067
|
ctx.fillStyle = c.toString();
|
|
1062
1068
|
ctx.fillRect(0, 0, $.canvas.width, $.canvas.height);
|
|
1063
1069
|
ctx.restore();
|
|
@@ -1154,9 +1160,12 @@ function Q5(scope, parent) {
|
|
|
1154
1160
|
y = x.y;
|
|
1155
1161
|
x = x.x;
|
|
1156
1162
|
}
|
|
1163
|
+
ctx.save();
|
|
1157
1164
|
ctx.beginPath();
|
|
1158
|
-
ctx.
|
|
1159
|
-
ctx.
|
|
1165
|
+
ctx.arc(x, y, ctx.lineWidth / 2, 0, Math.PI * 2);
|
|
1166
|
+
ctx.fillStyle = ctx.strokeStyle;
|
|
1167
|
+
ctx.fill();
|
|
1168
|
+
ctx.restore();
|
|
1160
1169
|
};
|
|
1161
1170
|
function rectImpl(x, y, w, h) {
|
|
1162
1171
|
if ($._doFill) ctx.fillRect(x, y, w, h);
|
|
@@ -1688,7 +1697,7 @@ function Q5(scope, parent) {
|
|
|
1688
1697
|
};
|
|
1689
1698
|
var p_perlin;
|
|
1690
1699
|
|
|
1691
|
-
$.noise = (x = 0, y = 0, z) => {
|
|
1700
|
+
$.noise = (x = 0, y = 0, z = 0) => {
|
|
1692
1701
|
if (p_perlin == null) {
|
|
1693
1702
|
p_perlin = new Array(PERLIN_SIZE + 1);
|
|
1694
1703
|
for (var i = 0; i < PERLIN_SIZE + 1; i++) {
|
|
@@ -2013,11 +2022,7 @@ function Q5(scope, parent) {
|
|
|
2013
2022
|
clearBuff();
|
|
2014
2023
|
firstVertex = true;
|
|
2015
2024
|
if (ctx) ctx.save();
|
|
2016
|
-
|
|
2017
|
-
$.draw();
|
|
2018
|
-
} catch (e) {
|
|
2019
|
-
console.error(e);
|
|
2020
|
-
}
|
|
2025
|
+
$.draw();
|
|
2021
2026
|
for (let m of Q5.prototype._methods.post) m.call($);
|
|
2022
2027
|
if (ctx) {
|
|
2023
2028
|
ctx.restore();
|
|
@@ -2306,6 +2311,72 @@ function Q5(scope, parent) {
|
|
|
2306
2311
|
return $.audioContext.resume();
|
|
2307
2312
|
};
|
|
2308
2313
|
|
|
2314
|
+
// AI
|
|
2315
|
+
|
|
2316
|
+
$.askAI = (q = '') => {
|
|
2317
|
+
throw Error('Ask AI ✨ ' + q);
|
|
2318
|
+
};
|
|
2319
|
+
|
|
2320
|
+
async function aiErrorAssistance(e) {
|
|
2321
|
+
let askAI = e.message.includes('Ask AI ✨');
|
|
2322
|
+
if (!askAI) console.error(e);
|
|
2323
|
+
if (Q5.disableFriendlyErrors) return;
|
|
2324
|
+
if (askAI || !Q5.errorTolerant) noLoop();
|
|
2325
|
+
let stackLines = e.stack.split('\n');
|
|
2326
|
+
if (stackLines.length <= 1) return;
|
|
2327
|
+
|
|
2328
|
+
let idx = 1;
|
|
2329
|
+
let sep = '(';
|
|
2330
|
+
if (navigator.userAgent.indexOf('Chrome') == -1) {
|
|
2331
|
+
idx = 0;
|
|
2332
|
+
sep = '@';
|
|
2333
|
+
}
|
|
2334
|
+
while (stackLines[idx].indexOf('q5.js:') >= 0) idx++;
|
|
2335
|
+
|
|
2336
|
+
let parts = stackLines[idx].split(sep).at(-1);
|
|
2337
|
+
parts = parts.split(':');
|
|
2338
|
+
let lineNum = parseInt(parts.at(-2));
|
|
2339
|
+
if (askAI) lineNum++;
|
|
2340
|
+
let fileUrl = parts.slice(0, -2).join(':');
|
|
2341
|
+
let fileBase = fileUrl.split('/').at(-1);
|
|
2342
|
+
|
|
2343
|
+
try {
|
|
2344
|
+
let res = await (await fetch(fileUrl)).text();
|
|
2345
|
+
let lines = res.split('\n');
|
|
2346
|
+
let errLine = lines[lineNum - 1].trim();
|
|
2347
|
+
|
|
2348
|
+
let context = '';
|
|
2349
|
+
let i = 1;
|
|
2350
|
+
while (context.length < 1600) {
|
|
2351
|
+
if (lineNum - i >= 0) {
|
|
2352
|
+
context = lines[lineNum - i].trim() + '\n' + context;
|
|
2353
|
+
}
|
|
2354
|
+
if (lineNum + i < lines.length) {
|
|
2355
|
+
context += lines[lineNum + i].trim() + '\n';
|
|
2356
|
+
}
|
|
2357
|
+
i++;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
let question =
|
|
2361
|
+
askAI && e.message.length > 10 ? e.message.slice(10) : 'Whats+wrong+with+this+line%3F+short+answer';
|
|
2362
|
+
|
|
2363
|
+
let url =
|
|
2364
|
+
'https://chatgpt.com/?q=q5.js+' +
|
|
2365
|
+
question +
|
|
2366
|
+
(askAI ? '' : '%0A%0A' + encodeURIComponent(e.name + ': ' + e.message)) +
|
|
2367
|
+
'%0A%0ALine%3A+' +
|
|
2368
|
+
encodeURIComponent(errLine) +
|
|
2369
|
+
'%0A%0AExcerpt+for+context%3A%0A%0A' +
|
|
2370
|
+
encodeURIComponent(context);
|
|
2371
|
+
|
|
2372
|
+
if (!askAI) console.log('Error in ' + fileBase + ' on line ' + lineNum + ':\n\n' + errLine);
|
|
2373
|
+
|
|
2374
|
+
console.warn('Ask AI ✨ ' + url);
|
|
2375
|
+
|
|
2376
|
+
if (askAI) window.open(url, '_blank');
|
|
2377
|
+
} catch (err) {}
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2309
2380
|
// INIT
|
|
2310
2381
|
|
|
2311
2382
|
if (scope == 'global') {
|
|
@@ -2349,7 +2420,7 @@ function Q5(scope, parent) {
|
|
|
2349
2420
|
|
|
2350
2421
|
let t = scope == 'global' ? (!Q5._nodejs ? window : global) : $;
|
|
2351
2422
|
let preloadDefined = t.preload;
|
|
2352
|
-
let
|
|
2423
|
+
let userFns = [
|
|
2353
2424
|
'setup',
|
|
2354
2425
|
'draw',
|
|
2355
2426
|
'preload',
|
|
@@ -2366,9 +2437,17 @@ function Q5(scope, parent) {
|
|
|
2366
2437
|
'touchEnded',
|
|
2367
2438
|
'windowResized'
|
|
2368
2439
|
];
|
|
2369
|
-
for (let k of
|
|
2440
|
+
for (let k of userFns) {
|
|
2370
2441
|
if (!t[k]) $[k] = () => {};
|
|
2371
|
-
else if ($._isGlobal)
|
|
2442
|
+
else if ($._isGlobal) {
|
|
2443
|
+
$[k] = () => {
|
|
2444
|
+
try {
|
|
2445
|
+
t[k]();
|
|
2446
|
+
} catch (e) {
|
|
2447
|
+
aiErrorAssistance(e);
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
}
|
|
2372
2451
|
}
|
|
2373
2452
|
|
|
2374
2453
|
$._isTouchAware = $.touchStarted || $.touchMoved || $.mouseReleased;
|
|
@@ -2377,6 +2456,10 @@ function Q5(scope, parent) {
|
|
|
2377
2456
|
window.addEventListener('mousemove', (e) => $._onmousemove(e), false);
|
|
2378
2457
|
window.addEventListener('keydown', (e) => $._onkeydown(e), false);
|
|
2379
2458
|
window.addEventListener('keyup', (e) => $._onkeyup(e), false);
|
|
2459
|
+
window.addEventListener('resize', () => {
|
|
2460
|
+
$._shouldResize = true;
|
|
2461
|
+
if (!$._loop) $.redraw();
|
|
2462
|
+
});
|
|
2380
2463
|
}
|
|
2381
2464
|
|
|
2382
2465
|
if (!($.setup || $.draw)) return;
|
|
@@ -2759,7 +2842,7 @@ if (!window.matchMedia || !matchMedia('(dynamic-range: high) and (color-gamut: p
|
|
|
2759
2842
|
|
|
2760
2843
|
Q5._instanceCount = 0;
|
|
2761
2844
|
Q5._friendlyError = (msg, func) => {
|
|
2762
|
-
throw func + ': ' + msg;
|
|
2845
|
+
throw Error(func + ': ' + msg);
|
|
2763
2846
|
};
|
|
2764
2847
|
Q5._validateParameters = () => true;
|
|
2765
2848
|
|
package/q5.min.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @author quinton-ashley and LingDong-
|
|
5
5
|
* @license LGPL-3.0
|
|
6
6
|
*/
|
|
7
|
-
function Q5(e,t){let a=this;a._q5=!0;let o=0;if(e||(e="global"),"auto"==e){if(!window.setup&&!window.draw)return;e="global"}"global"==e&&(Q5._hasGlobal=a._isGlobal=!0);let n=window.OffscreenCanvas||function(){return document.createElement("canvas")},i=null,r=a.ctx=a.drawingContext=null;if(a.canvas=null,a.pixels=[],a.noCanvas=()=>{a.canvas?.remove&&a.canvas.remove(),a.canvas=0,r=a.ctx=a.drawingContext=0},Q5._nodejs?Q5._createNodeJSCanvas&&(a.canvas=Q5._createNodeJSCanvas(100,100)):"image"!=e&&"graphics"!=e||(a.canvas=new n(100,100)),a.canvas||("object"==typeof document?(a.canvas=document.createElement("canvas"),a.canvas.id="defaultCanvas"+Q5._instanceCount++,a.canvas.classList.add("p5Canvas","q5Canvas")):a.noCanvas()),a.canvas.width=a.width=100,a.canvas.height=a.height=100,a.canvas&&"graphics"!=e&&"image"!=e){function s(){t??=document.getElementsByTagName("main")[0],t||(t=document.createElement("main"),document.body.append(t)),a.canvas.parent(t)}a._setupDone=!1,a._resize=()=>{a.frameCount>1&&(a._shouldResize=!0)},t&&"string"==typeof t&&(t=document.getElementById(t)),a.canvas.parent=e=>{"string"==typeof e&&(e=document.getElementById(e)),e.append(a.canvas),"function"==typeof ResizeObserver?(a._ro&&a._ro.disconnect(),a._ro=new ResizeObserver(a._resize),a._ro.observe(t)):a.frameCount||window.addEventListener("resize",a._resize)},document.body?s():document.addEventListener("DOMContentLoaded",s)}function l(e,t){t??=e||a.canvas.height,e??=a.canvas.width,null==f&&(f=new n(e,t).getContext("2d",{colorSpace:a.canvas.colorSpace})),f.canvas.width==e&&f.canvas.height==t||(f.canvas.width=e,f.canvas.height=t)}function c(){let e=a.canvas.width*a.canvas.height*4;x&&e==x.length||(x=new Uint8ClampedArray(e))}function h(e,t){a._filters||(a._filters=[],a._filters[a.THRESHOLD]=(e,t)=>{void 0===t?t=127.5:t*=255;for(let a=0;a<e.length;a+=4){const o=.2126*e[a]+.7152*e[a+1]+.0722*e[a+2];e[a]=e[a+1]=e[a+2]=o>=t?255:0}},a._filters[a.GRAY]=e=>{for(let t=0;t<e.length;t+=4){const a=.2126*e[t]+.7152*e[t+1]+.0722*e[t+2];e[t]=e[t+1]=e[t+2]=a}},a._filters[a.OPAQUE]=e=>{for(let t=0;t<e.length;t+=4)e[t+3]=255},a._filters[a.INVERT]=e=>{for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]},a._filters[a.POSTERIZE]=(e,t=4)=>{let a=t-1;for(let o=0;o<e.length;o+=4)e[o]=255*(e[o]*t>>8)/a,e[o+1]=255*(e[o+1]*t>>8)/a,e[o+2]=255*(e[o+2]*t>>8)/a},a._filters[a.DILATE]=e=>{c(),x.set(e);let[t,o]=[a.canvas.width,a.canvas.height];for(let a=0;a<o;a++)for(let n=0;n<t;n++){let i=4*Math.max(n-1,0),r=4*Math.min(n+1,t-1),s=4*Math.max(a-1,0)*t,l=4*Math.min(a+1,o-1)*t,c=4*a*t,h=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+c;e[c+h+t]=Math.max(x[a+h],x[n+i],x[n+h],x[n+r],x[o+h])}}},a._filters[a.ERODE]=e=>{c(),x.set(e);let[t,o]=[a.canvas.width,a.canvas.height];for(let a=0;a<o;a++)for(let n=0;n<t;n++){let i=4*Math.max(n-1,0),r=4*Math.min(n+1,t-1),s=4*Math.max(a-1,0)*t,l=4*Math.min(a+1,o-1)*t,c=4*a*t,h=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+c;e[c+h+t]=Math.min(x[a+h],x[n+i],x[n+h],x[n+r],x[o+h])}}},a._filters[a.BLUR]=(e,t)=>{t=t||1,t=Math.floor(t*a._pixelDensity),c(),x.set(e);let o=2*t+1,n=function(e){let a=new Float32Array(e),o=.3*t+.8,n=o*o*2;for(let t=0;t<e;t++){let i=t-e/2,r=Math.exp(-i*i/n)/(2.5066282746*o);a[t]=r}return a}(o),[i,r]=[a.canvas.width,a.canvas.height];for(let a=0;a<r;a++)for(let r=0;r<i;r++){let s=0,l=0,c=0,h=0;for(let e=0;e<o;e++){let o=4*(a*i+Math.min(Math.max(r-t+e,0),i-1));s+=x[o]*n[e],l+=x[o+1]*n[e],c+=x[o+2]*n[e],h+=x[o+3]*n[e]}let d=4*(a*i+r);e[d]=s,e[d+1]=l,e[d+2]=c,e[d+3]=h}x.set(e);for(let a=0;a<r;a++)for(let s=0;s<i;s++){let l=0,c=0,h=0,d=0;for(let e=0;e<o;e++){let o=4*(Math.min(Math.max(a-t+e,0),r-1)*i+s);l+=x[o]*n[e],c+=x[o+1]*n[e],h+=x[o+2]*n[e],d+=x[o+3]*n[e]}let u=4*(a*i+s);e[u]=l,e[u+1]=c,e[u+2]=h,e[u+3]=d}});let o=r.getImageData(0,0,a.canvas.width,a.canvas.height);a._filters[e](o.data,t),r.putImageData(o,0,0)}function d(e){f.clearRect(0,0,f.canvas.width,f.canvas.height),f.filter=e,f.drawImage(a.canvas,0,0),r.save(),r.resetTransform(),r.clearRect(0,0,a.canvas.width,a.canvas.height),r.drawImage(f.canvas,0,0),r.restore()}a.createCanvas=function(t,o,n,i){if("webgl"==n)throw"webgl renderer is not supported in q5, use '2d'";"object"==typeof n&&(i=n),a.width=a.canvas.width=t,a.height=a.canvas.height=o,a.canvas.renderer="2d";let s=Object.assign({},Q5.canvasOptions);if(i&&Object.assign(s,i),r=a.ctx=a.drawingContext=a.canvas.getContext("2d",s),Object.assign(a.canvas,s),"rgb"==a._colorMode&&a.colorMode("rgb"),r.fillStyle="white",r.strokeStyle="black",r.lineCap="round",r.lineJoin="miter",r.textAlign="left",r.save(),"image"!=e){let t=a.displayDensity();"graphics"==e&&(t=this._pixelDensity),a.pixelDensity(Math.ceil(t))}else this._pixelDensity=1;return a.canvas},a._createCanvas=a.createCanvas,a.loadPixels=()=>{i=r.getImageData(0,0,a.canvas.width,a.canvas.height),a.pixels=i.data},a.updatePixels=()=>{null!=i&&r.putImageData(i,0,0)},a.filter=(e,t)=>{if(!r.filter)return h(e,t);if(l(),"string"==typeof e)d(e);else if(e==a.THRESHOLD){t??=.5,t=Math.max(t,1e-5),d(`saturate(0%) brightness(${Math.floor(.5/t*100)}%) contrast(1000000%)`)}else e==a.GRAY?d("saturate(0%)"):e==a.OPAQUE?(f.fillStyle="black",f.fillRect(0,0,f.canvas.width,f.canvas.height),f.drawImage(a.canvas,0,0),r.save(),r.resetTransform(),r.drawImage(f.canvas,0,0),r.restore()):e==a.INVERT?d("invert(100%)"):e==a.BLUR?d(`blur(${Math.ceil(t*a._pixelDensity/1)||1}px)`):h(e,t)},a.resize=(e,t)=>{l(),f.drawImage(a.canvas,0,0),a.width=e,a.height=t,a.canvas.width=e*a._pixelDensity,a.canvas.height=t*a._pixelDensity,r.save(),r.resetTransform(),r.clearRect(0,0,a.canvas.width,a.canvas.height),r.drawImage(f.canvas,0,0,a.canvas.width,a.canvas.height),r.restore()},a.trim=()=>{let e=a._pixelDensity||1,t=r.getImageData(0,0,a.width*e,a.height*e).data,o=a.width,n=0,i=a.height,s=0;for(let r=0;r<a.height*e;r++)for(let l=0;l<a.width*e;l++){0!==t[4*(r*a.width*e+l)+3]&&(l<o&&(o=l),l>n&&(n=l),r<i&&(i=r),r>s&&(s=r))}return i=Math.floor(i/e),s=Math.floor(s/e),o=Math.floor(o/e),n=Math.floor(n/e),a.get(o,i,n-o+1,s-i+1)},a.get=(e,t,o,n)=>{let i=a._pixelDensity||1;if(void 0!==e&&void 0===o){let o=r.getImageData(e*i,t*i,1,1).data;return new a.Color(o[0],o[1],o[2],o[3]/255)}e=(e||0)*i,t=(t||0)*i;let s=o=o||a.width,l=n=n||a.height;o*=i,n*=i;let c=a.createImage(o,n),h=r.getImageData(e,t,o,n);return c.ctx.putImageData(h,0,0),c._pixelDensity=i,c.width=s,c.height=l,c},a.set=(e,t,o)=>{if(o._q5){let n=a._tint;return a._tint=null,a.image(o,e,t),void(a._tint=n)}a.pixels.length||a.loadPixels();let n=a._pixelDensity||1;for(let i=0;i<n;i++)for(let r=0;r<n;r++){let s=4*((t*n+i)*a.canvas.width+e*n+r);a.pixels[s]=o.r??o.l,a.pixels[s+1]=o.g??o.c,a.pixels[s+2]=o.b??o.h,a.pixels[s+3]=o.a}},a.tinted=function(e){let t=e.a;e.a=255,l(),f.clearRect(0,0,f.canvas.width,f.canvas.height),f.fillStyle=e.toString(),f.fillRect(0,0,f.canvas.width,f.canvas.height),f.globalCompositeOperation="multiply",f.drawImage(r.canvas,0,0),f.globalCompositeOperation="source-over",r.save(),r.resetTransform();let a=r.globalCompositeOperation;r.globalCompositeOperation="source-in",r.drawImage(f.canvas,0,0),r.globalCompositeOperation=a,r.restore(),f.globalAlpha=t/255,f.clearRect(0,0,f.canvas.width,f.canvas.height),f.drawImage(r.canvas,0,0),f.globalAlpha=1,r.save(),r.resetTransform(),r.clearRect(0,0,r.canvas.width,r.canvas.height),r.drawImage(f.canvas,0,0),r.restore()},a.tint=function(e){a._tint=e._q5Color?e:a.color(...arguments)},a.noTint=()=>a._tint=null,a.mask=e=>{r.save(),r.resetTransform();let t=r.globalCompositeOperation;r.globalCompositeOperation="destination-in",r.drawImage(e.canvas,0,0),r.globalCompositeOperation=t,r.restore()},a._save=async(e,t,a)=>{if(t=t||"untitled","jpg"==(a=a||"png")||"png"==a||"webp"==a)if(e instanceof OffscreenCanvas){const t=await e.convertToBlob({type:"image/"+a});e=await new Promise((e=>{const a=new FileReader;a.onloadend=()=>e(a.result),a.readAsDataURL(t)}))}else e=e.toDataURL("image/"+a);else{let t="text/plain";"json"==a&&("string"!=typeof e&&(e=JSON.stringify(e)),t="text/json"),e=new Blob([e],{type:t}),e=URL.createObjectURL(e)}let o=document.createElement("a");o.href=e,o.download=t+"."+a,document.body.append(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(o.href)},a.save=(e,t,o)=>{if((!e||"string"==typeof e&&(!t||!o&&t.length<5))&&(o=t,t=e,e=a.canvas),o)return a._save(e,t,o);t?(t=t.split("."),a._save(e,t[0],t.at(-1))):a._save(e)},a.canvas.save=a.save,a.saveCanvas=a.save,a.createImage=(e,t,a)=>new Q5.Image(e,t,a);let u=null,g=!0,_=[],p={},m=0,f=null,v=null,x=null;if(a.THRESHOLD=1,a.GRAY=2,a.OPAQUE=3,a.INVERT=4,a.POSTERIZE=5,a.DILATE=6,a.ERODE=7,a.BLUR=8,"image"==e)return;function y(e,t){a.width=e,a.height=t;let o=function(){let e={};for(let t in r)"function"!=typeof r[t]&&(e[t]=r[t]);return delete e.canvas,e}();a.canvas.width=Math.ceil(e*a._pixelDensity),a.canvas.height=Math.ceil(t*a._pixelDensity),!a.canvas.fullscreen&&a.canvas.style&&(a.canvas.style.width=e+"px",a.canvas.style.height=t+"px");for(let e in o)a.ctx[e]=o[e];r.scale(a._pixelDensity,a._pixelDensity)}a.BLEND="source-over",a.REMOVE="destination-out",a.ADD="lighter",a.DARKEST="darken",a.LIGHTEST="lighten",a.DIFFERENCE="difference",a.SUBTRACT="subtract",a.EXCLUSION="exclusion",a.MULTIPLY="multiply",a.SCREEN="screen",a.REPLACE="copy",a.OVERLAY="overlay",a.HARD_LIGHT="hard-light",a.SOFT_LIGHT="soft-light",a.DODGE="color-dodge",a.BURN="color-burn",a.RGB="rgb",a.RGBA="rgb",a.HSB="hsb",a.CHORD=0,a.PIE=1,a.OPEN=2,a.RADIUS="radius",a.CORNER="corner",a.CORNERS="corners",a.ROUND="round",a.SQUARE="butt",a.PROJECT="square",a.MITER="miter",a.BEVEL="bevel",a.CLOSE=1,a.NORMAL="normal",a.ITALIC="italic",a.BOLD="bold",a.BOLDITALIC="italic bold",a.CENTER="center",a.LEFT="left",a.RIGHT="right",a.TOP="top",a.BOTTOM="bottom",a.BASELINE="alphabetic",a.LANDSCAPE="landscape",a.PORTRAIT="portrait",a.ALT=18,a.BACKSPACE=8,a.CONTROL=17,a.DELETE=46,a.DOWN_ARROW=40,a.ENTER=13,a.ESCAPE=27,a.LEFT_ARROW=37,a.OPTION=18,a.RETURN=13,a.RIGHT_ARROW=39,a.SHIFT=16,a.TAB=9,a.UP_ARROW=38,a.DEGREES="degrees",a.RADIANS="radians",a.HALF_PI=Math.PI/2,a.PI=Math.PI,a.QUARTER_PI=Math.PI/4,a.TAU=2*Math.PI,a.TWO_PI=2*Math.PI,a.ARROW="default",a.CROSS="crosshair",a.HAND="pointer",a.MOVE="move",a.TEXT="text",a.VIDEO={video:!0,audio:!1},a.AUDIO={video:!1,audio:!0},a.SHR3=1,a.LCG=2,a.hint=(e,t)=>{a[e]=t},a.frameCount=0,a.deltaTime=16,a.mouseX=0,a.mouseY=0,a.touches=[],a.mouseButton=null,a.keyIsPressed=!1,a.mouseIsPressed=!1,a.key=null,a.keyCode=null,a.accelerationX=0,a.accelerationY=0,a.accelerationZ=0,a.rotationX=0,a.rotationY=0,a.rotationZ=0,a.relRotationX=0,a.relRotationY=0,a.relRotationZ=0,a.pmouseX=0,a.pmouseY=0,a.pAccelerationX=0,a.pAccelerationY=0,a.pAccelerationZ=0,a.pRotationX=0,a.pRotationY=0,a.pRotationZ=0,a.pRelRotationX=0,a.pRelRotationY=0,a.pRelRotationZ=0,Object.defineProperty(a,"deviceOrientation",{get:()=>window.screen?.orientation?.type}),Object.defineProperty(a,"windowWidth",{get:()=>window.innerWidth}),Object.defineProperty(a,"windowHeight",{get:()=>window.innerHeight}),a._colorMode="rgb",a._doStroke=!0,a._doFill=!0,a._strokeSet=!1,a._fillSet=!1,a._tint=null,a._ellipseMode=a.CENTER,a._rectMode=a.CORNER,a._curveDetail=20,a._curveAlpha=0,a._loop=!0,a._textFont="sans-serif",a._textSize=12,a._textLeading=15,a._textLeadDiff=3,a._textStyle="normal",a._pixelDensity=1,a._targetFrameRate=0,a._targetFrameDuration=16.666666666666668,a._frameRate=a._fps=60,a.resizeCanvas=(e,t)=>{e==a.width&&t==a.height||y(e,t)},a.createGraphics=function(e,t,o){let n=new Q5("graphics");return o??={},o.alpha??=!0,n._createCanvas.call(a,e,t,o),n},a.displayDensity=()=>window.devicePixelRatio,a.pixelDensity=e=>e&&e!=a._pixelDensity?(a._pixelDensity=e,y(a.width,a.height),e):a._pixelDensity,a.fullscreen=e=>{if(void 0===e)return document.fullscreenElement;e?document.body.requestFullscreen():document.body.exitFullscreen()},a.map=(e,t,a,o,n,i)=>{let r=o+1*(e-t)/(a-t)*(n-o);return i?o<n?Math.min(Math.max(r,o),n):Math.min(Math.max(r,n),o):r},a.lerp=(e,t,a)=>e*(1-a)+t*a,a.constrain=(e,t,a)=>Math.min(Math.max(e,t),a),a.dist=function(){let e=arguments;return 4==e.length?Math.hypot(e[0]-e[2],e[1]-e[3]):Math.hypot(e[0]-e[3],e[1]-e[4],e[2]-e[5])},a.norm=(e,t,o)=>a.map(e,t,o,0,1),a.sq=e=>e*e,a.fract=e=>e-Math.floor(e),a.angleMode=e=>a._angleMode=e,a._DEGTORAD=Math.PI/180,a._RADTODEG=180/Math.PI,a.degrees=e=>e*a._RADTODEG,a.radians=e=>e*a._DEGTORAD,a.abs=Math.abs,a.ceil=Math.ceil,a.exp=Math.exp,a.floor=Math.floor,a.log=Math.log,a.mag=Math.hypot,a.max=Math.max,a.min=Math.min,a.round=Math.round,a.pow=Math.pow,a.sqrt=Math.sqrt,a.sin=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.sin(e)),a.cos=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.cos(e)),a.tan=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.tan(e)),a.asin=e=>{let t=Math.asin(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.acos=e=>{let t=Math.acos(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.atan=e=>{let t=Math.atan(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.atan2=(e,t)=>{let o=Math.atan2(e,t);return"degrees"==a._angleMode&&(o=a.degrees(o)),o},a.nf=(e,t,a)=>{let o=e<0,n=(e=Math.abs(e)).toFixed(a).split(".");n[0]=n[0].padStart(t,"0");let i=n.join(".");return o&&(i="-"+i),i},a.createVector=(e,t,o)=>new Q5.Vector(e,t,o,a),a.curvePoint=(e,t,a,o,n)=>{const i=n*n*n,r=n*n;return e*(-.5*i+r-.5*n)+t*(1.5*i-2.5*r+1)+a*(-1.5*i+2*r+.5*n)+o*(.5*i-.5*r)},a.bezierPoint=(e,t,a,o,n)=>{const i=1-n;return Math.pow(i,3)*e+3*Math.pow(i,2)*n*t+3*i*Math.pow(n,2)*a+Math.pow(n,3)*o},a.curveTangent=(e,t,a,o,n)=>{const i=n*n;return e*(-3*i/2+2*n-.5)+t*(9*i/2-5*n)+a*(-9*i/2+4*n+.5)+o*(3*i/2-n)},a.bezierTangent=(e,t,a,o,n)=>{const i=1-n;return 3*o*Math.pow(n,2)-3*a*Math.pow(n,2)+6*a*i*n-6*t*i*n+3*t*Math.pow(i,2)-3*e*Math.pow(i,2)},Q5.supportsHDR?a.Color=Q5.ColorRGBA_P3:a.Color=Q5.ColorRGBA,a.colorMode=e=>{a._colorMode=e,"oklch"==e?a.Color=Q5.ColorOKLCH:"rgb"==e?"srgb"==a.canvas.colorSpace?a.Color=Q5.ColorRGBA:a.Color=Q5.ColorRGBA_P3:"srgb"==e&&(a.Color=Q5.ColorRGBA,a._colorMode="rgb")};let w={aqua:[0,255,255],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],crimson:[220,20,60],darkviolet:[148,0,211],gold:[255,215,0],green:[0,128,0],gray:[128,128,128],grey:[128,128,128],hotpink:[255,105,180],indigo:[75,0,130],khaki:[240,230,140],lightgreen:[144,238,144],lime:[0,255,0],magenta:[255,0,255],navy:[0,0,128],orange:[255,165,0],olive:[128,128,0],peachpuff:[255,218,185],pink:[255,192,203],purple:[128,0,128],red:[255,0,0],skyblue:[135,206,235],tan:[210,180,140],turquoise:[64,224,208],transparent:[0,0,0,0],white:[255,255,255],violet:[238,130,238],yellow:[255,255,0]};function M(e){let t=a._angleMode==a.DEGREES?180:Math.PI,o=2*t;if(0<=e&&e<=o)return e;for(;e<0;)e+=o;for(;e>=t;)e-=o;return e}function R(e,t,o,n,i,s,l,c){if(!a._doFill&&!a._doStroke)return;let h=M(i),d=M(s);if(h>d&&([h,d]=[d,h]),0==h){if(0==d)return;if(a._angleMode==a.DEGREES&&360==d||d==a.TAU)return a.ellipse(e,t,o,n)}r.beginPath();for(let i=0;i<c+1;i++){let s=i/c,l=a.lerp(h,d,s),u=a.cos(l)*o/2,g=a.sin(l)*n/2;r[i?"lineTo":"moveTo"](e+u,t+g)}l==a.CHORD?r.closePath():l==a.PIE&&(r.lineTo(e,t),r.closePath()),a._doFill&&r.fill(),a._doStroke&&r.stroke()}function S(e,t,o,n){(a._doFill||a._doStroke)&&(r.beginPath(),r.ellipse(e,t,o/2,n/2,0,0,a.TAU),a._doFill&&r.fill(),a._doStroke&&r.stroke())}function C(e,t,o,n,i,s,l,c){if(!a._doFill&&!a._doStroke)return;if(void 0===i)return function(e,t,o,n){a._doFill&&r.fillRect(e,t,o,n),a._doStroke&&r.strokeRect(e,t,o,n)}(e,t,o,n);if(void 0===s)return C(e,t,o,n,i,i,i,i);const h=Math.min(Math.abs(n),Math.abs(o))/2;i=Math.min(h,i),s=Math.min(h,s),c=Math.min(h,c),l=Math.min(h,l),r.beginPath(),r.moveTo(e+i,t),r.arcTo(e+o,t,e+o,t+n,s),r.arcTo(e+o,t+n,e,t+n,l),r.arcTo(e,t+n,e,t,c),r.arcTo(e,t,e+o,t,i),r.closePath(),a._doFill&&r.fill(),a._doStroke&&r.stroke()}function b(){_=[]}a.color=function(e,t,o,n){let i=a.Color;if(e._q5Color)return new i(...e.levels);let r=arguments;if(1==r.length){if("string"==typeof e)return"#"==e[0]?new i(parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16),9!=e.length?null:parseInt(e.slice(7,9),16)):w[e]?new i(...w[e]):new i(0,0,0);if(Array.isArray(e))return new i(...e)}if("rgb"==a._colorMode){if(1==r.length)return new i(e,e,e);if(2==r.length)return new i(e,e,e,t);if(3==r.length)return new i(e,t,o);if(4==r.length)return new i(e,t,o,n)}},a.red=e=>e.r,a.green=e=>e.g,a.blue=e=>e.b,a.alpha=e=>e.a,a.lightness=e=>100*(.2126*e.r+.7152*e.g+.0722*e.b)/255,a.lerpColor=(e,t,o)=>{if("rgb"==a._colorMode)return new a.Color(a.constrain(a.lerp(e.r,t.r,o),0,255),a.constrain(a.lerp(e.g,t.g,o),0,255),a.constrain(a.lerp(e.b,t.b,o),0,255),a.constrain(a.lerp(e.a,t.a,o),0,255));{let n=t.h-e.h;n>180&&(n-=360),n<-180&&(n+=360);let i=e.h+o*n;return i<0&&(i+=360),i>360&&(i-=360),new a.Color(a.constrain(a.lerp(e.l,t.l,o),0,100),a.constrain(a.lerp(e.c,t.c,o),0,100),i,a.constrain(a.lerp(e.a,t.a,o),0,255))}},a.strokeWeight=e=>{e||(a._doStroke=!1),r.lineWidth=e||1e-4},a.stroke=function(e){if(a._doStroke=!0,a._strokeSet=!0,e._q5Color||"string"==typeof e||(e=a.color(...arguments)),e.a<=0)return a._doStroke=!1;r.strokeStyle=e.toString()},a.noStroke=()=>a._doStroke=!1,a.fill=function(e){if(a._doFill=!0,a._fillSet=!0,e._q5Color||"string"==typeof e||(e=a.color(...arguments)),e.a<=0)return a._doFill=!1;r.fillStyle=e.toString()},a.noFill=()=>a._doFill=!1,a.smooth=()=>a._smooth=!0,a.noSmooth=()=>a._smooth=!1,a.blendMode=e=>r.globalCompositeOperation=e,a.strokeCap=e=>r.lineCap=e,a.strokeJoin=e=>r.lineJoin=e,a.ellipseMode=e=>a._ellipseMode=e,a.rectMode=e=>a._rectMode=e,a.curveDetail=e=>a._curveDetail=e,a.curveAlpha=e=>a._curveAlpha=e,a.curveTightness=e=>a._curveAlpha=e,a.clear=()=>{r.clearRect(0,0,a.canvas.width,a.canvas.height)},a.background=function(e){if(e._q5)return a.image(e,0,0,a.width,a.height);r.save(),r.resetTransform(),e._q5color||"string"==typeof e||(e=a.color(...arguments)),r.fillStyle=e.toString(),r.fillRect(0,0,a.canvas.width,a.canvas.height),r.restore()},a.line=(e,t,o,n)=>{a._doStroke&&(r.beginPath(),r.moveTo(e,t),r.lineTo(o,n),r.stroke())},a.arc=(e,t,o,n,i,r,s,l=25)=>{if(i==r)return a.ellipse(e,t,o,n);s??=a.PIE,a._ellipseMode==a.CENTER?R(e,t,o,n,i,r,s,l):a._ellipseMode==a.RADIUS?R(e,t,2*o,2*n,i,r,s,l):a._ellipseMode==a.CORNER?R(e+o/2,t+n/2,o,n,i,r,s,l):a._ellipseMode==a.CORNERS&&R((e+o)/2,(t+n)/2,o-e,n-t,i,r,s,l)},a.ellipse=(e,t,o,n)=>{n??=o,a._ellipseMode==a.CENTER?S(e,t,o,n):a._ellipseMode==a.RADIUS?S(e,t,2*o,2*n):a._ellipseMode==a.CORNER?S(e+o/2,t+n/2,o,n):a._ellipseMode==a.CORNERS&&S((e+o)/2,(t+n)/2,o-e,n-t)},a.circle=(e,t,o)=>a.ellipse(e,t,o,o),a.point=(e,t)=>{e.x&&(t=e.y,e=e.x),r.beginPath(),r.ellipse(e,t,.4,.4,0,0,a.TAU),r.stroke()},a.rect=(e,t,o,n,i,r,s,l)=>{a._rectMode==a.CENTER?C(e-o/2,t-n/2,o,n,i,r,s,l):a._rectMode==a.RADIUS?C(e-o,t-n,2*o,2*n,i,r,s,l):a._rectMode==a.CORNER?C(e,t,o,n,i,r,s,l):a._rectMode==a.CORNERS&&C(e,t,o-e,n-t,i,r,s,l)},a.square=(e,t,o,n,i,r,s)=>a.rect(e,t,o,o,n,i,r,s),a.beginShape=()=>{b(),r.beginPath(),g=!0},a.beginContour=()=>{r.closePath(),b(),g=!0},a.endContour=()=>{b(),g=!0},a.vertex=(e,t)=>{b(),g?r.moveTo(e,t):r.lineTo(e,t),g=!1},a.bezierVertex=(e,t,a,o,n,i)=>{b(),r.bezierCurveTo(e,t,a,o,n,i)},a.quadraticVertex=(e,t,a,o)=>{b(),r.quadraticCurveTo(e,t,a,o)},a.bezier=(e,t,o,n,i,r,s,l)=>{a.beginShape(),a.vertex(e,t),a.bezierVertex(o,n,i,r,s,l),a.endShape()},a.triangle=(e,t,o,n,i,r)=>{a.beginShape(),a.vertex(e,t),a.vertex(o,n),a.vertex(i,r),a.endShape(a.CLOSE)},a.quad=(e,t,o,n,i,r,s,l)=>{a.beginShape(),a.vertex(e,t),a.vertex(o,n),a.vertex(i,r),a.vertex(s,l),a.endShape(a.CLOSE)},a.endShape=e=>{b(),e&&r.closePath(),a._doFill&&r.fill(),a._doStroke&&r.stroke()},a.curveVertex=(e,t)=>{if(_.push([e,t]),_.length<4)return;let o=function(e,t,a,o,n,i,r,s,l,c){function h(e,t,a,o,n,i){let r=Math.pow(o-t,2)+Math.pow(n-a,2);return Math.pow(r,.5*i)+e}let d=[],u=h(0,e,t,a,o,c),g=h(u,a,o,n,i,c),_=h(g,n,i,r,s,c);for(let c=0;c<l;c++){let h=u+c/(l-1)*(g-u),p=[(u-h)/(u-0),(h-0)/(u-0),(g-h)/(g-u),(h-u)/(g-u),(_-h)/(_-g),(h-g)/(_-g),(g-h)/(g-0),(h-0)/(g-0),(_-h)/(_-u),(h-u)/(_-u)];for(let e=0;e<p.length;e+=2)isNaN(p[e])&&(p[e]=1,p[e+1]=0),isFinite(p[e])||(p[e]>0?(p[e]=1,p[e+1]=0):(p[e]=0,p[e+1]=1));let m=e*p[0]+a*p[1],f=t*p[0]+o*p[1],v=a*p[2]+n*p[3],x=o*p[2]+i*p[3],y=n*p[4]+r*p[5],w=i*p[4]+s*p[5],M=m*p[6]+v*p[7],R=f*p[6]+x*p[7],S=v*p[8]+y*p[9],C=x*p[8]+w*p[9],b=M*p[2]+S*p[3],D=R*p[2]+C*p[3];d.push([b,D])}return d}(..._[_.length-4],..._[_.length-3],..._[_.length-2],..._[_.length-1],a._curveDetail,a._curveAlpha);for(let e=0;e<o.length;e++)g?r.moveTo(...o[e]):r.lineTo(...o[e]),g=!1},a.curve=(e,t,o,n,i,r,s,l)=>{a.beginShape(),a.curveVertex(e,t),a.curveVertex(o,n),a.curveVertex(i,r),a.curveVertex(s,l),a.endShape()},a.opacity=e=>r.globalAlpha=e,a.translate=(e,t)=>r.translate(e,t),a.rotate=e=>{"degrees"==a._angleMode&&(e=a.radians(e)),r.rotate(e)},a.scale=(e,t)=>{t??=e,r.scale(e,t)},a.applyMatrix=(e,t,a,o,n,i)=>r.transform(e,t,a,o,n,i),a.shearX=e=>r.transform(1,0,a.tan(e),1,0,0),a.shearY=e=>r.transform(1,a.tan(e),0,1,0,0),a.resetMatrix=()=>{r.resetTransform(),r.scale(a._pixelDensity,a._pixelDensity)},a._styleNames=["_doStroke","_doFill","_strokeSet","_fillSet","_tint","_imageMode","_rectMode","_ellipseMode","_textFont","_textLeading","_leadingSet","_textSize","_textAlign","_textBaseline","_textStyle","_textWrap"],a._styles=[],a.push=a.pushMatrix=()=>{r.save();let e={};for(let t of a._styleNames)e[t]=a[t];a._styles.push(e)},a.pop=a.popMatrix=()=>{r.restore();let e=a._styles.pop();for(let t of a._styleNames)a[t]=e[t]},a.imageMode=e=>a._imageMode=e,a.image=(e,t,o,i,s,l=0,c=0,h,d)=>{let u=e._q5?e.canvas:e;var g,_;Q5._createNodeJSCanvas&&(u=u.context.canvas),e._q5&&null!=a._tint&&(g=e.canvas.width,_=e.canvas.height,_??=g||a.canvas.height,g??=a.canvas.width,null==v&&(v=new n(g,_).getContext("2d",{colorSpace:a.canvas.colorSpace})),v.canvas.width==g&&v.canvas.height==_||(v.canvas.width=g,v.canvas.height=_),v.drawImage(e.canvas,0,0),e.tinted(a._tint)),i??=e.width||e.videoWidth,s??=e.height||e.videoHeight,"center"==a._imageMode&&(t-=.5*i,o-=.5*s);let p=e._pixelDensity||1;h?h*=p:h=u.width||u.videoWidth,d?d*=p:d=u.height||u.videoHeight,r.drawImage(u,l*p,c*p,h,d,t,o,i,s),function(){if(!e._q5||!a._tint)return;let t=e.ctx;t.save(),t.resetTransform(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(v.canvas,0,0),t.restore()}()},a._incrementPreload=()=>o++,a._decrementPreload=()=>o--,a.loadImage=function(e,t,n){o++;let i=[...arguments].at(-1);n="object"!=typeof i||i;let r=a.createImage(1,1,n.alpha),s=r.ctx;if(Q5._nodejs&&global.CairoCanvas)CairoCanvas.loadImage(e).then((e=>{r.width=s.canvas.width=e.width,r.height=s.canvas.height=e.height,s.drawImage(e,0,0),o--,t&&t(r)})).catch((e=>{throw o--,e}));else{let a=new window.Image;a.src=e,a.crossOrigin="Anonymous",a._pixelDensity=1,a.onload=()=>{r.width=s.canvas.width=a.naturalWidth,r.height=s.canvas.height=a.naturalHeight,s.drawImage(a,0,0),o--,t&&t(r)},a.onerror=e=>{throw o--,e}}return r},a._clearTemporaryBuffers=()=>{f=null,v=null,x=null},a.loadFont=(e,t)=>{o++;let a=e.split("/"),n=a[a.length-1].split(".")[0].replace(" ",""),i=new FontFace(n,"url("+e+")");return document.fonts.add(i),i.load().then((()=>{o--,t&&t(n)})),n},a.textFont=e=>a._textFont=e,a.textSize=e=>{if(void 0===e)return a._textSize;a._textSize=e,a._leadingSet||(a._textLeading=1.25*e,a._textLeadDiff=a._textLeading-e)},a.textLeading=e=>{if(void 0===e)return a._textLeading;a._textLeading=e,a._textLeadDiff=e-a._textSize,a._leadingSet=!0},a.textStyle=e=>a._textStyle=e,a.textAlign=(e,t)=>{r.textAlign=e,t&&(r.textBaseline=t==a.CENTER?"middle":t)},a.textWidth=e=>(r.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,r.measureText(e).width),a.textAscent=e=>(r.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,r.measureText(e).actualBoundingBoxAscent),a.textDescent=e=>(r.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,r.measureText(e).actualBoundingBoxDescent),a._textCache=!0,a._TimedCache=class extends Map{constructor(){super(),this.maxSize=500}set(e,t){t.lastAccessed=Date.now(),super.set(e,t),this.size>this.maxSize&&this.gc()}get(e){const t=super.get(e);return t&&(t.lastAccessed=Date.now()),t}gc(){let e,t=1/0,a=0;for(const[o,n]of this.entries())n.lastAccessed<t&&(t=n.lastAccessed,e=a),a++;a=e;for(const t of this.keys()){if(0==a){e=t;break}a--}this.delete(e)}},a._tic=new a._TimedCache,a.textCache=(e,t)=>(t&&(a._tic.maxSize=t),void 0!==e&&(a._textCache=e),a._textCache),a._genTextImageKey=(e,t,o)=>e.slice(0,200)+a._textStyle+a._textSize+a._textFont+(a._doFill?r.fillStyle:"")+"_"+(a._doStroke&&a._strokeSet?r.lineWidth+r.strokeStyle+"_":"")+(t||"")+(o?"x"+o:""),a.createTextImage=(e,t,o)=>{let n=a._textCache;a._textCache=!0,a._genTextImage=!0,a.text(e,0,0,t,o),a._genTextImage=!1;let i=a._genTextImageKey(e,t,o);return a._textCache=n,a._tic.get(i)},a.text=(e,t,o,n,i)=>{if(void 0===e)return;if(e=e.toString(),!a._doFill&&!a._doStroke)return;let s,l,c,h,d,u,g,_,p=1,m=r.getTransform(),f=a._genTextImage||a._textCache&&(0!=m.b||0!=m.c);if(f){if(h=a._genTextImageKey(e,n,i),l=a._tic.get(h),l&&!a._genTextImage)return void a.textImage(l,t,o);c=a.createGraphics.call(a,1,1),s=c.ctx,p=a._pixelDensity}else s=r,d=t,u=o;s.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`;let v=e.split("\n");if(f){d=0,u=a._textLeading*v.length;let t=s.measureText(" ");g=t.fontBoundingBoxAscent,_=t.fontBoundingBoxDescent,i??=u+_,c.resizeCanvas(Math.ceil(s.measureText(e).width),Math.ceil(i)),s.fillStyle=r.fillStyle,s.strokeStyle=r.strokeStyle,s.lineWidth=r.lineWidth}let x=s.fillStyle;a._fillSet||(s.fillStyle="black");for(let e=0;e<v.length&&(a._doStroke&&a._strokeSet&&s.strokeText(v[e],d,u),a._doFill&&s.fillText(v[e],d,u),u+=a._textLeading,!(u>i));e++);a._fillSet||(s.fillStyle=x),f&&(l=c.get(),l._ascent=g,l._descent=_,a._tic.set(h,l),a._genTextImage||a.textImage(l,t,o))},a.textImage=(e,t,o)=>{let n=a._imageMode;a._imageMode="corner","center"==r.textAlign?t-=.5*e.width:"right"==r.textAlign&&(t-=e.width),"alphabetic"==r.textBaseline&&(o-=a._textLeading),"middle"==r.textBaseline?o-=e._descent+.5*e._ascent+a._textLeadDiff:"bottom"==r.textBaseline?o-=e._ascent+e._descent+a._textLeadDiff:"top"==r.textBaseline&&(o-=e._descent+a._textLeadDiff),a.image(e,t,o),a._imageMode=n};var D,I=4095,E=4,T=.5,A=e=>.5*(1-Math.cos(e*Math.PI));a.noise=(e=0,t=0,a)=>{if(null==D){D=new Array(4096);for(var o=0;o<4096;o++)D[o]=Math.random()}e<0&&(e=-e),t<0&&(t=-t),a<0&&(a=-a);for(var n,i,r,s,l,c=Math.floor(e),h=Math.floor(t),d=Math.floor(a),u=e-c,g=t-h,_=a-d,p=0,m=.5,f=0;f<E;f++){var v=c+(h<<4)+(d<<8);n=A(u),i=A(g),r=D[v&I],r+=n*(D[v+1&I]-r),s=D[v+16&I],r+=i*((s+=n*(D[v+16+1&I]-s))-r),s=D[(v+=256)&I],s+=n*(D[v+1&I]-s),l=D[v+16&I],s+=i*((l+=n*(D[v+16+1&I]-l))-s),p+=(r+=A(_)*(s-r))*m,m*=T,c<<=1,h<<=1,d<<=1,(u*=2)>=1&&(c++,u--),(g*=2)>=1&&(h++,g--),(_*=2)>=1&&(d++,_--)}return p},a.noiseDetail=(e,t)=>{e>0&&(E=e),t>0&&(T=t)};const O=()=>{let e,t,a=4294967295;return{setSeed(o){e=t=(o??Math.random()*a)>>>0},getSeed:()=>t,rand:()=>(e^=e<<17,e^=e>>13,e^=e<<5,(e>>>0)/a)}};let P=O();P.setSeed(),a.noiseSeed=e=>{let t=void 0===e?4294967295*Math.random():e;D||(D=new Float32Array(4096));for(var a=0;a<4096;a++)t^=t<<17,t^=t>>13,t^=t<<5,D[a]=(t>>>0)/4294967295},a.randomSeed=e=>P.setSeed(e),a.random=(e,t)=>void 0===e?P.rand():"number"==typeof e?void 0!==t?P.rand()*(t-e)+e:P.rand()*e:e[Math.trunc(e.length*P.rand())],a.randomGenerator=e=>{e==a.LCG?P=(()=>{const e=4294967296;let t,a;return{setSeed(o){a=t=(o??Math.random()*e)>>>0},getSeed:()=>t,rand:()=>(a=(1664525*a+1013904223)%e,a/e)}})():e==a.SHR3&&(P=O()),P.setSeed()};var k=new function(){var e,t,a,o=new Array(128),n=new Array(256),i=new Array(128),r=new Array(128),s=new Array(256),l=new Array(256),c=()=>4294967296*P.rand()-2147483648,h=()=>.5+2.328306e-10*(c()|0),d=()=>{for(var t,n,s,l,d=3.44262;;){if(t=a*i[e],0==e){do{s=h(),l=h(),t=.2904764*-Math.log(s),n=-Math.log(l)}while(n+n<t*t);return a>0?d+t:-d-t}if(r[e]+h()*(r[e-1]-r[e])<Math.exp(-.5*t*t))return t;if(a=c(),e=127&a,Math.abs(a)<o[e])return a*i[e]}},u=()=>{for(var a;;){if(0==e)return 7.69711-Math.log(h());if(a=t*s[e],l[e]+h()*(l[e-1]-l[e])<Math.exp(-a))return a;if((t=c())<n[e=255&t])return t*s[e]}};this.SHR3=c,this.UNI=h,this.RNOR=()=>(a=c(),e=127&a,Math.abs(a)<o[e]?a*i[e]:d()),this.REXP=()=>(t=c()>>>0)<o[e=255&t]?t*s[e]:u(),this.zigset=()=>{var e,t,a=2147483648,c=4294967296,h=3.442619855899,d=h,u=.00991256303526217,g=7.697117470131487,_=g,p=.003949659822581572;for(e=u/Math.exp(-.5*h*h),o[0]=Math.floor(h/e*a),o[1]=0,i[0]=e/a,i[127]=h/a,r[0]=1,r[127]=Math.exp(-.5*h*h),t=126;t>=1;t--)h=Math.sqrt(-2*Math.log(u/h+Math.exp(-.5*h*h))),o[t+1]=Math.floor(h/d*a),d=h,r[t]=Math.exp(-.5*h*h),i[t]=h/a;for(e=p/Math.exp(-g),n[0]=Math.floor(g/e*c),n[1]=0,s[0]=e/c,s[255]=g/c,l[0]=1,l[255]=Math.exp(-g),t=254;t>=1;t--)g=-Math.log(p/g+Math.exp(-g)),n[t+1]=Math.floor(g/_*c),_=g,l[t]=Math.exp(-g),s[t]=g/c}};function z(e){let t=e||performance.now();if(a._lastFrameTime??=t-a._targetFrameDuration,a._loop)u=L(z);else if(a.frameCount&&!a._redraw)return;if(u&&a.frameCount){if(t-a._lastFrameTime<a._targetFrameDuration-1)return}a.deltaTime=t-a._lastFrameTime,a._frameRate=1e3/a.deltaTime,a.frameCount++,a._shouldResize&&(a.windowResized(),a._shouldResize=!1);let o=performance.now();for(let e of Q5.prototype._methods.pre)e.call(a);b(),g=!0,r&&r.save();try{a.draw()}catch(e){console.error(e)}for(let e of Q5.prototype._methods.post)e.call(a);r&&(r.restore(),a.resetMatrix()),a.pmouseX=a.mouseX,a.pmouseY=a.mouseY,a._lastFrameTime=t;let n=performance.now();a._fps=Math.round(1e3/(n-o))}function Q(e){const t=a.canvas.getBoundingClientRect(),o=a.canvas.scrollWidth/a.width||1,n=a.canvas.scrollHeight/a.height||1;return{x:(e.clientX-t.left)/o,y:(e.clientY-t.top)/n,id:e.identifier}}k.hasInit=!1,a.randomGaussian=(e,t)=>(k.hasInit||(k.zigset(),k.hasInit=!0),k.RNOR()*t+e),a.randomExponential=()=>(k.hasInit||(k.zigset(),k.hasInit=!0),k.REXP()),a.Element=function(e){this.elt=e},a._elements=[],a.createCapture=e=>{var t=document.createElement("video");return t.playsinline="playsinline",t.autoplay="autoplay",navigator.mediaDevices.getUserMedia(e).then((e=>{t.srcObject=e})),t.style.position="absolute",t.style.opacity=1e-5,t.style.zIndex=-1e3,document.body.append(t),t},a.print=console.log,a.describe=()=>{},a.noLoop=()=>{a._loop=!1,u=null},a.loop=()=>{a._loop=!0,null==u&&z()},a.redraw=(e=1)=>{a._redraw=!0;for(let t=0;t<e;t++)z();a._redraw=!1},a.remove=()=>{a.noLoop(),a.canvas.remove()},a.frameRate=e=>(e&&(a._targetFrameRate=e,a._targetFrameDuration=1e3/e),a._frameRate),a.getTargetFrameRate=()=>a._targetFrameRate,a.getFPS=()=>a._fps,"object"==typeof localStorage&&(a.storeItem=localStorage.setItem,a.getItem=localStorage.getItem,a.removeItem=localStorage.removeItem,a.clearStorage=localStorage.clear),a._updateMouse=e=>{if(e.changedTouches)return;let t=a.canvas.getBoundingClientRect(),o=a.canvas.scrollWidth/a.width||1,n=a.canvas.scrollHeight/a.height||1;a.mouseX=(e.clientX-t.left)/o,a.mouseY=(e.clientY-t.top)/n},a._onmousedown=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a.mouseButton=[a.LEFT,a.CENTER,a.RIGHT][e.button],a.mousePressed(e)},a._onmousemove=e=>{a._updateMouse(e),a.mouseIsPressed?a.mouseDragged(e):a.mouseMoved(e)},a._onmouseup=e=>{a._updateMouse(e),a.mouseIsPressed=!1,a.mouseReleased(e)},a._onclick=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a.mouseClicked(e),a.mouseIsPressed=!1},a.cursor=(e,t,o)=>{let n="";e.includes(".")&&(e=`url("${e}")`,n=", auto"),void 0!==t&&(e+=" "+t+" "+o),a.canvas.style.cursor=e+n},a.noCursor=()=>{a.canvas.style.cursor="none"},a._onkeydown=e=>{e.repeat||(a.keyIsPressed=!0,a.key=e.key,a.keyCode=e.keyCode,p[a.keyCode]=!0,a.keyPressed(e),1==e.key.length&&a.keyTyped(e))},a._onkeyup=e=>{a.keyIsPressed=!1,a.key=e.key,a.keyCode=e.keyCode,p[a.keyCode]=!1,a.keyReleased(e)},a._ontouchstart=e=>{a.touches=[...e.touches].map(Q),a._isTouchAware||(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseIsPressed=!0,a.mouseButton=a.LEFT,a.mousePressed(e)||e.preventDefault()),a.touchStarted(e)||e.preventDefault(),"running"!=a.getAudioContext()?.state&&a.userStartAudio()},a._ontouchmove=e=>{a.touches=[...e.touches].map(Q),a._isTouchAware||(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseDragged(e)||e.preventDefault()),a.touchMoved(e)||e.preventDefault()},a._ontouchend=e=>{a.touches=[...e.touches].map(Q),a._isTouchAware||a.touches.length||(a.mouseIsPressed=!1,a.mouseReleased(e)||e.preventDefault()),a.touchEnded(e)||e.preventDefault()},"graphics"!=e&&(a.keyIsDown=e=>!!p[e],a.canvas.onmousedown=e=>a._onmousedown(e),a.canvas.onmouseup=e=>a._onmouseup(e),a.canvas.onclick=e=>a._onclick(e),a.canvas.ontouchstart=e=>a._ontouchstart(e),a.canvas.ontouchmove=e=>a._ontouchmove(e),a.canvas.ontouchcancel=a.canvas.ontouchend=e=>a._ontouchend(e)),a.hasSensorPermission=!window.DeviceOrientationEvent&&!window.DeviceMotionEvent||!(DeviceOrientationEvent.requestPermission||DeviceMotionEvent.requestPermission),a.requestSensorPermissions=()=>{DeviceOrientationEvent.requestPermission&&DeviceOrientationEvent.requestPermission().then((e=>{"granted"==e&&DeviceMotionEvent.requestPermission&&DeviceMotionEvent.requestPermission().then((e=>{"granted"==e&&(a.hasSensorPermission=!0)})).catch(alert)})).catch(alert)};window.ondeviceorientation=e=>{a.pRotationX=a.rotationX,a.pRotationY=a.rotationY,a.pRotationZ=a.rotationZ,a.pRelRotationX=a.relRotationX,a.pRelRotationY=a.relRotationY,a.pRelRotationZ=a.relRotationZ,a.rotationX=e.beta*(Math.PI/180),a.rotationY=e.gamma*(Math.PI/180),a.rotationZ=e.alpha*(Math.PI/180),a.relRotationX=[-a.rotationY,-a.rotationX,a.rotationY][Math.trunc(window.orientation/90)+1],a.relRotationY=[-a.rotationX,a.rotationY,a.rotationX][Math.trunc(window.orientation/90)+1],a.relRotationZ=a.rotationZ},window.ondevicemotion=e=>{if(a.pAccelerationX=a.accelerationX,a.pAccelerationY=a.accelerationY,a.pAccelerationZ=a.accelerationZ,!e.acceleration){let i=((e,t)=>[(e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]),(e[4]*t[0]+e[5]*t[1]+e[6]*t[2]+e[7])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]),(e[8]*t[0]+e[9]*t[1]+e[10]*t[2]+e[11])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15])])((n=a.rotationY,t=[a.cos(n),0,a.sin(n),0,0,1,0,0,-a.sin(n),0,a.cos(n),0,0,0,0,1],o=(e=>[1,0,0,0,0,a.cos(e),-a.sin(e),0,0,a.sin(e),a.cos(e),0,0,0,0,1])(a.rotationX),[t[0]*o[0]+t[1]*o[4]+t[2]*o[8]+t[3]*o[12],t[0]*o[1]+t[1]*o[5]+t[2]*o[9]+t[3]*o[13],t[0]*o[2]+t[1]*o[6]+t[2]*o[10]+t[3]*o[14],t[0]*o[3]+t[1]*o[7]+t[2]*o[11]+t[3]*o[15],t[4]*o[0]+t[5]*o[4]+t[6]*o[8]+t[7]*o[12],t[4]*o[1]+t[5]*o[5]+t[6]*o[9]+t[7]*o[13],t[4]*o[2]+t[5]*o[6]+t[6]*o[10]+t[7]*o[14],t[4]*o[3]+t[5]*o[7]+t[6]*o[11]+t[7]*o[15],t[8]*o[0]+t[9]*o[4]+t[10]*o[8]+t[11]*o[12],t[8]*o[1]+t[9]*o[5]+t[10]*o[9]+t[11]*o[13],t[8]*o[2]+t[9]*o[6]+t[10]*o[10]+t[11]*o[14],t[8]*o[3]+t[9]*o[7]+t[10]*o[11]+t[11]*o[15],t[12]*o[0]+t[13]*o[4]+t[14]*o[8]+t[15]*o[12],t[12]*o[1]+t[13]*o[5]+t[14]*o[9]+t[15]*o[13],t[12]*o[2]+t[13]*o[6]+t[14]*o[10]+t[15]*o[14],t[12]*o[3]+t[13]*o[7]+t[14]*o[11]+t[15]*o[15]]),[0,0,-9.80665]);a.accelerationX=e.accelerationIncludingGravity.x+i[0],a.accelerationY=e.accelerationIncludingGravity.y+i[1],a.accelerationZ=e.accelerationIncludingGravity.z-i[2]}var t,o,n},a.year=()=>(new Date).getFullYear(),a.day=()=>(new Date).getDay(),a.hour=()=>(new Date).getHours(),a.minute=()=>(new Date).getMinutes(),a.second=()=>(new Date).getSeconds(),a.millis=()=>performance.now()-m,a._loadFile=(e,t,a)=>{o++;let n={};return fetch(e).then((e=>"json"==a?e.json():"text"==a?e.text():void 0)).then((e=>{o--,Object.assign(n,e),t&&t(e)})),n},a.loadStrings=(e,t)=>a._loadFile(e,t,"text"),a.loadJSON=(e,t)=>a._loadFile(e,t,"json"),a.loadSound=(e,t)=>{o++;let a=new Audio(e);return a.addEventListener("canplaythrough",(()=>{o--,t&&t(a)})),a.load(),a.setVolume=e=>a.volume=e,a.setLoop=e=>a.loop=e,a},a.getAudioContext=()=>a.audioContext,a.userStartAudio=()=>(a.audioContext??=new window.AudioContext,a.audioContext.resume()),"global"==e&&(Object.assign(Q5,a),delete Q5.Q5),Q5.Image??=_Q5Image;for(let $ of Q5.prototype._methods.init)$.call(a);for(let[G,V]of Object.entries(Q5.prototype))"_"!=G[0]&&"function"==typeof a[G]&&(a[G]=V.bind(a));if("global"==e){let Y=Object.getOwnPropertyNames(a),j=Q5._nodejs?global:window;for(let H of Y)"function"==typeof a[H]?j[H]=a[H]:Object.defineProperty(j,H,{get:()=>a[H],set:e=>a[H]=e})}if("function"==typeof e&&e(a),"image"==e||"graphics"==e)return;let L=window.requestAnimationFrame||function(e){const t=a._lastFrameTime+a._targetFrameDuration;return setTimeout((()=>{e(t)}),t-performance.now())},F="global"==e?Q5._nodejs?global:window:a,N=F.preload,q=["setup","draw","preload","mouseMoved","mousePressed","mouseReleased","mouseDragged","mouseClicked","keyPressed","keyReleased","keyTyped","touchStarted","touchMoved","touchEnded","windowResized"];for(let U of q)F[U]?a._isGlobal&&(a[U]=F[U]):a[U]=()=>{};function B(){if(a._startDone=!0,o>0)return L(B);m=performance.now(),a.setup(),a.frameCount||(null===r&&a.createCanvas(100,100),a._setupDone=!0,r&&a.resetMatrix(),L(z))}a._isTouchAware=a.touchStarted||a.touchMoved||a.mouseReleased,window&&"graphics"!=e&&(window.addEventListener("mousemove",(e=>a._onmousemove(e)),!1),window.addEventListener("keydown",(e=>a._onkeydown(e)),!1),window.addEventListener("keyup",(e=>a._onkeyup(e)),!1)),(a.setup||a.draw)&&(a._startDone=!1,arguments.length&&"namespace"!=e||N?(a.preload(),B()):(F.preload=a.preload=()=>{a._startDone||B()},setTimeout(a.preload,32)))}Q5.Color=class{constructor(){this._q5Color=!0}},Q5.ColorOKLCH=class extends Q5.Color{constructor(e,t,a,o){super(),this.l=e,this.c=t,this.h=a,this.a=o??1}toString(){return`color(oklch ${this.l} ${this.c} ${this.h} / ${this.a})`}},Q5.ColorRGBA=class extends Q5.Color{constructor(e,t,a,o){super(),this.r=e,this.g=t,this.b=a,this.a=o??255}setRed(e){this.r=e}setGreen(e){this.g=e}setBlue(e){this.b=e}setAlpha(e){this.a=e}get levels(){return[this.r,this.g,this.b,this.a]}toString(){return`rgb(${this.r} ${this.g} ${this.b} / ${this.a/255})`}},Q5.ColorRGBA_P3=class extends Q5.ColorRGBA{constructor(e,t,a,o){super(e,t,a,o),this._edited=!0}get r(){return this._r}set r(e){this._r=e,this._edited=!0}get g(){return this._g}set g(e){this._g=e,this._edited=!0}get b(){return this._b}set b(e){this._b=e,this._edited=!0}get a(){return this._a}set a(e){this._a=e,this._edited=!0}toString(){if(this._edited){let e=(this._r/255).toFixed(3),t=(this._g/255).toFixed(3),a=(this._b/255).toFixed(3),o=(this._a/255).toFixed(3);this._css=`color(display-p3 ${e} ${t} ${a} / ${o})`,this._edited=!1}return this._css}},Q5.Vector=class{constructor(e,t,a,o){this.x=e||0,this.y=t||0,this.z=a||0,this._$=o||window,this._cn=null,this._cnsq=null}set(e,t,a){this.x=e||0,this.y=t||0,this.z=a||0}copy(){return new Q5.Vector(this.x,this.y,this.z)}_arg2v(e,t,a){return void 0!==e.x?e:void 0!==t?{x:e,y:t,z:a||0}:{x:e,y:e,z:e}}_calcNorm(){this._cnsq=this.x*this.x+this.y*this.y+this.z*this.z,this._cn=Math.sqrt(this._cnsq)}add(){let e=this._arg2v(...arguments);return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}rem(){let e=this._arg2v(...arguments);return this.x%=e.x,this.y%=e.y,this.z%=e.z,this}sub(){let e=this._arg2v(...arguments);return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}mult(){let e=this._arg2v(...arguments);return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}div(){let e=this._arg2v(...arguments);return e.x?this.x/=e.x:this.x=0,e.y?this.y/=e.y:this.y=0,e.z?this.z/=e.z:this.z=0,this}mag(){return this._calcNorm(),this._cn}magSq(){return this._calcNorm(),this._cnsq}dot(){let e=this._arg2v(...arguments);return this.x*e.x+this.y*e.y+this.z*e.z}dist(){let e=this._arg2v(...arguments),t=this.x-e.x,a=this.y-e.y,o=this.z-e.z;return Math.sqrt(t*t+a*a+o*o)}cross(){let e=this._arg2v(...arguments),t=this.y*e.z-this.z*e.y,a=this.z*e.x-this.x*e.z,o=this.x*e.y-this.y*e.x;return this.x=t,this.y=a,this.z=o,this}normalize(){this._calcNorm();let e=this._cn;return 0!=e&&(this.x/=e,this.y/=e,this.z/=e),this._cn=1,this._cnsq=1,this}limit(e){this._calcNorm();let t=this._cn;if(t>e){let a=e/t;this.x*=a,this.y*=a,this.z*=a,this._cn=e,this._cnsq=e*e}return this}setMag(e){this._calcNorm();let t=e/this._cn;return this.x*=t,this.y*=t,this.z*=t,this._cn=e,this._cnsq=e*e,this}heading(){return this._$.atan2(this.y,this.x)}rotate(e){let t=this._$.cos(e),a=this._$.sin(e),o=this.x*t-this.y*a,n=this.x*a+this.y*t;return this.x=o,this.y=n,this}angleBetween(){let e=this._arg2v(...arguments),t=Q5.Vector.cross(this,e);return this._$.atan2(t.mag(),this.dot(e))*Math.sign(t.z||1)}lerp(){let e=[...arguments],t=this._arg2v(...e.slice(0,-1)),a=e[e.length-1];return this.x+=(t.x-this.x)*a,this.y+=(t.y-this.y)*a,this.z+=(t.z-this.z)*a,this}reflect(e){return e.normalize(),this.sub(e.mult(2*this.dot(e)))}array(){return[this.x,this.y,this.z]}equals(e,t){return t??=Number.EPSILON||0,Math.abs(e.x-this.x)<t&&Math.abs(e.y-this.y)<t&&Math.abs(e.z-this.z)<t}fromAngle(e,t){return void 0===t&&(t=1),this._cn=t,this._cnsq=t*t,this.x=t*this._$.cos(e),this.y=t*this._$.sin(e),this.z=0,this}fromAngles(e,t,a){void 0===a&&(a=1),this._cn=a,this._cnsq=a*a;const o=this._$.cos(t),n=this._$.sin(t),i=this._$.cos(e),r=this._$.sin(e);return this.x=a*r*n,this.y=-a*i,this.z=a*r*o,this}random2D(){return this._cn=this._cnsq=1,this.fromAngle(Math.random()*Math.PI*2)}random3D(){return this._cn=this._cnsq=1,this.fromAngles(Math.random()*Math.PI*2,Math.random()*Math.PI*2)}toString(){return`[${this.x}, ${this.y}, ${this.z}]`}},Q5.Vector.add=(e,t)=>e.copy().add(t),Q5.Vector.cross=(e,t)=>e.copy().cross(t),Q5.Vector.dist=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y,e.z-t.z),Q5.Vector.div=(e,t)=>e.copy().div(t),Q5.Vector.dot=(e,t)=>e.copy().dot(t),Q5.Vector.equals=(e,t,a)=>e.equals(t,a),Q5.Vector.lerp=(e,t,a)=>e.copy().lerp(t,a),Q5.Vector.limit=(e,t)=>e.copy().limit(t),Q5.Vector.heading=e=>this._$.atan2(e.y,e.x),Q5.Vector.magSq=e=>e.x*e.x+e.y*e.y+e.z*e.z,Q5.Vector.mag=e=>Math.sqrt(Q5.Vector.magSq(e)),Q5.Vector.mult=(e,t)=>e.copy().mult(t),Q5.Vector.normalize=e=>e.copy().normalize(),Q5.Vector.rem=(e,t)=>e.copy().rem(t),Q5.Vector.sub=(e,t)=>e.copy().sub(t);for(let e of["fromAngle","fromAngles","random2D","random3D"])Q5.Vector[e]=(t,a,o)=>(new Q5.Vector)[e](t,a,o);class _Q5Image extends Q5{constructor(e,t,a){super("image"),delete this.createCanvas,a??={},a.alpha??=!0,this._createCanvas(e,t,"2d",a),this._loop=!1}get w(){return this.width}get h(){return this.height}}"object"!=typeof window&&(window=0),Q5._nodejs="object"==typeof process,Q5.canvasOptions={alpha:!1,desynchronized:!1,colorSpace:"display-p3"},window.matchMedia&&matchMedia("(dynamic-range: high) and (color-gamut: p3)").matches?Q5.supportsHDR=!0:Q5.canvasOptions.colorSpace="srgb",Q5._instanceCount=0,Q5._friendlyError=(e,t)=>{throw t+": "+e},Q5._validateParameters=()=>!0,Q5.prototype._methods={init:[],pre:[],post:[],remove:[]},Q5.prototype.registerMethod=(e,t)=>Q5.prototype._methods[e].push(t),Q5.prototype.registerPreloadMethod=(e,t)=>Q5.prototype[e]=t[e],"object"==typeof module?(global.p5??=Q5,module.exports=global.Q5=Q5):(window.p5??=Q5,window.Q5=Q5),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{Q5._hasGlobal||new Q5("auto")}));
|
|
7
|
+
function Q5(e,t){let a=this;a._q5=!0;let o=0;if(e||(e="global"),"auto"==e){if(!window.setup&&!window.draw)return;e="global"}"global"==e&&(Q5._hasGlobal=a._isGlobal=!0);let n=window.OffscreenCanvas||function(){return document.createElement("canvas")},r=null,i=a.ctx=a.drawingContext=null;if(a.canvas=null,a.pixels=[],a.noCanvas=()=>{a.canvas?.remove&&a.canvas.remove(),a.canvas=0,i=a.ctx=a.drawingContext=0},Q5._nodejs?Q5._createNodeJSCanvas&&(a.canvas=Q5._createNodeJSCanvas(100,100)):"image"!=e&&"graphics"!=e||(a.canvas=new n(100,100)),a.canvas||("object"==typeof document?(a.canvas=document.createElement("canvas"),a.canvas.id="defaultCanvas"+Q5._instanceCount++,a.canvas.classList.add("p5Canvas","q5Canvas")):a.noCanvas()),a.canvas.width=a.width=100,a.canvas.height=a.height=100,a.canvas&&"graphics"!=e&&"image"!=e){function s(){t??=document.getElementsByTagName("main")[0],t||(t=document.createElement("main"),document.body.append(t)),a.canvas.parent(t)}a._setupDone=!1,a._resize=()=>{a.frameCount>1&&(a._shouldResize=!0)},t&&"string"==typeof t&&(t=document.getElementById(t)),a.canvas.parent=e=>{"string"==typeof e&&(e=document.getElementById(e)),e.append(a.canvas),"function"==typeof ResizeObserver?(a._ro&&a._ro.disconnect(),a._ro=new ResizeObserver(a._resize),a._ro.observe(t)):a.frameCount||window.addEventListener("resize",a._resize)},document.body?s():document.addEventListener("DOMContentLoaded",s)}function l(e,t){t??=e||a.canvas.height,e??=a.canvas.width,null==f&&(f=new n(e,t).getContext("2d",{colorSpace:a.canvas.colorSpace})),f.canvas.width==e&&f.canvas.height==t||(f.canvas.width=e,f.canvas.height=t)}function c(){let e=a.canvas.width*a.canvas.height*4;x&&e==x.length||(x=new Uint8ClampedArray(e))}function h(e,t){a._filters||(a._filters=[],a._filters[a.THRESHOLD]=(e,t)=>{void 0===t?t=127.5:t*=255;for(let a=0;a<e.length;a+=4){const o=.2126*e[a]+.7152*e[a+1]+.0722*e[a+2];e[a]=e[a+1]=e[a+2]=o>=t?255:0}},a._filters[a.GRAY]=e=>{for(let t=0;t<e.length;t+=4){const a=.2126*e[t]+.7152*e[t+1]+.0722*e[t+2];e[t]=e[t+1]=e[t+2]=a}},a._filters[a.OPAQUE]=e=>{for(let t=0;t<e.length;t+=4)e[t+3]=255},a._filters[a.INVERT]=e=>{for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]},a._filters[a.POSTERIZE]=(e,t=4)=>{let a=t-1;for(let o=0;o<e.length;o+=4)e[o]=255*(e[o]*t>>8)/a,e[o+1]=255*(e[o+1]*t>>8)/a,e[o+2]=255*(e[o+2]*t>>8)/a},a._filters[a.DILATE]=e=>{c(),x.set(e);let[t,o]=[a.canvas.width,a.canvas.height];for(let a=0;a<o;a++)for(let n=0;n<t;n++){let r=4*Math.max(n-1,0),i=4*Math.min(n+1,t-1),s=4*Math.max(a-1,0)*t,l=4*Math.min(a+1,o-1)*t,c=4*a*t,h=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+c;e[c+h+t]=Math.max(x[a+h],x[n+r],x[n+h],x[n+i],x[o+h])}}},a._filters[a.ERODE]=e=>{c(),x.set(e);let[t,o]=[a.canvas.width,a.canvas.height];for(let a=0;a<o;a++)for(let n=0;n<t;n++){let r=4*Math.max(n-1,0),i=4*Math.min(n+1,t-1),s=4*Math.max(a-1,0)*t,l=4*Math.min(a+1,o-1)*t,c=4*a*t,h=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+c;e[c+h+t]=Math.min(x[a+h],x[n+r],x[n+h],x[n+i],x[o+h])}}},a._filters[a.BLUR]=(e,t)=>{t=t||1,t=Math.floor(t*a._pixelDensity),c(),x.set(e);let o=2*t+1,n=function(e){let a=new Float32Array(e),o=.3*t+.8,n=o*o*2;for(let t=0;t<e;t++){let r=t-e/2,i=Math.exp(-r*r/n)/(2.5066282746*o);a[t]=i}return a}(o),[r,i]=[a.canvas.width,a.canvas.height];for(let a=0;a<i;a++)for(let i=0;i<r;i++){let s=0,l=0,c=0,h=0;for(let e=0;e<o;e++){let o=4*(a*r+Math.min(Math.max(i-t+e,0),r-1));s+=x[o]*n[e],l+=x[o+1]*n[e],c+=x[o+2]*n[e],h+=x[o+3]*n[e]}let d=4*(a*r+i);e[d]=s,e[d+1]=l,e[d+2]=c,e[d+3]=h}x.set(e);for(let a=0;a<i;a++)for(let s=0;s<r;s++){let l=0,c=0,h=0,d=0;for(let e=0;e<o;e++){let o=4*(Math.min(Math.max(a-t+e,0),i-1)*r+s);l+=x[o]*n[e],c+=x[o+1]*n[e],h+=x[o+2]*n[e],d+=x[o+3]*n[e]}let u=4*(a*r+s);e[u]=l,e[u+1]=c,e[u+2]=h,e[u+3]=d}});let o=i.getImageData(0,0,a.canvas.width,a.canvas.height);a._filters[e](o.data,t),i.putImageData(o,0,0)}function d(e){f.clearRect(0,0,f.canvas.width,f.canvas.height),f.filter=e,f.drawImage(a.canvas,0,0),i.save(),i.resetTransform(),i.clearRect(0,0,a.canvas.width,a.canvas.height),i.drawImage(f.canvas,0,0),i.restore()}a.createCanvas=function(t,o,n,r){if("webgl"==n)throw Error("webgl renderer is not supported in q5, use '2d'");"object"==typeof n&&(r=n),a.width=a.canvas.width=t||window.innerWidth,a.height=a.canvas.height=o||window.innerHeight,a.canvas.renderer="2d";let s=Object.assign({},Q5.canvasOptions);if(r&&Object.assign(s,r),i=a.ctx=a.drawingContext=a.canvas.getContext("2d",s),Object.assign(a.canvas,s),"rgb"==a._colorMode&&a.colorMode("rgb"),i.fillStyle="white",i.strokeStyle="black",i.lineCap="round",i.lineJoin="miter",i.textAlign="left",i.save(),"image"!=e){let t=a.displayDensity();"graphics"==e&&(t=this._pixelDensity),a.pixelDensity(Math.ceil(t))}else this._pixelDensity=1;return a.canvas},a._createCanvas=a.createCanvas,a.loadPixels=()=>{r=i.getImageData(0,0,a.canvas.width,a.canvas.height),a.pixels=r.data},a.updatePixels=()=>{null!=r&&i.putImageData(r,0,0)},a.filter=(e,t)=>{if(!i.filter)return h(e,t);if(l(),"string"==typeof e)d(e);else if(e==a.THRESHOLD){t??=.5,t=Math.max(t,1e-5),d(`saturate(0%) brightness(${Math.floor(.5/t*100)}%) contrast(1000000%)`)}else e==a.GRAY?d("saturate(0%)"):e==a.OPAQUE?(f.fillStyle="black",f.fillRect(0,0,f.canvas.width,f.canvas.height),f.drawImage(a.canvas,0,0),i.save(),i.resetTransform(),i.drawImage(f.canvas,0,0),i.restore()):e==a.INVERT?d("invert(100%)"):e==a.BLUR?d(`blur(${Math.ceil(t*a._pixelDensity/1)||1}px)`):h(e,t)},a.resize=(e,t)=>{l(),f.drawImage(a.canvas,0,0),a.width=e,a.height=t,a.canvas.width=e*a._pixelDensity,a.canvas.height=t*a._pixelDensity,i.save(),i.resetTransform(),i.clearRect(0,0,a.canvas.width,a.canvas.height),i.drawImage(f.canvas,0,0,a.canvas.width,a.canvas.height),i.restore()},a.trim=()=>{let e=a._pixelDensity||1,t=i.getImageData(0,0,a.width*e,a.height*e).data,o=a.width,n=0,r=a.height,s=0;for(let i=0;i<a.height*e;i++)for(let l=0;l<a.width*e;l++){0!==t[4*(i*a.width*e+l)+3]&&(l<o&&(o=l),l>n&&(n=l),i<r&&(r=i),i>s&&(s=i))}return r=Math.floor(r/e),s=Math.floor(s/e),o=Math.floor(o/e),n=Math.floor(n/e),a.get(o,r,n-o+1,s-r+1)},a.get=(e,t,o,n)=>{let r=a._pixelDensity||1;if(void 0!==e&&void 0===o){let o=i.getImageData(e*r,t*r,1,1).data;return new a.Color(o[0],o[1],o[2],o[3]/255)}e=(e||0)*r,t=(t||0)*r;let s=o=o||a.width,l=n=n||a.height;o*=r,n*=r;let c=a.createImage(o,n),h=i.getImageData(e,t,o,n);return c.ctx.putImageData(h,0,0),c._pixelDensity=r,c.width=s,c.height=l,c},a.set=(e,t,o)=>{if(o._q5){let n=a._tint;return a._tint=null,a.image(o,e,t),void(a._tint=n)}a.pixels.length||a.loadPixels();let n=a._pixelDensity||1;for(let r=0;r<n;r++)for(let i=0;i<n;i++){let s=4*((t*n+r)*a.canvas.width+e*n+i);a.pixels[s]=o.r??o.l,a.pixels[s+1]=o.g??o.c,a.pixels[s+2]=o.b??o.h,a.pixels[s+3]=o.a}},a.tinted=function(e){let t=e.a;e.a=255,l(),f.clearRect(0,0,f.canvas.width,f.canvas.height),f.fillStyle=e.toString(),f.fillRect(0,0,f.canvas.width,f.canvas.height),f.globalCompositeOperation="multiply",f.drawImage(i.canvas,0,0),f.globalCompositeOperation="source-over",i.save(),i.resetTransform();let a=i.globalCompositeOperation;i.globalCompositeOperation="source-in",i.drawImage(f.canvas,0,0),i.globalCompositeOperation=a,i.restore(),f.globalAlpha=t/255,f.clearRect(0,0,f.canvas.width,f.canvas.height),f.drawImage(i.canvas,0,0),f.globalAlpha=1,i.save(),i.resetTransform(),i.clearRect(0,0,i.canvas.width,i.canvas.height),i.drawImage(f.canvas,0,0),i.restore()},a.tint=function(e){a._tint=e._q5Color?e:a.color(...arguments)},a.noTint=()=>a._tint=null,a.mask=e=>{i.save(),i.resetTransform();let t=i.globalCompositeOperation;i.globalCompositeOperation="destination-in",i.drawImage(e.canvas,0,0),i.globalCompositeOperation=t,i.restore()},a._save=async(e,t,a)=>{if(t=t||"untitled","jpg"==(a=a||"png")||"png"==a||"webp"==a)if(e instanceof OffscreenCanvas){const t=await e.convertToBlob({type:"image/"+a});e=await new Promise((e=>{const a=new FileReader;a.onloadend=()=>e(a.result),a.readAsDataURL(t)}))}else e=e.toDataURL("image/"+a);else{let t="text/plain";"json"==a&&("string"!=typeof e&&(e=JSON.stringify(e)),t="text/json"),e=new Blob([e],{type:t}),e=URL.createObjectURL(e)}let o=document.createElement("a");o.href=e,o.download=t+"."+a,document.body.append(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(o.href)},a.save=(e,t,o)=>{if((!e||"string"==typeof e&&(!t||!o&&t.length<5))&&(o=t,t=e,e=a.canvas),o)return a._save(e,t,o);t?(t=t.split("."),a._save(e,t[0],t.at(-1))):a._save(e)},a.canvas.save=a.save,a.saveCanvas=a.save,a.createImage=(e,t,a)=>new Q5.Image(e,t,a);let u=null,g=!0,_=[],p={},m=0,f=null,v=null,x=null;if(a.THRESHOLD=1,a.GRAY=2,a.OPAQUE=3,a.INVERT=4,a.POSTERIZE=5,a.DILATE=6,a.ERODE=7,a.BLUR=8,"image"==e)return;function y(e,t){e??=window.innerWidth,t??=window.innerHeight,a.width=e,a.height=t;let o=function(){let e={};for(let t in i)"function"!=typeof i[t]&&(e[t]=i[t]);return delete e.canvas,e}();a.canvas.width=Math.ceil(e*a._pixelDensity),a.canvas.height=Math.ceil(t*a._pixelDensity),!a.canvas.fullscreen&&a.canvas.style&&(a.canvas.style.width=e+"px",a.canvas.style.height=t+"px");for(let e in o)a.ctx[e]=o[e];i.scale(a._pixelDensity,a._pixelDensity)}a.BLEND="source-over",a.REMOVE="destination-out",a.ADD="lighter",a.DARKEST="darken",a.LIGHTEST="lighten",a.DIFFERENCE="difference",a.SUBTRACT="subtract",a.EXCLUSION="exclusion",a.MULTIPLY="multiply",a.SCREEN="screen",a.REPLACE="copy",a.OVERLAY="overlay",a.HARD_LIGHT="hard-light",a.SOFT_LIGHT="soft-light",a.DODGE="color-dodge",a.BURN="color-burn",a.RGB="rgb",a.RGBA="rgb",a.HSB="hsb",a.CHORD=0,a.PIE=1,a.OPEN=2,a.RADIUS="radius",a.CORNER="corner",a.CORNERS="corners",a.ROUND="round",a.SQUARE="butt",a.PROJECT="square",a.MITER="miter",a.BEVEL="bevel",a.CLOSE=1,a.NORMAL="normal",a.ITALIC="italic",a.BOLD="bold",a.BOLDITALIC="italic bold",a.CENTER="center",a.LEFT="left",a.RIGHT="right",a.TOP="top",a.BOTTOM="bottom",a.BASELINE="alphabetic",a.LANDSCAPE="landscape",a.PORTRAIT="portrait",a.ALT=18,a.BACKSPACE=8,a.CONTROL=17,a.DELETE=46,a.DOWN_ARROW=40,a.ENTER=13,a.ESCAPE=27,a.LEFT_ARROW=37,a.OPTION=18,a.RETURN=13,a.RIGHT_ARROW=39,a.SHIFT=16,a.TAB=9,a.UP_ARROW=38,a.DEGREES="degrees",a.RADIANS="radians",a.HALF_PI=Math.PI/2,a.PI=Math.PI,a.QUARTER_PI=Math.PI/4,a.TAU=2*Math.PI,a.TWO_PI=2*Math.PI,a.ARROW="default",a.CROSS="crosshair",a.HAND="pointer",a.MOVE="move",a.TEXT="text",a.VIDEO={video:!0,audio:!1},a.AUDIO={video:!1,audio:!0},a.SHR3=1,a.LCG=2,a.hint=(e,t)=>{a[e]=t},a.frameCount=0,a.deltaTime=16,a.mouseX=0,a.mouseY=0,a.touches=[],a.mouseButton=null,a.keyIsPressed=!1,a.mouseIsPressed=!1,a.key=null,a.keyCode=null,a.accelerationX=0,a.accelerationY=0,a.accelerationZ=0,a.rotationX=0,a.rotationY=0,a.rotationZ=0,a.relRotationX=0,a.relRotationY=0,a.relRotationZ=0,a.pmouseX=0,a.pmouseY=0,a.pAccelerationX=0,a.pAccelerationY=0,a.pAccelerationZ=0,a.pRotationX=0,a.pRotationY=0,a.pRotationZ=0,a.pRelRotationX=0,a.pRelRotationY=0,a.pRelRotationZ=0,Object.defineProperty(a,"deviceOrientation",{get:()=>window.screen?.orientation?.type}),Object.defineProperty(a,"windowWidth",{get:()=>window.innerWidth}),Object.defineProperty(a,"windowHeight",{get:()=>window.innerHeight}),a._colorMode="rgb",a._doStroke=!0,a._doFill=!0,a._strokeSet=!1,a._fillSet=!1,a._tint=null,a._ellipseMode=a.CENTER,a._rectMode=a.CORNER,a._curveDetail=20,a._curveAlpha=0,a._loop=!0,a._textFont="sans-serif",a._textSize=12,a._textLeading=15,a._textLeadDiff=3,a._textStyle="normal",a._pixelDensity=1,a._targetFrameRate=0,a._targetFrameDuration=16.666666666666668,a._frameRate=a._fps=60,a.resizeCanvas=(e,t)=>{e==a.width&&t==a.height||y(e,t)},a.createGraphics=function(e,t,o){let n=new Q5("graphics");return o??={},o.alpha??=!0,n._createCanvas.call(a,e,t,o),n},a.displayDensity=()=>window.devicePixelRatio,a.pixelDensity=e=>e&&e!=a._pixelDensity?(a._pixelDensity=e,y(a.width,a.height),e):a._pixelDensity,a.fullscreen=e=>{if(void 0===e)return document.fullscreenElement;e?document.body.requestFullscreen():document.body.exitFullscreen()},a.map=(e,t,a,o,n,r)=>{let i=o+1*(e-t)/(a-t)*(n-o);return r?o<n?Math.min(Math.max(i,o),n):Math.min(Math.max(i,n),o):i},a.lerp=(e,t,a)=>e*(1-a)+t*a,a.constrain=(e,t,a)=>Math.min(Math.max(e,t),a),a.dist=function(){let e=arguments;return 4==e.length?Math.hypot(e[0]-e[2],e[1]-e[3]):Math.hypot(e[0]-e[3],e[1]-e[4],e[2]-e[5])},a.norm=(e,t,o)=>a.map(e,t,o,0,1),a.sq=e=>e*e,a.fract=e=>e-Math.floor(e),a.angleMode=e=>a._angleMode=e,a._DEGTORAD=Math.PI/180,a._RADTODEG=180/Math.PI,a.degrees=e=>e*a._RADTODEG,a.radians=e=>e*a._DEGTORAD,a.abs=Math.abs,a.ceil=Math.ceil,a.exp=Math.exp,a.floor=Math.floor,a.log=Math.log,a.mag=Math.hypot,a.max=Math.max,a.min=Math.min,a.round=Math.round,a.pow=Math.pow,a.sqrt=Math.sqrt,a.sin=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.sin(e)),a.cos=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.cos(e)),a.tan=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.tan(e)),a.asin=e=>{let t=Math.asin(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.acos=e=>{let t=Math.acos(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.atan=e=>{let t=Math.atan(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.atan2=(e,t)=>{let o=Math.atan2(e,t);return"degrees"==a._angleMode&&(o=a.degrees(o)),o},a.nf=(e,t,a)=>{let o=e<0,n=(e=Math.abs(e)).toFixed(a).split(".");n[0]=n[0].padStart(t,"0");let r=n.join(".");return o&&(r="-"+r),r},a.createVector=(e,t,o)=>new Q5.Vector(e,t,o,a),a.curvePoint=(e,t,a,o,n)=>{const r=n*n*n,i=n*n;return e*(-.5*r+i-.5*n)+t*(1.5*r-2.5*i+1)+a*(-1.5*r+2*i+.5*n)+o*(.5*r-.5*i)},a.bezierPoint=(e,t,a,o,n)=>{const r=1-n;return Math.pow(r,3)*e+3*Math.pow(r,2)*n*t+3*r*Math.pow(n,2)*a+Math.pow(n,3)*o},a.curveTangent=(e,t,a,o,n)=>{const r=n*n;return e*(-3*r/2+2*n-.5)+t*(9*r/2-5*n)+a*(-9*r/2+4*n+.5)+o*(3*r/2-n)},a.bezierTangent=(e,t,a,o,n)=>{const r=1-n;return 3*o*Math.pow(n,2)-3*a*Math.pow(n,2)+6*a*r*n-6*t*r*n+3*t*Math.pow(r,2)-3*e*Math.pow(r,2)},Q5.supportsHDR?a.Color=Q5.ColorRGBA_P3:a.Color=Q5.ColorRGBA,a.colorMode=e=>{a._colorMode=e,"oklch"==e?a.Color=Q5.ColorOKLCH:"rgb"==e?"srgb"==a.canvas.colorSpace?a.Color=Q5.ColorRGBA:a.Color=Q5.ColorRGBA_P3:"srgb"==e&&(a.Color=Q5.ColorRGBA,a._colorMode="rgb")};let w={aqua:[0,255,255],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],crimson:[220,20,60],cyan:[0,255,255],darkviolet:[148,0,211],gold:[255,215,0],green:[0,128,0],gray:[128,128,128],grey:[128,128,128],hotpink:[255,105,180],indigo:[75,0,130],khaki:[240,230,140],lightgreen:[144,238,144],lime:[0,255,0],magenta:[255,0,255],navy:[0,0,128],orange:[255,165,0],olive:[128,128,0],peachpuff:[255,218,185],pink:[255,192,203],purple:[128,0,128],red:[255,0,0],skyblue:[135,206,235],tan:[210,180,140],turquoise:[64,224,208],transparent:[0,0,0,0],white:[255,255,255],violet:[238,130,238],yellow:[255,255,0]};function M(e){let t=a._angleMode==a.DEGREES?180:Math.PI,o=2*t;if(0<=e&&e<=o)return e;for(;e<0;)e+=o;for(;e>=t;)e-=o;return e}function R(e,t,o,n,r,s,l,c){if(!a._doFill&&!a._doStroke)return;let h=M(r),d=M(s);if(h>d&&([h,d]=[d,h]),0==h){if(0==d)return;if(a._angleMode==a.DEGREES&&360==d||d==a.TAU)return a.ellipse(e,t,o,n)}i.beginPath();for(let r=0;r<c+1;r++){let s=r/c,l=a.lerp(h,d,s),u=a.cos(l)*o/2,g=a.sin(l)*n/2;i[r?"lineTo":"moveTo"](e+u,t+g)}l==a.CHORD?i.closePath():l==a.PIE&&(i.lineTo(e,t),i.closePath()),a._doFill&&i.fill(),a._doStroke&&i.stroke()}function S(e,t,o,n){(a._doFill||a._doStroke)&&(i.beginPath(),i.ellipse(e,t,o/2,n/2,0,0,a.TAU),a._doFill&&i.fill(),a._doStroke&&i.stroke())}function C(e,t,o,n,r,s,l,c){if(!a._doFill&&!a._doStroke)return;if(void 0===r)return function(e,t,o,n){a._doFill&&i.fillRect(e,t,o,n),a._doStroke&&i.strokeRect(e,t,o,n)}(e,t,o,n);if(void 0===s)return C(e,t,o,n,r,r,r,r);const h=Math.min(Math.abs(n),Math.abs(o))/2;r=Math.min(h,r),s=Math.min(h,s),c=Math.min(h,c),l=Math.min(h,l),i.beginPath(),i.moveTo(e+r,t),i.arcTo(e+o,t,e+o,t+n,s),i.arcTo(e+o,t+n,e,t+n,l),i.arcTo(e,t+n,e,t,c),i.arcTo(e,t,e+o,t,r),i.closePath(),a._doFill&&i.fill(),a._doStroke&&i.stroke()}function b(){_=[]}a.color=function(e,t,o,n){let r=a.Color;if(e._q5Color)return new r(...e.levels);let i=arguments;if(1==i.length){if("string"==typeof e)return"#"==e[0]?new r(parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16),9!=e.length?null:parseInt(e.slice(7,9),16)):w[e]?new r(...w[e]):new r(0,0,0);if(Array.isArray(e))return new r(...e)}if("rgb"==a._colorMode){if(1==i.length)return new r(e,e,e);if(2==i.length)return new r(e,e,e,t);if(3==i.length)return new r(e,t,o);if(4==i.length)return new r(e,t,o,n)}},a.red=e=>e.r,a.green=e=>e.g,a.blue=e=>e.b,a.alpha=e=>e.a,a.lightness=e=>100*(.2126*e.r+.7152*e.g+.0722*e.b)/255,a.lerpColor=(e,t,o)=>{if("rgb"==a._colorMode)return new a.Color(a.constrain(a.lerp(e.r,t.r,o),0,255),a.constrain(a.lerp(e.g,t.g,o),0,255),a.constrain(a.lerp(e.b,t.b,o),0,255),a.constrain(a.lerp(e.a,t.a,o),0,255));{let n=t.h-e.h;n>180&&(n-=360),n<-180&&(n+=360);let r=e.h+o*n;return r<0&&(r+=360),r>360&&(r-=360),new a.Color(a.constrain(a.lerp(e.l,t.l,o),0,100),a.constrain(a.lerp(e.c,t.c,o),0,100),r,a.constrain(a.lerp(e.a,t.a,o),0,255))}},a.strokeWeight=e=>{e||(a._doStroke=!1),i.lineWidth=e||1e-4},a.stroke=function(e){if(a._doStroke=!0,a._strokeSet=!0,e._q5Color||"string"==typeof e?w[e]&&(e=a.color(...w[e])):e=a.color(...arguments),e.a<=0)return a._doStroke=!1;i.strokeStyle=e.toString()},a.noStroke=()=>a._doStroke=!1,a.fill=function(e){if(a._doFill=!0,a._fillSet=!0,e._q5Color||"string"==typeof e?w[e]&&(e=a.color(...w[e])):e=a.color(...arguments),e.a<=0)return a._doFill=!1;i.fillStyle=e.toString()},a.noFill=()=>a._doFill=!1,a.smooth=()=>a._smooth=!0,a.noSmooth=()=>a._smooth=!1,a.blendMode=e=>i.globalCompositeOperation=e,a.strokeCap=e=>i.lineCap=e,a.strokeJoin=e=>i.lineJoin=e,a.ellipseMode=e=>a._ellipseMode=e,a.rectMode=e=>a._rectMode=e,a.curveDetail=e=>a._curveDetail=e,a.curveAlpha=e=>a._curveAlpha=e,a.curveTightness=e=>a._curveAlpha=e,a.clear=()=>{i.clearRect(0,0,a.canvas.width,a.canvas.height)},a.background=function(e){if(e._q5)return a.image(e,0,0,a.width,a.height);i.save(),i.resetTransform(),e._q5Color||"string"==typeof e?w[e]&&(e=a.color(...w[e])):e=a.color(...arguments),i.fillStyle=e.toString(),i.fillRect(0,0,a.canvas.width,a.canvas.height),i.restore()},a.line=(e,t,o,n)=>{a._doStroke&&(i.beginPath(),i.moveTo(e,t),i.lineTo(o,n),i.stroke())},a.arc=(e,t,o,n,r,i,s,l=25)=>{if(r==i)return a.ellipse(e,t,o,n);s??=a.PIE,a._ellipseMode==a.CENTER?R(e,t,o,n,r,i,s,l):a._ellipseMode==a.RADIUS?R(e,t,2*o,2*n,r,i,s,l):a._ellipseMode==a.CORNER?R(e+o/2,t+n/2,o,n,r,i,s,l):a._ellipseMode==a.CORNERS&&R((e+o)/2,(t+n)/2,o-e,n-t,r,i,s,l)},a.ellipse=(e,t,o,n)=>{n??=o,a._ellipseMode==a.CENTER?S(e,t,o,n):a._ellipseMode==a.RADIUS?S(e,t,2*o,2*n):a._ellipseMode==a.CORNER?S(e+o/2,t+n/2,o,n):a._ellipseMode==a.CORNERS&&S((e+o)/2,(t+n)/2,o-e,n-t)},a.circle=(e,t,o)=>a.ellipse(e,t,o,o),a.point=(e,t)=>{e.x&&(t=e.y,e=e.x),i.save(),i.beginPath(),i.arc(e,t,i.lineWidth/2,0,2*Math.PI),i.fillStyle=i.strokeStyle,i.fill(),i.restore()},a.rect=(e,t,o,n,r,i,s,l)=>{a._rectMode==a.CENTER?C(e-o/2,t-n/2,o,n,r,i,s,l):a._rectMode==a.RADIUS?C(e-o,t-n,2*o,2*n,r,i,s,l):a._rectMode==a.CORNER?C(e,t,o,n,r,i,s,l):a._rectMode==a.CORNERS&&C(e,t,o-e,n-t,r,i,s,l)},a.square=(e,t,o,n,r,i,s)=>a.rect(e,t,o,o,n,r,i,s),a.beginShape=()=>{b(),i.beginPath(),g=!0},a.beginContour=()=>{i.closePath(),b(),g=!0},a.endContour=()=>{b(),g=!0},a.vertex=(e,t)=>{b(),g?i.moveTo(e,t):i.lineTo(e,t),g=!1},a.bezierVertex=(e,t,a,o,n,r)=>{b(),i.bezierCurveTo(e,t,a,o,n,r)},a.quadraticVertex=(e,t,a,o)=>{b(),i.quadraticCurveTo(e,t,a,o)},a.bezier=(e,t,o,n,r,i,s,l)=>{a.beginShape(),a.vertex(e,t),a.bezierVertex(o,n,r,i,s,l),a.endShape()},a.triangle=(e,t,o,n,r,i)=>{a.beginShape(),a.vertex(e,t),a.vertex(o,n),a.vertex(r,i),a.endShape(a.CLOSE)},a.quad=(e,t,o,n,r,i,s,l)=>{a.beginShape(),a.vertex(e,t),a.vertex(o,n),a.vertex(r,i),a.vertex(s,l),a.endShape(a.CLOSE)},a.endShape=e=>{b(),e&&i.closePath(),a._doFill&&i.fill(),a._doStroke&&i.stroke()},a.curveVertex=(e,t)=>{if(_.push([e,t]),_.length<4)return;let o=function(e,t,a,o,n,r,i,s,l,c){function h(e,t,a,o,n,r){let i=Math.pow(o-t,2)+Math.pow(n-a,2);return Math.pow(i,.5*r)+e}let d=[],u=h(0,e,t,a,o,c),g=h(u,a,o,n,r,c),_=h(g,n,r,i,s,c);for(let c=0;c<l;c++){let h=u+c/(l-1)*(g-u),p=[(u-h)/(u-0),(h-0)/(u-0),(g-h)/(g-u),(h-u)/(g-u),(_-h)/(_-g),(h-g)/(_-g),(g-h)/(g-0),(h-0)/(g-0),(_-h)/(_-u),(h-u)/(_-u)];for(let e=0;e<p.length;e+=2)isNaN(p[e])&&(p[e]=1,p[e+1]=0),isFinite(p[e])||(p[e]>0?(p[e]=1,p[e+1]=0):(p[e]=0,p[e+1]=1));let m=e*p[0]+a*p[1],f=t*p[0]+o*p[1],v=a*p[2]+n*p[3],x=o*p[2]+r*p[3],y=n*p[4]+i*p[5],w=r*p[4]+s*p[5],M=m*p[6]+v*p[7],R=f*p[6]+x*p[7],S=v*p[8]+y*p[9],C=x*p[8]+w*p[9],b=M*p[2]+S*p[3],I=R*p[2]+C*p[3];d.push([b,I])}return d}(..._[_.length-4],..._[_.length-3],..._[_.length-2],..._[_.length-1],a._curveDetail,a._curveAlpha);for(let e=0;e<o.length;e++)g?i.moveTo(...o[e]):i.lineTo(...o[e]),g=!1},a.curve=(e,t,o,n,r,i,s,l)=>{a.beginShape(),a.curveVertex(e,t),a.curveVertex(o,n),a.curveVertex(r,i),a.curveVertex(s,l),a.endShape()},a.opacity=e=>i.globalAlpha=e,a.translate=(e,t)=>i.translate(e,t),a.rotate=e=>{"degrees"==a._angleMode&&(e=a.radians(e)),i.rotate(e)},a.scale=(e,t)=>{t??=e,i.scale(e,t)},a.applyMatrix=(e,t,a,o,n,r)=>i.transform(e,t,a,o,n,r),a.shearX=e=>i.transform(1,0,a.tan(e),1,0,0),a.shearY=e=>i.transform(1,a.tan(e),0,1,0,0),a.resetMatrix=()=>{i.resetTransform(),i.scale(a._pixelDensity,a._pixelDensity)},a._styleNames=["_doStroke","_doFill","_strokeSet","_fillSet","_tint","_imageMode","_rectMode","_ellipseMode","_textFont","_textLeading","_leadingSet","_textSize","_textAlign","_textBaseline","_textStyle","_textWrap"],a._styles=[],a.push=a.pushMatrix=()=>{i.save();let e={};for(let t of a._styleNames)e[t]=a[t];a._styles.push(e)},a.pop=a.popMatrix=()=>{i.restore();let e=a._styles.pop();for(let t of a._styleNames)a[t]=e[t]},a.imageMode=e=>a._imageMode=e,a.image=(e,t,o,r,s,l=0,c=0,h,d)=>{let u=e._q5?e.canvas:e;var g,_;Q5._createNodeJSCanvas&&(u=u.context.canvas),e._q5&&null!=a._tint&&(g=e.canvas.width,_=e.canvas.height,_??=g||a.canvas.height,g??=a.canvas.width,null==v&&(v=new n(g,_).getContext("2d",{colorSpace:a.canvas.colorSpace})),v.canvas.width==g&&v.canvas.height==_||(v.canvas.width=g,v.canvas.height=_),v.drawImage(e.canvas,0,0),e.tinted(a._tint)),r??=e.width||e.videoWidth,s??=e.height||e.videoHeight,"center"==a._imageMode&&(t-=.5*r,o-=.5*s);let p=e._pixelDensity||1;h?h*=p:h=u.width||u.videoWidth,d?d*=p:d=u.height||u.videoHeight,i.drawImage(u,l*p,c*p,h,d,t,o,r,s),function(){if(!e._q5||!a._tint)return;let t=e.ctx;t.save(),t.resetTransform(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(v.canvas,0,0),t.restore()}()},a._incrementPreload=()=>o++,a._decrementPreload=()=>o--,a.loadImage=function(e,t,n){o++;let r=[...arguments].at(-1);n="object"!=typeof r||r;let i=a.createImage(1,1,n.alpha),s=i.ctx;if(Q5._nodejs&&global.CairoCanvas)CairoCanvas.loadImage(e).then((e=>{i.width=s.canvas.width=e.width,i.height=s.canvas.height=e.height,s.drawImage(e,0,0),o--,t&&t(i)})).catch((e=>{throw o--,e}));else{let a=new window.Image;a.src=e,a.crossOrigin="Anonymous",a._pixelDensity=1,a.onload=()=>{i.width=s.canvas.width=a.naturalWidth,i.height=s.canvas.height=a.naturalHeight,s.drawImage(a,0,0),o--,t&&t(i)},a.onerror=e=>{throw o--,e}}return i},a._clearTemporaryBuffers=()=>{f=null,v=null,x=null},a.loadFont=(e,t)=>{o++;let a=e.split("/"),n=a[a.length-1].split(".")[0].replace(" ",""),r=new FontFace(n,"url("+e+")");return document.fonts.add(r),r.load().then((()=>{o--,t&&t(n)})),n},a.textFont=e=>a._textFont=e,a.textSize=e=>{if(void 0===e)return a._textSize;a._textSize=e,a._leadingSet||(a._textLeading=1.25*e,a._textLeadDiff=a._textLeading-e)},a.textLeading=e=>{if(void 0===e)return a._textLeading;a._textLeading=e,a._textLeadDiff=e-a._textSize,a._leadingSet=!0},a.textStyle=e=>a._textStyle=e,a.textAlign=(e,t)=>{i.textAlign=e,t&&(i.textBaseline=t==a.CENTER?"middle":t)},a.textWidth=e=>(i.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,i.measureText(e).width),a.textAscent=e=>(i.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,i.measureText(e).actualBoundingBoxAscent),a.textDescent=e=>(i.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,i.measureText(e).actualBoundingBoxDescent),a._textCache=!0,a._TimedCache=class extends Map{constructor(){super(),this.maxSize=500}set(e,t){t.lastAccessed=Date.now(),super.set(e,t),this.size>this.maxSize&&this.gc()}get(e){const t=super.get(e);return t&&(t.lastAccessed=Date.now()),t}gc(){let e,t=1/0,a=0;for(const[o,n]of this.entries())n.lastAccessed<t&&(t=n.lastAccessed,e=a),a++;a=e;for(const t of this.keys()){if(0==a){e=t;break}a--}this.delete(e)}},a._tic=new a._TimedCache,a.textCache=(e,t)=>(t&&(a._tic.maxSize=t),void 0!==e&&(a._textCache=e),a._textCache),a._genTextImageKey=(e,t,o)=>e.slice(0,200)+a._textStyle+a._textSize+a._textFont+(a._doFill?i.fillStyle:"")+"_"+(a._doStroke&&a._strokeSet?i.lineWidth+i.strokeStyle+"_":"")+(t||"")+(o?"x"+o:""),a.createTextImage=(e,t,o)=>{let n=a._textCache;a._textCache=!0,a._genTextImage=!0,a.text(e,0,0,t,o),a._genTextImage=!1;let r=a._genTextImageKey(e,t,o);return a._textCache=n,a._tic.get(r)},a.text=(e,t,o,n,r)=>{if(void 0===e)return;if(e=e.toString(),!a._doFill&&!a._doStroke)return;let s,l,c,h,d,u,g,_,p=1,m=i.getTransform(),f=a._genTextImage||a._textCache&&(0!=m.b||0!=m.c);if(f){if(h=a._genTextImageKey(e,n,r),l=a._tic.get(h),l&&!a._genTextImage)return void a.textImage(l,t,o);c=a.createGraphics.call(a,1,1),s=c.ctx,p=a._pixelDensity}else s=i,d=t,u=o;s.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`;let v=e.split("\n");if(f){d=0,u=a._textLeading*v.length;let t=s.measureText(" ");g=t.fontBoundingBoxAscent,_=t.fontBoundingBoxDescent,r??=u+_,c.resizeCanvas(Math.ceil(s.measureText(e).width),Math.ceil(r)),s.fillStyle=i.fillStyle,s.strokeStyle=i.strokeStyle,s.lineWidth=i.lineWidth}let x=s.fillStyle;a._fillSet||(s.fillStyle="black");for(let e=0;e<v.length&&(a._doStroke&&a._strokeSet&&s.strokeText(v[e],d,u),a._doFill&&s.fillText(v[e],d,u),u+=a._textLeading,!(u>r));e++);a._fillSet||(s.fillStyle=x),f&&(l=c.get(),l._ascent=g,l._descent=_,a._tic.set(h,l),a._genTextImage||a.textImage(l,t,o))},a.textImage=(e,t,o)=>{let n=a._imageMode;a._imageMode="corner","center"==i.textAlign?t-=.5*e.width:"right"==i.textAlign&&(t-=e.width),"alphabetic"==i.textBaseline&&(o-=a._textLeading),"middle"==i.textBaseline?o-=e._descent+.5*e._ascent+a._textLeadDiff:"bottom"==i.textBaseline?o-=e._ascent+e._descent+a._textLeadDiff:"top"==i.textBaseline&&(o-=e._descent+a._textLeadDiff),a.image(e,t,o),a._imageMode=n};var I,E=4095,D=4,A=.5,T=e=>.5*(1-Math.cos(e*Math.PI));a.noise=(e=0,t=0,a=0)=>{if(null==I){I=new Array(4096);for(var o=0;o<4096;o++)I[o]=Math.random()}e<0&&(e=-e),t<0&&(t=-t),a<0&&(a=-a);for(var n,r,i,s,l,c=Math.floor(e),h=Math.floor(t),d=Math.floor(a),u=e-c,g=t-h,_=a-d,p=0,m=.5,f=0;f<D;f++){var v=c+(h<<4)+(d<<8);n=T(u),r=T(g),i=I[v&E],i+=n*(I[v+1&E]-i),s=I[v+16&E],i+=r*((s+=n*(I[v+16+1&E]-s))-i),s=I[(v+=256)&E],s+=n*(I[v+1&E]-s),l=I[v+16&E],s+=r*((l+=n*(I[v+16+1&E]-l))-s),p+=(i+=T(_)*(s-i))*m,m*=A,c<<=1,h<<=1,d<<=1,(u*=2)>=1&&(c++,u--),(g*=2)>=1&&(h++,g--),(_*=2)>=1&&(d++,_--)}return p},a.noiseDetail=(e,t)=>{e>0&&(D=e),t>0&&(A=t)};const O=()=>{let e,t,a=4294967295;return{setSeed(o){e=t=(o??Math.random()*a)>>>0},getSeed:()=>t,rand:()=>(e^=e<<17,e^=e>>13,e^=e<<5,(e>>>0)/a)}};let k=O();k.setSeed(),a.noiseSeed=e=>{let t=void 0===e?4294967295*Math.random():e;I||(I=new Float32Array(4096));for(var a=0;a<4096;a++)t^=t<<17,t^=t>>13,t^=t<<5,I[a]=(t>>>0)/4294967295},a.randomSeed=e=>k.setSeed(e),a.random=(e,t)=>void 0===e?k.rand():"number"==typeof e?void 0!==t?k.rand()*(t-e)+e:k.rand()*e:e[Math.trunc(e.length*k.rand())],a.randomGenerator=e=>{e==a.LCG?k=(()=>{const e=4294967296;let t,a;return{setSeed(o){a=t=(o??Math.random()*e)>>>0},getSeed:()=>t,rand:()=>(a=(1664525*a+1013904223)%e,a/e)}})():e==a.SHR3&&(k=O()),k.setSeed()};var P=new function(){var e,t,a,o=new Array(128),n=new Array(256),r=new Array(128),i=new Array(128),s=new Array(256),l=new Array(256),c=()=>4294967296*k.rand()-2147483648,h=()=>.5+2.328306e-10*(c()|0),d=()=>{for(var t,n,s,l,d=3.44262;;){if(t=a*r[e],0==e){do{s=h(),l=h(),t=.2904764*-Math.log(s),n=-Math.log(l)}while(n+n<t*t);return a>0?d+t:-d-t}if(i[e]+h()*(i[e-1]-i[e])<Math.exp(-.5*t*t))return t;if(a=c(),e=127&a,Math.abs(a)<o[e])return a*r[e]}},u=()=>{for(var a;;){if(0==e)return 7.69711-Math.log(h());if(a=t*s[e],l[e]+h()*(l[e-1]-l[e])<Math.exp(-a))return a;if((t=c())<n[e=255&t])return t*s[e]}};this.SHR3=c,this.UNI=h,this.RNOR=()=>(a=c(),e=127&a,Math.abs(a)<o[e]?a*r[e]:d()),this.REXP=()=>(t=c()>>>0)<o[e=255&t]?t*s[e]:u(),this.zigset=()=>{var e,t,a=2147483648,c=4294967296,h=3.442619855899,d=h,u=.00991256303526217,g=7.697117470131487,_=g,p=.003949659822581572;for(e=u/Math.exp(-.5*h*h),o[0]=Math.floor(h/e*a),o[1]=0,r[0]=e/a,r[127]=h/a,i[0]=1,i[127]=Math.exp(-.5*h*h),t=126;t>=1;t--)h=Math.sqrt(-2*Math.log(u/h+Math.exp(-.5*h*h))),o[t+1]=Math.floor(h/d*a),d=h,i[t]=Math.exp(-.5*h*h),r[t]=h/a;for(e=p/Math.exp(-g),n[0]=Math.floor(g/e*c),n[1]=0,s[0]=e/c,s[255]=g/c,l[0]=1,l[255]=Math.exp(-g),t=254;t>=1;t--)g=-Math.log(p/g+Math.exp(-g)),n[t+1]=Math.floor(g/_*c),_=g,l[t]=Math.exp(-g),s[t]=g/c}};function z(e){let t=e||performance.now();if(a._lastFrameTime??=t-a._targetFrameDuration,a._loop)u=F(z);else if(a.frameCount&&!a._redraw)return;if(u&&a.frameCount){if(t-a._lastFrameTime<a._targetFrameDuration-1)return}a.deltaTime=t-a._lastFrameTime,a._frameRate=1e3/a.deltaTime,a.frameCount++,a._shouldResize&&(a.windowResized(),a._shouldResize=!1);let o=performance.now();for(let e of Q5.prototype._methods.pre)e.call(a);b(),g=!0,i&&i.save(),a.draw();for(let e of Q5.prototype._methods.post)e.call(a);i&&(i.restore(),a.resetMatrix()),a.pmouseX=a.mouseX,a.pmouseY=a.mouseY,a._lastFrameTime=t;let n=performance.now();a._fps=Math.round(1e3/(n-o))}function Q(e){const t=a.canvas.getBoundingClientRect(),o=a.canvas.scrollWidth/a.width||1,n=a.canvas.scrollHeight/a.height||1;return{x:(e.clientX-t.left)/o,y:(e.clientY-t.top)/n,id:e.identifier}}P.hasInit=!1,a.randomGaussian=(e,t)=>(P.hasInit||(P.zigset(),P.hasInit=!0),P.RNOR()*t+e),a.randomExponential=()=>(P.hasInit||(P.zigset(),P.hasInit=!0),P.REXP()),a.Element=function(e){this.elt=e},a._elements=[],a.createCapture=e=>{var t=document.createElement("video");return t.playsinline="playsinline",t.autoplay="autoplay",navigator.mediaDevices.getUserMedia(e).then((e=>{t.srcObject=e})),t.style.position="absolute",t.style.opacity=1e-5,t.style.zIndex=-1e3,document.body.append(t),t},a.print=console.log,a.describe=()=>{},a.noLoop=()=>{a._loop=!1,u=null},a.loop=()=>{a._loop=!0,null==u&&z()},a.redraw=(e=1)=>{a._redraw=!0;for(let t=0;t<e;t++)z();a._redraw=!1},a.remove=()=>{a.noLoop(),a.canvas.remove()},a.frameRate=e=>(e&&(a._targetFrameRate=e,a._targetFrameDuration=1e3/e),a._frameRate),a.getTargetFrameRate=()=>a._targetFrameRate,a.getFPS=()=>a._fps,"object"==typeof localStorage&&(a.storeItem=localStorage.setItem,a.getItem=localStorage.getItem,a.removeItem=localStorage.removeItem,a.clearStorage=localStorage.clear),a._updateMouse=e=>{if(e.changedTouches)return;let t=a.canvas.getBoundingClientRect(),o=a.canvas.scrollWidth/a.width||1,n=a.canvas.scrollHeight/a.height||1;a.mouseX=(e.clientX-t.left)/o,a.mouseY=(e.clientY-t.top)/n},a._onmousedown=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a.mouseButton=[a.LEFT,a.CENTER,a.RIGHT][e.button],a.mousePressed(e)},a._onmousemove=e=>{a._updateMouse(e),a.mouseIsPressed?a.mouseDragged(e):a.mouseMoved(e)},a._onmouseup=e=>{a._updateMouse(e),a.mouseIsPressed=!1,a.mouseReleased(e)},a._onclick=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a.mouseClicked(e),a.mouseIsPressed=!1},a.cursor=(e,t,o)=>{let n="";e.includes(".")&&(e=`url("${e}")`,n=", auto"),void 0!==t&&(e+=" "+t+" "+o),a.canvas.style.cursor=e+n},a.noCursor=()=>{a.canvas.style.cursor="none"},a._onkeydown=e=>{e.repeat||(a.keyIsPressed=!0,a.key=e.key,a.keyCode=e.keyCode,p[a.keyCode]=!0,a.keyPressed(e),1==e.key.length&&a.keyTyped(e))},a._onkeyup=e=>{a.keyIsPressed=!1,a.key=e.key,a.keyCode=e.keyCode,p[a.keyCode]=!1,a.keyReleased(e)},a._ontouchstart=e=>{a.touches=[...e.touches].map(Q),a._isTouchAware||(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseIsPressed=!0,a.mouseButton=a.LEFT,a.mousePressed(e)||e.preventDefault()),a.touchStarted(e)||e.preventDefault(),"running"!=a.getAudioContext()?.state&&a.userStartAudio()},a._ontouchmove=e=>{a.touches=[...e.touches].map(Q),a._isTouchAware||(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseDragged(e)||e.preventDefault()),a.touchMoved(e)||e.preventDefault()},a._ontouchend=e=>{a.touches=[...e.touches].map(Q),a._isTouchAware||a.touches.length||(a.mouseIsPressed=!1,a.mouseReleased(e)||e.preventDefault()),a.touchEnded(e)||e.preventDefault()},"graphics"!=e&&(a.keyIsDown=e=>!!p[e],a.canvas.onmousedown=e=>a._onmousedown(e),a.canvas.onmouseup=e=>a._onmouseup(e),a.canvas.onclick=e=>a._onclick(e),a.canvas.ontouchstart=e=>a._ontouchstart(e),a.canvas.ontouchmove=e=>a._ontouchmove(e),a.canvas.ontouchcancel=a.canvas.ontouchend=e=>a._ontouchend(e)),a.hasSensorPermission=!window.DeviceOrientationEvent&&!window.DeviceMotionEvent||!(DeviceOrientationEvent.requestPermission||DeviceMotionEvent.requestPermission),a.requestSensorPermissions=()=>{DeviceOrientationEvent.requestPermission&&DeviceOrientationEvent.requestPermission().then((e=>{"granted"==e&&DeviceMotionEvent.requestPermission&&DeviceMotionEvent.requestPermission().then((e=>{"granted"==e&&(a.hasSensorPermission=!0)})).catch(alert)})).catch(alert)};async function L(e){let t=e.message.includes("Ask AI ✨");if(t||console.error(e),Q5.disableFriendlyErrors)return;!t&&Q5.errorTolerant||noLoop();let a=e.stack.split("\n");if(a.length<=1)return;let o=1,n="(";for(-1==navigator.userAgent.indexOf("Chrome")&&(o=0,n="@");a[o].indexOf("q5.js:")>=0;)o++;let r=a[o].split(n).at(-1);r=r.split(":");let i=parseInt(r.at(-2));t&&i++;let s=r.slice(0,-2).join(":"),l=s.split("/").at(-1);try{let a=(await(await fetch(s)).text()).split("\n"),o=a[i-1].trim(),n="",r=1;for(;n.length<1600;)i-r>=0&&(n=a[i-r].trim()+"\n"+n),i+r<a.length&&(n+=a[i+r].trim()+"\n"),r++;let c="https://chatgpt.com/?q=q5.js+"+(t&&e.message.length>10?e.message.slice(10):"Whats+wrong+with+this+line%3F+short+answer")+(t?"":"%0A%0A"+encodeURIComponent(e.name+": "+e.message))+"%0A%0ALine%3A+"+encodeURIComponent(o)+"%0A%0AExcerpt+for+context%3A%0A%0A"+encodeURIComponent(n);t||console.log("Error in "+l+" on line "+i+":\n\n"+o),console.warn("Ask AI ✨ "+c),t&&window.open(c,"_blank")}catch(e){}}window.ondeviceorientation=e=>{a.pRotationX=a.rotationX,a.pRotationY=a.rotationY,a.pRotationZ=a.rotationZ,a.pRelRotationX=a.relRotationX,a.pRelRotationY=a.relRotationY,a.pRelRotationZ=a.relRotationZ,a.rotationX=e.beta*(Math.PI/180),a.rotationY=e.gamma*(Math.PI/180),a.rotationZ=e.alpha*(Math.PI/180),a.relRotationX=[-a.rotationY,-a.rotationX,a.rotationY][Math.trunc(window.orientation/90)+1],a.relRotationY=[-a.rotationX,a.rotationY,a.rotationX][Math.trunc(window.orientation/90)+1],a.relRotationZ=a.rotationZ},window.ondevicemotion=e=>{if(a.pAccelerationX=a.accelerationX,a.pAccelerationY=a.accelerationY,a.pAccelerationZ=a.accelerationZ,!e.acceleration){let r=((e,t)=>[(e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]),(e[4]*t[0]+e[5]*t[1]+e[6]*t[2]+e[7])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]),(e[8]*t[0]+e[9]*t[1]+e[10]*t[2]+e[11])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15])])((n=a.rotationY,t=[a.cos(n),0,a.sin(n),0,0,1,0,0,-a.sin(n),0,a.cos(n),0,0,0,0,1],o=(e=>[1,0,0,0,0,a.cos(e),-a.sin(e),0,0,a.sin(e),a.cos(e),0,0,0,0,1])(a.rotationX),[t[0]*o[0]+t[1]*o[4]+t[2]*o[8]+t[3]*o[12],t[0]*o[1]+t[1]*o[5]+t[2]*o[9]+t[3]*o[13],t[0]*o[2]+t[1]*o[6]+t[2]*o[10]+t[3]*o[14],t[0]*o[3]+t[1]*o[7]+t[2]*o[11]+t[3]*o[15],t[4]*o[0]+t[5]*o[4]+t[6]*o[8]+t[7]*o[12],t[4]*o[1]+t[5]*o[5]+t[6]*o[9]+t[7]*o[13],t[4]*o[2]+t[5]*o[6]+t[6]*o[10]+t[7]*o[14],t[4]*o[3]+t[5]*o[7]+t[6]*o[11]+t[7]*o[15],t[8]*o[0]+t[9]*o[4]+t[10]*o[8]+t[11]*o[12],t[8]*o[1]+t[9]*o[5]+t[10]*o[9]+t[11]*o[13],t[8]*o[2]+t[9]*o[6]+t[10]*o[10]+t[11]*o[14],t[8]*o[3]+t[9]*o[7]+t[10]*o[11]+t[11]*o[15],t[12]*o[0]+t[13]*o[4]+t[14]*o[8]+t[15]*o[12],t[12]*o[1]+t[13]*o[5]+t[14]*o[9]+t[15]*o[13],t[12]*o[2]+t[13]*o[6]+t[14]*o[10]+t[15]*o[14],t[12]*o[3]+t[13]*o[7]+t[14]*o[11]+t[15]*o[15]]),[0,0,-9.80665]);a.accelerationX=e.accelerationIncludingGravity.x+r[0],a.accelerationY=e.accelerationIncludingGravity.y+r[1],a.accelerationZ=e.accelerationIncludingGravity.z-r[2]}var t,o,n},a.year=()=>(new Date).getFullYear(),a.day=()=>(new Date).getDay(),a.hour=()=>(new Date).getHours(),a.minute=()=>(new Date).getMinutes(),a.second=()=>(new Date).getSeconds(),a.millis=()=>performance.now()-m,a._loadFile=(e,t,a)=>{o++;let n={};return fetch(e).then((e=>"json"==a?e.json():"text"==a?e.text():void 0)).then((e=>{o--,Object.assign(n,e),t&&t(e)})),n},a.loadStrings=(e,t)=>a._loadFile(e,t,"text"),a.loadJSON=(e,t)=>a._loadFile(e,t,"json"),a.loadSound=(e,t)=>{o++;let a=new Audio(e);return a.addEventListener("canplaythrough",(()=>{o--,t&&t(a)})),a.load(),a.setVolume=e=>a.volume=e,a.setLoop=e=>a.loop=e,a},a.getAudioContext=()=>a.audioContext,a.userStartAudio=()=>(a.audioContext??=new window.AudioContext,a.audioContext.resume()),a.askAI=(e="")=>{throw Error("Ask AI ✨ "+e)},"global"==e&&(Object.assign(Q5,a),delete Q5.Q5),Q5.Image??=_Q5Image;for(let G of Q5.prototype._methods.init)G.call(a);for(let[V,j]of Object.entries(Q5.prototype))"_"!=V[0]&&"function"==typeof a[V]&&(a[V]=j.bind(a));if("global"==e){let H=Object.getOwnPropertyNames(a),U=Q5._nodejs?global:window;for(let Y of H)"function"==typeof a[Y]?U[Y]=a[Y]:Object.defineProperty(U,Y,{get:()=>a[Y],set:e=>a[Y]=e})}if("function"==typeof e&&e(a),"image"==e||"graphics"==e)return;let F=window.requestAnimationFrame||function(e){const t=a._lastFrameTime+a._targetFrameDuration;return setTimeout((()=>{e(t)}),t-performance.now())},N="global"==e?Q5._nodejs?global:window:a,q=N.preload,B=["setup","draw","preload","mouseMoved","mousePressed","mouseReleased","mouseDragged","mouseClicked","keyPressed","keyReleased","keyTyped","touchStarted","touchMoved","touchEnded","windowResized"];for(let X of B)N[X]?a._isGlobal&&(a[X]=()=>{try{N[X]()}catch(e){L(e)}}):a[X]=()=>{};function $(){if(a._startDone=!0,o>0)return F($);m=performance.now(),a.setup(),a.frameCount||(null===i&&a.createCanvas(100,100),a._setupDone=!0,i&&a.resetMatrix(),F(z))}a._isTouchAware=a.touchStarted||a.touchMoved||a.mouseReleased,window&&"graphics"!=e&&(window.addEventListener("mousemove",(e=>a._onmousemove(e)),!1),window.addEventListener("keydown",(e=>a._onkeydown(e)),!1),window.addEventListener("keyup",(e=>a._onkeyup(e)),!1),window.addEventListener("resize",(()=>{a._shouldResize=!0,a._loop||a.redraw()}))),(a.setup||a.draw)&&(a._startDone=!1,arguments.length&&"namespace"!=e||q?(a.preload(),$()):(N.preload=a.preload=()=>{a._startDone||$()},setTimeout(a.preload,32)))}Q5.Color=class{constructor(){this._q5Color=!0}},Q5.ColorOKLCH=class extends Q5.Color{constructor(e,t,a,o){super(),this.l=e,this.c=t,this.h=a,this.a=o??1}toString(){return`color(oklch ${this.l} ${this.c} ${this.h} / ${this.a})`}},Q5.ColorRGBA=class extends Q5.Color{constructor(e,t,a,o){super(),this.r=e,this.g=t,this.b=a,this.a=o??255}setRed(e){this.r=e}setGreen(e){this.g=e}setBlue(e){this.b=e}setAlpha(e){this.a=e}get levels(){return[this.r,this.g,this.b,this.a]}toString(){return`rgb(${this.r} ${this.g} ${this.b} / ${this.a/255})`}},Q5.ColorRGBA_P3=class extends Q5.ColorRGBA{constructor(e,t,a,o){super(e,t,a,o),this._edited=!0}get r(){return this._r}set r(e){this._r=e,this._edited=!0}get g(){return this._g}set g(e){this._g=e,this._edited=!0}get b(){return this._b}set b(e){this._b=e,this._edited=!0}get a(){return this._a}set a(e){this._a=e,this._edited=!0}toString(){if(this._edited){let e=(this._r/255).toFixed(3),t=(this._g/255).toFixed(3),a=(this._b/255).toFixed(3),o=(this._a/255).toFixed(3);this._css=`color(display-p3 ${e} ${t} ${a} / ${o})`,this._edited=!1}return this._css}},Q5.Vector=class{constructor(e,t,a,o){this.x=e||0,this.y=t||0,this.z=a||0,this._$=o||window,this._cn=null,this._cnsq=null}set(e,t,a){this.x=e||0,this.y=t||0,this.z=a||0}copy(){return new Q5.Vector(this.x,this.y,this.z)}_arg2v(e,t,a){return void 0!==e.x?e:void 0!==t?{x:e,y:t,z:a||0}:{x:e,y:e,z:e}}_calcNorm(){this._cnsq=this.x*this.x+this.y*this.y+this.z*this.z,this._cn=Math.sqrt(this._cnsq)}add(){let e=this._arg2v(...arguments);return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}rem(){let e=this._arg2v(...arguments);return this.x%=e.x,this.y%=e.y,this.z%=e.z,this}sub(){let e=this._arg2v(...arguments);return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}mult(){let e=this._arg2v(...arguments);return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}div(){let e=this._arg2v(...arguments);return e.x?this.x/=e.x:this.x=0,e.y?this.y/=e.y:this.y=0,e.z?this.z/=e.z:this.z=0,this}mag(){return this._calcNorm(),this._cn}magSq(){return this._calcNorm(),this._cnsq}dot(){let e=this._arg2v(...arguments);return this.x*e.x+this.y*e.y+this.z*e.z}dist(){let e=this._arg2v(...arguments),t=this.x-e.x,a=this.y-e.y,o=this.z-e.z;return Math.sqrt(t*t+a*a+o*o)}cross(){let e=this._arg2v(...arguments),t=this.y*e.z-this.z*e.y,a=this.z*e.x-this.x*e.z,o=this.x*e.y-this.y*e.x;return this.x=t,this.y=a,this.z=o,this}normalize(){this._calcNorm();let e=this._cn;return 0!=e&&(this.x/=e,this.y/=e,this.z/=e),this._cn=1,this._cnsq=1,this}limit(e){this._calcNorm();let t=this._cn;if(t>e){let a=e/t;this.x*=a,this.y*=a,this.z*=a,this._cn=e,this._cnsq=e*e}return this}setMag(e){this._calcNorm();let t=e/this._cn;return this.x*=t,this.y*=t,this.z*=t,this._cn=e,this._cnsq=e*e,this}heading(){return this._$.atan2(this.y,this.x)}rotate(e){let t=this._$.cos(e),a=this._$.sin(e),o=this.x*t-this.y*a,n=this.x*a+this.y*t;return this.x=o,this.y=n,this}angleBetween(){let e=this._arg2v(...arguments),t=Q5.Vector.cross(this,e);return this._$.atan2(t.mag(),this.dot(e))*Math.sign(t.z||1)}lerp(){let e=[...arguments],t=this._arg2v(...e.slice(0,-1)),a=e[e.length-1];return this.x+=(t.x-this.x)*a,this.y+=(t.y-this.y)*a,this.z+=(t.z-this.z)*a,this}reflect(e){return e.normalize(),this.sub(e.mult(2*this.dot(e)))}array(){return[this.x,this.y,this.z]}equals(e,t){return t??=Number.EPSILON||0,Math.abs(e.x-this.x)<t&&Math.abs(e.y-this.y)<t&&Math.abs(e.z-this.z)<t}fromAngle(e,t){return void 0===t&&(t=1),this._cn=t,this._cnsq=t*t,this.x=t*this._$.cos(e),this.y=t*this._$.sin(e),this.z=0,this}fromAngles(e,t,a){void 0===a&&(a=1),this._cn=a,this._cnsq=a*a;const o=this._$.cos(t),n=this._$.sin(t),r=this._$.cos(e),i=this._$.sin(e);return this.x=a*i*n,this.y=-a*r,this.z=a*i*o,this}random2D(){return this._cn=this._cnsq=1,this.fromAngle(Math.random()*Math.PI*2)}random3D(){return this._cn=this._cnsq=1,this.fromAngles(Math.random()*Math.PI*2,Math.random()*Math.PI*2)}toString(){return`[${this.x}, ${this.y}, ${this.z}]`}},Q5.Vector.add=(e,t)=>e.copy().add(t),Q5.Vector.cross=(e,t)=>e.copy().cross(t),Q5.Vector.dist=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y,e.z-t.z),Q5.Vector.div=(e,t)=>e.copy().div(t),Q5.Vector.dot=(e,t)=>e.copy().dot(t),Q5.Vector.equals=(e,t,a)=>e.equals(t,a),Q5.Vector.lerp=(e,t,a)=>e.copy().lerp(t,a),Q5.Vector.limit=(e,t)=>e.copy().limit(t),Q5.Vector.heading=e=>this._$.atan2(e.y,e.x),Q5.Vector.magSq=e=>e.x*e.x+e.y*e.y+e.z*e.z,Q5.Vector.mag=e=>Math.sqrt(Q5.Vector.magSq(e)),Q5.Vector.mult=(e,t)=>e.copy().mult(t),Q5.Vector.normalize=e=>e.copy().normalize(),Q5.Vector.rem=(e,t)=>e.copy().rem(t),Q5.Vector.sub=(e,t)=>e.copy().sub(t);for(let e of["fromAngle","fromAngles","random2D","random3D"])Q5.Vector[e]=(t,a,o)=>(new Q5.Vector)[e](t,a,o);class _Q5Image extends Q5{constructor(e,t,a){super("image"),delete this.createCanvas,a??={},a.alpha??=!0,this._createCanvas(e,t,"2d",a),this._loop=!1}get w(){return this.width}get h(){return this.height}}"object"!=typeof window&&(window=0),Q5._nodejs="object"==typeof process,Q5.canvasOptions={alpha:!1,desynchronized:!1,colorSpace:"display-p3"},window.matchMedia&&matchMedia("(dynamic-range: high) and (color-gamut: p3)").matches?Q5.supportsHDR=!0:Q5.canvasOptions.colorSpace="srgb",Q5._instanceCount=0,Q5._friendlyError=(e,t)=>{throw Error(t+": "+e)},Q5._validateParameters=()=>!0,Q5.prototype._methods={init:[],pre:[],post:[],remove:[]},Q5.prototype.registerMethod=(e,t)=>Q5.prototype._methods[e].push(t),Q5.prototype.registerPreloadMethod=(e,t)=>Q5.prototype[e]=t[e],"object"==typeof module?(global.p5??=Q5,module.exports=global.Q5=Q5):(window.p5??=Q5,window.Q5=Q5),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{Q5._hasGlobal||new Q5("auto")}));
|
package/q5js_brand.webp
CHANGED
|
Binary file
|
package/q5js_logo.webp
CHANGED
|
Binary file
|