q5 1.4.0 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/q5.js +16 -7
  3. package/q5.min.js +1 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "quinton-ashley",
3
3
  "name": "q5",
4
- "version": "1.4.0",
4
+ "version": "1.4.2",
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
@@ -216,7 +216,8 @@ function Q5(scope, parent) {
216
216
 
217
217
  $._textFont = 'sans-serif';
218
218
  $._textSize = 12;
219
- $._textLeading = 12;
219
+ $._textLeading = 15;
220
+ $._textLeadDiff = 3;
220
221
  $._textStyle = 'normal';
221
222
 
222
223
  $._pixelDensity = 1;
@@ -1520,10 +1521,18 @@ function Q5(scope, parent) {
1520
1521
  $.textFont = (x) => ($._textFont = x);
1521
1522
  $.textSize = (x) => {
1522
1523
  if (x === undefined) return $._textSize;
1523
- $._textLeading = x;
1524
1524
  $._textSize = x;
1525
+ if (!$._leadingSet) {
1526
+ $._textLeading = x * 1.25;
1527
+ $._textLeadDiff = $._textLeading - x;
1528
+ }
1529
+ };
1530
+ $.textLeading = (x) => {
1531
+ if (x === undefined) return $._textLeading;
1532
+ $._textLeading = x;
1533
+ $._textLeadDiff = x - $._textSize;
1534
+ $._leadingSet = true;
1525
1535
  };
1526
- $.textLeading = (x) => ($._textLeading = x);
1527
1536
  $.textStyle = (x) => ($._textStyle = x);
1528
1537
  $.textAlign = (horiz, vert) => {
1529
1538
  ctx.textAlign = horiz;
@@ -1628,7 +1637,7 @@ function Q5(scope, parent) {
1628
1637
  $.textImage(ti, x, y);
1629
1638
  return;
1630
1639
  }
1631
- ti = $.createGraphics(1, 1);
1640
+ ti = $.createImage(1, 1);
1632
1641
  c = ti._ctx;
1633
1642
  }
1634
1643
  c.font = `${$._textStyle} ${$._textSize}px ${$._textFont}`;
@@ -1666,9 +1675,9 @@ function Q5(scope, parent) {
1666
1675
  if (ctx.textAlign == 'center') x -= img.width * 0.5;
1667
1676
  else if (ctx.textAlign == 'right') x -= img.width;
1668
1677
  if (ctx.textBaseline == 'alphabetic') y -= $._textLeading;
1669
- if (ctx.textBaseline == 'middle') y -= img._ascent * 0.5 + img._descent;
1670
- else if (ctx.textBaseline == 'bottom') y -= img._ascent + img._descent;
1671
- else if (ctx.textBaseline == 'top') y -= img._descent;
1678
+ if (ctx.textBaseline == 'middle') y -= img._descent + img._ascent * 0.5 + $._textLeadDiff;
1679
+ else if (ctx.textBaseline == 'bottom') y -= img._ascent + img._descent + $._textLeadDiff;
1680
+ else if (ctx.textBaseline == 'top') y -= img._descent + $._textLeadDiff;
1672
1681
  $.image(img, x, y);
1673
1682
  $._imageMode = og;
1674
1683
  };
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(void 0===e&&(e="global"),"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 n=a._ctx=a.canvas.getContext("2d");if(a.canvas.classList.add("p5Canvas","q5Canvas"),a.canvas.id="defaultCanvas"+Q5._instanceCount++,a.width=100,a.height=100,a.canvas.width=a.width,a.canvas.height=a.height,a._windowResizedFn=()=>{},"graphics"!=e&&"image"!=e){function o(){t??=document.getElementsByTagName("main")[0],t??=document.body,a.canvas.parent(t)}a._resize=()=>{a.frameCount>1&&(a._shouldResize=!0)},a.canvas.parent=e=>{"string"==typeof e&&(e=document.getElementById(e)),e.append(a.canvas),"undefined"!=typeof ResizeObserver?(a._ro&&a._ro.disconnect(),a._ro=new ResizeObserver(a._resize),a._ro.observe(t)):0==a.frameCount&&addEventListener("resize",a._resize)},document.body?o():window.addEventListener("load",o)}f(),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 i=null,r=!0,s=[],l=null,h=0,c={},d=0,u=null,_=null,g=null;function m(){let e={};for(let t in n)"function"!=typeof n[t]&&(e[t]=n[t]);return delete e.canvas,e}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:()=>n}),a.createCanvas=(t,n)=>(a.width=t,a.height=n,a.canvas.width=t*a._pixelDensity,a.canvas.height=n*a._pixelDensity,f(),"graphics"!=e&&"image"!=e&&a.pixelDensity(Math.ceil(a.displayDensity())),a.canvas),a.resizeCanvas=(t,o)=>{a.width=t,a.height=o;let i=m();a.canvas.width=t*a._pixelDensity,a.canvas.height=o*a._pixelDensity,n=a._ctx=a.canvas.getContext("2d");for(let e in i)a._ctx[e]=i[e];"graphics"!=e&&"image"!=e&&a.pixelDensity(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.displayDensity=()=>window.devicePixelRatio,a.pixelDensity=e=>{if(void 0===e)return a._pixelDensity;a._pixelDensity=e;let t=m();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",n=a._ctx=a.canvas.getContext("2d");for(let e in t)a._ctx[e]=t[e];return n.scale(a._pixelDensity,a._pixelDensity),a._pixelDensity},a.map=(e,t,a,n,o,i)=>{let r=n+1*(e-t)/(a-t)*(o-n);return i?n<o?Math.min(Math.max(r,n),o):Math.min(Math.max(r,o),n):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(){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,n)=>a.map(e,t,n,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 n=Math.atan2(e,t);return"degrees"==a._angleMode&&(n=a.degrees(n)),n},a.nf=(e,t,a)=>{let n=e<0,o=e.toString();return n&&(o=o.slice(1)),o=o.padStart(t,"0"),a>0&&(-1==o.indexOf(".")&&(o+="."),o=o.padEnd(t+1+a,"0")),n&&(o="-"+o),o},a.createVector=(e,t,n)=>new Q5.Vector(e,t,n,a),a.curvePoint=(e,t,a,n,o)=>{const i=o*o*o,r=o*o;return e*(-.5*i+r-.5*o)+t*(1.5*i-2.5*r+1)+a*(-1.5*i+2*r+.5*o)+n*(.5*i-.5*r)},a.bezierPoint=(e,t,a,n,o)=>{const i=1-o;return Math.pow(i,3)*e+3*Math.pow(i,2)*o*t+3*i*Math.pow(o,2)*a+Math.pow(o,3)*n},a.curveTangent=(e,t,a,n,o)=>{const i=o*o;return e*(-3*i/2+2*o-.5)+t*(9*i/2-5*o)+a*(-9*i/2+4*o+.5)+n*(3*i/2-o)},a.bezierTangent=(e,t,a,n,o)=>{const i=1-o;return 3*n*Math.pow(o,2)-3*a*Math.pow(o,2)+6*a*i*o-6*t*i*o+3*t*Math.pow(i,2)-3*e*Math.pow(i,2)},a.Color=Q5.Color,a.colorMode=e=>{a._colorMode=e};let p={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],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 f(){n.fillStyle="white",n.strokeStyle="black",n.lineCap="round",n.lineJoin="miter",n.textAlign="left"}function v(e){let t=a._angleMode==a.DEGREES?180:Math.PI,n=2*t;if(0<=e&&e<=n)return e;for(;e<0;)e+=n;for(;e>=t;)e-=n;return e}function x(e,t,o,i,r,s,l,h){if(!a._doFill&&!a._doStroke)return;let c=v(r),d=v(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,o,i)}n.beginPath();for(let r=0;r<h+1;r++){let s=r/h,l=a.lerp(c,d,s),u=a.cos(l)*o/2,_=a.sin(l)*i/2;n[r?"lineTo":"moveTo"](e+u,t+_)}l==a.CHORD?n.closePath():l==a.PIE&&(n.lineTo(e,t),n.closePath()),a._doFill&&n.fill(),a._doStroke&&n.stroke()}function y(e,t,o,i){(a._doFill||a._doStroke)&&(n.beginPath(),n.ellipse(e,t,o/2,i/2,0,0,a.TAU),a._doFill&&n.fill(),a._doStroke&&n.stroke())}function M(e,t,o,i,r,s,l,h){if(!a._doFill&&!a._doStroke)return;if(void 0===r)return function(e,t,o,i){a._doFill&&n.fillRect(e,t,o,i),a._doStroke&&n.strokeRect(e,t,o,i)}(e,t,o,i);if(void 0===s)return M(e,t,o,i,r,r,r,r);const c=Math.min(Math.abs(i),Math.abs(o))/2;r=Math.min(c,r),s=Math.min(c,s),h=Math.min(c,h),l=Math.min(c,l),n.beginPath(),n.moveTo(e+r,t),n.arcTo(e+o,t,e+o,t+i,s),n.arcTo(e+o,t+i,e,t+i,l),n.arcTo(e,t+i,e,t,h),n.arcTo(e,t,e+o,t,r),n.closePath(),a._doFill&&n.fill(),a._doStroke&&n.stroke()}function w(){s=[]}a.color=function(){let e=arguments;if(1==e.length){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):p[e[0]]?new Q5.Color(...p[e[0]],1):new Q5.Color(0,0,0,1);if("number"!=typeof e[0]&&786698==e[0].MAGIC)return e[0]}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,n)=>a._colorMode==a.RGB?new Q5.Color(a.constrain(a.lerp(e._r,t._r,n),0,255),a.constrain(a.lerp(e._g,t._g,n),0,255),a.constrain(a.lerp(e._b,t._b,n),0,255),a.constrain(a.lerp(e._a,t._a,n),0,1)):(e._inferHSV(),t._inferHSV(),new Q5.Color(a.constrain(function(e,t,n){var o=[[Math.abs(t-e),a.map(n,0,1,e,t)],[Math.abs(t+360-e),a.map(n,0,1,e,t+360)],[Math.abs(t-360-e),a.map(n,0,1,e,t-360)]];return o.sort(((e,t)=>e[0]-t[0])),(o[0][1]+720)%360}(e._h,t._h,n),0,360),a.constrain(a.lerp(e._s,t._s,n),0,100),a.constrain(a.lerp(e._v,t._v,n),0,100),a.constrain(a.lerp(e._a,t._a,n),0,1))),a.strokeWeight=e=>{a._doStroke=e>0,n.lineWidth=e},a.stroke=function(){if(a._doStroke=!0,a._strokeSet=!0,"string"==typeof arguments[0])return void(n.strokeStyle=arguments[0]);let e=a.color(...arguments);e._a<=0?a._doStroke=!1:n.strokeStyle=e},a.noStroke=()=>a._doStroke=!1,a.fill=function(){if(a._doFill=!0,a._fillSet=!0,"string"==typeof arguments[0])return void(n.fillStyle=arguments[0]);let e=a.color(...arguments);e._a<=0?a._doFill=!1:n.fillStyle=e},a.noFill=()=>a._doFill=!1,a.smooth=()=>a._smooth=!0,a.noSmooth=()=>a._smooth=!1,a.blendMode=e=>n.globalCompositeOperation=e,a.strokeCap=e=>n.lineCap=e,a.strokeJoin=e=>n.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=()=>{n.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);n.save(),n.resetTransform(),n.fillStyle="string"==typeof arguments[0]?arguments[0]:a.color(...Array.from(arguments)),n.fillRect(0,0,a.canvas.width,a.canvas.height),n.restore()},a.line=(e,t,o,i)=>{a._doStroke&&(n.beginPath(),n.moveTo(e,t),n.lineTo(o,i),n.stroke())},a.arc=(e,t,n,o,i,r,s,l)=>{if(i==r)return a.ellipse(e,t,n,o);l??=25,s??=a.PIE,a._ellipseMode==a.CENTER?x(e,t,n,o,i,r,s,l):a._ellipseMode==a.RADIUS?x(e,t,2*n,2*o,i,r,s,l):a._ellipseMode==a.CORNER?x(e+n/2,t+o/2,n,o,i,r,s,l):a._ellipseMode==a.CORNERS&&x((e+n)/2,(t+o)/2,n-e,o-t,i,r,s,l)},a.ellipse=(e,t,n,o)=>{o??=n,a._ellipseMode==a.CENTER?y(e,t,n,o):a._ellipseMode==a.RADIUS?y(e,t,2*n,2*o):a._ellipseMode==a.CORNER?y(e+n/2,t+o/2,n,o):a._ellipseMode==a.CORNERS&&y((e+n)/2,(t+o)/2,n-e,o-t)},a.circle=(e,t,n)=>a.ellipse(e,t,n,n),a.point=(e,t)=>{e.x&&(t=e.y,e=e.x),n.beginPath(),n.ellipse(e,t,.4,.4,0,0,a.TAU),n.stroke()},a.rect=(e,t,n,o,i,r,s,l)=>{a._rectMode==a.CENTER?M(e-n/2,t-o/2,n,o,i,r,s,l):a._rectMode==a.RADIUS?M(e-n,t-o,2*n,2*o,i,r,s,l):a._rectMode==a.CORNER?M(e,t,n,o,i,r,s,l):a._rectMode==a.CORNERS&&M(e,t,n-e,o-t,i,r,s,l)},a.square=(e,t,n,o,i,r,s)=>a.rect(e,t,n,n,o,i,r,s),a.beginShape=()=>{w(),n.beginPath(),r=!0},a.beginContour=()=>{n.closePath(),w(),r=!0},a.endContour=()=>{w(),r=!0},a.vertex=(e,t)=>{w(),r?n.moveTo(e,t):n.lineTo(e,t),r=!1},a.bezierVertex=(e,t,a,o,i,r)=>{w(),n.bezierCurveTo(e,t,a,o,i,r)},a.quadraticVertex=(e,t,a,o)=>{w(),n.quadraticCurveTo(e,t,a,o)},a.bezier=(e,t,n,o,i,r,s,l)=>{a.beginShape(),a.vertex(e,t),a.bezierVertex(n,o,i,r,s,l),a.endShape()},a.triangle=(e,t,n,o,i,r)=>{a.beginShape(),a.vertex(e,t),a.vertex(n,o),a.vertex(i,r),a.endShape(a.CLOSE)},a.quad=(e,t,n,o,i,r,s,l)=>{a.beginShape(),a.vertex(e,t),a.vertex(n,o),a.vertex(i,r),a.vertex(s,l),a.endShape(a.CLOSE)},a.endShape=e=>{w(),e&&n.closePath(),a._doFill&&n.fill(),a._doStroke&&n.stroke(),a._doFill||a._doStroke||(n.save(),n.fillStyle="none",n.fill(),n.restore())},a.curveVertex=(e,t)=>{if(s.push([e,t]),s.length<4)return;let o=function(e,t,a,n,o,i,r,s,l,h){function c(e,t,a,n,o,i){let r=Math.pow(n-t,2)+Math.pow(o-a,2);return Math.pow(r,.5*i)+e}let d=[],u=c(0,e,t,a,n,h),_=c(u,a,n,o,i,h),g=c(_,o,i,r,s,h);for(let h=0;h<l;h++){let c=u+h/(l-1)*(_-u),m=[(u-c)/(u-0),(c-0)/(u-0),(_-c)/(_-u),(c-u)/(_-u),(g-c)/(g-_),(c-_)/(g-_),(_-c)/(_-0),(c-0)/(_-0),(g-c)/(g-u),(c-u)/(g-u)];for(let e=0;e<m.length;e+=2)isNaN(m[e])&&(m[e]=1,m[e+1]=0),isFinite(m[e])||(m[e]>0?(m[e]=1,m[e+1]=0):(m[e]=0,m[e+1]=1));let p=e*m[0]+a*m[1],f=t*m[0]+n*m[1],v=a*m[2]+o*m[3],x=n*m[2]+i*m[3],y=o*m[4]+r*m[5],M=i*m[4]+s*m[5],w=p*m[6]+v*m[7],R=f*m[6]+x*m[7],S=v*m[8]+y*m[9],C=x*m[8]+M*m[9],I=w*m[2]+S*m[3],E=R*m[2]+C*m[3];d.push([I,E])}return d}(...s[s.length-4],...s[s.length-3],...s[s.length-2],...s[s.length-1],a._curveDetail,a._curveAlpha);for(let e=0;e<o.length;e++)r?n.moveTo(...o[e]):n.lineTo(...o[e]),r=!1},a.curve=(e,t,n,o,i,r,s,l)=>{a.beginShape(),a.curveVertex(e,t),a.curveVertex(n,o),a.curveVertex(i,r),a.curveVertex(s,l),a.endShape()},a.translate=(e,t)=>n.translate(e,t),a.rotate=e=>{"degrees"==a._angleMode&&(e=a.radians(e)),n.rotate(e)},a.scale=(e,t)=>{t??=e,n.scale(e,t)},a.applyMatrix=(e,t,a,o,i,r)=>{n.transform(e,t,a,o,i,r)},a.shearX=e=>{n.transform(1,0,a.tan(e),1,0,0)},a.shearY=e=>{n.transform(1,a.tan(e),0,1,0,0)},a.resetMatrix=()=>{n.resetTransform(),n.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=()=>{n.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]=n[e];a._ctxStyles.push(t)},a.popMatrix=a.pop=()=>{n.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)n[e]=t[e]},a.imageMode=e=>a._imageMode=e,a.image=(e,t,o,i,r,s,l,h,c)=>{let d=e.MAGIC==a.MAGIC?e.canvas:e;function u(){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(_.canvas,0,0),t.restore()}if(e.MAGIC==a.MAGIC&&null!=a._tint&&(!function(e,t){null==_&&(_=document.createElement("canvas").getContext("2d"));t??=e||n.canvas.height,e??=n.canvas.width,(_.canvas.width!=e||_.canvas.height!=t)&&(_.canvas.width=e,_.canvas.height=t)}(e.canvas.width,e.canvas.height),_.drawImage(e.canvas,0,0),e.tinted(a._tint)),i||(e.MAGIC==a.MAGIC||e.width?(i=e.width,r=e.height):(i=e.videoWidth,r=e.videoHeight)),"center"==a._imageMode&&(t-=.5*i,o-=.5*r),void 0===s)return n.drawImage(d,t,o,i,r),void u();h??=d.width,c??=d.height,n.drawImage(d,s,l,h,c,t,o,i,r),u()},a.loadPixels=()=>{l=n.getImageData(0,0,a.canvas.width,a.canvas.height),a.pixels=l.data},a.updatePixels=()=>{null!=l&&n.putImageData(l,0,0)},a._incrementPreload=()=>h++,a._decrementPreload=()=>h--,a.loadImage=(e,t)=>{h++;let n=a.createImage(100,100),o=n.canvas.getContext("2d"),i=new window.Image;return i.src=e,i.crossOrigin="Anonymous",i.onload=()=>{n.width=o.canvas.width=i.naturalWidth,n.height=o.canvas.height=i.naturalHeight,o.drawImage(i,0,0),h--,t&&t(n)},i.onerror=e=>{throw h--,e},n};let R={};function S(e,t){null==u&&(u=document.createElement("canvas").getContext("2d")),t??=e||n.canvas.height,e??=n.canvas.width,u.canvas.width==e&&u.canvas.height==t||(u.canvas.width=e,u.canvas.height=t)}function C(){let e=n.canvas.width*n.canvas.height*4;g&&e==g.length||(g=new Uint8ClampedArray(e))}function I(e){u.clearRect(0,0,u.canvas.width,u.canvas.height),u.filter=e,u.drawImage(n.canvas,0,0),n.save(),n.resetTransform(),n.clearRect(0,0,n.canvas.width,n.canvas.height),n.drawImage(u.canvas,0,0),n.restore()}if(R[a.THRESHOLD]=(e,t)=>{void 0===t?t=127.5:t*=255;for(let a=0;a<e.length;a+=4){const n=.2126*e[a]+.7152*e[a+1]+.0722*e[a+2];e[a]=e[a+1]=e[a+2]=n>=t?255:0}},R[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}},R[a.OPAQUE]=e=>{for(let t=0;t<e.length;t+=4)e[t+3]=255},R[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]},R[a.POSTERIZE]=(e,t)=>{let a=t-1;for(let n=0;n<e.length;n+=4)e[n]=255*(e[n]*t>>8)/a,e[n+1]=255*(e[n+1]*t>>8)/a,e[n+2]=255*(e[n+2]*t>>8)/a},R[a.DILATE]=e=>{C(),g.set(e);let[t,a]=[n.canvas.width,n.canvas.height];for(let n=0;n<a;n++)for(let o=0;o<t;o++){let i=4*Math.max(o-1,0),r=4*Math.min(o+1,t-1),s=4*Math.max(n-1,0)*t,l=4*Math.min(n+1,a-1)*t,h=4*n*t,c=4*o;for(let t=0;t<4;t++){let a=t+s,n=t+l,o=t+h;e[h+c+t]=Math.max(g[a+c],g[o+i],g[o+c],g[o+r],g[n+c])}}},R[a.ERODE]=e=>{C(),g.set(e);let[t,a]=[n.canvas.width,n.canvas.height];for(let n=0;n<a;n++)for(let o=0;o<t;o++){let i=4*Math.max(o-1,0),r=4*Math.min(o+1,t-1),s=4*Math.max(n-1,0)*t,l=4*Math.min(n+1,a-1)*t,h=4*n*t,c=4*o;for(let t=0;t<4;t++){let a=t+s,n=t+l,o=t+h;e[h+c+t]=Math.min(g[a+c],g[o+i],g[o+c],g[o+r],g[n+c])}}},R[a.BLUR]=(e,t)=>{t=t||1,t=Math.floor(t*a._pixelDensity),C(),g.set(e);let o=2*t+1;let i=function(e){let a=new Float32Array(e),n=.3*t+.8,o=n*n*2;for(let t=0;t<e;t++){let i=t-e/2,r=Math.exp(-i*i/o)/(2.5066282746*n);a[t]=r}return a}(o),[r,s]=[n.canvas.width,n.canvas.height];for(let a=0;a<s;a++)for(let n=0;n<r;n++){let s=0,l=0,h=0,c=0;for(let e=0;e<o;e++){let o=4*(a*r+Math.min(Math.max(n-t+e,0),r-1));s+=g[o]*i[e],l+=g[o+1]*i[e],h+=g[o+2]*i[e],c+=g[o+3]*i[e]}let d=4*(a*r+n);e[d]=s,e[d+1]=l,e[d+2]=h,e[d+3]=c}g.set(e);for(let a=0;a<s;a++)for(let n=0;n<r;n++){let l=0,h=0,c=0,d=0;for(let e=0;e<o;e++){let o=4*(Math.min(Math.max(a-t+e,0),s-1)*r+n);l+=g[o]*i[e],h+=g[o+1]*i[e],c+=g[o+2]*i[e],d+=g[o+3]*i[e]}let u=4*(a*r+n);e[u]=l,e[u+1]=h,e[u+2]=c,e[u+3]=d}},a.filter=(e,t)=>{if(a.HARDWARE_FILTERS&&null!=n.filter)if(S(),e==a.THRESHOLD){t??=.5,t=Math.max(t,1e-5),I(`saturate(0%) brightness(${Math.floor(.5/t*100)}%) contrast(1000000%)`)}else if(e==a.GRAY)I("saturate(0%)");else if(e==a.OPAQUE)u.fillStyle="black",u.fillRect(0,0,u.canvas.width,u.canvas.height),u.drawImage(n.canvas,0,0),n.save(),n.resetTransform(),n.drawImage(u.canvas,0,0),n.restore();else if(e==a.INVERT)I("invert(100%)");else if(e==a.BLUR)I(`blur(${Math.ceil(t*a._pixelDensity/1)||1}px)`);else{let a=n.getImageData(0,0,n.canvas.width,n.canvas.height);R[e](a.data,t),n.putImageData(a,0,0)}else{let a=n.getImageData(0,0,n.canvas.width,n.canvas.height);R[e](a.data,t),n.putImageData(a,0,0)}},a.resize=(e,t)=>{S(),u.drawImage(n.canvas,0,0),a.width=e,a.height=t,n.canvas.width=e*a._pixelDensity,n.canvas.height=t*a._pixelDensity,n.save(),n.resetTransform(),n.clearRect(0,0,n.canvas.width,n.canvas.height),n.drawImage(u.canvas,0,0,n.canvas.width,n.canvas.height),n.restore()},a.get=(e,t,o,i)=>{if(void 0!==e&&void 0===o){let a=n.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,o=o||a.width,i=i||a.height;let r=a.createGraphics(o,i);r.pixelDensity(a._pixelDensity);let s=n.getImageData(e*a._pixelDensity,t*a._pixelDensity,o*a._pixelDensity,i*a._pixelDensity);return r.canvas.getContext("2d").putImageData(s,0,0),r},a.set=(e,t,o)=>{if(o.MAGIC==a.MAGIC){let n=a._tint;return a._tint=null,a.image(o,e,t),void(a._tint=n)}for(let i=0;i<a._pixelDensity;i++)for(let r=0;r<a._pixelDensity;r++){let s=4*((t*a._pixelDensity+i)*n.canvas.width+e*a._pixelDensity+r);a.pixels[s]=o._r,a.pixels[s+1]=o._g,a.pixels[s+2]=o._b,a.pixels[s+3]=255*o._a}},a.tinted=function(){let e=a.color(...Array.from(arguments)),t=e._a;e._a=1,S(),u.clearRect(0,0,u.canvas.width,u.canvas.height),u.fillStyle=e,u.fillRect(0,0,u.canvas.width,u.canvas.height),u.globalCompositeOperation="multiply",u.drawImage(n.canvas,0,0),u.globalCompositeOperation="source-over",n.save(),n.resetTransform();let o=n.globalCompositeOperation;n.globalCompositeOperation="source-in",n.drawImage(u.canvas,0,0),n.globalCompositeOperation=o,n.restore(),u.globalAlpha=t,u.clearRect(0,0,u.canvas.width,u.canvas.height),u.drawImage(n.canvas,0,0),u.globalAlpha=1,n.save(),n.resetTransform(),n.clearRect(0,0,n.canvas.width,n.canvas.height),n.drawImage(u.canvas,0,0),n.restore()},a.tint=function(){a._tint=a.color(...Array.from(arguments))},a.noTint=()=>a._tint=null,a.mask=e=>{n.save(),n.resetTransform();let t=n.globalCompositeOperation;n.globalCompositeOperation="destination-in",n.drawImage(e.canvas,0,0),n.globalCompositeOperation=t,n.restore()},a.clearTemporaryBuffers=()=>{u=null,_=null,g=null},a._save=(e,t,a)=>{if(t=t||"untitled","jpg"==(a=a||"png")||"png"==a)e=e.toDataURL();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 n=document.createElement("a");n.href=e,n.download=t+"."+a,document.body.append(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(n.href)},a.save=(e,t,o)=>{if((!e||"string"==typeof e&&(!t||!o&&t.length<5))&&(o=t,t=e,e=n.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.remove=()=>{a.noLoop(),a.canvas.remove()},"image"==e)return;function E(e,t,o){return e.slice(0,200)+a._textStyle+a._textSize+a._textFont+(a._doFill?n.fillStyle:"")+"_"+(a._doStroke&&a._strokeSet?n.lineWidth+n.strokeStyle+"_":"")+(t||"")+(o?"x"+o:"")}a.loadFont=(e,t)=>{let a=e.split("/"),n=a[a.length-1].split(".")[0].replace(" ",""),o=`@font-face {\n font-family: '${n}';\n src: url('${e}');\n }`;const i=document.createElement("style");return i.textContent=o,document.head.append(i),n},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)=>{n.textAlign=e,t&&(n.textBaseline=t==a.CENTER?"middle":t)},a.textWidth=e=>(n.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,n.measureText(e).width),a.textAscent=e=>(n.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,n.measureText(e).actualBoundingBoxAscent),a.textDescent=e=>(n.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,n.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[n,o]of this.entries())o.lastAccessed<t&&(t=o.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.createTextImage=(e,t,n)=>{let o=a._textCache;a._textCache=!0,a._useCache=!0,a.text(e,0,0,t,n),a._useCache=!1;let i=E(e,t,n);return a._textCache=o,a._tic.get(i)},a.text=(e,t,o,i,r)=>{if(void 0===e)return;if(e=e.toString(),!a._doFill&&!a._doStroke)return;let s,l,h,c,d,u=n.getTransform(),_=a._useCache||a._textCache&&(0!=u.b||0!=u.c);if(_){if(h=E(e,i,r),l=a._tic.get(h),l)return void a.textImage(l,t,o);l=a.createGraphics(1,1),s=l._ctx}else s=n,c=t,d=o;s.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`;let g=e.split("\n");if(_){c=0,d=a._textLeading*g.length;let t=s.measureText(" ");l._ascent=t.fontBoundingBoxAscent,l._descent=t.fontBoundingBoxDescent,r??=d+l._descent,l.resizeCanvas(Math.ceil(a.textWidth(e)),Math.ceil(r)),l.pixelDensity(a._pixelDensity),s.fillStyle=n.fillStyle,s.strokeStyle=n.strokeStyle}for(let e=0;e<g.length;e++){a._doStroke&&a._strokeSet&&s.strokeText(g[e],c,d);let t=s.fillStyle;if(a._fillSet||(s.fillStyle="black"),a._doFill&&s.fillText(g[e],c,d),a._fillSet||(s.fillStyle=t),d+=a._textLeading,d>r)break}_&&(a._tic.set(h,l),a.textImage(l,t,o))},a.textImage=(e,t,o)=>{let i=a._imageMode;a._imageMode="corner","center"==n.textAlign?t-=.5*e.width:"right"==n.textAlign&&(t-=e.width),"alphabetic"==n.textBaseline&&(o-=a._textLeading),"middle"==n.textBaseline?o-=.5*e._ascent+e._descent:"bottom"==n.textBaseline?o-=e._ascent+e._descent:"top"==n.textBaseline&&(o-=e._descent),a.image(e,t,o),a._imageMode=i};var b,D=4095,A=4,T=.5,k=e=>.5*(1-Math.cos(e*Math.PI));a.noise=(e,t,a)=>{if(t??=0,a??=0,null==b){b=new Array(4096);for(var n=0;n<4096;n++)b[n]=Math.random()}e<0&&(e=-e),t<0&&(t=-t),a<0&&(a=-a);for(var o,i,r,s,l,h=Math.floor(e),c=Math.floor(t),d=Math.floor(a),u=e-h,_=t-c,g=a-d,m=0,p=.5,f=0;f<A;f++){var v=h+(c<<4)+(d<<8);o=k(u),i=k(_),r=b[v&D],r+=o*(b[v+1&D]-r),s=b[v+16&D],r+=i*((s+=o*(b[v+16+1&D]-s))-r),s=b[(v+=256)&D],s+=o*(b[v+1&D]-s),l=b[v+16&D],s+=i*((l+=o*(b[v+16+1&D]-l))-s),m+=(r+=k(g)*(s-r))*p,p*=T,h<<=1,c<<=1,d<<=1,(u*=2)>=1&&(h++,u--),(_*=2)>=1&&(c++,_--),(g*=2)>=1&&(d++,g--)}return m},a.noiseDetail=(e,t)=>{e>0&&(A=e),t>0&&(T=t)};const P=()=>{let e,t,a=4294967295;return{setSeed(n){e=t=(null==n?Math.random()*a:n)>>>0},getSeed:()=>t,rand:()=>(e^=e<<17,e^=e>>13,e^=e<<5,(e>>>0)/a)}};let O=P();O.setSeed(),a.noiseSeed=e=>{let t=void 0===e?4294967295*Math.random():e;b||(b=new Float32Array(4096));for(var a=0;a<4096;a++)t^=t<<17,t^=t>>13,t^=t<<5,b[a]=(t>>>0)/4294967295},a.randomSeed=e=>O.setSeed(e),a.random=(e,t)=>void 0===e?O.rand():"number"==typeof e?void 0!==t?O.rand()*(t-e)+e:O.rand()*e:e[~~(e.length*O.rand())],a.randomGenerator=e=>{e==a.LCG?O=(()=>{const e=4294967296;let t,a;return{setSeed(n){a=t=(null==n?Math.random()*e:n)>>>0},getSeed:()=>t,rand:()=>(a=(1664525*a+1013904223)%e,a/e)}})():e==a.SHR3&&(O=P()),O.setSeed()};var z=new function(){var e,t,a,n=new Array(128),o=new Array(256),i=new Array(128),r=new Array(128),s=new Array(256),l=new Array(256),h=()=>4294967296*O.rand()-2147483648,c=()=>.5+2.328306e-10*(h()<<0),d=()=>{for(var t,o,s,l,d=3.44262;;){if(t=a*i[e],0==e){do{s=c(),l=c(),t=.2904764*-Math.log(s),o=-Math.log(l)}while(o+o<t*t);return a>0?d+t:-d-t}if(r[e]+c()*(r[e-1]-r[e])<Math.exp(-.5*t*t))return t;if(a=h(),e=127&a,Math.abs(a)<n[e])return a*i[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())<o[e=255&t])return t*s[e]}};this.SHR3=h,this.UNI=c,this.RNOR=()=>(a=h(),e=127&a,Math.abs(a)<n[e]?a*i[e]:d()),this.REXP=()=>(t=h()>>>0)<n[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,g=_,m=.003949659822581572;for(e=u/Math.exp(-.5*c*c),n[0]=Math.floor(c/e*a),n[1]=0,i[0]=e/a,i[127]=c/a,r[0]=1,r[127]=Math.exp(-.5*c*c),t=126;t>=1;t--)c=Math.sqrt(-2*Math.log(u/c+Math.exp(-.5*c*c))),n[t+1]=Math.floor(c/d*a),d=c,r[t]=Math.exp(-.5*c*c),i[t]=c/a;for(e=m/Math.exp(-_),o[0]=Math.floor(_/e*h),o[1]=0,s[0]=e/h,s[255]=_/h,l[0]=1,l[255]=Math.exp(-_),t=254;t>=1;t--)_=-Math.log(m/_+Math.exp(-_)),o[t+1]=Math.floor(_/g*h),g=_,l[t]=Math.exp(-_),s[t]=_/h}};function F(){let e=performance.now();if(a._loop)i=a._targetFrameRate?setTimeout(F,1e3/a._targetFrameRate):requestAnimationFrame(F);else if(a.frameCount>0)return;if(i&&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++,a._shouldResize&&(a._windowResizedFn(),a._shouldResize=!1);for(let e of Q5.prototype._methods.pre)e.call(a);w(),r=!0,n.save(),a._drawFn();for(let e of Q5.prototype._methods.post)e.call(a);n.restore();let t=performance.now();a._fps=Math.round(1e3/(t-e)),a._lastFrameTime=e,a.pmouseX=a.mouseX,a.pmouseY=a.mouseY}function Q(e){const t=a.canvas.getBoundingClientRect(),n=a.canvas.scrollWidth/a.width||1,o=a.canvas.scrollHeight/a.height||1;return{x:(e.clientX-t.left)/n,y:(e.clientY-t.top)/o,id:e.identifier}}function N(){return a._touchStartedFn.isPlaceHolder&&a._touchMovedFn.isPlaceHolder&&a._touchEndedFn.isPlaceHolder}z.hasInit=!1,a.randomGaussian=(e,t)=>(z.hasInit||(z.zigset(),z.hasInit=!0),z.RNOR()*t+e),a.randomExponential=()=>(z.hasInit||(z.zigset(),z.hasInit=!0),z.REXP()),a.print=console.log,a.cursor=(e,t,n)=>{let o="";e.includes(".")&&(e=`url("${e}")`,o=", auto"),void 0!==t&&(e+=" "+t+" "+n),a.canvas.style.cursor=e+o},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.append(t),t},a.noLoop=()=>{a._loop=!1,i=null},a.loop=()=>{a._loop=!0,null==i&&F()},a.redraw=()=>F(),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(),n=t.canvas.scrollWidth/t.width||1,o=t.canvas.scrollHeight/t.height||1;t.mouseX=(e.clientX-a.left)/n,t.mouseY=(e.clientY-a.top)/o}.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,c[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,c[a.keyCode]=!1,a._keyReleasedFn(e)},a.canvas.onmousedown=e=>a._onmousedown(e),a.canvas.onmouseup=e=>a._onmouseup(e),a.canvas.onclick=e=>a._onclick(e),a.keyIsDown=e=>!!c[e],a._ontouchstart=e=>{a.touches=[...e.touches].map(Q),N()&&(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(Q),N()&&(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(Q),N()&&(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 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])])((o=a.rotationY,t=[a.cos(o),0,a.sin(o),0,0,1,0,0,-a.sin(o),0,a.cos(o),0,0,0,0,1],n=(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]*n[0]+t[1]*n[4]+t[2]*n[8]+t[3]*n[12],t[0]*n[1]+t[1]*n[5]+t[2]*n[9]+t[3]*n[13],t[0]*n[2]+t[1]*n[6]+t[2]*n[10]+t[3]*n[14],t[0]*n[3]+t[1]*n[7]+t[2]*n[11]+t[3]*n[15],t[4]*n[0]+t[5]*n[4]+t[6]*n[8]+t[7]*n[12],t[4]*n[1]+t[5]*n[5]+t[6]*n[9]+t[7]*n[13],t[4]*n[2]+t[5]*n[6]+t[6]*n[10]+t[7]*n[14],t[4]*n[3]+t[5]*n[7]+t[6]*n[11]+t[7]*n[15],t[8]*n[0]+t[9]*n[4]+t[10]*n[8]+t[11]*n[12],t[8]*n[1]+t[9]*n[5]+t[10]*n[9]+t[11]*n[13],t[8]*n[2]+t[9]*n[6]+t[10]*n[10]+t[11]*n[14],t[8]*n[3]+t[9]*n[7]+t[10]*n[11]+t[11]*n[15],t[12]*n[0]+t[13]*n[4]+t[14]*n[8]+t[15]*n[12],t[12]*n[1]+t[13]*n[5]+t[14]*n[9]+t[15]*n[13],t[12]*n[2]+t[13]*n[6]+t[14]*n[10]+t[15]*n[14],t[12]*n[3]+t[13]*n[7]+t[14]*n[11]+t[15]*n[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,n,o}),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()-d,a.storeItem=localStorage.setItem,a.getItem=localStorage.getItem,a.removeItem=localStorage.removeItem,a.clearStorage=localStorage.clear,a._loadFile=(e,t,a)=>{h++;let n={};return fetch(e).then((e=>"json"==a?e.json():"text"==a?e.text():void 0)).then((e=>{h--,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)=>{h++;let a=new Audio(e);return a.addEventListener("canplaythrough",(()=>{h--,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 G of Q5.prototype._methods.init)G.call(a);if("global"==e){let V=Object.getOwnPropertyNames(a);for(let q of V)"function"==typeof a[q]?window[q]=a[q]:Object.defineProperty(window,q,{get:()=>a[q],set:e=>a[q]=e})}function L(){let t="global"==e?window:a,n=["setup","draw","preload","mouseMoved","mousePressed","mouseReleased","mouseDragged","mouseClicked","keyPressed","keyReleased","keyTyped","touchStarted","touchMoved","touchEnded","windowResized"];for(let e of n){let n="_"+e+"Fn";a[n]=()=>{},a[n].isPlaceHolder=!0,t[e]?a[n]=t[e]:Object.defineProperty(a,e,{set:e=>{a[n]=e}})}if("graphics"!=e||"image"!=e){a._preloadFn(),d=performance.now(),function e(){if(h>0)return requestAnimationFrame(e);a._setupFn(),requestAnimationFrame(F)}()}addEventListener("mousemove",(e=>a._onmousemove(e)),!1),addEventListener("keydown",(e=>a._onkeydown(e)),!1),addEventListener("keyup",(e=>a._onkeyup(e)),!1)}"function"==typeof e&&e(a),"global"==e?L():requestAnimationFrame(L)}Q5.Color=class{constructor(e,t,a,n){this.MAGIC=786698,this._r=e,this._g=t,this._b=a,this._a=n,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._instanceCount=0,Q5.Color._rgb2hsv=(e,t,a)=>{let n,o,i,r,s;return n=e<t?e<a?e:a:t<a?t:a,o=e>t?e>a?e:a:t>a?t:a,s=100*o/255,0==s?(i=0,r=0,[i,r,s]):(r=100*(o-n)/o,0==r?(i=0,[i,r,s]):(i=o==e?0+60*(t-a)/(o-n):o==t?120+60*(a-e)/(o-n):240+60*(e-t)/(o-n),[i,r,s]))},Q5.Color._hsv2rgb=(e,t,a)=>{let n,o,i,r,s,l,h,c,d;if(0==t)return n=a,o=a,i=a,[255*n,255*o,255*i];switch(r=e,r>360&&(r=0),r/=60,s=~~r,l=r-s,h=a*(1-t),c=a*(1-t*l),d=a*(1-t*(1-l)),s){case 0:n=a,o=d,i=h;break;case 1:n=c,o=a,i=h;break;case 2:n=h,o=a,i=d;break;case 3:n=h,o=c,i=a;break;case 4:n=d,o=h,i=a;break;default:n=a,o=h,i=c}return[255*n,255*o,255*i]},Q5.Vector=class{constructor(e,t,a,n){this.x=e||0,this.y=t||0,this.z=a||0,this._$=n||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 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._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,n=this.z-e.z;return Math.sqrt(t*t+a*a+n*n)}cross(){let e=this._arg2v(...arguments),t=this.y*e.z-this.z*e.y,a=this.z*e.x-this.x*e.z,n=this.x*e.y-this.y*e.x;return this.x=t,this.y=a,this.z=n,this._deprecNorm(),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),n=this.x*t-this.y*a,o=this.x*a+this.y*t;return this.x=n,this.y=o,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 n=this._$.cos(t),o=this._$.sin(t),i=this._$.cos(e),r=this._$.sin(e);return this.x=a*r*o,this.y=-a*i,this.z=a*r*n,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=>Math.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,n)=>(new Q5.Vector)[e](t,a,n);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(void 0===e&&(e="global"),"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 n=a._ctx=a.canvas.getContext("2d");if(a.canvas.classList.add("p5Canvas","q5Canvas"),a.canvas.id="defaultCanvas"+Q5._instanceCount++,a.width=100,a.height=100,a.canvas.width=a.width,a.canvas.height=a.height,a._windowResizedFn=()=>{},"graphics"!=e&&"image"!=e){function o(){t??=document.getElementsByTagName("main")[0],t??=document.body,a.canvas.parent(t)}a._resize=()=>{a.frameCount>1&&(a._shouldResize=!0)},a.canvas.parent=e=>{"string"==typeof e&&(e=document.getElementById(e)),e.append(a.canvas),"undefined"!=typeof ResizeObserver?(a._ro&&a._ro.disconnect(),a._ro=new ResizeObserver(a._resize),a._ro.observe(t)):0==a.frameCount&&addEventListener("resize",a._resize)},document.body?o():window.addEventListener("load",o)}f(),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=15,a._textLeadDiff=3,a._textStyle="normal",a._pixelDensity=1,a._lastFrameTime=0,a._targetFrameRate=null,a._frameRate=a._fps=60,a._tint=null;let i=null,r=!0,s=[],l=null,h=0,c={},d=0,u=null,_=null,g=null;function m(){let e={};for(let t in n)"function"!=typeof n[t]&&(e[t]=n[t]);return delete e.canvas,e}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:()=>n}),a.createCanvas=(t,n)=>(a.width=t,a.height=n,a.canvas.width=t*a._pixelDensity,a.canvas.height=n*a._pixelDensity,f(),"graphics"!=e&&"image"!=e&&a.pixelDensity(Math.ceil(a.displayDensity())),a.canvas),a.resizeCanvas=(t,o)=>{a.width=t,a.height=o;let i=m();a.canvas.width=t*a._pixelDensity,a.canvas.height=o*a._pixelDensity,n=a._ctx=a.canvas.getContext("2d");for(let e in i)a._ctx[e]=i[e];"graphics"!=e&&"image"!=e&&a.pixelDensity(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.displayDensity=()=>window.devicePixelRatio,a.pixelDensity=e=>{if(void 0===e)return a._pixelDensity;a._pixelDensity=e;let t=m();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",n=a._ctx=a.canvas.getContext("2d");for(let e in t)a._ctx[e]=t[e];return n.scale(a._pixelDensity,a._pixelDensity),a._pixelDensity},a.map=(e,t,a,n,o,i)=>{let r=n+1*(e-t)/(a-t)*(o-n);return i?n<o?Math.min(Math.max(r,n),o):Math.min(Math.max(r,o),n):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(){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,n)=>a.map(e,t,n,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 n=Math.atan2(e,t);return"degrees"==a._angleMode&&(n=a.degrees(n)),n},a.nf=(e,t,a)=>{let n=e<0,o=e.toString();return n&&(o=o.slice(1)),o=o.padStart(t,"0"),a>0&&(-1==o.indexOf(".")&&(o+="."),o=o.padEnd(t+1+a,"0")),n&&(o="-"+o),o},a.createVector=(e,t,n)=>new Q5.Vector(e,t,n,a),a.curvePoint=(e,t,a,n,o)=>{const i=o*o*o,r=o*o;return e*(-.5*i+r-.5*o)+t*(1.5*i-2.5*r+1)+a*(-1.5*i+2*r+.5*o)+n*(.5*i-.5*r)},a.bezierPoint=(e,t,a,n,o)=>{const i=1-o;return Math.pow(i,3)*e+3*Math.pow(i,2)*o*t+3*i*Math.pow(o,2)*a+Math.pow(o,3)*n},a.curveTangent=(e,t,a,n,o)=>{const i=o*o;return e*(-3*i/2+2*o-.5)+t*(9*i/2-5*o)+a*(-9*i/2+4*o+.5)+n*(3*i/2-o)},a.bezierTangent=(e,t,a,n,o)=>{const i=1-o;return 3*n*Math.pow(o,2)-3*a*Math.pow(o,2)+6*a*i*o-6*t*i*o+3*t*Math.pow(i,2)-3*e*Math.pow(i,2)},a.Color=Q5.Color,a.colorMode=e=>{a._colorMode=e};let p={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],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 f(){n.fillStyle="white",n.strokeStyle="black",n.lineCap="round",n.lineJoin="miter",n.textAlign="left"}function v(e){let t=a._angleMode==a.DEGREES?180:Math.PI,n=2*t;if(0<=e&&e<=n)return e;for(;e<0;)e+=n;for(;e>=t;)e-=n;return e}function x(e,t,o,i,r,s,l,h){if(!a._doFill&&!a._doStroke)return;let c=v(r),d=v(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,o,i)}n.beginPath();for(let r=0;r<h+1;r++){let s=r/h,l=a.lerp(c,d,s),u=a.cos(l)*o/2,_=a.sin(l)*i/2;n[r?"lineTo":"moveTo"](e+u,t+_)}l==a.CHORD?n.closePath():l==a.PIE&&(n.lineTo(e,t),n.closePath()),a._doFill&&n.fill(),a._doStroke&&n.stroke()}function y(e,t,o,i){(a._doFill||a._doStroke)&&(n.beginPath(),n.ellipse(e,t,o/2,i/2,0,0,a.TAU),a._doFill&&n.fill(),a._doStroke&&n.stroke())}function M(e,t,o,i,r,s,l,h){if(!a._doFill&&!a._doStroke)return;if(void 0===r)return function(e,t,o,i){a._doFill&&n.fillRect(e,t,o,i),a._doStroke&&n.strokeRect(e,t,o,i)}(e,t,o,i);if(void 0===s)return M(e,t,o,i,r,r,r,r);const c=Math.min(Math.abs(i),Math.abs(o))/2;r=Math.min(c,r),s=Math.min(c,s),h=Math.min(c,h),l=Math.min(c,l),n.beginPath(),n.moveTo(e+r,t),n.arcTo(e+o,t,e+o,t+i,s),n.arcTo(e+o,t+i,e,t+i,l),n.arcTo(e,t+i,e,t,h),n.arcTo(e,t,e+o,t,r),n.closePath(),a._doFill&&n.fill(),a._doStroke&&n.stroke()}function w(){s=[]}a.color=function(){let e=arguments;if(1==e.length){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):p[e[0]]?new Q5.Color(...p[e[0]],1):new Q5.Color(0,0,0,1);if("number"!=typeof e[0]&&786698==e[0].MAGIC)return e[0]}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,n)=>a._colorMode==a.RGB?new Q5.Color(a.constrain(a.lerp(e._r,t._r,n),0,255),a.constrain(a.lerp(e._g,t._g,n),0,255),a.constrain(a.lerp(e._b,t._b,n),0,255),a.constrain(a.lerp(e._a,t._a,n),0,1)):(e._inferHSV(),t._inferHSV(),new Q5.Color(a.constrain(function(e,t,n){var o=[[Math.abs(t-e),a.map(n,0,1,e,t)],[Math.abs(t+360-e),a.map(n,0,1,e,t+360)],[Math.abs(t-360-e),a.map(n,0,1,e,t-360)]];return o.sort(((e,t)=>e[0]-t[0])),(o[0][1]+720)%360}(e._h,t._h,n),0,360),a.constrain(a.lerp(e._s,t._s,n),0,100),a.constrain(a.lerp(e._v,t._v,n),0,100),a.constrain(a.lerp(e._a,t._a,n),0,1))),a.strokeWeight=e=>{a._doStroke=e>0,n.lineWidth=e},a.stroke=function(){if(a._doStroke=!0,a._strokeSet=!0,"string"==typeof arguments[0])return void(n.strokeStyle=arguments[0]);let e=a.color(...arguments);e._a<=0?a._doStroke=!1:n.strokeStyle=e},a.noStroke=()=>a._doStroke=!1,a.fill=function(){if(a._doFill=!0,a._fillSet=!0,"string"==typeof arguments[0])return void(n.fillStyle=arguments[0]);let e=a.color(...arguments);e._a<=0?a._doFill=!1:n.fillStyle=e},a.noFill=()=>a._doFill=!1,a.smooth=()=>a._smooth=!0,a.noSmooth=()=>a._smooth=!1,a.blendMode=e=>n.globalCompositeOperation=e,a.strokeCap=e=>n.lineCap=e,a.strokeJoin=e=>n.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=()=>{n.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);n.save(),n.resetTransform(),n.fillStyle="string"==typeof arguments[0]?arguments[0]:a.color(...Array.from(arguments)),n.fillRect(0,0,a.canvas.width,a.canvas.height),n.restore()},a.line=(e,t,o,i)=>{a._doStroke&&(n.beginPath(),n.moveTo(e,t),n.lineTo(o,i),n.stroke())},a.arc=(e,t,n,o,i,r,s,l)=>{if(i==r)return a.ellipse(e,t,n,o);l??=25,s??=a.PIE,a._ellipseMode==a.CENTER?x(e,t,n,o,i,r,s,l):a._ellipseMode==a.RADIUS?x(e,t,2*n,2*o,i,r,s,l):a._ellipseMode==a.CORNER?x(e+n/2,t+o/2,n,o,i,r,s,l):a._ellipseMode==a.CORNERS&&x((e+n)/2,(t+o)/2,n-e,o-t,i,r,s,l)},a.ellipse=(e,t,n,o)=>{o??=n,a._ellipseMode==a.CENTER?y(e,t,n,o):a._ellipseMode==a.RADIUS?y(e,t,2*n,2*o):a._ellipseMode==a.CORNER?y(e+n/2,t+o/2,n,o):a._ellipseMode==a.CORNERS&&y((e+n)/2,(t+o)/2,n-e,o-t)},a.circle=(e,t,n)=>a.ellipse(e,t,n,n),a.point=(e,t)=>{e.x&&(t=e.y,e=e.x),n.beginPath(),n.ellipse(e,t,.4,.4,0,0,a.TAU),n.stroke()},a.rect=(e,t,n,o,i,r,s,l)=>{a._rectMode==a.CENTER?M(e-n/2,t-o/2,n,o,i,r,s,l):a._rectMode==a.RADIUS?M(e-n,t-o,2*n,2*o,i,r,s,l):a._rectMode==a.CORNER?M(e,t,n,o,i,r,s,l):a._rectMode==a.CORNERS&&M(e,t,n-e,o-t,i,r,s,l)},a.square=(e,t,n,o,i,r,s)=>a.rect(e,t,n,n,o,i,r,s),a.beginShape=()=>{w(),n.beginPath(),r=!0},a.beginContour=()=>{n.closePath(),w(),r=!0},a.endContour=()=>{w(),r=!0},a.vertex=(e,t)=>{w(),r?n.moveTo(e,t):n.lineTo(e,t),r=!1},a.bezierVertex=(e,t,a,o,i,r)=>{w(),n.bezierCurveTo(e,t,a,o,i,r)},a.quadraticVertex=(e,t,a,o)=>{w(),n.quadraticCurveTo(e,t,a,o)},a.bezier=(e,t,n,o,i,r,s,l)=>{a.beginShape(),a.vertex(e,t),a.bezierVertex(n,o,i,r,s,l),a.endShape()},a.triangle=(e,t,n,o,i,r)=>{a.beginShape(),a.vertex(e,t),a.vertex(n,o),a.vertex(i,r),a.endShape(a.CLOSE)},a.quad=(e,t,n,o,i,r,s,l)=>{a.beginShape(),a.vertex(e,t),a.vertex(n,o),a.vertex(i,r),a.vertex(s,l),a.endShape(a.CLOSE)},a.endShape=e=>{w(),e&&n.closePath(),a._doFill&&n.fill(),a._doStroke&&n.stroke(),a._doFill||a._doStroke||(n.save(),n.fillStyle="none",n.fill(),n.restore())},a.curveVertex=(e,t)=>{if(s.push([e,t]),s.length<4)return;let o=function(e,t,a,n,o,i,r,s,l,h){function c(e,t,a,n,o,i){let r=Math.pow(n-t,2)+Math.pow(o-a,2);return Math.pow(r,.5*i)+e}let d=[],u=c(0,e,t,a,n,h),_=c(u,a,n,o,i,h),g=c(_,o,i,r,s,h);for(let h=0;h<l;h++){let c=u+h/(l-1)*(_-u),m=[(u-c)/(u-0),(c-0)/(u-0),(_-c)/(_-u),(c-u)/(_-u),(g-c)/(g-_),(c-_)/(g-_),(_-c)/(_-0),(c-0)/(_-0),(g-c)/(g-u),(c-u)/(g-u)];for(let e=0;e<m.length;e+=2)isNaN(m[e])&&(m[e]=1,m[e+1]=0),isFinite(m[e])||(m[e]>0?(m[e]=1,m[e+1]=0):(m[e]=0,m[e+1]=1));let p=e*m[0]+a*m[1],f=t*m[0]+n*m[1],v=a*m[2]+o*m[3],x=n*m[2]+i*m[3],y=o*m[4]+r*m[5],M=i*m[4]+s*m[5],w=p*m[6]+v*m[7],R=f*m[6]+x*m[7],S=v*m[8]+y*m[9],C=x*m[8]+M*m[9],I=w*m[2]+S*m[3],E=R*m[2]+C*m[3];d.push([I,E])}return d}(...s[s.length-4],...s[s.length-3],...s[s.length-2],...s[s.length-1],a._curveDetail,a._curveAlpha);for(let e=0;e<o.length;e++)r?n.moveTo(...o[e]):n.lineTo(...o[e]),r=!1},a.curve=(e,t,n,o,i,r,s,l)=>{a.beginShape(),a.curveVertex(e,t),a.curveVertex(n,o),a.curveVertex(i,r),a.curveVertex(s,l),a.endShape()},a.translate=(e,t)=>n.translate(e,t),a.rotate=e=>{"degrees"==a._angleMode&&(e=a.radians(e)),n.rotate(e)},a.scale=(e,t)=>{t??=e,n.scale(e,t)},a.applyMatrix=(e,t,a,o,i,r)=>{n.transform(e,t,a,o,i,r)},a.shearX=e=>{n.transform(1,0,a.tan(e),1,0,0)},a.shearY=e=>{n.transform(1,a.tan(e),0,1,0,0)},a.resetMatrix=()=>{n.resetTransform(),n.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=()=>{n.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]=n[e];a._ctxStyles.push(t)},a.popMatrix=a.pop=()=>{n.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)n[e]=t[e]},a.imageMode=e=>a._imageMode=e,a.image=(e,t,o,i,r,s,l,h,c)=>{let d=e.MAGIC==a.MAGIC?e.canvas:e;function u(){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(_.canvas,0,0),t.restore()}if(e.MAGIC==a.MAGIC&&null!=a._tint&&(!function(e,t){null==_&&(_=document.createElement("canvas").getContext("2d"));t??=e||n.canvas.height,e??=n.canvas.width,(_.canvas.width!=e||_.canvas.height!=t)&&(_.canvas.width=e,_.canvas.height=t)}(e.canvas.width,e.canvas.height),_.drawImage(e.canvas,0,0),e.tinted(a._tint)),i||(e.MAGIC==a.MAGIC||e.width?(i=e.width,r=e.height):(i=e.videoWidth,r=e.videoHeight)),"center"==a._imageMode&&(t-=.5*i,o-=.5*r),void 0===s)return n.drawImage(d,t,o,i,r),void u();h??=d.width,c??=d.height,n.drawImage(d,s,l,h,c,t,o,i,r),u()},a.loadPixels=()=>{l=n.getImageData(0,0,a.canvas.width,a.canvas.height),a.pixels=l.data},a.updatePixels=()=>{null!=l&&n.putImageData(l,0,0)},a._incrementPreload=()=>h++,a._decrementPreload=()=>h--,a.loadImage=(e,t)=>{h++;let n=a.createImage(100,100),o=n.canvas.getContext("2d"),i=new window.Image;return i.src=e,i.crossOrigin="Anonymous",i.onload=()=>{n.width=o.canvas.width=i.naturalWidth,n.height=o.canvas.height=i.naturalHeight,o.drawImage(i,0,0),h--,t&&t(n)},i.onerror=e=>{throw h--,e},n};let R={};function S(e,t){null==u&&(u=document.createElement("canvas").getContext("2d")),t??=e||n.canvas.height,e??=n.canvas.width,u.canvas.width==e&&u.canvas.height==t||(u.canvas.width=e,u.canvas.height=t)}function C(){let e=n.canvas.width*n.canvas.height*4;g&&e==g.length||(g=new Uint8ClampedArray(e))}function I(e){u.clearRect(0,0,u.canvas.width,u.canvas.height),u.filter=e,u.drawImage(n.canvas,0,0),n.save(),n.resetTransform(),n.clearRect(0,0,n.canvas.width,n.canvas.height),n.drawImage(u.canvas,0,0),n.restore()}if(R[a.THRESHOLD]=(e,t)=>{void 0===t?t=127.5:t*=255;for(let a=0;a<e.length;a+=4){const n=.2126*e[a]+.7152*e[a+1]+.0722*e[a+2];e[a]=e[a+1]=e[a+2]=n>=t?255:0}},R[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}},R[a.OPAQUE]=e=>{for(let t=0;t<e.length;t+=4)e[t+3]=255},R[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]},R[a.POSTERIZE]=(e,t)=>{let a=t-1;for(let n=0;n<e.length;n+=4)e[n]=255*(e[n]*t>>8)/a,e[n+1]=255*(e[n+1]*t>>8)/a,e[n+2]=255*(e[n+2]*t>>8)/a},R[a.DILATE]=e=>{C(),g.set(e);let[t,a]=[n.canvas.width,n.canvas.height];for(let n=0;n<a;n++)for(let o=0;o<t;o++){let i=4*Math.max(o-1,0),r=4*Math.min(o+1,t-1),s=4*Math.max(n-1,0)*t,l=4*Math.min(n+1,a-1)*t,h=4*n*t,c=4*o;for(let t=0;t<4;t++){let a=t+s,n=t+l,o=t+h;e[h+c+t]=Math.max(g[a+c],g[o+i],g[o+c],g[o+r],g[n+c])}}},R[a.ERODE]=e=>{C(),g.set(e);let[t,a]=[n.canvas.width,n.canvas.height];for(let n=0;n<a;n++)for(let o=0;o<t;o++){let i=4*Math.max(o-1,0),r=4*Math.min(o+1,t-1),s=4*Math.max(n-1,0)*t,l=4*Math.min(n+1,a-1)*t,h=4*n*t,c=4*o;for(let t=0;t<4;t++){let a=t+s,n=t+l,o=t+h;e[h+c+t]=Math.min(g[a+c],g[o+i],g[o+c],g[o+r],g[n+c])}}},R[a.BLUR]=(e,t)=>{t=t||1,t=Math.floor(t*a._pixelDensity),C(),g.set(e);let o=2*t+1;let i=function(e){let a=new Float32Array(e),n=.3*t+.8,o=n*n*2;for(let t=0;t<e;t++){let i=t-e/2,r=Math.exp(-i*i/o)/(2.5066282746*n);a[t]=r}return a}(o),[r,s]=[n.canvas.width,n.canvas.height];for(let a=0;a<s;a++)for(let n=0;n<r;n++){let s=0,l=0,h=0,c=0;for(let e=0;e<o;e++){let o=4*(a*r+Math.min(Math.max(n-t+e,0),r-1));s+=g[o]*i[e],l+=g[o+1]*i[e],h+=g[o+2]*i[e],c+=g[o+3]*i[e]}let d=4*(a*r+n);e[d]=s,e[d+1]=l,e[d+2]=h,e[d+3]=c}g.set(e);for(let a=0;a<s;a++)for(let n=0;n<r;n++){let l=0,h=0,c=0,d=0;for(let e=0;e<o;e++){let o=4*(Math.min(Math.max(a-t+e,0),s-1)*r+n);l+=g[o]*i[e],h+=g[o+1]*i[e],c+=g[o+2]*i[e],d+=g[o+3]*i[e]}let u=4*(a*r+n);e[u]=l,e[u+1]=h,e[u+2]=c,e[u+3]=d}},a.filter=(e,t)=>{if(a.HARDWARE_FILTERS&&null!=n.filter)if(S(),e==a.THRESHOLD){t??=.5,t=Math.max(t,1e-5),I(`saturate(0%) brightness(${Math.floor(.5/t*100)}%) contrast(1000000%)`)}else if(e==a.GRAY)I("saturate(0%)");else if(e==a.OPAQUE)u.fillStyle="black",u.fillRect(0,0,u.canvas.width,u.canvas.height),u.drawImage(n.canvas,0,0),n.save(),n.resetTransform(),n.drawImage(u.canvas,0,0),n.restore();else if(e==a.INVERT)I("invert(100%)");else if(e==a.BLUR)I(`blur(${Math.ceil(t*a._pixelDensity/1)||1}px)`);else{let a=n.getImageData(0,0,n.canvas.width,n.canvas.height);R[e](a.data,t),n.putImageData(a,0,0)}else{let a=n.getImageData(0,0,n.canvas.width,n.canvas.height);R[e](a.data,t),n.putImageData(a,0,0)}},a.resize=(e,t)=>{S(),u.drawImage(n.canvas,0,0),a.width=e,a.height=t,n.canvas.width=e*a._pixelDensity,n.canvas.height=t*a._pixelDensity,n.save(),n.resetTransform(),n.clearRect(0,0,n.canvas.width,n.canvas.height),n.drawImage(u.canvas,0,0,n.canvas.width,n.canvas.height),n.restore()},a.get=(e,t,o,i)=>{if(void 0!==e&&void 0===o){let a=n.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,o=o||a.width,i=i||a.height;let r=a.createGraphics(o,i);r.pixelDensity(a._pixelDensity);let s=n.getImageData(e*a._pixelDensity,t*a._pixelDensity,o*a._pixelDensity,i*a._pixelDensity);return r.canvas.getContext("2d").putImageData(s,0,0),r},a.set=(e,t,o)=>{if(o.MAGIC==a.MAGIC){let n=a._tint;return a._tint=null,a.image(o,e,t),void(a._tint=n)}for(let i=0;i<a._pixelDensity;i++)for(let r=0;r<a._pixelDensity;r++){let s=4*((t*a._pixelDensity+i)*n.canvas.width+e*a._pixelDensity+r);a.pixels[s]=o._r,a.pixels[s+1]=o._g,a.pixels[s+2]=o._b,a.pixels[s+3]=255*o._a}},a.tinted=function(){let e=a.color(...Array.from(arguments)),t=e._a;e._a=1,S(),u.clearRect(0,0,u.canvas.width,u.canvas.height),u.fillStyle=e,u.fillRect(0,0,u.canvas.width,u.canvas.height),u.globalCompositeOperation="multiply",u.drawImage(n.canvas,0,0),u.globalCompositeOperation="source-over",n.save(),n.resetTransform();let o=n.globalCompositeOperation;n.globalCompositeOperation="source-in",n.drawImage(u.canvas,0,0),n.globalCompositeOperation=o,n.restore(),u.globalAlpha=t,u.clearRect(0,0,u.canvas.width,u.canvas.height),u.drawImage(n.canvas,0,0),u.globalAlpha=1,n.save(),n.resetTransform(),n.clearRect(0,0,n.canvas.width,n.canvas.height),n.drawImage(u.canvas,0,0),n.restore()},a.tint=function(){a._tint=a.color(...Array.from(arguments))},a.noTint=()=>a._tint=null,a.mask=e=>{n.save(),n.resetTransform();let t=n.globalCompositeOperation;n.globalCompositeOperation="destination-in",n.drawImage(e.canvas,0,0),n.globalCompositeOperation=t,n.restore()},a.clearTemporaryBuffers=()=>{u=null,_=null,g=null},a._save=(e,t,a)=>{if(t=t||"untitled","jpg"==(a=a||"png")||"png"==a)e=e.toDataURL();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 n=document.createElement("a");n.href=e,n.download=t+"."+a,document.body.append(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(n.href)},a.save=(e,t,o)=>{if((!e||"string"==typeof e&&(!t||!o&&t.length<5))&&(o=t,t=e,e=n.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.remove=()=>{a.noLoop(),a.canvas.remove()},"image"==e)return;function E(e,t,o){return e.slice(0,200)+a._textStyle+a._textSize+a._textFont+(a._doFill?n.fillStyle:"")+"_"+(a._doStroke&&a._strokeSet?n.lineWidth+n.strokeStyle+"_":"")+(t||"")+(o?"x"+o:"")}a.loadFont=(e,t)=>{let a=e.split("/"),n=a[a.length-1].split(".")[0].replace(" ",""),o=`@font-face {\n font-family: '${n}';\n src: url('${e}');\n }`;const i=document.createElement("style");return i.textContent=o,document.head.append(i),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)=>{n.textAlign=e,t&&(n.textBaseline=t==a.CENTER?"middle":t)},a.textWidth=e=>(n.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,n.measureText(e).width),a.textAscent=e=>(n.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,n.measureText(e).actualBoundingBoxAscent),a.textDescent=e=>(n.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,n.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[n,o]of this.entries())o.lastAccessed<t&&(t=o.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.createTextImage=(e,t,n)=>{let o=a._textCache;a._textCache=!0,a._useCache=!0,a.text(e,0,0,t,n),a._useCache=!1;let i=E(e,t,n);return a._textCache=o,a._tic.get(i)},a.text=(e,t,o,i,r)=>{if(void 0===e)return;if(e=e.toString(),!a._doFill&&!a._doStroke)return;let s,l,h,c,d,u=n.getTransform(),_=a._useCache||a._textCache&&(0!=u.b||0!=u.c);if(_){if(h=E(e,i,r),l=a._tic.get(h),l)return void a.textImage(l,t,o);l=a.createImage(1,1),s=l._ctx}else s=n,c=t,d=o;s.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`;let g=e.split("\n");if(_){c=0,d=a._textLeading*g.length;let t=s.measureText(" ");l._ascent=t.fontBoundingBoxAscent,l._descent=t.fontBoundingBoxDescent,r??=d+l._descent,l.resizeCanvas(Math.ceil(a.textWidth(e)),Math.ceil(r)),l.pixelDensity(a._pixelDensity),s.fillStyle=n.fillStyle,s.strokeStyle=n.strokeStyle}for(let e=0;e<g.length;e++){a._doStroke&&a._strokeSet&&s.strokeText(g[e],c,d);let t=s.fillStyle;if(a._fillSet||(s.fillStyle="black"),a._doFill&&s.fillText(g[e],c,d),a._fillSet||(s.fillStyle=t),d+=a._textLeading,d>r)break}_&&(a._tic.set(h,l),a.textImage(l,t,o))},a.textImage=(e,t,o)=>{let i=a._imageMode;a._imageMode="corner","center"==n.textAlign?t-=.5*e.width:"right"==n.textAlign&&(t-=e.width),"alphabetic"==n.textBaseline&&(o-=a._textLeading),"middle"==n.textBaseline?o-=e._descent+.5*e._ascent+a._textLeadDiff:"bottom"==n.textBaseline?o-=e._ascent+e._descent+a._textLeadDiff:"top"==n.textBaseline&&(o-=e._descent+a._textLeadDiff),a.image(e,t,o),a._imageMode=i};var D,b=4095,A=4,T=.5,k=e=>.5*(1-Math.cos(e*Math.PI));a.noise=(e,t,a)=>{if(t??=0,a??=0,null==D){D=new Array(4096);for(var n=0;n<4096;n++)D[n]=Math.random()}e<0&&(e=-e),t<0&&(t=-t),a<0&&(a=-a);for(var o,i,r,s,l,h=Math.floor(e),c=Math.floor(t),d=Math.floor(a),u=e-h,_=t-c,g=a-d,m=0,p=.5,f=0;f<A;f++){var v=h+(c<<4)+(d<<8);o=k(u),i=k(_),r=D[v&b],r+=o*(D[v+1&b]-r),s=D[v+16&b],r+=i*((s+=o*(D[v+16+1&b]-s))-r),s=D[(v+=256)&b],s+=o*(D[v+1&b]-s),l=D[v+16&b],s+=i*((l+=o*(D[v+16+1&b]-l))-s),m+=(r+=k(g)*(s-r))*p,p*=T,h<<=1,c<<=1,d<<=1,(u*=2)>=1&&(h++,u--),(_*=2)>=1&&(c++,_--),(g*=2)>=1&&(d++,g--)}return m},a.noiseDetail=(e,t)=>{e>0&&(A=e),t>0&&(T=t)};const P=()=>{let e,t,a=4294967295;return{setSeed(n){e=t=(null==n?Math.random()*a:n)>>>0},getSeed:()=>t,rand:()=>(e^=e<<17,e^=e>>13,e^=e<<5,(e>>>0)/a)}};let O=P();O.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=>O.setSeed(e),a.random=(e,t)=>void 0===e?O.rand():"number"==typeof e?void 0!==t?O.rand()*(t-e)+e:O.rand()*e:e[~~(e.length*O.rand())],a.randomGenerator=e=>{e==a.LCG?O=(()=>{const e=4294967296;let t,a;return{setSeed(n){a=t=(null==n?Math.random()*e:n)>>>0},getSeed:()=>t,rand:()=>(a=(1664525*a+1013904223)%e,a/e)}})():e==a.SHR3&&(O=P()),O.setSeed()};var z=new function(){var e,t,a,n=new Array(128),o=new Array(256),i=new Array(128),r=new Array(128),s=new Array(256),l=new Array(256),h=()=>4294967296*O.rand()-2147483648,c=()=>.5+2.328306e-10*(h()<<0),d=()=>{for(var t,o,s,l,d=3.44262;;){if(t=a*i[e],0==e){do{s=c(),l=c(),t=.2904764*-Math.log(s),o=-Math.log(l)}while(o+o<t*t);return a>0?d+t:-d-t}if(r[e]+c()*(r[e-1]-r[e])<Math.exp(-.5*t*t))return t;if(a=h(),e=127&a,Math.abs(a)<n[e])return a*i[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())<o[e=255&t])return t*s[e]}};this.SHR3=h,this.UNI=c,this.RNOR=()=>(a=h(),e=127&a,Math.abs(a)<n[e]?a*i[e]:d()),this.REXP=()=>(t=h()>>>0)<n[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,g=_,m=.003949659822581572;for(e=u/Math.exp(-.5*c*c),n[0]=Math.floor(c/e*a),n[1]=0,i[0]=e/a,i[127]=c/a,r[0]=1,r[127]=Math.exp(-.5*c*c),t=126;t>=1;t--)c=Math.sqrt(-2*Math.log(u/c+Math.exp(-.5*c*c))),n[t+1]=Math.floor(c/d*a),d=c,r[t]=Math.exp(-.5*c*c),i[t]=c/a;for(e=m/Math.exp(-_),o[0]=Math.floor(_/e*h),o[1]=0,s[0]=e/h,s[255]=_/h,l[0]=1,l[255]=Math.exp(-_),t=254;t>=1;t--)_=-Math.log(m/_+Math.exp(-_)),o[t+1]=Math.floor(_/g*h),g=_,l[t]=Math.exp(-_),s[t]=_/h}};function F(){let e=performance.now();if(a._loop)i=a._targetFrameRate?setTimeout(F,1e3/a._targetFrameRate):requestAnimationFrame(F);else if(a.frameCount>0)return;if(i&&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++,a._shouldResize&&(a._windowResizedFn(),a._shouldResize=!1);for(let e of Q5.prototype._methods.pre)e.call(a);w(),r=!0,n.save(),a._drawFn();for(let e of Q5.prototype._methods.post)e.call(a);n.restore();let t=performance.now();a._fps=Math.round(1e3/(t-e)),a._lastFrameTime=e,a.pmouseX=a.mouseX,a.pmouseY=a.mouseY}function Q(e){const t=a.canvas.getBoundingClientRect(),n=a.canvas.scrollWidth/a.width||1,o=a.canvas.scrollHeight/a.height||1;return{x:(e.clientX-t.left)/n,y:(e.clientY-t.top)/o,id:e.identifier}}function L(){return a._touchStartedFn.isPlaceHolder&&a._touchMovedFn.isPlaceHolder&&a._touchEndedFn.isPlaceHolder}z.hasInit=!1,a.randomGaussian=(e,t)=>(z.hasInit||(z.zigset(),z.hasInit=!0),z.RNOR()*t+e),a.randomExponential=()=>(z.hasInit||(z.zigset(),z.hasInit=!0),z.REXP()),a.print=console.log,a.cursor=(e,t,n)=>{let o="";e.includes(".")&&(e=`url("${e}")`,o=", auto"),void 0!==t&&(e+=" "+t+" "+n),a.canvas.style.cursor=e+o},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.append(t),t},a.noLoop=()=>{a._loop=!1,i=null},a.loop=()=>{a._loop=!0,null==i&&F()},a.redraw=()=>F(),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(),n=t.canvas.scrollWidth/t.width||1,o=t.canvas.scrollHeight/t.height||1;t.mouseX=(e.clientX-a.left)/n,t.mouseY=(e.clientY-a.top)/o}.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,c[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,c[a.keyCode]=!1,a._keyReleasedFn(e)},a.canvas.onmousedown=e=>a._onmousedown(e),a.canvas.onmouseup=e=>a._onmouseup(e),a.canvas.onclick=e=>a._onclick(e),a.keyIsDown=e=>!!c[e],a._ontouchstart=e=>{a.touches=[...e.touches].map(Q),L()&&(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(Q),L()&&(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(Q),L()&&(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 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])])((o=a.rotationY,t=[a.cos(o),0,a.sin(o),0,0,1,0,0,-a.sin(o),0,a.cos(o),0,0,0,0,1],n=(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]*n[0]+t[1]*n[4]+t[2]*n[8]+t[3]*n[12],t[0]*n[1]+t[1]*n[5]+t[2]*n[9]+t[3]*n[13],t[0]*n[2]+t[1]*n[6]+t[2]*n[10]+t[3]*n[14],t[0]*n[3]+t[1]*n[7]+t[2]*n[11]+t[3]*n[15],t[4]*n[0]+t[5]*n[4]+t[6]*n[8]+t[7]*n[12],t[4]*n[1]+t[5]*n[5]+t[6]*n[9]+t[7]*n[13],t[4]*n[2]+t[5]*n[6]+t[6]*n[10]+t[7]*n[14],t[4]*n[3]+t[5]*n[7]+t[6]*n[11]+t[7]*n[15],t[8]*n[0]+t[9]*n[4]+t[10]*n[8]+t[11]*n[12],t[8]*n[1]+t[9]*n[5]+t[10]*n[9]+t[11]*n[13],t[8]*n[2]+t[9]*n[6]+t[10]*n[10]+t[11]*n[14],t[8]*n[3]+t[9]*n[7]+t[10]*n[11]+t[11]*n[15],t[12]*n[0]+t[13]*n[4]+t[14]*n[8]+t[15]*n[12],t[12]*n[1]+t[13]*n[5]+t[14]*n[9]+t[15]*n[13],t[12]*n[2]+t[13]*n[6]+t[14]*n[10]+t[15]*n[14],t[12]*n[3]+t[13]*n[7]+t[14]*n[11]+t[15]*n[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,n,o}),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()-d,a.storeItem=localStorage.setItem,a.getItem=localStorage.getItem,a.removeItem=localStorage.removeItem,a.clearStorage=localStorage.clear,a._loadFile=(e,t,a)=>{h++;let n={};return fetch(e).then((e=>"json"==a?e.json():"text"==a?e.text():void 0)).then((e=>{h--,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)=>{h++;let a=new Audio(e);return a.addEventListener("canplaythrough",(()=>{h--,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 G of Q5.prototype._methods.init)G.call(a);if("global"==e){let V=Object.getOwnPropertyNames(a);for(let q of V)"function"==typeof a[q]?window[q]=a[q]:Object.defineProperty(window,q,{get:()=>a[q],set:e=>a[q]=e})}function N(){let t="global"==e?window:a,n=["setup","draw","preload","mouseMoved","mousePressed","mouseReleased","mouseDragged","mouseClicked","keyPressed","keyReleased","keyTyped","touchStarted","touchMoved","touchEnded","windowResized"];for(let e of n){let n="_"+e+"Fn";a[n]=()=>{},a[n].isPlaceHolder=!0,t[e]?a[n]=t[e]:Object.defineProperty(a,e,{set:e=>{a[n]=e}})}if("graphics"!=e||"image"!=e){a._preloadFn(),d=performance.now(),function e(){if(h>0)return requestAnimationFrame(e);a._setupFn(),requestAnimationFrame(F)}()}addEventListener("mousemove",(e=>a._onmousemove(e)),!1),addEventListener("keydown",(e=>a._onkeydown(e)),!1),addEventListener("keyup",(e=>a._onkeyup(e)),!1)}"function"==typeof e&&e(a),"global"==e?N():requestAnimationFrame(N)}Q5.Color=class{constructor(e,t,a,n){this.MAGIC=786698,this._r=e,this._g=t,this._b=a,this._a=n,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._instanceCount=0,Q5.Color._rgb2hsv=(e,t,a)=>{let n,o,i,r,s;return n=e<t?e<a?e:a:t<a?t:a,o=e>t?e>a?e:a:t>a?t:a,s=100*o/255,0==s?(i=0,r=0,[i,r,s]):(r=100*(o-n)/o,0==r?(i=0,[i,r,s]):(i=o==e?0+60*(t-a)/(o-n):o==t?120+60*(a-e)/(o-n):240+60*(e-t)/(o-n),[i,r,s]))},Q5.Color._hsv2rgb=(e,t,a)=>{let n,o,i,r,s,l,h,c,d;if(0==t)return n=a,o=a,i=a,[255*n,255*o,255*i];switch(r=e,r>360&&(r=0),r/=60,s=~~r,l=r-s,h=a*(1-t),c=a*(1-t*l),d=a*(1-t*(1-l)),s){case 0:n=a,o=d,i=h;break;case 1:n=c,o=a,i=h;break;case 2:n=h,o=a,i=d;break;case 3:n=h,o=c,i=a;break;case 4:n=d,o=h,i=a;break;default:n=a,o=h,i=c}return[255*n,255*o,255*i]},Q5.Vector=class{constructor(e,t,a,n){this.x=e||0,this.y=t||0,this.z=a||0,this._$=n||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 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._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,n=this.z-e.z;return Math.sqrt(t*t+a*a+n*n)}cross(){let e=this._arg2v(...arguments),t=this.y*e.z-this.z*e.y,a=this.z*e.x-this.x*e.z,n=this.x*e.y-this.y*e.x;return this.x=t,this.y=a,this.z=n,this._deprecNorm(),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),n=this.x*t-this.y*a,o=this.x*a+this.y*t;return this.x=n,this.y=o,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 n=this._$.cos(t),o=this._$.sin(t),i=this._$.cos(e),r=this._$.sin(e);return this.x=a*r*o,this.y=-a*i,this.z=a*r*n,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=>Math.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,n)=>(new Q5.Vector)[e](t,a,n);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")}));