q5 1.1.11 → 1.1.13

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.
Files changed (4) hide show
  1. package/README.md +10 -12
  2. package/package.json +1 -1
  3. package/q5.js +15 -13
  4. package/q5.min.js +1 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # <img src="q5js_logo.png" height="64"> <img src="q5js_brand.png" height="64">
2
2
 
3
- q5.js is a drop-in replacement for [p5.js][]. It supports all of p5.js's 2D drawing API's, math functionality, and some other utilities.
3
+ q5.js is a drop-in replacement for [p5.js][]. It supports all of p5's 2D drawing APIs, math functionality, and some other utilities.
4
4
 
5
- q5.min.js (38kb) is 24x smaller than p5.min.js (914kb), which makes using [q5 better for the environment!][] q5 will also load and run faster, which is especially important on mobile devices.
5
+ q5.min.js (39kb) is 24x smaller than p5.min.js (914kb), which makes using [q5 better for the environment!][] q5 will also load and run faster, which is especially important on mobile devices.
6
6
 
7
7
  q5 doesn't include any friendly error messages to help you code though. 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.
8
8
 
@@ -37,7 +37,7 @@ To use addons, simply load them after q5.js:
37
37
  <script src="https://p5play.org/v3/p5play.js"></script>
38
38
  ```
39
39
 
40
- ## What's new in Version 1.0?
40
+ ## What's new in Version 1.1?
41
41
 
42
42
  Co-creator of q5, @quinton-ashley, added a ton of features:
43
43
 
@@ -82,11 +82,9 @@ I thought @LingDong-'s work on q5 and the idea itself had great potential. So I
82
82
 
83
83
  An increase in performance of even a few frames per second can make a significant difference in the user experience of a work of interactive art or a game, especially on mobile devices.
84
84
 
85
- As a Computer Science teacher at Crimson Education, I teach students from all over the world. I also live in Colombia, where there are many people who don't have access to a PC, as in no desktop or laptop. There are businesses here that charge for time based access to 10 year old desktop PCs. But 6.3 billion people in the world own a smartphone. Improving the UX of p5.js on mobile devices is therefore a major priority for me. q5 is a step in that direction.
85
+ I was also interested in working on q5 because for a lot of p5.js users, the library itself is a black box. Even as an expert JS programmer and someone who teaches CS for a living, I still find myself scratching my head when I look at the p5.js source code. p5 was initially released 10 years ago and I think some bad design choices were made due to JS limitations at the time. It's also become an absolutely massive library, with literally over 100,000 lines of code and documentation! p5.js is 4 MB un-minified, q5.js is just 66kb.
86
86
 
87
- I was also interested in working on q5 because for a lot of p5.js users, the library itself is a black box. Even as an expert JS programmer and someone who teaches CS for a living, I still find myself scratching my head when I look at the p5.js source code. p5 was initially released 10 years ago and I think some bad design choices were made due to JS limitations at the time. It's also an absolutely massive library, with literally over 100,000 lines of code and documentation! p5.js is 4 MB unminified compared to q5.js which is 65kb.
88
-
89
- I'm not saying all this as a slight against the authors of p5, but it does make the source code very difficult to understand. I think it'd be better if the canvas mode, webgl mode, Friendly Error System, and accessibility features of p5 were offered in separate files. Yet, the powers that be at the Processing Foundation have made it clear that they don't want to do that. Instead they insist on adding more accessibility features to the base library, which the majority of people just don't need. So q5 is a good alternative that trims out the fat.
87
+ I think it'd be better if the canvas mode, webgl mode, Friendly Error System, and accessibility features of p5 were offered in separate files. Yet, the powers that be at the Processing Foundation have made it clear that they don't want to do that. Instead they insist on adding more accessibility features to the base library, which the majority of people just don't need. So q5 is a good alternative that trims out the fat.
90
88
 
91
89
  Thanks in large part to @LingDong-'s design, q5 is well organized, concise, and utilizes many modern JS features! I think even without documentation, the source code is easier for experienced JS programmers to comprehend.
92
90
 
@@ -193,16 +191,16 @@ q5.js provides some other features that are not in p5.js:
193
191
  - p5.min.js 898kb
194
192
  - p5.sound.min.js 200kb
195
193
 
196
- - q5.min.js 35kb
194
+ - q5.min.js 39kb
197
195
 
198
196
  - planck.min.js 193kb
199
- - p5play.min.js 66kb
197
+ - p5play.min.js 90kb
200
198
 
201
199
  ## Benchmarks
202
200
 
203
- q5.js has significant speed advantage in imaging operations because it uses hardware accelerated Canvas API directly whenever possible, instead of going over pixel by pixel. Most other functionalities have very marginal speed improvements (or none at all when parameter validation overhead is negligible). The operations with important performance differences are listed below.
201
+ q5.js has significant speed advantage in imaging operations because it uses hardware accelerated Canvas APIs directly whenever possible, instead of going over pixel by pixel. Most other functionalities have very marginal speed improvements (or none at all when parameter validation overhead is negligible). The operations with important performance differences are listed below.
204
202
 
205
- The following benchmarks are generated with Google Chrome 84, on an old-ish Macbook Pro 2015 (with lots of apps and tabs running); Performance varies depending on software and hardware.
203
+ The following benchmarks are generated with Google Chrome 84, on an old-ish MacBook Pro 2015 (with lots of apps and tabs running); Performance varies depending on software and hardware.
206
204
 
207
205
  p5.js version used is **1.1.9**.
208
206
 
@@ -225,7 +223,7 @@ p5.js version used is **1.1.9**.
225
223
 
226
224
  <sub>\* Only for browsers that support CanvasRenderingContext2D.filter ([75% of all](https://caniuse.com/#feat=mdn-api_canvasrenderingcontext2d_filter) as of Aug 2020, including Chrome, Firefox and Edge). For those that don't, performance is similar to p5.js, as identical implementations are usually used as fallbacks.</sub>
227
225
 
228
- Speed is a goal for q5.js, and we would very much like to see the above list grow. If you know how to make something faster, advice/pull requests are very welcome.
226
+ Speed is a goal for q5.js, and we would very much like to see the above list grow. If you know how to make something faster, advice/pull requests are very welcome!
229
227
 
230
228
  [p5.js]: https://p5js.org
231
229
  [make an issue report.]: https://github.com/quinton-ashley/q5.js/issues
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "quinton-ashley",
3
3
  "name": "q5",
4
- "version": "1.1.11",
4
+ "version": "1.1.13",
5
5
  "description": "An implementation of the p5.js 2D API that's smaller and faster",
6
6
  "main": "q5.js",
7
7
  "scripts": {
package/q5.js CHANGED
@@ -26,7 +26,7 @@ function Q5(scope, parent) {
26
26
  $.windowResized = () => {};
27
27
 
28
28
  if (scope != 'graphics' && scope != 'image') {
29
- window.addEventListener('resize', $.windowResized);
29
+ window.addEventListener('resize', () => $.windowResized());
30
30
  $.canvas.parent = (el) => {
31
31
  if (el[0]) el = document.getElementById(el);
32
32
  el.append($.canvas);
@@ -264,6 +264,7 @@ function Q5(scope, parent) {
264
264
  $.height = height;
265
265
  $.canvas.width = width * $._pixelDensity;
266
266
  $.canvas.height = height * $._pixelDensity;
267
+ if (scope != 'graphics' && scope != 'image') $.pixelDensity(2);
267
268
  };
268
269
 
269
270
  $.createGraphics = (width, height) => {
@@ -376,7 +377,7 @@ function Q5(scope, parent) {
376
377
  if (neg) s = '-' + s;
377
378
  return s;
378
379
  };
379
- $.createVector = (x, y, z) => new Q5.Vector(x, y, z);
380
+ $.createVector = (x, y, z) => new Q5.Vector(x, y, z, $);
380
381
 
381
382
  //================================================================
382
383
  // CURVE QUERY
@@ -2351,10 +2352,11 @@ Q5.Color._hsv2rgb = (h, s, v) => {
2351
2352
  // VECTOR
2352
2353
  //================================================================
2353
2354
  Q5.Vector = class {
2354
- constructor(_x, _y, _z) {
2355
+ constructor(_x, _y, _z, _$) {
2355
2356
  this.x = _x || 0;
2356
2357
  this.y = _y || 0;
2357
2358
  this.z = _z || 0;
2359
+ this._$ = _$ || window;
2358
2360
  this._cn = null;
2359
2361
  this._cnsq = null;
2360
2362
  }
@@ -2489,11 +2491,11 @@ Q5.Vector = class {
2489
2491
  return this;
2490
2492
  }
2491
2493
  heading() {
2492
- return atan2(this.y, this.x);
2494
+ return this._$.atan2(this.y, this.x);
2493
2495
  }
2494
2496
  rotate(ang) {
2495
- let costh = cos(ang);
2496
- let sinth = sin(ang);
2497
+ let costh = this._$.cos(ang);
2498
+ let sinth = this._$.sin(ang);
2497
2499
  let vx = this.x * costh - this.y * sinth;
2498
2500
  let vy = this.x * sinth + this.y * costh;
2499
2501
  this.x = vx;
@@ -2504,7 +2506,7 @@ Q5.Vector = class {
2504
2506
  let u = this._arg2v(...arguments);
2505
2507
  const costh = this.dot(u) / (this.mag() * u.mag());
2506
2508
  let ang;
2507
- ang = tan(Math.min(1, Math.max(-1, costh)));
2509
+ ang = this._$.tan(Math.min(1, Math.max(-1, costh)));
2508
2510
  ang = ang * Math.sign(this.cross(u).z || 1);
2509
2511
  return ang;
2510
2512
  }
@@ -2533,8 +2535,8 @@ Q5.Vector = class {
2533
2535
  if (l === undefined) l = 1;
2534
2536
  this._cn = l;
2535
2537
  this._cnsq = l * l;
2536
- this.x = l * cos(th);
2537
- this.y = l * sin(th);
2538
+ this.x = l * this._$.cos(th);
2539
+ this.y = l * this._$.sin(th);
2538
2540
  this.z = 0;
2539
2541
  return this;
2540
2542
  }
@@ -2542,10 +2544,10 @@ Q5.Vector = class {
2542
2544
  if (l === undefined) l = 1;
2543
2545
  this._cn = l;
2544
2546
  this._cnsq = l * l;
2545
- const cosph = cos(ph);
2546
- const sinph = sin(ph);
2547
- const costh = cos(th);
2548
- const sinth = sin(th);
2547
+ const cosph = this._$.cos(ph);
2548
+ const sinph = this._$.sin(ph);
2549
+ const costh = this._$.cos(th);
2550
+ const sinth = this._$.sin(th);
2549
2551
  this.x = l * sinth * sinph;
2550
2552
  this.y = -l * costh;
2551
2553
  this.z = l * sinth * cosph;
package/q5.min.js CHANGED
@@ -4,4 +4,4 @@
4
4
  * @author quinton-ashley and LingDong-
5
5
  * @license GPL-3.0-only
6
6
  */
7
- function Q5(e,t){if("auto"==e){if(void 0===window.setup)return;e="global"}1==arguments.length&&"string"!=typeof e&&"function"!=typeof e&&(t=arguments[0],e=null),"global"==e&&(Q5._hasGlobal=!0);let a=this;a.canvas=document.createElement("canvas");let o=a.canvas.getContext("2d");a.width=100,a.height=100,a.canvas.width=a.width,a.canvas.height=a.height,a.windowResized=()=>{},"graphics"!=e&&"image"!=e&&(window.addEventListener("resize",a.windowResized),a.canvas.parent=e=>{e[0]&&(e=document.getElementById(e)),e.append(a.canvas)},document.body?(t??=document.getElementsByTagName("main")[0],t?.append?t.append(a.canvas):document.body.appendChild(a.canvas)):window.addEventListener("load",(()=>{document.body.appendChild(a.canvas)}))),g(),a.MAGIC=161533525,a.RGB=0,a.HSV=1,a.HSB=1,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.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.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.THRESHOLD=1,a.GRAY=2,a.OPAQUE=3,a.INVERT=4,a.POSTERIZE=5,a.DILATE=6,a.ERODE=7,a.BLUR=8,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.HARDWARE_FILTERS=!0,a.hint=(e,t)=>{a[e]=t},a.frameCount=0,a.deltaTime=16,a.mouseX=0,a.mouseY=0,a.mouseButton=null,a.keyIsPressed=!1,a.mouseIsPressed=!1,a.key=null,a.keyCode=null,a.pixels=[],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,a.touches=[],a._colorMode=a.RGB,a._doStroke=!0,a._doFill=!0,a._strokeSet=!1,a._fillSet=!1,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=12,a._textStyle="normal",a._pixelDensity=1,a._lastFrameTime=0,a._targetFrameRate=null,a._frameRate=a._fps=60,a._tint=null;let n=null,r=!0,i=[],s=null,l=0,h={},c=0,d=null,u=null,_=null;Object.defineProperty(a,"deviceOrientation",{get:()=>window.screen.orientation.type}),Object.defineProperty(a,"windowWidth",{get:()=>window.innerWidth}),Object.defineProperty(a,"windowHeight",{get:()=>window.innerHeight}),Object.defineProperty(a,"drawingContext",{get:()=>o}),a.createCanvas=(t,o)=>(a.width=t,a.height=o,a.canvas.width=t*a._pixelDensity,a.canvas.height=o*a._pixelDensity,g(),"graphics"!=e&&"image"!=e&&a.pixelDensity(2),a.canvas),a.resizeCanvas=(e,t)=>{a.width=e,a.height=t,a.canvas.width=e*a._pixelDensity,a.canvas.height=t*a._pixelDensity},a.createGraphics=(e,t)=>{let a=new Q5("graphics");return a.createCanvas(e,t),a},a.createImage=(e,t)=>new Q5.Image(e,t),a.pixelDensity=e=>(void 0===e||(a._pixelDensity=e,a.canvas.width=Math.ceil(a.width*e),a.canvas.height=Math.ceil(a.height*e),a.canvas.style.width=a.width+"px",a.canvas.style.height=a.height+"px",o.scale(a._pixelDensity,a._pixelDensity),g()),a._pixelDensity),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(){return 4==arguments.length?Math.hypot(arguments[0]-arguments[2],arguments[1]-arguments[3]):Math.hypot(arguments[0]-arguments[3],arguments[1]-arguments[4],arguments[2]-arguments[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.toString();return o&&(n=n.slice(1)),n=n.padStart(t,"0"),a>0&&(-1==n.indexOf(".")&&(n+="."),n=n.padEnd(t+1+a,"0")),o&&(n="-"+n),n},a.createVector=(e,t,a)=>new Q5.Vector(e,t,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)},a.Color=Q5.Color,a.colorMode=e=>{a._colorMode=e};let m={black:[0,0,0],blue:[0,0,255],brown:[165,42,42],crimson:[220,20,60],gold:[255,215,0],green:[0,128,0],gray:[128,128,128],magenta:[255,0,255],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],red:[255,0,0],skyblue:[135,206,235],white:[255,255,255],yellow:[255,255,0]};function g(){o.fillStyle="white",o.strokeStyle="black",o.lineCap="round",o.lineJoin="miter"}function p(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 v(e,t,n,r,i,s,l,h){if(!a._doFill&&!a._doStroke)return;let c=p(i),d=p(s);if(c>d&&([c,d]=[d,c]),0==c){if(0==d)return;if(a._angleMode==a.DEGREES&&360==d||d==a.TAU)return a.ellipse(e,t,n,r)}o.beginPath();for(let i=0;i<h+1;i++){let s=i/h,l=a.lerp(c,d,s),u=a.cos(l)*n/2,_=a.sin(l)*r/2;o[i?"lineTo":"moveTo"](e+u,t+_)}l==a.CHORD?o.closePath():l==a.PIE&&(o.lineTo(e,t),o.closePath()),a._doFill&&o.fill(),a._doStroke&&o.stroke()}function f(e,t,n,r){(a._doFill||a._doStroke)&&(o.beginPath(),o.ellipse(e,t,n/2,r/2,0,0,a.TAU),a._doFill&&o.fill(),a._doStroke&&o.stroke())}function y(e,t,n,r,i,s,l,h){if(!a._doFill&&!a._doStroke)return;if(void 0===i)return function(e,t,n,r){a._doFill&&o.fillRect(e,t,n,r),a._doStroke&&o.strokeRect(e,t,n,r)}(e,t,n,r);if(void 0===s)return y(e,t,n,r,i,i,i,i);const c=Math.min(Math.abs(r),Math.abs(n))/2;i=Math.min(c,i),s=Math.min(c,s),h=Math.min(c,h),l=Math.min(c,l),o.beginPath(),o.moveTo(e+i,t),o.arcTo(e+n,t,e+n,t+r,s),o.arcTo(e+n,t+r,e,t+r,l),o.arcTo(e,t+r,e,t,h),o.arcTo(e,t,e+n,t,i),o.closePath(),a._doFill&&o.fill(),a._doStroke&&o.stroke()}function x(){i=[]}a.color=function(){let e=arguments;if(1==e.length){if(786698==e[0].MAGIC)return e[0];if("string"==typeof e[0])return"#"==e[0][0]?new Q5.Color(parseInt(e[0].slice(1,3),16),parseInt(e[0].slice(3,5),16),parseInt(e[0].slice(5,7),16),1):m[e[0]]?new Q5.Color(...m[e[0]],1):new Q5.Color(0,0,0,1)}if(a._colorMode==a.RGB){if(1==e.length)return new Q5.Color(e[0],e[0],e[0],1);if(2==e.length)return new Q5.Color(e[0],e[0],e[0],e[1]/255);if(3==e.length)return new Q5.Color(e[0],e[1],e[2],1);if(4==e.length)return new Q5.Color(e[0],e[1],e[2],e[3]/255)}else{if(1==e.length)return new Q5.Color(...Q5.Color._hsv2rgb(0,0,e[0]/100),1);if(2==e.length)return new Q5.Color(...Q5.Color._hsv2rgb(0,0,e[0]/100),e[1]/255);if(3==e.length)return new Q5.Color(...Q5.Color._hsv2rgb(e[0],e[1]/100,e[2]/100),1);if(4==e.length)return new Q5.Color(...Q5.Color._hsv2rgb(e[0],e[1]/100,e[2]/100),e[3])}return null},a.red=e=>e._r,a.green=e=>e._g,a.blue=e=>e._b,a.alpha=e=>255*e._a,a.hue=e=>(e._inferHSV(),e._h),a.saturation=e=>(e._inferHSV(),e._s),a.brightness=e=>(e._inferHSV(),e._v),a.lightness=e=>100*(.2126*e._r+.7152*e._g+.0722*e._b)/255,a.lerpColor=(e,t,o)=>a._colorMode==a.RGB?new Q5.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,1)):(e._inferHSV(),t._inferHSV(),new Q5.Color(a.constrain(function(e,t,o){var n=[[Math.abs(t-e),a.map(o,0,1,e,t)],[Math.abs(t+360-e),a.map(o,0,1,e,t+360)],[Math.abs(t-360-e),a.map(o,0,1,e,t-360)]];return n.sort(((e,t)=>e[0]-t[0])),(n[0][1]+720)%360}(e._h,t._h,o),0,360),a.constrain(a.lerp(e._s,t._s,o),0,100),a.constrain(a.lerp(e._v,t._v,o),0,100),a.constrain(a.lerp(e._a,t._a,o),0,1))),a.strokeWeight=e=>{a._doStroke=e>0,o.lineWidth=e},a.stroke=function(){if(a._doStroke=!0,a._strokeSet=!0,"string"==typeof arguments[0])return void(o.strokeStyle=arguments[0]);let e=a.color(...arguments);e._a<=0?a._doStroke=!1:o.strokeStyle=e},a.noStroke=()=>a._doStroke=!1,a.fill=function(){if(a._doFill=!0,a._fillSet=!0,"string"==typeof arguments[0])return void(o.fillStyle=arguments[0]);let e=a.color(...arguments);e._a<=0?a._doFill=!1:o.fillStyle=e},a.noFill=()=>a._doFill=!1,a.smooth=()=>a._smooth=!0,a.noSmooth=()=>a._smooth=!1,a.blendMode=e=>o.globalCompositeOperation=e,a.strokeCap=e=>o.lineCap=e,a.strokeJoin=e=>o.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=>{console.warn("curveTightness() sets the 'alpha' parameter of Catmull-Rom curve, and is NOT identical to p5.js counterpart. As this might change in the future, please call curveAlpha() directly."),a._curveAlpha=e},a.clear=()=>{o.clearRect(0,0,a.canvas.width,a.canvas.height)},a.background=function(){if(arguments[0]&&arguments[0].MAGIC==a.MAGIC)return a.image(arguments[0],0,0,a.width,a.height);o.save(),o.resetTransform(),o.fillStyle="string"==typeof arguments[0]?arguments[0]:a.color(...Array.from(arguments)),o.fillRect(0,0,a.canvas.width,a.canvas.height),o.restore()},a.line=(e,t,n,r)=>{a._doStroke&&(o.beginPath(),o.moveTo(e,t),o.lineTo(n,r),o.stroke())},a.arc=(e,t,o,n,r,i,s,l)=>{if(r==i)return a.ellipse(e,t,o,n);l??=25,s??=a.PIE,a._ellipseMode==a.CENTER?v(e,t,o,n,r,i,s,l):a._ellipseMode==a.RADIUS?v(e,t,2*o,2*n,r,i,s,l):a._ellipseMode==a.CORNER?v(e+o/2,t+n/2,o,n,r,i,s,l):a._ellipseMode==a.CORNERS&&v((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?f(e,t,o,n):a._ellipseMode==a.RADIUS?f(e,t,2*o,2*n):a._ellipseMode==a.CORNER?f(e+o/2,t+n/2,o,n):a._ellipseMode==a.CORNERS&&f((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),o.beginPath(),o.ellipse(e,t,.4,.4,0,0,a.TAU),o.stroke()},a.rect=(e,t,o,n,r,i,s,l)=>{a._rectMode==a.CENTER?y(e-o/2,t-n/2,o,n,r,i,s,l):a._rectMode==a.RADIUS?y(e-o,t-n,2*o,2*n,r,i,s,l):a._rectMode==a.CORNER?y(e,t,o,n,r,i,s,l):a._rectMode==a.CORNERS&&y(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=()=>{x(),o.beginPath(),r=!0},a.beginContour=()=>{o.closePath(),x(),r=!0},a.endContour=()=>{x(),r=!0},a.vertex=(e,t)=>{x(),r?o.moveTo(e,t):o.lineTo(e,t),r=!1},a.bezierVertex=(e,t,a,n,r,i)=>{x(),o.bezierCurveTo(e,t,a,n,r,i)},a.quadraticVertex=(e,t,a,n)=>{x(),o.quadraticCurveTo(e,t,a,n)},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=>{x(),e&&o.closePath(),a._doFill&&o.fill(),a._doStroke&&o.stroke(),a._doFill||a._doStroke||(o.save(),o.fillStyle="none",o.fill(),o.restore())},a.curveVertex=(e,t)=>{if(i.push([e,t]),i.length<4)return;let n=function(e,t,a,o,n,r,i,s,l,h){function c(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=c(0,e,t,a,o,h),_=c(u,a,o,n,r,h),m=c(_,n,r,i,s,h);for(let h=0;h<l;h++){let c=u+h/(l-1)*(_-u),g=[(u-c)/(u-0),(c-0)/(u-0),(_-c)/(_-u),(c-u)/(_-u),(m-c)/(m-_),(c-_)/(m-_),(_-c)/(_-0),(c-0)/(_-0),(m-c)/(m-u),(c-u)/(m-u)];for(let e=0;e<g.length;e+=2)isNaN(g[e])&&(g[e]=1,g[e+1]=0),isFinite(g[e])||(g[e]>0?(g[e]=1,g[e+1]=0):(g[e]=0,g[e+1]=1));let p=e*g[0]+a*g[1],v=t*g[0]+o*g[1],f=a*g[2]+n*g[3],y=o*g[2]+r*g[3],x=n*g[4]+i*g[5],M=r*g[4]+s*g[5],w=p*g[6]+f*g[7],R=v*g[6]+y*g[7],S=f*g[8]+x*g[9],I=y*g[8]+M*g[9],E=w*g[2]+S*g[3],C=R*g[2]+I*g[3];d.push([E,C])}return d}(...i[i.length-4],...i[i.length-3],...i[i.length-2],...i[i.length-1],a._curveDetail,a._curveAlpha);for(let e=0;e<n.length;e++)r?o.moveTo(...n[e]):o.lineTo(...n[e]),r=!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.translate=(e,t)=>o.translate(e,t),a.rotate=e=>{"degrees"==a._angleMode&&(e=a.radians(e)),o.rotate(e)},a.scale=(e,t)=>{t??=e,o.scale(e,t)},a.applyMatrix=(e,t,a,n,r,i)=>{o.transform(e,t,a,n,r,i)},a.shearX=e=>{o.transform(1,0,a.tan(e),1,0,0)},a.shearY=e=>{o.transform(1,a.tan(e),0,1,0,0)},a.resetMatrix=()=>{o.resetTransform(),o.scale(a._pixelDensity,a._pixelDensity)},a._styleNames=["_doStroke","_doFill","_strokeSet","_fillSet","_tint","_imageMode","_rectMode","_ellipseMode","_textFont","_textLeading","_leadingSet","_textSize","_textAlign","_textBaseline","_textStyle","_textWrap"],a._ctxStyleNames=["strokeStyle","fillStyle","lineWidth","lineCap","lineJoin"],a._styles=[],a._ctxStyles=[],a.pushMatrix=a.push=()=>{o.save();let e={};for(let t of a._styleNames)e[t]=a[t];a._styles.push(e);let t={};for(let e of a._ctxStyleNames)t[e]=o[e];a._ctxStyles.push(t)},a.popMatrix=a.pop=()=>{o.restore();let e=a._styles.pop();for(let t of a._styleNames)a[t]=e[t];let t=a._ctxStyles.pop();for(let e of a._ctxStyleNames)o[e]=t[e]},a.imageMode=e=>a._imageMode=e,a.image=(e,t,n,r,i,s,l,h,c)=>{let d=e.MAGIC==a.MAGIC?e.canvas:e;function _(){if(e.MAGIC!=a.MAGIC||!a._tint)return;let t=e.canvas.getContext("2d");t.save(),t.resetTransform(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(u.canvas,0,0),t.restore()}if(e.MAGIC==a.MAGIC&&null!=a._tint&&(!function(e,t){null==u&&(u=document.createElement("canvas").getContext("2d"));t??=e||o.canvas.height,e??=o.canvas.width,(u.canvas.width!=e||u.canvas.height!=t)&&(u.canvas.width=e,u.canvas.height=t)}(e.canvas.width,e.canvas.height),u.drawImage(e.canvas,0,0),e.tinted(a._tint)),r||(e.MAGIC==a.MAGIC||e.width?(r=e.width,i=e.height):(r=e.videoWidth,i=e.videoHeight)),"center"==a._imageMode&&(t-=.5*r,n-=.5*i),void 0===s)return o.drawImage(d,t,n,r,i),void _();h??=d.width,c??=d.height,o.drawImage(d,s,l,h,c,t,n,r,i),_()},a.loadPixels=()=>{s=o.getImageData(0,0,a.canvas.width,a.canvas.height),a.pixels=s.data},a.updatePixels=()=>{null!=s&&o.putImageData(s,0,0)},a._incrementPreload=()=>l++,a._decrementPreload=()=>l--,a.loadImage=(e,t)=>{l++;let o=a.createImage(100,100),n=o.canvas.getContext("2d"),r=new window.Image;return r.src=e,r.crossOrigin="Anonymous",r.onload=()=>{o.width=n.canvas.width=r.naturalWidth,o.height=n.canvas.height=r.naturalHeight,n.drawImage(r,0,0),l--,t&&t(o)},r.onerror=e=>{throw l--,e},o};let M={};function w(e,t){null==d&&(d=document.createElement("canvas").getContext("2d")),t??=e||o.canvas.height,e??=o.canvas.width,d.canvas.width==e&&d.canvas.height==t||(d.canvas.width=e,d.canvas.height=t)}function R(){let e=o.canvas.width*o.canvas.height*4;_&&e==_.length||(_=new Uint8ClampedArray(e))}function S(e){d.clearRect(0,0,d.canvas.width,d.canvas.height),d.filter=e,d.drawImage(o.canvas,0,0),o.save(),o.resetTransform(),o.clearRect(0,0,o.canvas.width,o.canvas.height),o.drawImage(d.canvas,0,0),o.restore()}if(M[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}},M[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}},M[a.OPAQUE]=e=>{for(let t=0;t<e.length;t+=4)e[t+3]=255},M[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]},M[a.POSTERIZE]=(e,t)=>{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},M[a.DILATE]=e=>{R(),_.set(e);let[t,a]=[o.canvas.width,o.canvas.height];for(let o=0;o<a;o++)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(o-1,0)*t,l=4*Math.min(o+1,a-1)*t,h=4*o*t,c=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+h;e[h+c+t]=Math.max(_[a+c],_[n+r],_[n+c],_[n+i],_[o+c])}}},M[a.ERODE]=e=>{R(),_.set(e);let[t,a]=[o.canvas.width,o.canvas.height];for(let o=0;o<a;o++)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(o-1,0)*t,l=4*Math.min(o+1,a-1)*t,h=4*o*t,c=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+h;e[h+c+t]=Math.min(_[a+c],_[n+r],_[n+c],_[n+i],_[o+c])}}},M[a.BLUR]=(e,t)=>{t=t||1,t=Math.floor(t*a._pixelDensity),R(),_.set(e);let n=2*t+1;let r=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}(n),[i,s]=[o.canvas.width,o.canvas.height];for(let a=0;a<s;a++)for(let o=0;o<i;o++){let s=0,l=0,h=0,c=0;for(let e=0;e<n;e++){let n=4*(a*i+Math.min(Math.max(o-t+e,0),i-1));s+=_[n]*r[e],l+=_[n+1]*r[e],h+=_[n+2]*r[e],c+=_[n+3]*r[e]}let d=4*(a*i+o);e[d]=s,e[d+1]=l,e[d+2]=h,e[d+3]=c}_.set(e);for(let a=0;a<s;a++)for(let o=0;o<i;o++){let l=0,h=0,c=0,d=0;for(let e=0;e<n;e++){let n=4*(Math.min(Math.max(a-t+e,0),s-1)*i+o);l+=_[n]*r[e],h+=_[n+1]*r[e],c+=_[n+2]*r[e],d+=_[n+3]*r[e]}let u=4*(a*i+o);e[u]=l,e[u+1]=h,e[u+2]=c,e[u+3]=d}},a.filter=(e,t)=>{if(a.HARDWARE_FILTERS&&null!=o.filter)if(w(),e==a.THRESHOLD){t??=.5,t=Math.max(t,1e-5),S(`saturate(0%) brightness(${Math.floor(.5/t*100)}%) contrast(1000000%)`)}else if(e==a.GRAY)S("saturate(0%)");else if(e==a.OPAQUE)d.fillStyle="black",d.fillRect(0,0,d.canvas.width,d.canvas.height),d.drawImage(o.canvas,0,0),o.save(),o.resetTransform(),o.drawImage(d.canvas,0,0),o.restore();else if(e==a.INVERT)S("invert(100%)");else if(e==a.BLUR)S(`blur(${Math.ceil(t*a._pixelDensity/1)||1}px)`);else{let a=o.getImageData(0,0,o.canvas.width,o.canvas.height);M[e](a.data,t),o.putImageData(a,0,0)}else{let a=o.getImageData(0,0,o.canvas.width,o.canvas.height);M[e](a.data,t),o.putImageData(a,0,0)}},a.resize=(e,t)=>{w(),d.drawImage(o.canvas,0,0),a.width=e,a.height=t,o.canvas.width=e*a._pixelDensity,o.canvas.height=t*a._pixelDensity,o.save(),o.resetTransform(),o.clearRect(0,0,o.canvas.width,o.canvas.height),o.drawImage(d.canvas,0,0,o.canvas.width,o.canvas.height),o.restore()},a.get=(e,t,n,r)=>{if(void 0!==e&&void 0===n){let a=o.getImageData(e,t,1,1).data;return new Q5.Color(a[0],a[1],a[2],a[3]/255)}e=e||0,t=t||0,n=n||a.width,r=r||a.height;let i=a.createGraphics(n,r);i.pixelDensity(a._pixelDensity);let s=o.getImageData(e*a._pixelDensity,t*a._pixelDensity,n*a._pixelDensity,r*a._pixelDensity);return i.canvas.getContext("2d").putImageData(s,0,0),i},a.set=(e,t,n)=>{if(n.MAGIC==a.MAGIC){let o=a._tint;return a._tint=null,a.image(n,e,t),void(a._tint=o)}for(let r=0;r<a._pixelDensity;r++)for(let i=0;i<a._pixelDensity;i++){let s=4*((t*a._pixelDensity+r)*o.canvas.width+e*a._pixelDensity+i);a.pixels[s]=n._r,a.pixels[s+1]=n._g,a.pixels[s+2]=n._b,a.pixels[s+3]=255*n._a}},a.tinted=function(){let e=a.color(...Array.from(arguments)),t=e._a;e._a=1,w(),d.clearRect(0,0,d.canvas.width,d.canvas.height),d.fillStyle=e,d.fillRect(0,0,d.canvas.width,d.canvas.height),d.globalCompositeOperation="multiply",d.drawImage(o.canvas,0,0),d.globalCompositeOperation="source-over",o.save(),o.resetTransform();let n=o.globalCompositeOperation;o.globalCompositeOperation="source-in",o.drawImage(d.canvas,0,0),o.globalCompositeOperation=n,o.restore(),d.globalAlpha=t,d.clearRect(0,0,d.canvas.width,d.canvas.height),d.drawImage(o.canvas,0,0),d.globalAlpha=1,o.save(),o.resetTransform(),o.clearRect(0,0,o.canvas.width,o.canvas.height),o.drawImage(d.canvas,0,0),o.restore()},a.tint=function(){a._tint=a.color(...Array.from(arguments))},a.noTint=()=>a._tint=null,a.mask=e=>{o.save(),o.resetTransform();let t=o.globalCompositeOperation;o.globalCompositeOperation="destination-in",o.drawImage(e.canvas,0,0),o.globalCompositeOperation=t,o.restore()},a.clearTemporaryBuffers=()=>{d=null,u=null,_=null},a.save=(e,t)=>{e=e||"untitled",t=t||"png";var a=document.createElement("a");a.innerHTML="[Download]",a.addEventListener("click",(function(){this.href=o.canvas.toDataURL(),this.download=e+"."+t}),!1),document.body.appendChild(a),a.click(),document.body.removeChild(a)},a.saveCanvas=(e,t,o)=>{if(e.MAGIC==a.MAGIC){o&&e.save(t,o);let a=t.split(".");return e.save(a.slice(0,-1).join("."),a[a.length-1])}if(t)return a.save(e,t);let n=e.split(".");return a.save(n.slice(0,-1).join("."),n[n.length-1])},a.remove=()=>{a.noLoop(),a.canvas.remove()},"image"==e)return;a.loadFont=(e,t)=>{let a=e.split("/"),o=a[a.length-1].split(".")[0].replace(" ",""),n=`@font-face {\n font-family: '${o}';\n src: url('${e}');\n }`;const r=document.createElement("style");return r.textContent=n,document.head.append(r),o},a.textFont=e=>{a._textFont=e},a.textSize=e=>{if(void 0===e)return a._textSize;a._textLeading=e,a._textSize=e},a.textLeading=e=>{a._textLeading=e},a.textStyle=e=>{a._textStyle=e},a.textAlign=(e,t)=>{o.textAlign=e,t&&(o.textBaseline=t==a.CENTER?"middle":t)},a.text=(e,t,n,r)=>{if(void 0===e)return;if(e=e.toString(),!a._doFill&&!a._doStroke)return;o.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`;let i=e.split("\n");for(let e=0;e<i.length;e++){let s=o.fillStyle;a._fillSet||(o.fillStyle="black"),a._doFill&&o.fillText(i[e],t,n,r),a._doStroke&&a._strokeSet&&o.strokeText(i[e],t,n,r),a._fillSet||(o.fillStyle=s),n+=a._textLeading}},a.textWidth=e=>(o.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,o.measureText(e).width),a.textAscent=e=>(o.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,o.measureText(e).actualBoundingBoxAscent),a.textDescent=e=>(o.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,o.measureText(e).actualBoundingBoxDescent);var I,E=4095,C=4,D=.5,b=e=>.5*(1-Math.cos(e*Math.PI));a.noise=(e,t,a)=>{if(t??=0,a??=0,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,h=Math.floor(e),c=Math.floor(t),d=Math.floor(a),u=e-h,_=t-c,m=a-d,g=0,p=.5,v=0;v<C;v++){var f=h+(c<<4)+(d<<8);n=b(u),r=b(_),i=I[f&E],i+=n*(I[f+1&E]-i),s=I[f+16&E],i+=r*((s+=n*(I[f+16+1&E]-s))-i),s=I[(f+=256)&E],s+=n*(I[f+1&E]-s),l=I[f+16&E],s+=r*((l+=n*(I[f+16+1&E]-l))-s),g+=(i+=b(m)*(s-i))*p,p*=D,h<<=1,c<<=1,d<<=1,(u*=2)>=1&&(h++,u--),(_*=2)>=1&&(c++,_--),(m*=2)>=1&&(d++,m--)}return g},a.noiseDetail=(e,t)=>{e>0&&(C=e),t>0&&(D=t)};const A=()=>{let e,t,a=4294967295;return{setSeed(o){e=t=(null==o?Math.random()*a:o)>>>0},getSeed:()=>t,rand:()=>(e^=e<<17,e^=e>>13,e^=e<<5,(e>>>0)/a)}};let T=A();T.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=>T.setSeed(e),a.random=(e,t)=>void 0===e?T.rand():"number"==typeof e?void 0!==t?T.rand()*(t-e)+e:T.rand()*e:e[~~(e.length*T.rand())],a.randomGenerator=e=>{e==a.LCG?T=(()=>{const e=4294967296;let t,a;return{setSeed(o){a=t=(null==o?Math.random()*e:o)>>>0},getSeed:()=>t,rand:()=>(a=(1664525*a+1013904223)%e,a/e)}})():e==a.SHR3&&(T=A()),T.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),h=()=>4294967296*T.rand()-2147483648,c=()=>.5+2.328306e-10*(h()<<0),d=()=>{for(var t,n,s,l,d=3.44262;;){if(t=a*r[e],0==e){do{s=c(),l=c(),t=.2904764*-Math.log(s),n=-Math.log(l)}while(n+n<t*t);return a>0?d+t:-d-t}if(i[e]+c()*(i[e-1]-i[e])<Math.exp(-.5*t*t))return t;if(a=h(),e=127&a,Math.abs(a)<o[e])return a*r[e]}},u=()=>{for(var a;;){if(0==e)return 7.69711-Math.log(c());if(a=t*s[e],l[e]+c()*(l[e-1]-l[e])<Math.exp(-a))return a;if((t=h())<n[e=255&t])return t*s[e]}};this.SHR3=h,this.UNI=c,this.RNOR=()=>(a=h(),e=127&a,Math.abs(a)<o[e]?a*r[e]:d()),this.REXP=()=>(t=h()>>>0)<o[e=255&t]?t*s[e]:u(),this.zigset=()=>{var e,t,a=2147483648,h=4294967296,c=3.442619855899,d=c,u=.00991256303526217,_=7.697117470131487,m=_,g=.003949659822581572;for(e=u/Math.exp(-.5*c*c),o[0]=Math.floor(c/e*a),o[1]=0,r[0]=e/a,r[127]=c/a,i[0]=1,i[127]=Math.exp(-.5*c*c),t=126;t>=1;t--)c=Math.sqrt(-2*Math.log(u/c+Math.exp(-.5*c*c))),o[t+1]=Math.floor(c/d*a),d=c,i[t]=Math.exp(-.5*c*c),r[t]=c/a;for(e=g/Math.exp(-_),n[0]=Math.floor(_/e*h),n[1]=0,s[0]=e/h,s[255]=_/h,l[0]=1,l[255]=Math.exp(-_),t=254;t>=1;t--)_=-Math.log(g/_+Math.exp(-_)),n[t+1]=Math.floor(_/m*h),m=_,l[t]=Math.exp(-_),s[t]=_/h}};function O(){let e=performance.now();if(a._loop&&(n=a._targetFrameRate?setTimeout(O,1e3/a._targetFrameRate):requestAnimationFrame(O)),n&&0!=a._frameCount){if(e-a._lastFrameTime<1e3/(a._targetFrameRate||60)-5)return}a.deltaTime=e-a._lastFrameTime,a._frameRate=1e3/a.deltaTime,a.frameCount++;for(let e of Q5.prototype._methods.pre)e.call(a);x(),r=!0,o.save(),a._drawFn();for(let e of Q5.prototype._methods.post)e.call(a);o.restore();let t=performance.now();a._fps=Math.round(1e3/(t-e)),a._lastFrameTime=e,a.pmouseX=a.mouseX,a.pmouseY=a.mouseY}function k(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}}function z(){return a._touchStartedFn.isPlaceHolder&&a._touchMovedFn.isPlaceHolder&&a._touchEndedFn.isPlaceHolder}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.print=console.log,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.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.appendChild(t),t},a.noLoop=()=>{a._loop=!1,n=null},a.loop=()=>{a._loop=!0,null==n&&O()},a.redraw=()=>O(),a.frameRate=e=>(e&&(a._targetFrameRate=e),a._frameRate),a.getFrameRate=()=>a._frameRate,a.getFPS=()=>a._fps,a._updateMouse=function(e){let t=this,a=t.canvas.getBoundingClientRect(),o=t.canvas.scrollWidth/t.width||1,n=t.canvas.scrollHeight/t.height||1;t.mouseX=(e.clientX-a.left)/o,t.mouseY=(e.clientY-a.top)/n}.bind(a),a._onmousemove=function(e){a._updateMouse(e),this.mouseIsPressed?this._mouseDraggedFn(e):this._mouseMovedFn(e)}.bind(a),a._onmousedown=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a.mouseButton=[a.LEFT,a.CENTER,a.RIGHT][e.button],a._mousePressedFn(e)},a._onmouseup=e=>{a._updateMouse(e),a.mouseIsPressed=!1,a._mouseReleasedFn(e)},a._onclick=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a._mouseClickedFn(e),a.mouseIsPressed=!1},a._onkeydown=e=>{e.repeat||(a.keyIsPressed=!0,a.key=e.key,a.keyCode=e.keyCode,h[a.keyCode]=!0,a._keyPressedFn(e),1==e.key.length&&a._keyTypedFn(e))},a._onkeyup=e=>{a.keyIsPressed=!1,a.key=e.key,a.keyCode=e.keyCode,h[a.keyCode]=!1,a._keyReleasedFn(e)},addEventListener("mousemove",(e=>a._onmousemove(e)),!1),a.canvas.onmousedown=e=>a._onmousedown(e),a.canvas.onmouseup=e=>a._onmouseup(e),a.canvas.onclick=e=>a._onclick(e),addEventListener("keydown",(e=>a._onkeydown(e)),!1),addEventListener("keyup",(e=>a._onkeyup(e)),!1),a.keyIsDown=e=>!!h[e],a._ontouchstart=e=>{a.touches=[...e.touches].map(k),z()&&(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseIsPressed=!0,a.mouseButton=a.LEFT,a._mousePressedFn(e)||e.preventDefault()),a._touchStartedFn(e)||e.preventDefault()},a._ontouchmove=e=>{a.touches=[...e.touches].map(k),z()&&(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseIsPressed=!0,a.mouseButton=a.LEFT,a._mouseDraggedFn(e)||e.preventDefault()),a._touchMovedFn(e)||e.preventDefault()},a._ontouchend=e=>{a.touches=[...e.touches].map(k),z()&&(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseIsPressed=!1,a._mouseReleasedFn(e)||e.preventDefault()),a._touchEndedFn(e)||e.preventDefault()},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)};"undefined"!=typeof window&&(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][1+~~(window.orientation/90)],a.relRotationY=[-a.rotationX,a.rotationY,a.rotationX][1+~~(window.orientation/90)],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()-c,a.storeItem=localStorage.setItem,a.getItem=localStorage.getItem,a.removeItem=localStorage.removeItem,a.clearStorage=localStorage.clear,a._loadFile=(e,t,a)=>{l++;let o={};return fetch(e).then((e=>"json"==a?e.json():"text"==a?e.text():void 0)).then((e=>{l--,Object.assign(o,e),t&&t(e)})),o},a.loadStrings=(e,t)=>a._loadFile(e,t,"text"),a.loadJSON=(e,t)=>a._loadFile(e,t,"json"),a.loadSound=(e,t)=>{l++;let a=new Audio(e);return a.addEventListener("canplaythrough",(()=>{l--,t&&t(a)})),a.load(),a.setVolume=e=>a.volume=e,a},a.Element=function(e){this.elt=e},a._elements=[],"global"==e&&(Object.assign(Q5,a),delete Q5.Q5),Q5.Image??=_Q5Image;for(let e of Q5.prototype._methods.init)e.call(a);if("global"==e){let e=Object.getOwnPropertyNames(a);for(let t of e)"function"==typeof a[t]?window[t]=a[t]:Object.defineProperty(window,t,{get:()=>a[t],set:e=>a[t]=e})}"function"==typeof e&&e(a);let F="global"==e?window:a,Q=["setup","draw","preload","mouseMoved","mousePressed","mouseReleased","mouseDragged","mouseClicked","keyPressed","keyReleased","keyTyped","touchStarted","touchMoved","touchEnded"];for(let e of Q){let t="_"+e+"Fn";a[t]=()=>{},a[t].isPlaceHolder=!0,F[e]?a[t]=F[e]:Object.defineProperty(a,e,{set:e=>{a[t]=e}})}if("graphics"!=e||"image"!=e){a._preloadFn(),c=performance.now(),function e(){if(l>0)return requestAnimationFrame(e);a._setupFn(),requestAnimationFrame(O)}()}}Q5.Color=class{constructor(e,t,a,o){this.MAGIC=786698,this._r=e,this._g=t,this._b=a,this._a=o,this._h=0,this._s=0,this._v=0,this._hsvInferred=!1}setRed(e){this._r=e,this._hsvInferred=!1}setGreen(e){this._g=e,this._hsvInferred=!1}setBlue(e){this._b=e,this._hsvInferred=!1}setAlpha(e){this._a=e/255,this._hsvInferred=!1}get levels(){return[this._r,this._g,this._b,255*this._a]}_inferHSV(){this._hsvInferred||([this._h,this._s,this._v]=Q5.Color._rgb2hsv(this._r,this._g,this._b),this._hsvInferred=!0)}toString(){return`rgba(${Math.round(this._r)},${Math.round(this._g)},${Math.round(this._b)},${~~(1e3*this._a)/1e3})`}},Q5.Color._rgb2hsv=(e,t,a)=>{let o,n,r,i,s;return o=e<t?e<a?e:a:t<a?t:a,n=e>t?e>a?e:a:t>a?t:a,s=100*n/255,0==s?(r=0,i=0,[r,i,s]):(i=100*(n-o)/n,0==i?(r=0,[r,i,s]):(r=n==e?0+60*(t-a)/(n-o):n==t?120+60*(a-e)/(n-o):240+60*(e-t)/(n-o),[r,i,s]))},Q5.Color._hsv2rgb=(e,t,a)=>{let o,n,r,i,s,l,h,c,d;if(0==t)return o=a,n=a,r=a,[255*o,255*n,255*r];switch(i=e,i>360&&(i=0),i/=60,s=~~i,l=i-s,h=a*(1-t),c=a*(1-t*l),d=a*(1-t*(1-l)),s){case 0:o=a,n=d,r=h;break;case 1:o=c,n=a,r=h;break;case 2:o=h,n=a,r=d;break;case 3:o=h,n=c,r=a;break;case 4:o=d,n=h,r=a;break;default:o=a,n=h,r=c}return[255*o,255*n,255*r]},Q5.Vector=class{constructor(e,t,a){this.x=e||0,this.y=t||0,this.z=a||0,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(){null==this._cnsq&&(this._cnsq=this.x*this.x+this.y*this.y+this.z*this.z,this._cn=Math.sqrt(this._cnsq))}_deprecNorm(){this._cnsq=null,this._cn=null}add(){let e=this._arg2v(...arguments);return this.x+=e.x,this.y+=e.y,this.z+=e.z,this._deprecNorm(),this}rem(){let e=this._arg2v(...arguments);return this.x%=e.x,this.y%=e.y,this.z%=e.z,this._deprecNorm(),this}sub(){let e=this._arg2v(...arguments);return this.x-=e.x,this.y-=e.y,this.z-=e.z,this._deprecNorm(),this}mult(){let e=this._arg2v(...arguments);return this.x*=e.x,this.y*=e.y,this.z*=e.z,this._deprecNorm(),this}div(){let e=this._arg2v(...arguments);return this.x/=e.x,this.y/=e.y,this.z/=e.z,this._deprecNorm(),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._deprecNorm(),this}normalize(){this._calcNorm();let e=this._cn;return 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 atan2(this.y,this.x)}rotate(e){let t=cos(e),a=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);const t=this.dot(e)/(this.mag()*e.mag());let a;return a=tan(Math.min(1,Math.max(-1,t))),a*=Math.sign(this.cross(e).z||1),a}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._deprecNorm(),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*cos(e),this.y=t*sin(e),this.z=0,this}fromAngles(e,t,a){void 0===a&&(a=1),this._cn=a,this._cnsq=a*a;const o=cos(t),n=sin(t),r=cos(e),i=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)=>new Q5.Vector(e.x+t.x,e.y+t.y,e.z+t.z),Q5.Vector.rem=(e,t)=>new Q5.Vector(e.x%t.x,e.y%t.y,e.z%t.z),Q5.Vector.sub=(e,t)=>new Q5.Vector(e.x-t.x,e.y-t.y,e.z-t.z),Q5.Vector.mult=(e,t)=>void 0===t.x?new Q5.Vector(e.x*t,e.y*t,e.z*t):new Q5.Vector(e.x*t.x,e.y*t.y,e.z*t.z),Q5.Vector.div=(e,t)=>void 0===t.x?new Q5.Vector(e.x/t,e.y/t,e.z/t):new Q5.Vector(e.x/t.x,e.y/t.y,e.z/t.z),Q5.Vector.dist=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y,e.z-t.z),Q5.Vector.cross=(e,t)=>new Q5.Vector(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x),Q5.Vector.lerp=(e,t,a)=>new Q5.Vector(e.x+(t.x-e.x)*a,e.y+(t.y-e.y)*a,e.z+(t.z-e.z)*a),Q5.Vector.equals=(e,t,a)=>e.equals(t,a);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){super("image"),this.createCanvas(e,t),this._loop=!1}}Q5._friendlyError=(e,t)=>{throw t+": "+e},Q5.prototype._methods={init:[],pre:[],post:[],remove:[]},Q5.prototype.registerMethod=function(){Q5.prototype._methods[arguments[0]].push(arguments[1])},Q5.prototype.registerPreloadMethod=()=>{},Q5._validateParameters=()=>!0,"undefined"!=typeof module?module.exports=Q5:window.p5??=Q5,document.addEventListener("DOMContentLoaded",(()=>{Q5._hasGlobal||new Q5("auto")}));
7
+ function Q5(e,t){if("auto"==e){if(void 0===window.setup)return;e="global"}1==arguments.length&&"string"!=typeof e&&"function"!=typeof e&&(t=arguments[0],e=null),"global"==e&&(Q5._hasGlobal=!0);let a=this;a.canvas=document.createElement("canvas");let o=a.canvas.getContext("2d");a.width=100,a.height=100,a.canvas.width=a.width,a.canvas.height=a.height,a.windowResized=()=>{},"graphics"!=e&&"image"!=e&&(window.addEventListener("resize",(()=>a.windowResized())),a.canvas.parent=e=>{e[0]&&(e=document.getElementById(e)),e.append(a.canvas)},document.body?(t??=document.getElementsByTagName("main")[0],t?.append?t.append(a.canvas):document.body.appendChild(a.canvas)):window.addEventListener("load",(()=>{document.body.appendChild(a.canvas)}))),g(),a.MAGIC=161533525,a.RGB=0,a.HSV=1,a.HSB=1,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.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.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.THRESHOLD=1,a.GRAY=2,a.OPAQUE=3,a.INVERT=4,a.POSTERIZE=5,a.DILATE=6,a.ERODE=7,a.BLUR=8,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.HARDWARE_FILTERS=!0,a.hint=(e,t)=>{a[e]=t},a.frameCount=0,a.deltaTime=16,a.mouseX=0,a.mouseY=0,a.mouseButton=null,a.keyIsPressed=!1,a.mouseIsPressed=!1,a.key=null,a.keyCode=null,a.pixels=[],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,a.touches=[],a._colorMode=a.RGB,a._doStroke=!0,a._doFill=!0,a._strokeSet=!1,a._fillSet=!1,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=12,a._textStyle="normal",a._pixelDensity=1,a._lastFrameTime=0,a._targetFrameRate=null,a._frameRate=a._fps=60,a._tint=null;let n=null,r=!0,i=[],s=null,l=0,h={},c=0,d=null,u=null,_=null;Object.defineProperty(a,"deviceOrientation",{get:()=>window.screen.orientation.type}),Object.defineProperty(a,"windowWidth",{get:()=>window.innerWidth}),Object.defineProperty(a,"windowHeight",{get:()=>window.innerHeight}),Object.defineProperty(a,"drawingContext",{get:()=>o}),a.createCanvas=(t,o)=>(a.width=t,a.height=o,a.canvas.width=t*a._pixelDensity,a.canvas.height=o*a._pixelDensity,g(),"graphics"!=e&&"image"!=e&&a.pixelDensity(2),a.canvas),a.resizeCanvas=(t,o)=>{a.width=t,a.height=o,a.canvas.width=t*a._pixelDensity,a.canvas.height=o*a._pixelDensity,"graphics"!=e&&"image"!=e&&a.pixelDensity(2)},a.createGraphics=(e,t)=>{let a=new Q5("graphics");return a.createCanvas(e,t),a},a.createImage=(e,t)=>new Q5.Image(e,t),a.pixelDensity=e=>(void 0===e||(a._pixelDensity=e,a.canvas.width=Math.ceil(a.width*e),a.canvas.height=Math.ceil(a.height*e),a.canvas.style.width=a.width+"px",a.canvas.style.height=a.height+"px",o.scale(a._pixelDensity,a._pixelDensity),g()),a._pixelDensity),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(){return 4==arguments.length?Math.hypot(arguments[0]-arguments[2],arguments[1]-arguments[3]):Math.hypot(arguments[0]-arguments[3],arguments[1]-arguments[4],arguments[2]-arguments[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.toString();return o&&(n=n.slice(1)),n=n.padStart(t,"0"),a>0&&(-1==n.indexOf(".")&&(n+="."),n=n.padEnd(t+1+a,"0")),o&&(n="-"+n),n},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)},a.Color=Q5.Color,a.colorMode=e=>{a._colorMode=e};let m={black:[0,0,0],blue:[0,0,255],brown:[165,42,42],crimson:[220,20,60],gold:[255,215,0],green:[0,128,0],gray:[128,128,128],magenta:[255,0,255],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],red:[255,0,0],skyblue:[135,206,235],white:[255,255,255],yellow:[255,255,0]};function g(){o.fillStyle="white",o.strokeStyle="black",o.lineCap="round",o.lineJoin="miter"}function p(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 v(e,t,n,r,i,s,l,h){if(!a._doFill&&!a._doStroke)return;let c=p(i),d=p(s);if(c>d&&([c,d]=[d,c]),0==c){if(0==d)return;if(a._angleMode==a.DEGREES&&360==d||d==a.TAU)return a.ellipse(e,t,n,r)}o.beginPath();for(let i=0;i<h+1;i++){let s=i/h,l=a.lerp(c,d,s),u=a.cos(l)*n/2,_=a.sin(l)*r/2;o[i?"lineTo":"moveTo"](e+u,t+_)}l==a.CHORD?o.closePath():l==a.PIE&&(o.lineTo(e,t),o.closePath()),a._doFill&&o.fill(),a._doStroke&&o.stroke()}function f(e,t,n,r){(a._doFill||a._doStroke)&&(o.beginPath(),o.ellipse(e,t,n/2,r/2,0,0,a.TAU),a._doFill&&o.fill(),a._doStroke&&o.stroke())}function y(e,t,n,r,i,s,l,h){if(!a._doFill&&!a._doStroke)return;if(void 0===i)return function(e,t,n,r){a._doFill&&o.fillRect(e,t,n,r),a._doStroke&&o.strokeRect(e,t,n,r)}(e,t,n,r);if(void 0===s)return y(e,t,n,r,i,i,i,i);const c=Math.min(Math.abs(r),Math.abs(n))/2;i=Math.min(c,i),s=Math.min(c,s),h=Math.min(c,h),l=Math.min(c,l),o.beginPath(),o.moveTo(e+i,t),o.arcTo(e+n,t,e+n,t+r,s),o.arcTo(e+n,t+r,e,t+r,l),o.arcTo(e,t+r,e,t,h),o.arcTo(e,t,e+n,t,i),o.closePath(),a._doFill&&o.fill(),a._doStroke&&o.stroke()}function x(){i=[]}a.color=function(){let e=arguments;if(1==e.length){if(786698==e[0].MAGIC)return e[0];if("string"==typeof e[0])return"#"==e[0][0]?new Q5.Color(parseInt(e[0].slice(1,3),16),parseInt(e[0].slice(3,5),16),parseInt(e[0].slice(5,7),16),1):m[e[0]]?new Q5.Color(...m[e[0]],1):new Q5.Color(0,0,0,1)}if(a._colorMode==a.RGB){if(1==e.length)return new Q5.Color(e[0],e[0],e[0],1);if(2==e.length)return new Q5.Color(e[0],e[0],e[0],e[1]/255);if(3==e.length)return new Q5.Color(e[0],e[1],e[2],1);if(4==e.length)return new Q5.Color(e[0],e[1],e[2],e[3]/255)}else{if(1==e.length)return new Q5.Color(...Q5.Color._hsv2rgb(0,0,e[0]/100),1);if(2==e.length)return new Q5.Color(...Q5.Color._hsv2rgb(0,0,e[0]/100),e[1]/255);if(3==e.length)return new Q5.Color(...Q5.Color._hsv2rgb(e[0],e[1]/100,e[2]/100),1);if(4==e.length)return new Q5.Color(...Q5.Color._hsv2rgb(e[0],e[1]/100,e[2]/100),e[3])}return null},a.red=e=>e._r,a.green=e=>e._g,a.blue=e=>e._b,a.alpha=e=>255*e._a,a.hue=e=>(e._inferHSV(),e._h),a.saturation=e=>(e._inferHSV(),e._s),a.brightness=e=>(e._inferHSV(),e._v),a.lightness=e=>100*(.2126*e._r+.7152*e._g+.0722*e._b)/255,a.lerpColor=(e,t,o)=>a._colorMode==a.RGB?new Q5.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,1)):(e._inferHSV(),t._inferHSV(),new Q5.Color(a.constrain(function(e,t,o){var n=[[Math.abs(t-e),a.map(o,0,1,e,t)],[Math.abs(t+360-e),a.map(o,0,1,e,t+360)],[Math.abs(t-360-e),a.map(o,0,1,e,t-360)]];return n.sort(((e,t)=>e[0]-t[0])),(n[0][1]+720)%360}(e._h,t._h,o),0,360),a.constrain(a.lerp(e._s,t._s,o),0,100),a.constrain(a.lerp(e._v,t._v,o),0,100),a.constrain(a.lerp(e._a,t._a,o),0,1))),a.strokeWeight=e=>{a._doStroke=e>0,o.lineWidth=e},a.stroke=function(){if(a._doStroke=!0,a._strokeSet=!0,"string"==typeof arguments[0])return void(o.strokeStyle=arguments[0]);let e=a.color(...arguments);e._a<=0?a._doStroke=!1:o.strokeStyle=e},a.noStroke=()=>a._doStroke=!1,a.fill=function(){if(a._doFill=!0,a._fillSet=!0,"string"==typeof arguments[0])return void(o.fillStyle=arguments[0]);let e=a.color(...arguments);e._a<=0?a._doFill=!1:o.fillStyle=e},a.noFill=()=>a._doFill=!1,a.smooth=()=>a._smooth=!0,a.noSmooth=()=>a._smooth=!1,a.blendMode=e=>o.globalCompositeOperation=e,a.strokeCap=e=>o.lineCap=e,a.strokeJoin=e=>o.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=>{console.warn("curveTightness() sets the 'alpha' parameter of Catmull-Rom curve, and is NOT identical to p5.js counterpart. As this might change in the future, please call curveAlpha() directly."),a._curveAlpha=e},a.clear=()=>{o.clearRect(0,0,a.canvas.width,a.canvas.height)},a.background=function(){if(arguments[0]&&arguments[0].MAGIC==a.MAGIC)return a.image(arguments[0],0,0,a.width,a.height);o.save(),o.resetTransform(),o.fillStyle="string"==typeof arguments[0]?arguments[0]:a.color(...Array.from(arguments)),o.fillRect(0,0,a.canvas.width,a.canvas.height),o.restore()},a.line=(e,t,n,r)=>{a._doStroke&&(o.beginPath(),o.moveTo(e,t),o.lineTo(n,r),o.stroke())},a.arc=(e,t,o,n,r,i,s,l)=>{if(r==i)return a.ellipse(e,t,o,n);l??=25,s??=a.PIE,a._ellipseMode==a.CENTER?v(e,t,o,n,r,i,s,l):a._ellipseMode==a.RADIUS?v(e,t,2*o,2*n,r,i,s,l):a._ellipseMode==a.CORNER?v(e+o/2,t+n/2,o,n,r,i,s,l):a._ellipseMode==a.CORNERS&&v((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?f(e,t,o,n):a._ellipseMode==a.RADIUS?f(e,t,2*o,2*n):a._ellipseMode==a.CORNER?f(e+o/2,t+n/2,o,n):a._ellipseMode==a.CORNERS&&f((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),o.beginPath(),o.ellipse(e,t,.4,.4,0,0,a.TAU),o.stroke()},a.rect=(e,t,o,n,r,i,s,l)=>{a._rectMode==a.CENTER?y(e-o/2,t-n/2,o,n,r,i,s,l):a._rectMode==a.RADIUS?y(e-o,t-n,2*o,2*n,r,i,s,l):a._rectMode==a.CORNER?y(e,t,o,n,r,i,s,l):a._rectMode==a.CORNERS&&y(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=()=>{x(),o.beginPath(),r=!0},a.beginContour=()=>{o.closePath(),x(),r=!0},a.endContour=()=>{x(),r=!0},a.vertex=(e,t)=>{x(),r?o.moveTo(e,t):o.lineTo(e,t),r=!1},a.bezierVertex=(e,t,a,n,r,i)=>{x(),o.bezierCurveTo(e,t,a,n,r,i)},a.quadraticVertex=(e,t,a,n)=>{x(),o.quadraticCurveTo(e,t,a,n)},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=>{x(),e&&o.closePath(),a._doFill&&o.fill(),a._doStroke&&o.stroke(),a._doFill||a._doStroke||(o.save(),o.fillStyle="none",o.fill(),o.restore())},a.curveVertex=(e,t)=>{if(i.push([e,t]),i.length<4)return;let n=function(e,t,a,o,n,r,i,s,l,h){function c(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=c(0,e,t,a,o,h),_=c(u,a,o,n,r,h),m=c(_,n,r,i,s,h);for(let h=0;h<l;h++){let c=u+h/(l-1)*(_-u),g=[(u-c)/(u-0),(c-0)/(u-0),(_-c)/(_-u),(c-u)/(_-u),(m-c)/(m-_),(c-_)/(m-_),(_-c)/(_-0),(c-0)/(_-0),(m-c)/(m-u),(c-u)/(m-u)];for(let e=0;e<g.length;e+=2)isNaN(g[e])&&(g[e]=1,g[e+1]=0),isFinite(g[e])||(g[e]>0?(g[e]=1,g[e+1]=0):(g[e]=0,g[e+1]=1));let p=e*g[0]+a*g[1],v=t*g[0]+o*g[1],f=a*g[2]+n*g[3],y=o*g[2]+r*g[3],x=n*g[4]+i*g[5],M=r*g[4]+s*g[5],w=p*g[6]+f*g[7],R=v*g[6]+y*g[7],S=f*g[8]+x*g[9],I=y*g[8]+M*g[9],E=w*g[2]+S*g[3],C=R*g[2]+I*g[3];d.push([E,C])}return d}(...i[i.length-4],...i[i.length-3],...i[i.length-2],...i[i.length-1],a._curveDetail,a._curveAlpha);for(let e=0;e<n.length;e++)r?o.moveTo(...n[e]):o.lineTo(...n[e]),r=!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.translate=(e,t)=>o.translate(e,t),a.rotate=e=>{"degrees"==a._angleMode&&(e=a.radians(e)),o.rotate(e)},a.scale=(e,t)=>{t??=e,o.scale(e,t)},a.applyMatrix=(e,t,a,n,r,i)=>{o.transform(e,t,a,n,r,i)},a.shearX=e=>{o.transform(1,0,a.tan(e),1,0,0)},a.shearY=e=>{o.transform(1,a.tan(e),0,1,0,0)},a.resetMatrix=()=>{o.resetTransform(),o.scale(a._pixelDensity,a._pixelDensity)},a._styleNames=["_doStroke","_doFill","_strokeSet","_fillSet","_tint","_imageMode","_rectMode","_ellipseMode","_textFont","_textLeading","_leadingSet","_textSize","_textAlign","_textBaseline","_textStyle","_textWrap"],a._ctxStyleNames=["strokeStyle","fillStyle","lineWidth","lineCap","lineJoin"],a._styles=[],a._ctxStyles=[],a.pushMatrix=a.push=()=>{o.save();let e={};for(let t of a._styleNames)e[t]=a[t];a._styles.push(e);let t={};for(let e of a._ctxStyleNames)t[e]=o[e];a._ctxStyles.push(t)},a.popMatrix=a.pop=()=>{o.restore();let e=a._styles.pop();for(let t of a._styleNames)a[t]=e[t];let t=a._ctxStyles.pop();for(let e of a._ctxStyleNames)o[e]=t[e]},a.imageMode=e=>a._imageMode=e,a.image=(e,t,n,r,i,s,l,h,c)=>{let d=e.MAGIC==a.MAGIC?e.canvas:e;function _(){if(e.MAGIC!=a.MAGIC||!a._tint)return;let t=e.canvas.getContext("2d");t.save(),t.resetTransform(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(u.canvas,0,0),t.restore()}if(e.MAGIC==a.MAGIC&&null!=a._tint&&(!function(e,t){null==u&&(u=document.createElement("canvas").getContext("2d"));t??=e||o.canvas.height,e??=o.canvas.width,(u.canvas.width!=e||u.canvas.height!=t)&&(u.canvas.width=e,u.canvas.height=t)}(e.canvas.width,e.canvas.height),u.drawImage(e.canvas,0,0),e.tinted(a._tint)),r||(e.MAGIC==a.MAGIC||e.width?(r=e.width,i=e.height):(r=e.videoWidth,i=e.videoHeight)),"center"==a._imageMode&&(t-=.5*r,n-=.5*i),void 0===s)return o.drawImage(d,t,n,r,i),void _();h??=d.width,c??=d.height,o.drawImage(d,s,l,h,c,t,n,r,i),_()},a.loadPixels=()=>{s=o.getImageData(0,0,a.canvas.width,a.canvas.height),a.pixels=s.data},a.updatePixels=()=>{null!=s&&o.putImageData(s,0,0)},a._incrementPreload=()=>l++,a._decrementPreload=()=>l--,a.loadImage=(e,t)=>{l++;let o=a.createImage(100,100),n=o.canvas.getContext("2d"),r=new window.Image;return r.src=e,r.crossOrigin="Anonymous",r.onload=()=>{o.width=n.canvas.width=r.naturalWidth,o.height=n.canvas.height=r.naturalHeight,n.drawImage(r,0,0),l--,t&&t(o)},r.onerror=e=>{throw l--,e},o};let M={};function w(e,t){null==d&&(d=document.createElement("canvas").getContext("2d")),t??=e||o.canvas.height,e??=o.canvas.width,d.canvas.width==e&&d.canvas.height==t||(d.canvas.width=e,d.canvas.height=t)}function R(){let e=o.canvas.width*o.canvas.height*4;_&&e==_.length||(_=new Uint8ClampedArray(e))}function S(e){d.clearRect(0,0,d.canvas.width,d.canvas.height),d.filter=e,d.drawImage(o.canvas,0,0),o.save(),o.resetTransform(),o.clearRect(0,0,o.canvas.width,o.canvas.height),o.drawImage(d.canvas,0,0),o.restore()}if(M[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}},M[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}},M[a.OPAQUE]=e=>{for(let t=0;t<e.length;t+=4)e[t+3]=255},M[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]},M[a.POSTERIZE]=(e,t)=>{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},M[a.DILATE]=e=>{R(),_.set(e);let[t,a]=[o.canvas.width,o.canvas.height];for(let o=0;o<a;o++)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(o-1,0)*t,l=4*Math.min(o+1,a-1)*t,h=4*o*t,c=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+h;e[h+c+t]=Math.max(_[a+c],_[n+r],_[n+c],_[n+i],_[o+c])}}},M[a.ERODE]=e=>{R(),_.set(e);let[t,a]=[o.canvas.width,o.canvas.height];for(let o=0;o<a;o++)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(o-1,0)*t,l=4*Math.min(o+1,a-1)*t,h=4*o*t,c=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+h;e[h+c+t]=Math.min(_[a+c],_[n+r],_[n+c],_[n+i],_[o+c])}}},M[a.BLUR]=(e,t)=>{t=t||1,t=Math.floor(t*a._pixelDensity),R(),_.set(e);let n=2*t+1;let r=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}(n),[i,s]=[o.canvas.width,o.canvas.height];for(let a=0;a<s;a++)for(let o=0;o<i;o++){let s=0,l=0,h=0,c=0;for(let e=0;e<n;e++){let n=4*(a*i+Math.min(Math.max(o-t+e,0),i-1));s+=_[n]*r[e],l+=_[n+1]*r[e],h+=_[n+2]*r[e],c+=_[n+3]*r[e]}let d=4*(a*i+o);e[d]=s,e[d+1]=l,e[d+2]=h,e[d+3]=c}_.set(e);for(let a=0;a<s;a++)for(let o=0;o<i;o++){let l=0,h=0,c=0,d=0;for(let e=0;e<n;e++){let n=4*(Math.min(Math.max(a-t+e,0),s-1)*i+o);l+=_[n]*r[e],h+=_[n+1]*r[e],c+=_[n+2]*r[e],d+=_[n+3]*r[e]}let u=4*(a*i+o);e[u]=l,e[u+1]=h,e[u+2]=c,e[u+3]=d}},a.filter=(e,t)=>{if(a.HARDWARE_FILTERS&&null!=o.filter)if(w(),e==a.THRESHOLD){t??=.5,t=Math.max(t,1e-5),S(`saturate(0%) brightness(${Math.floor(.5/t*100)}%) contrast(1000000%)`)}else if(e==a.GRAY)S("saturate(0%)");else if(e==a.OPAQUE)d.fillStyle="black",d.fillRect(0,0,d.canvas.width,d.canvas.height),d.drawImage(o.canvas,0,0),o.save(),o.resetTransform(),o.drawImage(d.canvas,0,0),o.restore();else if(e==a.INVERT)S("invert(100%)");else if(e==a.BLUR)S(`blur(${Math.ceil(t*a._pixelDensity/1)||1}px)`);else{let a=o.getImageData(0,0,o.canvas.width,o.canvas.height);M[e](a.data,t),o.putImageData(a,0,0)}else{let a=o.getImageData(0,0,o.canvas.width,o.canvas.height);M[e](a.data,t),o.putImageData(a,0,0)}},a.resize=(e,t)=>{w(),d.drawImage(o.canvas,0,0),a.width=e,a.height=t,o.canvas.width=e*a._pixelDensity,o.canvas.height=t*a._pixelDensity,o.save(),o.resetTransform(),o.clearRect(0,0,o.canvas.width,o.canvas.height),o.drawImage(d.canvas,0,0,o.canvas.width,o.canvas.height),o.restore()},a.get=(e,t,n,r)=>{if(void 0!==e&&void 0===n){let a=o.getImageData(e,t,1,1).data;return new Q5.Color(a[0],a[1],a[2],a[3]/255)}e=e||0,t=t||0,n=n||a.width,r=r||a.height;let i=a.createGraphics(n,r);i.pixelDensity(a._pixelDensity);let s=o.getImageData(e*a._pixelDensity,t*a._pixelDensity,n*a._pixelDensity,r*a._pixelDensity);return i.canvas.getContext("2d").putImageData(s,0,0),i},a.set=(e,t,n)=>{if(n.MAGIC==a.MAGIC){let o=a._tint;return a._tint=null,a.image(n,e,t),void(a._tint=o)}for(let r=0;r<a._pixelDensity;r++)for(let i=0;i<a._pixelDensity;i++){let s=4*((t*a._pixelDensity+r)*o.canvas.width+e*a._pixelDensity+i);a.pixels[s]=n._r,a.pixels[s+1]=n._g,a.pixels[s+2]=n._b,a.pixels[s+3]=255*n._a}},a.tinted=function(){let e=a.color(...Array.from(arguments)),t=e._a;e._a=1,w(),d.clearRect(0,0,d.canvas.width,d.canvas.height),d.fillStyle=e,d.fillRect(0,0,d.canvas.width,d.canvas.height),d.globalCompositeOperation="multiply",d.drawImage(o.canvas,0,0),d.globalCompositeOperation="source-over",o.save(),o.resetTransform();let n=o.globalCompositeOperation;o.globalCompositeOperation="source-in",o.drawImage(d.canvas,0,0),o.globalCompositeOperation=n,o.restore(),d.globalAlpha=t,d.clearRect(0,0,d.canvas.width,d.canvas.height),d.drawImage(o.canvas,0,0),d.globalAlpha=1,o.save(),o.resetTransform(),o.clearRect(0,0,o.canvas.width,o.canvas.height),o.drawImage(d.canvas,0,0),o.restore()},a.tint=function(){a._tint=a.color(...Array.from(arguments))},a.noTint=()=>a._tint=null,a.mask=e=>{o.save(),o.resetTransform();let t=o.globalCompositeOperation;o.globalCompositeOperation="destination-in",o.drawImage(e.canvas,0,0),o.globalCompositeOperation=t,o.restore()},a.clearTemporaryBuffers=()=>{d=null,u=null,_=null},a.save=(e,t)=>{e=e||"untitled",t=t||"png";var a=document.createElement("a");a.innerHTML="[Download]",a.addEventListener("click",(function(){this.href=o.canvas.toDataURL(),this.download=e+"."+t}),!1),document.body.appendChild(a),a.click(),document.body.removeChild(a)},a.saveCanvas=(e,t,o)=>{if(e.MAGIC==a.MAGIC){o&&e.save(t,o);let a=t.split(".");return e.save(a.slice(0,-1).join("."),a[a.length-1])}if(t)return a.save(e,t);let n=e.split(".");return a.save(n.slice(0,-1).join("."),n[n.length-1])},a.remove=()=>{a.noLoop(),a.canvas.remove()},"image"==e)return;a.loadFont=(e,t)=>{let a=e.split("/"),o=a[a.length-1].split(".")[0].replace(" ",""),n=`@font-face {\n font-family: '${o}';\n src: url('${e}');\n }`;const r=document.createElement("style");return r.textContent=n,document.head.append(r),o},a.textFont=e=>{a._textFont=e},a.textSize=e=>{if(void 0===e)return a._textSize;a._textLeading=e,a._textSize=e},a.textLeading=e=>{a._textLeading=e},a.textStyle=e=>{a._textStyle=e},a.textAlign=(e,t)=>{o.textAlign=e,t&&(o.textBaseline=t==a.CENTER?"middle":t)},a.text=(e,t,n,r)=>{if(void 0===e)return;if(e=e.toString(),!a._doFill&&!a._doStroke)return;o.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`;let i=e.split("\n");for(let e=0;e<i.length;e++){let s=o.fillStyle;a._fillSet||(o.fillStyle="black"),a._doFill&&o.fillText(i[e],t,n,r),a._doStroke&&a._strokeSet&&o.strokeText(i[e],t,n,r),a._fillSet||(o.fillStyle=s),n+=a._textLeading}},a.textWidth=e=>(o.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,o.measureText(e).width),a.textAscent=e=>(o.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,o.measureText(e).actualBoundingBoxAscent),a.textDescent=e=>(o.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,o.measureText(e).actualBoundingBoxDescent);var I,E=4095,C=4,D=.5,b=e=>.5*(1-Math.cos(e*Math.PI));a.noise=(e,t,a)=>{if(t??=0,a??=0,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,h=Math.floor(e),c=Math.floor(t),d=Math.floor(a),u=e-h,_=t-c,m=a-d,g=0,p=.5,v=0;v<C;v++){var f=h+(c<<4)+(d<<8);n=b(u),r=b(_),i=I[f&E],i+=n*(I[f+1&E]-i),s=I[f+16&E],i+=r*((s+=n*(I[f+16+1&E]-s))-i),s=I[(f+=256)&E],s+=n*(I[f+1&E]-s),l=I[f+16&E],s+=r*((l+=n*(I[f+16+1&E]-l))-s),g+=(i+=b(m)*(s-i))*p,p*=D,h<<=1,c<<=1,d<<=1,(u*=2)>=1&&(h++,u--),(_*=2)>=1&&(c++,_--),(m*=2)>=1&&(d++,m--)}return g},a.noiseDetail=(e,t)=>{e>0&&(C=e),t>0&&(D=t)};const A=()=>{let e,t,a=4294967295;return{setSeed(o){e=t=(null==o?Math.random()*a:o)>>>0},getSeed:()=>t,rand:()=>(e^=e<<17,e^=e>>13,e^=e<<5,(e>>>0)/a)}};let T=A();T.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=>T.setSeed(e),a.random=(e,t)=>void 0===e?T.rand():"number"==typeof e?void 0!==t?T.rand()*(t-e)+e:T.rand()*e:e[~~(e.length*T.rand())],a.randomGenerator=e=>{e==a.LCG?T=(()=>{const e=4294967296;let t,a;return{setSeed(o){a=t=(null==o?Math.random()*e:o)>>>0},getSeed:()=>t,rand:()=>(a=(1664525*a+1013904223)%e,a/e)}})():e==a.SHR3&&(T=A()),T.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),h=()=>4294967296*T.rand()-2147483648,c=()=>.5+2.328306e-10*(h()<<0),d=()=>{for(var t,n,s,l,d=3.44262;;){if(t=a*r[e],0==e){do{s=c(),l=c(),t=.2904764*-Math.log(s),n=-Math.log(l)}while(n+n<t*t);return a>0?d+t:-d-t}if(i[e]+c()*(i[e-1]-i[e])<Math.exp(-.5*t*t))return t;if(a=h(),e=127&a,Math.abs(a)<o[e])return a*r[e]}},u=()=>{for(var a;;){if(0==e)return 7.69711-Math.log(c());if(a=t*s[e],l[e]+c()*(l[e-1]-l[e])<Math.exp(-a))return a;if((t=h())<n[e=255&t])return t*s[e]}};this.SHR3=h,this.UNI=c,this.RNOR=()=>(a=h(),e=127&a,Math.abs(a)<o[e]?a*r[e]:d()),this.REXP=()=>(t=h()>>>0)<o[e=255&t]?t*s[e]:u(),this.zigset=()=>{var e,t,a=2147483648,h=4294967296,c=3.442619855899,d=c,u=.00991256303526217,_=7.697117470131487,m=_,g=.003949659822581572;for(e=u/Math.exp(-.5*c*c),o[0]=Math.floor(c/e*a),o[1]=0,r[0]=e/a,r[127]=c/a,i[0]=1,i[127]=Math.exp(-.5*c*c),t=126;t>=1;t--)c=Math.sqrt(-2*Math.log(u/c+Math.exp(-.5*c*c))),o[t+1]=Math.floor(c/d*a),d=c,i[t]=Math.exp(-.5*c*c),r[t]=c/a;for(e=g/Math.exp(-_),n[0]=Math.floor(_/e*h),n[1]=0,s[0]=e/h,s[255]=_/h,l[0]=1,l[255]=Math.exp(-_),t=254;t>=1;t--)_=-Math.log(g/_+Math.exp(-_)),n[t+1]=Math.floor(_/m*h),m=_,l[t]=Math.exp(-_),s[t]=_/h}};function O(){let e=performance.now();if(a._loop&&(n=a._targetFrameRate?setTimeout(O,1e3/a._targetFrameRate):requestAnimationFrame(O)),n&&0!=a._frameCount){if(e-a._lastFrameTime<1e3/(a._targetFrameRate||60)-5)return}a.deltaTime=e-a._lastFrameTime,a._frameRate=1e3/a.deltaTime,a.frameCount++;for(let e of Q5.prototype._methods.pre)e.call(a);x(),r=!0,o.save(),a._drawFn();for(let e of Q5.prototype._methods.post)e.call(a);o.restore();let t=performance.now();a._fps=Math.round(1e3/(t-e)),a._lastFrameTime=e,a.pmouseX=a.mouseX,a.pmouseY=a.mouseY}function k(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}}function z(){return a._touchStartedFn.isPlaceHolder&&a._touchMovedFn.isPlaceHolder&&a._touchEndedFn.isPlaceHolder}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.print=console.log,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.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.appendChild(t),t},a.noLoop=()=>{a._loop=!1,n=null},a.loop=()=>{a._loop=!0,null==n&&O()},a.redraw=()=>O(),a.frameRate=e=>(e&&(a._targetFrameRate=e),a._frameRate),a.getFrameRate=()=>a._frameRate,a.getFPS=()=>a._fps,a._updateMouse=function(e){let t=this,a=t.canvas.getBoundingClientRect(),o=t.canvas.scrollWidth/t.width||1,n=t.canvas.scrollHeight/t.height||1;t.mouseX=(e.clientX-a.left)/o,t.mouseY=(e.clientY-a.top)/n}.bind(a),a._onmousemove=function(e){a._updateMouse(e),this.mouseIsPressed?this._mouseDraggedFn(e):this._mouseMovedFn(e)}.bind(a),a._onmousedown=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a.mouseButton=[a.LEFT,a.CENTER,a.RIGHT][e.button],a._mousePressedFn(e)},a._onmouseup=e=>{a._updateMouse(e),a.mouseIsPressed=!1,a._mouseReleasedFn(e)},a._onclick=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a._mouseClickedFn(e),a.mouseIsPressed=!1},a._onkeydown=e=>{e.repeat||(a.keyIsPressed=!0,a.key=e.key,a.keyCode=e.keyCode,h[a.keyCode]=!0,a._keyPressedFn(e),1==e.key.length&&a._keyTypedFn(e))},a._onkeyup=e=>{a.keyIsPressed=!1,a.key=e.key,a.keyCode=e.keyCode,h[a.keyCode]=!1,a._keyReleasedFn(e)},addEventListener("mousemove",(e=>a._onmousemove(e)),!1),a.canvas.onmousedown=e=>a._onmousedown(e),a.canvas.onmouseup=e=>a._onmouseup(e),a.canvas.onclick=e=>a._onclick(e),addEventListener("keydown",(e=>a._onkeydown(e)),!1),addEventListener("keyup",(e=>a._onkeyup(e)),!1),a.keyIsDown=e=>!!h[e],a._ontouchstart=e=>{a.touches=[...e.touches].map(k),z()&&(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseIsPressed=!0,a.mouseButton=a.LEFT,a._mousePressedFn(e)||e.preventDefault()),a._touchStartedFn(e)||e.preventDefault()},a._ontouchmove=e=>{a.touches=[...e.touches].map(k),z()&&(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseIsPressed=!0,a.mouseButton=a.LEFT,a._mouseDraggedFn(e)||e.preventDefault()),a._touchMovedFn(e)||e.preventDefault()},a._ontouchend=e=>{a.touches=[...e.touches].map(k),z()&&(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseIsPressed=!1,a._mouseReleasedFn(e)||e.preventDefault()),a._touchEndedFn(e)||e.preventDefault()},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)};"undefined"!=typeof window&&(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][1+~~(window.orientation/90)],a.relRotationY=[-a.rotationX,a.rotationY,a.rotationX][1+~~(window.orientation/90)],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()-c,a.storeItem=localStorage.setItem,a.getItem=localStorage.getItem,a.removeItem=localStorage.removeItem,a.clearStorage=localStorage.clear,a._loadFile=(e,t,a)=>{l++;let o={};return fetch(e).then((e=>"json"==a?e.json():"text"==a?e.text():void 0)).then((e=>{l--,Object.assign(o,e),t&&t(e)})),o},a.loadStrings=(e,t)=>a._loadFile(e,t,"text"),a.loadJSON=(e,t)=>a._loadFile(e,t,"json"),a.loadSound=(e,t)=>{l++;let a=new Audio(e);return a.addEventListener("canplaythrough",(()=>{l--,t&&t(a)})),a.load(),a.setVolume=e=>a.volume=e,a},a.Element=function(e){this.elt=e},a._elements=[],"global"==e&&(Object.assign(Q5,a),delete Q5.Q5),Q5.Image??=_Q5Image;for(let e of Q5.prototype._methods.init)e.call(a);if("global"==e){let e=Object.getOwnPropertyNames(a);for(let t of e)"function"==typeof a[t]?window[t]=a[t]:Object.defineProperty(window,t,{get:()=>a[t],set:e=>a[t]=e})}"function"==typeof e&&e(a);let F="global"==e?window:a,Q=["setup","draw","preload","mouseMoved","mousePressed","mouseReleased","mouseDragged","mouseClicked","keyPressed","keyReleased","keyTyped","touchStarted","touchMoved","touchEnded"];for(let e of Q){let t="_"+e+"Fn";a[t]=()=>{},a[t].isPlaceHolder=!0,F[e]?a[t]=F[e]:Object.defineProperty(a,e,{set:e=>{a[t]=e}})}if("graphics"!=e||"image"!=e){a._preloadFn(),c=performance.now(),function e(){if(l>0)return requestAnimationFrame(e);a._setupFn(),requestAnimationFrame(O)}()}}Q5.Color=class{constructor(e,t,a,o){this.MAGIC=786698,this._r=e,this._g=t,this._b=a,this._a=o,this._h=0,this._s=0,this._v=0,this._hsvInferred=!1}setRed(e){this._r=e,this._hsvInferred=!1}setGreen(e){this._g=e,this._hsvInferred=!1}setBlue(e){this._b=e,this._hsvInferred=!1}setAlpha(e){this._a=e/255,this._hsvInferred=!1}get levels(){return[this._r,this._g,this._b,255*this._a]}_inferHSV(){this._hsvInferred||([this._h,this._s,this._v]=Q5.Color._rgb2hsv(this._r,this._g,this._b),this._hsvInferred=!0)}toString(){return`rgba(${Math.round(this._r)},${Math.round(this._g)},${Math.round(this._b)},${~~(1e3*this._a)/1e3})`}},Q5.Color._rgb2hsv=(e,t,a)=>{let o,n,r,i,s;return o=e<t?e<a?e:a:t<a?t:a,n=e>t?e>a?e:a:t>a?t:a,s=100*n/255,0==s?(r=0,i=0,[r,i,s]):(i=100*(n-o)/n,0==i?(r=0,[r,i,s]):(r=n==e?0+60*(t-a)/(n-o):n==t?120+60*(a-e)/(n-o):240+60*(e-t)/(n-o),[r,i,s]))},Q5.Color._hsv2rgb=(e,t,a)=>{let o,n,r,i,s,l,h,c,d;if(0==t)return o=a,n=a,r=a,[255*o,255*n,255*r];switch(i=e,i>360&&(i=0),i/=60,s=~~i,l=i-s,h=a*(1-t),c=a*(1-t*l),d=a*(1-t*(1-l)),s){case 0:o=a,n=d,r=h;break;case 1:o=c,n=a,r=h;break;case 2:o=h,n=a,r=d;break;case 3:o=h,n=c,r=a;break;case 4:o=d,n=h,r=a;break;default:o=a,n=h,r=c}return[255*o,255*n,255*r]},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(){null==this._cnsq&&(this._cnsq=this.x*this.x+this.y*this.y+this.z*this.z,this._cn=Math.sqrt(this._cnsq))}_deprecNorm(){this._cnsq=null,this._cn=null}add(){let e=this._arg2v(...arguments);return this.x+=e.x,this.y+=e.y,this.z+=e.z,this._deprecNorm(),this}rem(){let e=this._arg2v(...arguments);return this.x%=e.x,this.y%=e.y,this.z%=e.z,this._deprecNorm(),this}sub(){let e=this._arg2v(...arguments);return this.x-=e.x,this.y-=e.y,this.z-=e.z,this._deprecNorm(),this}mult(){let e=this._arg2v(...arguments);return this.x*=e.x,this.y*=e.y,this.z*=e.z,this._deprecNorm(),this}div(){let e=this._arg2v(...arguments);return this.x/=e.x,this.y/=e.y,this.z/=e.z,this._deprecNorm(),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._deprecNorm(),this}normalize(){this._calcNorm();let e=this._cn;return 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);const t=this.dot(e)/(this.mag()*e.mag());let a;return a=this._$.tan(Math.min(1,Math.max(-1,t))),a*=Math.sign(this.cross(e).z||1),a}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._deprecNorm(),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)=>new Q5.Vector(e.x+t.x,e.y+t.y,e.z+t.z),Q5.Vector.rem=(e,t)=>new Q5.Vector(e.x%t.x,e.y%t.y,e.z%t.z),Q5.Vector.sub=(e,t)=>new Q5.Vector(e.x-t.x,e.y-t.y,e.z-t.z),Q5.Vector.mult=(e,t)=>void 0===t.x?new Q5.Vector(e.x*t,e.y*t,e.z*t):new Q5.Vector(e.x*t.x,e.y*t.y,e.z*t.z),Q5.Vector.div=(e,t)=>void 0===t.x?new Q5.Vector(e.x/t,e.y/t,e.z/t):new Q5.Vector(e.x/t.x,e.y/t.y,e.z/t.z),Q5.Vector.dist=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y,e.z-t.z),Q5.Vector.cross=(e,t)=>new Q5.Vector(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x),Q5.Vector.lerp=(e,t,a)=>new Q5.Vector(e.x+(t.x-e.x)*a,e.y+(t.y-e.y)*a,e.z+(t.z-e.z)*a),Q5.Vector.equals=(e,t,a)=>e.equals(t,a);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){super("image"),this.createCanvas(e,t),this._loop=!1}}Q5._friendlyError=(e,t)=>{throw t+": "+e},Q5.prototype._methods={init:[],pre:[],post:[],remove:[]},Q5.prototype.registerMethod=function(){Q5.prototype._methods[arguments[0]].push(arguments[1])},Q5.prototype.registerPreloadMethod=()=>{},Q5._validateParameters=()=>!0,"undefined"!=typeof module?module.exports=Q5:window.p5??=Q5,document.addEventListener("DOMContentLoaded",(()=>{Q5._hasGlobal||new Q5("auto")}));