q5 1.9.18 → 1.9.20

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 +3 -5
  2. package/package.json +2 -2
  3. package/q5.js +63 -28
  4. package/q5.min.js +2 -2
package/README.md CHANGED
@@ -26,11 +26,9 @@ Or try out the [q5.js template sketch](https://editor.p5js.org/quinton-ashley/sk
26
26
 
27
27
  ## Support this project 🤝
28
28
 
29
- q5 is open source and [multi-licensed](https://github.com/quinton-ashley/p5play-web/blob/main/LICENSING.md). Anyone can use q5 for free under the terms of the AGPLv3. 🎉
29
+ q5 is open source. Anyone can use q5 for free under the terms of the LGPL, just like p5.js. 🎉
30
30
 
31
- But if you want to use q5 commercially in a closed source product or service, you must comply with the [p5play Professional License](https://github.com/quinton-ashley/p5play-web/blob/main/pro/LICENSE.md), which is only available to current p5play [GitHub Sponsors](https://github.com/sponsors/quinton-ashley) or [Patreon](https://www.patreon.com/p5play) members paying for the appropriate tier.
32
-
33
- If you can't afford to pay, you can apply for the free [p5play Novice License](https://github.com/quinton-ashley/p5play-novice/blob/main/LICENSE.md). See [LICENSING.md](https://github.com/quinton-ashley/p5play-web/blob/main/LICENSING.md) for more info.
31
+ If you'd like to support this project, please donate via [GitHub Sponsors](https://github.com/sponsors/quinton-ashley) or [Patreon](https://www.patreon.com/p5play).
34
32
 
35
33
  ## Using p5 Addon Libraries
36
34
 
@@ -288,7 +286,7 @@ q5.js is not affiliated with the Processing Foundation. p5.js is licensed under
288
286
 
289
287
  @LingDong- created the original q5xjs library and licensed it under the MIT license.
290
288
 
291
- @quinton-ashley created q5.js (this project) which contains many bug fixes, additional p5.js API implementations, and several exclusive features. q5.js is licensed under the AGPLv3.
289
+ @quinton-ashley created q5.js (this project) which contains many bug fixes, additional p5.js API implementations, and several exclusive features. q5.js is licensed under the LGPLv3.
292
290
 
293
291
  ## Credits
294
292
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "quinton-ashley",
3
3
  "name": "q5",
4
- "version": "1.9.18",
4
+ "version": "1.9.20",
5
5
  "description": "An implementation of the p5.js 2D API that's smaller and faster",
6
6
  "main": "q5-server.js",
7
7
  "scripts": {
@@ -25,7 +25,7 @@
25
25
  "q5.js",
26
26
  "q5js"
27
27
  ],
28
- "license": "AGPL-3.0",
28
+ "license": "LGPL-3.0",
29
29
  "bugs": {
30
30
  "url": "https://github.com/quinton-ashley/q5.js/issues"
31
31
  },
package/q5.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * q5.js
3
3
  * @version 1.9
4
4
  * @author quinton-ashley and LingDong-
5
- * @license AGPL-3.0
5
+ * @license LGPL-3.0
6
6
  */
7
7
 
8
8
  /**
@@ -186,8 +186,7 @@ function Q5(scope, parent) {
186
186
  data[i + 2] = 255 - data[i + 2];
187
187
  }
188
188
  };
189
- $._filters[$.POSTERIZE] = (data, lvl) => {
190
- lvl ??= 4;
189
+ $._filters[$.POSTERIZE] = (data, lvl = 4) => {
191
190
  let lvl1 = lvl - 1;
192
191
  for (let i = 0; i < data.length; i += 4) {
193
192
  data[i] = (((data[i] * lvl) >> 8) * 255) / lvl1;
@@ -378,6 +377,34 @@ function Q5(scope, parent) {
378
377
  ctx.restore();
379
378
  };
380
379
 
380
+ $.trim = () => {
381
+ let pd = $._pixelDensity || 1;
382
+ let imgData = ctx.getImageData(0, 0, $.width * pd, $.height * pd);
383
+ let data = imgData.data;
384
+ let left = $.width,
385
+ right = 0,
386
+ top = $.height,
387
+ bottom = 0;
388
+
389
+ for (let y = 0; y < $.height * pd; y++) {
390
+ for (let x = 0; x < $.width * pd; x++) {
391
+ let index = (y * $.width * pd + x) * 4;
392
+ if (data[index + 3] !== 0) {
393
+ if (x < left) left = x;
394
+ if (x > right) right = x;
395
+ if (y < top) top = y;
396
+ if (y > bottom) bottom = y;
397
+ }
398
+ }
399
+ }
400
+ top = Math.floor(top / pd);
401
+ bottom = Math.floor(bottom / pd);
402
+ left = Math.floor(left / pd);
403
+ right = Math.floor(right / pd);
404
+
405
+ return $.get(left, top, right - left + 1, bottom - top + 1);
406
+ };
407
+
381
408
  $.get = (x, y, w, h) => {
382
409
  let pd = $._pixelDensity || 1;
383
410
  if (x !== undefined && w === undefined) {
@@ -465,11 +492,20 @@ function Q5(scope, parent) {
465
492
  ctx.restore();
466
493
  };
467
494
 
468
- $._save = (data, name, ext) => {
495
+ $._save = async (data, name, ext) => {
469
496
  name = name || 'untitled';
470
497
  ext = ext || 'png';
471
498
  if (ext == 'jpg' || ext == 'png' || ext == 'webp') {
472
- data = data.toDataURL('image/' + ext);
499
+ if (data instanceof OffscreenCanvas) {
500
+ const blob = await data.convertToBlob({ type: 'image/' + ext });
501
+ data = await new Promise((resolve) => {
502
+ const reader = new FileReader();
503
+ reader.onloadend = () => resolve(reader.result);
504
+ reader.readAsDataURL(blob);
505
+ });
506
+ } else {
507
+ data = data.toDataURL('image/' + ext);
508
+ }
473
509
  } else {
474
510
  let type = 'text/plain';
475
511
  if (ext == 'json') {
@@ -502,6 +538,10 @@ function Q5(scope, parent) {
502
538
  $.canvas.save = $.save;
503
539
  $.saveCanvas = $.save;
504
540
 
541
+ $.createImage = (w, h, opt) => {
542
+ return new Q5.Image(w, h, opt);
543
+ };
544
+
505
545
  // PRIVATE VARS
506
546
 
507
547
  let looper = null;
@@ -721,9 +761,6 @@ function Q5(scope, parent) {
721
761
  g._createCanvas.call($, w, h, opt);
722
762
  return g;
723
763
  };
724
- $.createImage = (w, h, opt) => {
725
- return new Q5.Image(w, h, opt);
726
- };
727
764
 
728
765
  $.displayDensity = () => window.devicePixelRatio;
729
766
  $.pixelDensity = (v) => {
@@ -1076,9 +1113,8 @@ function Q5(scope, parent) {
1076
1113
  if ($._doFill) ctx.fill();
1077
1114
  if ($._doStroke) ctx.stroke();
1078
1115
  }
1079
- $.arc = (x, y, w, h, start, stop, mode, detail) => {
1116
+ $.arc = (x, y, w, h, start, stop, mode, detail = 25) => {
1080
1117
  if (start == stop) return $.ellipse(x, y, w, h);
1081
- detail ??= 25;
1082
1118
  mode ??= $.PIE;
1083
1119
  if ($._ellipseMode == $.CENTER) {
1084
1120
  arcImpl(x, y, w, h, start, stop, mode, detail);
@@ -1371,7 +1407,7 @@ function Q5(scope, parent) {
1371
1407
  // IMAGING
1372
1408
 
1373
1409
  $.imageMode = (mode) => ($._imageMode = mode);
1374
- $.image = (img, dx, dy, dWidth, dHeight, sx, sy, sWidth, sHeight) => {
1410
+ $.image = (img, dx, dy, dWidth, dHeight, sx = 0, sy = 0, sWidth, sHeight) => {
1375
1411
  let drawable = img._q5 ? img.canvas : img;
1376
1412
  if (Q5._createNodeJSCanvas) {
1377
1413
  drawable = drawable.context.canvas;
@@ -1397,8 +1433,6 @@ function Q5(scope, parent) {
1397
1433
  dy -= dHeight * 0.5;
1398
1434
  }
1399
1435
  let pd = img._pixelDensity || 1;
1400
- sx ??= 0;
1401
- sy ??= 0;
1402
1436
  if (!sWidth) {
1403
1437
  sWidth = drawable.width || drawable.videoWidth;
1404
1438
  } else sWidth *= pd;
@@ -1549,7 +1583,7 @@ function Q5(scope, parent) {
1549
1583
  if (b !== undefined) $._textCache = b;
1550
1584
  return $._textCache;
1551
1585
  };
1552
- function _genTextImageKey(str, w, h) {
1586
+ $._genTextImageKey = (str, w, h) => {
1553
1587
  return (
1554
1588
  str.slice(0, 200) +
1555
1589
  $._textStyle +
@@ -1561,14 +1595,14 @@ function Q5(scope, parent) {
1561
1595
  (w || '') +
1562
1596
  (h ? 'x' + h : '')
1563
1597
  );
1564
- }
1598
+ };
1565
1599
  $.createTextImage = (str, w, h) => {
1566
1600
  let og = $._textCache;
1567
1601
  $._textCache = true;
1568
- $._useCache = true;
1602
+ $._genTextImage = true;
1569
1603
  $.text(str, 0, 0, w, h);
1570
- $._useCache = false;
1571
- let k = _genTextImageKey(str, w, h);
1604
+ $._genTextImage = false;
1605
+ let k = $._genTextImageKey(str, w, h);
1572
1606
  $._textCache = og;
1573
1607
  return $._tic.get(k);
1574
1608
  };
@@ -1579,15 +1613,15 @@ function Q5(scope, parent) {
1579
1613
  let c, ti, tg, k, cX, cY, _ascent, _descent;
1580
1614
  let pd = 1;
1581
1615
  let t = ctx.getTransform();
1582
- let useCache = $._useCache || ($._textCache && (t.b != 0 || t.c != 0));
1616
+ let useCache = $._genTextImage || ($._textCache && (t.b != 0 || t.c != 0));
1583
1617
  if (!useCache) {
1584
1618
  c = ctx;
1585
1619
  cX = x;
1586
1620
  cY = y;
1587
1621
  } else {
1588
- k = _genTextImageKey(str, w, h);
1622
+ k = $._genTextImageKey(str, w, h);
1589
1623
  ti = $._tic.get(k);
1590
- if (ti) {
1624
+ if (ti && !$._genTextImage) {
1591
1625
  $.textImage(ti, x, y);
1592
1626
  return;
1593
1627
  }
@@ -1624,7 +1658,7 @@ function Q5(scope, parent) {
1624
1658
  ti._ascent = _ascent;
1625
1659
  ti._descent = _descent;
1626
1660
  $._tic.set(k, ti);
1627
- $.textImage(ti, x, y);
1661
+ if (!$._genTextImage) $.textImage(ti, x, y);
1628
1662
  }
1629
1663
  };
1630
1664
  $.textImage = (img, x, y) => {
@@ -1654,9 +1688,7 @@ function Q5(scope, parent) {
1654
1688
  };
1655
1689
  var p_perlin;
1656
1690
 
1657
- $.noise = (x, y, z) => {
1658
- y ??= 0;
1659
- z ??= 0;
1691
+ $.noise = (x = 0, y = 0, z) => {
1660
1692
  if (p_perlin == null) {
1661
1693
  p_perlin = new Array(PERLIN_SIZE + 1);
1662
1694
  for (var i = 0; i < PERLIN_SIZE + 1; i++) {
@@ -1981,7 +2013,11 @@ function Q5(scope, parent) {
1981
2013
  clearBuff();
1982
2014
  firstVertex = true;
1983
2015
  if (ctx) ctx.save();
1984
- $.draw();
2016
+ try {
2017
+ $.draw();
2018
+ } catch (e) {
2019
+ console.error(e);
2020
+ }
1985
2021
  for (let m of Q5.prototype._methods.post) m.call($);
1986
2022
  if (ctx) {
1987
2023
  ctx.restore();
@@ -2001,8 +2037,7 @@ function Q5(scope, parent) {
2001
2037
  $._loop = true;
2002
2038
  if (looper == null) _draw();
2003
2039
  };
2004
- $.redraw = (n) => {
2005
- n ??= 1;
2040
+ $.redraw = (n = 1) => {
2006
2041
  $._redraw = true;
2007
2042
  for (let i = 0; i < n; i++) {
2008
2043
  _draw();
package/q5.min.js CHANGED
@@ -2,6 +2,6 @@
2
2
  * q5.js
3
3
  * @version 1.9
4
4
  * @author quinton-ashley and LingDong-
5
- * @license AGPL-3.0
5
+ * @license LGPL-3.0
6
6
  */
7
- function Q5(e,t){let a=this;a._q5=!0;let o=0;if(e||(e="global"),"auto"==e){if(!window.setup&&!window.draw)return;e="global"}"global"==e&&(Q5._hasGlobal=a._isGlobal=!0);let n=window.OffscreenCanvas||function(){return document.createElement("canvas")},i=null,r=a.ctx=a.drawingContext=null;if(a.canvas=null,a.pixels=[],a.noCanvas=()=>{a.canvas?.remove&&a.canvas.remove(),a.canvas=0,r=a.ctx=a.drawingContext=0},Q5._nodejs?Q5._createNodeJSCanvas&&(a.canvas=Q5._createNodeJSCanvas(100,100)):"image"!=e&&"graphics"!=e||(a.canvas=new n(100,100)),a.canvas||("object"==typeof document?(a.canvas=document.createElement("canvas"),a.canvas.id="defaultCanvas"+Q5._instanceCount++,a.canvas.classList.add("p5Canvas","q5Canvas")):a.noCanvas()),a.canvas.width=a.width=100,a.canvas.height=a.height=100,a.canvas&&"graphics"!=e&&"image"!=e){function s(){t??=document.getElementsByTagName("main")[0],t||(t=document.createElement("main"),document.body.append(t)),a.canvas.parent(t)}a._setupDone=!1,a._resize=()=>{a.frameCount>1&&(a._shouldResize=!0)},t&&"string"==typeof t&&(t=document.getElementById(t)),a.canvas.parent=e=>{"string"==typeof e&&(e=document.getElementById(e)),e.append(a.canvas),"function"==typeof ResizeObserver?(a._ro&&a._ro.disconnect(),a._ro=new ResizeObserver(a._resize),a._ro.observe(t)):a.frameCount||window.addEventListener("resize",a._resize)},document.body?s():document.addEventListener("DOMContentLoaded",s)}function l(e,t){t??=e||a.canvas.height,e??=a.canvas.width,null==f&&(f=new n(e,t).getContext("2d",{colorSpace:a.canvas.colorSpace})),f.canvas.width==e&&f.canvas.height==t||(f.canvas.width=e,f.canvas.height=t)}function c(){let e=a.canvas.width*a.canvas.height*4;x&&e==x.length||(x=new Uint8ClampedArray(e))}function h(e,t){a._filters||(a._filters=[],a._filters[a.THRESHOLD]=(e,t)=>{void 0===t?t=127.5:t*=255;for(let a=0;a<e.length;a+=4){const o=.2126*e[a]+.7152*e[a+1]+.0722*e[a+2];e[a]=e[a+1]=e[a+2]=o>=t?255:0}},a._filters[a.GRAY]=e=>{for(let t=0;t<e.length;t+=4){const a=.2126*e[t]+.7152*e[t+1]+.0722*e[t+2];e[t]=e[t+1]=e[t+2]=a}},a._filters[a.OPAQUE]=e=>{for(let t=0;t<e.length;t+=4)e[t+3]=255},a._filters[a.INVERT]=e=>{for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]},a._filters[a.POSTERIZE]=(e,t)=>{t??=4;let a=t-1;for(let o=0;o<e.length;o+=4)e[o]=255*(e[o]*t>>8)/a,e[o+1]=255*(e[o+1]*t>>8)/a,e[o+2]=255*(e[o+2]*t>>8)/a},a._filters[a.DILATE]=e=>{c(),x.set(e);let[t,o]=[a.canvas.width,a.canvas.height];for(let a=0;a<o;a++)for(let n=0;n<t;n++){let i=4*Math.max(n-1,0),r=4*Math.min(n+1,t-1),s=4*Math.max(a-1,0)*t,l=4*Math.min(a+1,o-1)*t,c=4*a*t,h=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+c;e[c+h+t]=Math.max(x[a+h],x[n+i],x[n+h],x[n+r],x[o+h])}}},a._filters[a.ERODE]=e=>{c(),x.set(e);let[t,o]=[a.canvas.width,a.canvas.height];for(let a=0;a<o;a++)for(let n=0;n<t;n++){let i=4*Math.max(n-1,0),r=4*Math.min(n+1,t-1),s=4*Math.max(a-1,0)*t,l=4*Math.min(a+1,o-1)*t,c=4*a*t,h=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+c;e[c+h+t]=Math.min(x[a+h],x[n+i],x[n+h],x[n+r],x[o+h])}}},a._filters[a.BLUR]=(e,t)=>{t=t||1,t=Math.floor(t*a._pixelDensity),c(),x.set(e);let o=2*t+1,n=function(e){let a=new Float32Array(e),o=.3*t+.8,n=o*o*2;for(let t=0;t<e;t++){let i=t-e/2,r=Math.exp(-i*i/n)/(2.5066282746*o);a[t]=r}return a}(o),[i,r]=[a.canvas.width,a.canvas.height];for(let a=0;a<r;a++)for(let r=0;r<i;r++){let s=0,l=0,c=0,h=0;for(let e=0;e<o;e++){let o=4*(a*i+Math.min(Math.max(r-t+e,0),i-1));s+=x[o]*n[e],l+=x[o+1]*n[e],c+=x[o+2]*n[e],h+=x[o+3]*n[e]}let d=4*(a*i+r);e[d]=s,e[d+1]=l,e[d+2]=c,e[d+3]=h}x.set(e);for(let a=0;a<r;a++)for(let s=0;s<i;s++){let l=0,c=0,h=0,d=0;for(let e=0;e<o;e++){let o=4*(Math.min(Math.max(a-t+e,0),r-1)*i+s);l+=x[o]*n[e],c+=x[o+1]*n[e],h+=x[o+2]*n[e],d+=x[o+3]*n[e]}let u=4*(a*i+s);e[u]=l,e[u+1]=c,e[u+2]=h,e[u+3]=d}});let o=r.getImageData(0,0,a.canvas.width,a.canvas.height);a._filters[e](o.data,t),r.putImageData(o,0,0)}function d(e){f.clearRect(0,0,f.canvas.width,f.canvas.height),f.filter=e,f.drawImage(a.canvas,0,0),r.save(),r.resetTransform(),r.clearRect(0,0,a.canvas.width,a.canvas.height),r.drawImage(f.canvas,0,0),r.restore()}a.createCanvas=function(t,o,n,i){if("webgl"==n)throw"webgl renderer is not supported in q5, use '2d'";"object"==typeof n&&(i=n),a.width=a.canvas.width=t,a.height=a.canvas.height=o,a.canvas.renderer="2d";let s=Object.assign({},Q5.canvasOptions);if(i&&Object.assign(s,i),r=a.ctx=a.drawingContext=a.canvas.getContext("2d",s),Object.assign(a.canvas,s),"rgb"==a._colorMode&&a.colorMode("rgb"),r.fillStyle="white",r.strokeStyle="black",r.lineCap="round",r.lineJoin="miter",r.textAlign="left",r.save(),"image"!=e){let t=a.displayDensity();"graphics"==e&&(t=this._pixelDensity),a.pixelDensity(Math.ceil(t))}else this._pixelDensity=1;return a.canvas},a._createCanvas=a.createCanvas,a.loadPixels=()=>{i=r.getImageData(0,0,a.canvas.width,a.canvas.height),a.pixels=i.data},a.updatePixels=()=>{null!=i&&r.putImageData(i,0,0)},a.filter=(e,t)=>{if(!r.filter)return h(e,t);if(l(),"string"==typeof e)d(e);else if(e==a.THRESHOLD){t??=.5,t=Math.max(t,1e-5),d(`saturate(0%) brightness(${Math.floor(.5/t*100)}%) contrast(1000000%)`)}else e==a.GRAY?d("saturate(0%)"):e==a.OPAQUE?(f.fillStyle="black",f.fillRect(0,0,f.canvas.width,f.canvas.height),f.drawImage(a.canvas,0,0),r.save(),r.resetTransform(),r.drawImage(f.canvas,0,0),r.restore()):e==a.INVERT?d("invert(100%)"):e==a.BLUR?d(`blur(${Math.ceil(t*a._pixelDensity/1)||1}px)`):h(e,t)},a.resize=(e,t)=>{l(),f.drawImage(a.canvas,0,0),a.width=e,a.height=t,a.canvas.width=e*a._pixelDensity,a.canvas.height=t*a._pixelDensity,r.save(),r.resetTransform(),r.clearRect(0,0,a.canvas.width,a.canvas.height),r.drawImage(f.canvas,0,0,a.canvas.width,a.canvas.height),r.restore()},a.get=(e,t,o,n)=>{let i=a._pixelDensity||1;if(void 0!==e&&void 0===o){let o=r.getImageData(e*i,t*i,1,1).data;return new a.Color(o[0],o[1],o[2],o[3]/255)}e=(e||0)*i,t=(t||0)*i;let s=o=o||a.width,l=n=n||a.height;o*=i,n*=i;let c=a.createImage(o,n),h=r.getImageData(e,t,o,n);return c.ctx.putImageData(h,0,0),c._pixelDensity=i,c.width=s,c.height=l,c},a.set=(e,t,o)=>{if(o._q5){let n=a._tint;return a._tint=null,a.image(o,e,t),void(a._tint=n)}a.pixels.length||a.loadPixels();let n=a._pixelDensity||1;for(let i=0;i<n;i++)for(let r=0;r<n;r++){let s=4*((t*n+i)*a.canvas.width+e*n+r);a.pixels[s]=o.r??o.l,a.pixels[s+1]=o.g??o.c,a.pixels[s+2]=o.b??o.h,a.pixels[s+3]=o.a}},a.tinted=function(e){let t=e.a;e.a=255,l(),f.clearRect(0,0,f.canvas.width,f.canvas.height),f.fillStyle=e.toString(),f.fillRect(0,0,f.canvas.width,f.canvas.height),f.globalCompositeOperation="multiply",f.drawImage(r.canvas,0,0),f.globalCompositeOperation="source-over",r.save(),r.resetTransform();let a=r.globalCompositeOperation;r.globalCompositeOperation="source-in",r.drawImage(f.canvas,0,0),r.globalCompositeOperation=a,r.restore(),f.globalAlpha=t/255,f.clearRect(0,0,f.canvas.width,f.canvas.height),f.drawImage(r.canvas,0,0),f.globalAlpha=1,r.save(),r.resetTransform(),r.clearRect(0,0,r.canvas.width,r.canvas.height),r.drawImage(f.canvas,0,0),r.restore()},a.tint=function(e){a._tint=e._q5Color?e:a.color(...arguments)},a.noTint=()=>a._tint=null,a.mask=e=>{r.save(),r.resetTransform();let t=r.globalCompositeOperation;r.globalCompositeOperation="destination-in",r.drawImage(e.canvas,0,0),r.globalCompositeOperation=t,r.restore()},a._save=(e,t,a)=>{if(t=t||"untitled","jpg"==(a=a||"png")||"png"==a||"webp"==a)e=e.toDataURL("image/"+a);else{let t="text/plain";"json"==a&&("string"!=typeof e&&(e=JSON.stringify(e)),t="text/json"),e=new Blob([e],{type:t}),e=URL.createObjectURL(e)}let o=document.createElement("a");o.href=e,o.download=t+"."+a,document.body.append(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(o.href)},a.save=(e,t,o)=>{if((!e||"string"==typeof e&&(!t||!o&&t.length<5))&&(o=t,t=e,e=a.canvas),o)return a._save(e,t,o);t?(t=t.split("."),a._save(e,t[0],t.at(-1))):a._save(e)},a.canvas.save=a.save,a.saveCanvas=a.save;let u=null,g=!0,_=[],p={},m=0,f=null,v=null,x=null;if(a.THRESHOLD=1,a.GRAY=2,a.OPAQUE=3,a.INVERT=4,a.POSTERIZE=5,a.DILATE=6,a.ERODE=7,a.BLUR=8,"image"==e)return;function y(e,t){a.width=e,a.height=t;let o=function(){let e={};for(let t in r)"function"!=typeof r[t]&&(e[t]=r[t]);return delete e.canvas,e}();a.canvas.width=Math.ceil(e*a._pixelDensity),a.canvas.height=Math.ceil(t*a._pixelDensity),!a.canvas.fullscreen&&a.canvas.style&&(a.canvas.style.width=e+"px",a.canvas.style.height=t+"px");for(let e in o)a.ctx[e]=o[e];r.scale(a._pixelDensity,a._pixelDensity)}a.BLEND="source-over",a.REMOVE="destination-out",a.ADD="lighter",a.DARKEST="darken",a.LIGHTEST="lighten",a.DIFFERENCE="difference",a.SUBTRACT="subtract",a.EXCLUSION="exclusion",a.MULTIPLY="multiply",a.SCREEN="screen",a.REPLACE="copy",a.OVERLAY="overlay",a.HARD_LIGHT="hard-light",a.SOFT_LIGHT="soft-light",a.DODGE="color-dodge",a.BURN="color-burn",a.RGB="rgb",a.RGBA="rgb",a.HSB="hsb",a.CHORD=0,a.PIE=1,a.OPEN=2,a.RADIUS="radius",a.CORNER="corner",a.CORNERS="corners",a.ROUND="round",a.SQUARE="butt",a.PROJECT="square",a.MITER="miter",a.BEVEL="bevel",a.CLOSE=1,a.NORMAL="normal",a.ITALIC="italic",a.BOLD="bold",a.BOLDITALIC="italic bold",a.CENTER="center",a.LEFT="left",a.RIGHT="right",a.TOP="top",a.BOTTOM="bottom",a.BASELINE="alphabetic",a.LANDSCAPE="landscape",a.PORTRAIT="portrait",a.ALT=18,a.BACKSPACE=8,a.CONTROL=17,a.DELETE=46,a.DOWN_ARROW=40,a.ENTER=13,a.ESCAPE=27,a.LEFT_ARROW=37,a.OPTION=18,a.RETURN=13,a.RIGHT_ARROW=39,a.SHIFT=16,a.TAB=9,a.UP_ARROW=38,a.DEGREES="degrees",a.RADIANS="radians",a.HALF_PI=Math.PI/2,a.PI=Math.PI,a.QUARTER_PI=Math.PI/4,a.TAU=2*Math.PI,a.TWO_PI=2*Math.PI,a.ARROW="default",a.CROSS="crosshair",a.HAND="pointer",a.MOVE="move",a.TEXT="text",a.VIDEO={video:!0,audio:!1},a.AUDIO={video:!1,audio:!0},a.SHR3=1,a.LCG=2,a.hint=(e,t)=>{a[e]=t},a.frameCount=0,a.deltaTime=16,a.mouseX=0,a.mouseY=0,a.touches=[],a.mouseButton=null,a.keyIsPressed=!1,a.mouseIsPressed=!1,a.key=null,a.keyCode=null,a.accelerationX=0,a.accelerationY=0,a.accelerationZ=0,a.rotationX=0,a.rotationY=0,a.rotationZ=0,a.relRotationX=0,a.relRotationY=0,a.relRotationZ=0,a.pmouseX=0,a.pmouseY=0,a.pAccelerationX=0,a.pAccelerationY=0,a.pAccelerationZ=0,a.pRotationX=0,a.pRotationY=0,a.pRotationZ=0,a.pRelRotationX=0,a.pRelRotationY=0,a.pRelRotationZ=0,Object.defineProperty(a,"deviceOrientation",{get:()=>window.screen?.orientation?.type}),Object.defineProperty(a,"windowWidth",{get:()=>window.innerWidth}),Object.defineProperty(a,"windowHeight",{get:()=>window.innerHeight}),a._colorMode="rgb",a._doStroke=!0,a._doFill=!0,a._strokeSet=!1,a._fillSet=!1,a._tint=null,a._ellipseMode=a.CENTER,a._rectMode=a.CORNER,a._curveDetail=20,a._curveAlpha=0,a._loop=!0,a._textFont="sans-serif",a._textSize=12,a._textLeading=15,a._textLeadDiff=3,a._textStyle="normal",a._pixelDensity=1,a._targetFrameRate=0,a._targetFrameDuration=16.666666666666668,a._frameRate=a._fps=60,a.resizeCanvas=(e,t)=>{e==a.width&&t==a.height||y(e,t)},a.createGraphics=function(e,t,o){let n=new Q5("graphics");return o??={},o.alpha??=!0,n._createCanvas.call(a,e,t,o),n},a.createImage=(e,t,a)=>new Q5.Image(e,t,a),a.displayDensity=()=>window.devicePixelRatio,a.pixelDensity=e=>e&&e!=a._pixelDensity?(a._pixelDensity=e,y(a.width,a.height),e):a._pixelDensity,a.fullscreen=e=>{if(void 0===e)return document.fullscreenElement;e?document.body.requestFullscreen():document.body.exitFullscreen()},a.map=(e,t,a,o,n,i)=>{let r=o+1*(e-t)/(a-t)*(n-o);return i?o<n?Math.min(Math.max(r,o),n):Math.min(Math.max(r,n),o):r},a.lerp=(e,t,a)=>e*(1-a)+t*a,a.constrain=(e,t,a)=>Math.min(Math.max(e,t),a),a.dist=function(){let e=arguments;return 4==e.length?Math.hypot(e[0]-e[2],e[1]-e[3]):Math.hypot(e[0]-e[3],e[1]-e[4],e[2]-e[5])},a.norm=(e,t,o)=>a.map(e,t,o,0,1),a.sq=e=>e*e,a.fract=e=>e-Math.floor(e),a.angleMode=e=>a._angleMode=e,a._DEGTORAD=Math.PI/180,a._RADTODEG=180/Math.PI,a.degrees=e=>e*a._RADTODEG,a.radians=e=>e*a._DEGTORAD,a.abs=Math.abs,a.ceil=Math.ceil,a.exp=Math.exp,a.floor=Math.floor,a.log=Math.log,a.mag=Math.hypot,a.max=Math.max,a.min=Math.min,a.round=Math.round,a.pow=Math.pow,a.sqrt=Math.sqrt,a.sin=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.sin(e)),a.cos=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.cos(e)),a.tan=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.tan(e)),a.asin=e=>{let t=Math.asin(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.acos=e=>{let t=Math.acos(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.atan=e=>{let t=Math.atan(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.atan2=(e,t)=>{let o=Math.atan2(e,t);return"degrees"==a._angleMode&&(o=a.degrees(o)),o},a.nf=(e,t,a)=>{let o=e<0,n=(e=Math.abs(e)).toFixed(a).split(".");n[0]=n[0].padStart(t,"0");let i=n.join(".");return o&&(i="-"+i),i},a.createVector=(e,t,o)=>new Q5.Vector(e,t,o,a),a.curvePoint=(e,t,a,o,n)=>{const i=n*n*n,r=n*n;return e*(-.5*i+r-.5*n)+t*(1.5*i-2.5*r+1)+a*(-1.5*i+2*r+.5*n)+o*(.5*i-.5*r)},a.bezierPoint=(e,t,a,o,n)=>{const i=1-n;return Math.pow(i,3)*e+3*Math.pow(i,2)*n*t+3*i*Math.pow(n,2)*a+Math.pow(n,3)*o},a.curveTangent=(e,t,a,o,n)=>{const i=n*n;return e*(-3*i/2+2*n-.5)+t*(9*i/2-5*n)+a*(-9*i/2+4*n+.5)+o*(3*i/2-n)},a.bezierTangent=(e,t,a,o,n)=>{const i=1-n;return 3*o*Math.pow(n,2)-3*a*Math.pow(n,2)+6*a*i*n-6*t*i*n+3*t*Math.pow(i,2)-3*e*Math.pow(i,2)},Q5.supportsHDR?a.Color=Q5.ColorRGBA_P3:a.Color=Q5.ColorRGBA,a.colorMode=e=>{a._colorMode=e,"oklch"==e?a.Color=Q5.ColorOKLCH:"rgb"==e?"srgb"==a.canvas.colorSpace?a.Color=Q5.ColorRGBA:a.Color=Q5.ColorRGBA_P3:"srgb"==e&&(a.Color=Q5.ColorRGBA,a._colorMode="rgb")};let w={aqua:[0,255,255],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],crimson:[220,20,60],darkviolet:[148,0,211],gold:[255,215,0],green:[0,128,0],gray:[128,128,128],grey:[128,128,128],hotpink:[255,105,180],indigo:[75,0,130],khaki:[240,230,140],lightgreen:[144,238,144],lime:[0,255,0],magenta:[255,0,255],navy:[0,0,128],orange:[255,165,0],olive:[128,128,0],peachpuff:[255,218,185],pink:[255,192,203],purple:[128,0,128],red:[255,0,0],skyblue:[135,206,235],tan:[210,180,140],turquoise:[64,224,208],transparent:[0,0,0,0],white:[255,255,255],violet:[238,130,238],yellow:[255,255,0]};function M(e){let t=a._angleMode==a.DEGREES?180:Math.PI,o=2*t;if(0<=e&&e<=o)return e;for(;e<0;)e+=o;for(;e>=t;)e-=o;return e}function R(e,t,o,n,i,s,l,c){if(!a._doFill&&!a._doStroke)return;let h=M(i),d=M(s);if(h>d&&([h,d]=[d,h]),0==h){if(0==d)return;if(a._angleMode==a.DEGREES&&360==d||d==a.TAU)return a.ellipse(e,t,o,n)}r.beginPath();for(let i=0;i<c+1;i++){let s=i/c,l=a.lerp(h,d,s),u=a.cos(l)*o/2,g=a.sin(l)*n/2;r[i?"lineTo":"moveTo"](e+u,t+g)}l==a.CHORD?r.closePath():l==a.PIE&&(r.lineTo(e,t),r.closePath()),a._doFill&&r.fill(),a._doStroke&&r.stroke()}function S(e,t,o,n){(a._doFill||a._doStroke)&&(r.beginPath(),r.ellipse(e,t,o/2,n/2,0,0,a.TAU),a._doFill&&r.fill(),a._doStroke&&r.stroke())}function C(e,t,o,n,i,s,l,c){if(!a._doFill&&!a._doStroke)return;if(void 0===i)return function(e,t,o,n){a._doFill&&r.fillRect(e,t,o,n),a._doStroke&&r.strokeRect(e,t,o,n)}(e,t,o,n);if(void 0===s)return C(e,t,o,n,i,i,i,i);const h=Math.min(Math.abs(n),Math.abs(o))/2;i=Math.min(h,i),s=Math.min(h,s),c=Math.min(h,c),l=Math.min(h,l),r.beginPath(),r.moveTo(e+i,t),r.arcTo(e+o,t,e+o,t+n,s),r.arcTo(e+o,t+n,e,t+n,l),r.arcTo(e,t+n,e,t,c),r.arcTo(e,t,e+o,t,i),r.closePath(),a._doFill&&r.fill(),a._doStroke&&r.stroke()}function b(){_=[]}function D(e,t,o){return e.slice(0,200)+a._textStyle+a._textSize+a._textFont+(a._doFill?r.fillStyle:"")+"_"+(a._doStroke&&a._strokeSet?r.lineWidth+r.strokeStyle+"_":"")+(t||"")+(o?"x"+o:"")}a.color=function(e,t,o,n){let i=a.Color;if(e._q5Color)return new i(...e.levels);let r=arguments;if(1==r.length){if("string"==typeof e)return"#"==e[0]?new i(parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16),9!=e.length?null:parseInt(e.slice(7,9),16)):w[e]?new i(...w[e]):new i(0,0,0);if(Array.isArray(e))return new i(...e)}if("rgb"==a._colorMode){if(1==r.length)return new i(e,e,e);if(2==r.length)return new i(e,e,e,t);if(3==r.length)return new i(e,t,o);if(4==r.length)return new i(e,t,o,n)}},a.red=e=>e.r,a.green=e=>e.g,a.blue=e=>e.b,a.alpha=e=>e.a,a.lightness=e=>100*(.2126*e.r+.7152*e.g+.0722*e.b)/255,a.lerpColor=(e,t,o)=>{if("rgb"==a._colorMode)return new a.Color(a.constrain(a.lerp(e.r,t.r,o),0,255),a.constrain(a.lerp(e.g,t.g,o),0,255),a.constrain(a.lerp(e.b,t.b,o),0,255),a.constrain(a.lerp(e.a,t.a,o),0,255));{let n=t.h-e.h;n>180&&(n-=360),n<-180&&(n+=360);let i=e.h+o*n;return i<0&&(i+=360),i>360&&(i-=360),new a.Color(a.constrain(a.lerp(e.l,t.l,o),0,100),a.constrain(a.lerp(e.c,t.c,o),0,100),i,a.constrain(a.lerp(e.a,t.a,o),0,255))}},a.strokeWeight=e=>{e||(a._doStroke=!1),r.lineWidth=e||1e-4},a.stroke=function(e){if(a._doStroke=!0,a._strokeSet=!0,e._q5Color||"string"==typeof e||(e=a.color(...arguments)),e.a<=0)return a._doStroke=!1;r.strokeStyle=e.toString()},a.noStroke=()=>a._doStroke=!1,a.fill=function(e){if(a._doFill=!0,a._fillSet=!0,e._q5Color||"string"==typeof e||(e=a.color(...arguments)),e.a<=0)return a._doFill=!1;r.fillStyle=e.toString()},a.noFill=()=>a._doFill=!1,a.smooth=()=>a._smooth=!0,a.noSmooth=()=>a._smooth=!1,a.blendMode=e=>r.globalCompositeOperation=e,a.strokeCap=e=>r.lineCap=e,a.strokeJoin=e=>r.lineJoin=e,a.ellipseMode=e=>a._ellipseMode=e,a.rectMode=e=>a._rectMode=e,a.curveDetail=e=>a._curveDetail=e,a.curveAlpha=e=>a._curveAlpha=e,a.curveTightness=e=>a._curveAlpha=e,a.clear=()=>{r.clearRect(0,0,a.canvas.width,a.canvas.height)},a.background=function(e){if(e._q5)return a.image(e,0,0,a.width,a.height);r.save(),r.resetTransform(),e._q5color||"string"==typeof e||(e=a.color(...arguments)),r.fillStyle=e.toString(),r.fillRect(0,0,a.canvas.width,a.canvas.height),r.restore()},a.line=(e,t,o,n)=>{a._doStroke&&(r.beginPath(),r.moveTo(e,t),r.lineTo(o,n),r.stroke())},a.arc=(e,t,o,n,i,r,s,l)=>{if(i==r)return a.ellipse(e,t,o,n);l??=25,s??=a.PIE,a._ellipseMode==a.CENTER?R(e,t,o,n,i,r,s,l):a._ellipseMode==a.RADIUS?R(e,t,2*o,2*n,i,r,s,l):a._ellipseMode==a.CORNER?R(e+o/2,t+n/2,o,n,i,r,s,l):a._ellipseMode==a.CORNERS&&R((e+o)/2,(t+n)/2,o-e,n-t,i,r,s,l)},a.ellipse=(e,t,o,n)=>{n??=o,a._ellipseMode==a.CENTER?S(e,t,o,n):a._ellipseMode==a.RADIUS?S(e,t,2*o,2*n):a._ellipseMode==a.CORNER?S(e+o/2,t+n/2,o,n):a._ellipseMode==a.CORNERS&&S((e+o)/2,(t+n)/2,o-e,n-t)},a.circle=(e,t,o)=>a.ellipse(e,t,o,o),a.point=(e,t)=>{e.x&&(t=e.y,e=e.x),r.beginPath(),r.ellipse(e,t,.4,.4,0,0,a.TAU),r.stroke()},a.rect=(e,t,o,n,i,r,s,l)=>{a._rectMode==a.CENTER?C(e-o/2,t-n/2,o,n,i,r,s,l):a._rectMode==a.RADIUS?C(e-o,t-n,2*o,2*n,i,r,s,l):a._rectMode==a.CORNER?C(e,t,o,n,i,r,s,l):a._rectMode==a.CORNERS&&C(e,t,o-e,n-t,i,r,s,l)},a.square=(e,t,o,n,i,r,s)=>a.rect(e,t,o,o,n,i,r,s),a.beginShape=()=>{b(),r.beginPath(),g=!0},a.beginContour=()=>{r.closePath(),b(),g=!0},a.endContour=()=>{b(),g=!0},a.vertex=(e,t)=>{b(),g?r.moveTo(e,t):r.lineTo(e,t),g=!1},a.bezierVertex=(e,t,a,o,n,i)=>{b(),r.bezierCurveTo(e,t,a,o,n,i)},a.quadraticVertex=(e,t,a,o)=>{b(),r.quadraticCurveTo(e,t,a,o)},a.bezier=(e,t,o,n,i,r,s,l)=>{a.beginShape(),a.vertex(e,t),a.bezierVertex(o,n,i,r,s,l),a.endShape()},a.triangle=(e,t,o,n,i,r)=>{a.beginShape(),a.vertex(e,t),a.vertex(o,n),a.vertex(i,r),a.endShape(a.CLOSE)},a.quad=(e,t,o,n,i,r,s,l)=>{a.beginShape(),a.vertex(e,t),a.vertex(o,n),a.vertex(i,r),a.vertex(s,l),a.endShape(a.CLOSE)},a.endShape=e=>{b(),e&&r.closePath(),a._doFill&&r.fill(),a._doStroke&&r.stroke()},a.curveVertex=(e,t)=>{if(_.push([e,t]),_.length<4)return;let o=function(e,t,a,o,n,i,r,s,l,c){function h(e,t,a,o,n,i){let r=Math.pow(o-t,2)+Math.pow(n-a,2);return Math.pow(r,.5*i)+e}let d=[],u=h(0,e,t,a,o,c),g=h(u,a,o,n,i,c),_=h(g,n,i,r,s,c);for(let c=0;c<l;c++){let h=u+c/(l-1)*(g-u),p=[(u-h)/(u-0),(h-0)/(u-0),(g-h)/(g-u),(h-u)/(g-u),(_-h)/(_-g),(h-g)/(_-g),(g-h)/(g-0),(h-0)/(g-0),(_-h)/(_-u),(h-u)/(_-u)];for(let e=0;e<p.length;e+=2)isNaN(p[e])&&(p[e]=1,p[e+1]=0),isFinite(p[e])||(p[e]>0?(p[e]=1,p[e+1]=0):(p[e]=0,p[e+1]=1));let m=e*p[0]+a*p[1],f=t*p[0]+o*p[1],v=a*p[2]+n*p[3],x=o*p[2]+i*p[3],y=n*p[4]+r*p[5],w=i*p[4]+s*p[5],M=m*p[6]+v*p[7],R=f*p[6]+x*p[7],S=v*p[8]+y*p[9],C=x*p[8]+w*p[9],b=M*p[2]+S*p[3],D=R*p[2]+C*p[3];d.push([b,D])}return d}(..._[_.length-4],..._[_.length-3],..._[_.length-2],..._[_.length-1],a._curveDetail,a._curveAlpha);for(let e=0;e<o.length;e++)g?r.moveTo(...o[e]):r.lineTo(...o[e]),g=!1},a.curve=(e,t,o,n,i,r,s,l)=>{a.beginShape(),a.curveVertex(e,t),a.curveVertex(o,n),a.curveVertex(i,r),a.curveVertex(s,l),a.endShape()},a.opacity=e=>r.globalAlpha=e,a.translate=(e,t)=>r.translate(e,t),a.rotate=e=>{"degrees"==a._angleMode&&(e=a.radians(e)),r.rotate(e)},a.scale=(e,t)=>{t??=e,r.scale(e,t)},a.applyMatrix=(e,t,a,o,n,i)=>r.transform(e,t,a,o,n,i),a.shearX=e=>r.transform(1,0,a.tan(e),1,0,0),a.shearY=e=>r.transform(1,a.tan(e),0,1,0,0),a.resetMatrix=()=>{r.resetTransform(),r.scale(a._pixelDensity,a._pixelDensity)},a._styleNames=["_doStroke","_doFill","_strokeSet","_fillSet","_tint","_imageMode","_rectMode","_ellipseMode","_textFont","_textLeading","_leadingSet","_textSize","_textAlign","_textBaseline","_textStyle","_textWrap"],a._styles=[],a.push=a.pushMatrix=()=>{r.save();let e={};for(let t of a._styleNames)e[t]=a[t];a._styles.push(e)},a.pop=a.popMatrix=()=>{r.restore();let e=a._styles.pop();for(let t of a._styleNames)a[t]=e[t]},a.imageMode=e=>a._imageMode=e,a.image=(e,t,o,i,s,l,c,h,d)=>{let u=e._q5?e.canvas:e;var g,_;Q5._createNodeJSCanvas&&(u=u.context.canvas),e._q5&&null!=a._tint&&(g=e.canvas.width,_=e.canvas.height,_??=g||a.canvas.height,g??=a.canvas.width,null==v&&(v=new n(g,_).getContext("2d",{colorSpace:a.canvas.colorSpace})),v.canvas.width==g&&v.canvas.height==_||(v.canvas.width=g,v.canvas.height=_),v.drawImage(e.canvas,0,0),e.tinted(a._tint)),i??=e.width||e.videoWidth,s??=e.height||e.videoHeight,"center"==a._imageMode&&(t-=.5*i,o-=.5*s);let p=e._pixelDensity||1;l??=0,c??=0,h?h*=p:h=u.width||u.videoWidth,d?d*=p:d=u.height||u.videoHeight,r.drawImage(u,l*p,c*p,h,d,t,o,i,s),function(){if(!e._q5||!a._tint)return;let t=e.ctx;t.save(),t.resetTransform(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(v.canvas,0,0),t.restore()}()},a._incrementPreload=()=>o++,a._decrementPreload=()=>o--,a.loadImage=function(e,t,n){o++;let i=[...arguments].at(-1);n="object"!=typeof i||i;let r=a.createImage(1,1,n.alpha),s=r.ctx;if(Q5._nodejs&&global.CairoCanvas)CairoCanvas.loadImage(e).then((e=>{r.width=s.canvas.width=e.width,r.height=s.canvas.height=e.height,s.drawImage(e,0,0),o--,t&&t(r)})).catch((e=>{throw o--,e}));else{let a=new window.Image;a.src=e,a.crossOrigin="Anonymous",a._pixelDensity=1,a.onload=()=>{r.width=s.canvas.width=a.naturalWidth,r.height=s.canvas.height=a.naturalHeight,s.drawImage(a,0,0),o--,t&&t(r)},a.onerror=e=>{throw o--,e}}return r},a._clearTemporaryBuffers=()=>{f=null,v=null,x=null},a.loadFont=(e,t)=>{o++;let a=e.split("/"),n=a[a.length-1].split(".")[0].replace(" ",""),i=new FontFace(n,"url("+e+")");return document.fonts.add(i),i.load().then((()=>{o--,t&&t(n)})),n},a.textFont=e=>a._textFont=e,a.textSize=e=>{if(void 0===e)return a._textSize;a._textSize=e,a._leadingSet||(a._textLeading=1.25*e,a._textLeadDiff=a._textLeading-e)},a.textLeading=e=>{if(void 0===e)return a._textLeading;a._textLeading=e,a._textLeadDiff=e-a._textSize,a._leadingSet=!0},a.textStyle=e=>a._textStyle=e,a.textAlign=(e,t)=>{r.textAlign=e,t&&(r.textBaseline=t==a.CENTER?"middle":t)},a.textWidth=e=>(r.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,r.measureText(e).width),a.textAscent=e=>(r.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,r.measureText(e).actualBoundingBoxAscent),a.textDescent=e=>(r.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,r.measureText(e).actualBoundingBoxDescent),a._textCache=!0,a._TimedCache=class extends Map{constructor(){super(),this.maxSize=500}set(e,t){t.lastAccessed=Date.now(),super.set(e,t),this.size>this.maxSize&&this.gc()}get(e){const t=super.get(e);return t&&(t.lastAccessed=Date.now()),t}gc(){let e,t=1/0,a=0;for(const[o,n]of this.entries())n.lastAccessed<t&&(t=n.lastAccessed,e=a),a++;a=e;for(const t of this.keys()){if(0==a){e=t;break}a--}this.delete(e)}},a._tic=new a._TimedCache,a.textCache=(e,t)=>(t&&(a._tic.maxSize=t),void 0!==e&&(a._textCache=e),a._textCache),a.createTextImage=(e,t,o)=>{let n=a._textCache;a._textCache=!0,a._useCache=!0,a.text(e,0,0,t,o),a._useCache=!1;let i=D(e,t,o);return a._textCache=n,a._tic.get(i)},a.text=(e,t,o,n,i)=>{if(void 0===e)return;if(e=e.toString(),!a._doFill&&!a._doStroke)return;let s,l,c,h,d,u,g,_,p=1,m=r.getTransform(),f=a._useCache||a._textCache&&(0!=m.b||0!=m.c);if(f){if(h=D(e,n,i),l=a._tic.get(h),l)return void a.textImage(l,t,o);c=a.createGraphics.call(a,1,1),s=c.ctx,p=a._pixelDensity}else s=r,d=t,u=o;s.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`;let v=e.split("\n");if(f){d=0,u=a._textLeading*v.length;let t=s.measureText(" ");g=t.fontBoundingBoxAscent,_=t.fontBoundingBoxDescent,i??=u+_,c.resizeCanvas(Math.ceil(s.measureText(e).width),Math.ceil(i)),s.fillStyle=r.fillStyle,s.strokeStyle=r.strokeStyle,s.lineWidth=r.lineWidth}let x=s.fillStyle;a._fillSet||(s.fillStyle="black");for(let e=0;e<v.length&&(a._doStroke&&a._strokeSet&&s.strokeText(v[e],d,u),a._doFill&&s.fillText(v[e],d,u),u+=a._textLeading,!(u>i));e++);a._fillSet||(s.fillStyle=x),f&&(l=c.get(),l._ascent=g,l._descent=_,a._tic.set(h,l),a.textImage(l,t,o))},a.textImage=(e,t,o)=>{let n=a._imageMode;a._imageMode="corner","center"==r.textAlign?t-=.5*e.width:"right"==r.textAlign&&(t-=e.width),"alphabetic"==r.textBaseline&&(o-=a._textLeading),"middle"==r.textBaseline?o-=e._descent+.5*e._ascent+a._textLeadDiff:"bottom"==r.textBaseline?o-=e._ascent+e._descent+a._textLeadDiff:"top"==r.textBaseline&&(o-=e._descent+a._textLeadDiff),a.image(e,t,o),a._imageMode=n};var E,I=4095,T=4,A=.5,O=e=>.5*(1-Math.cos(e*Math.PI));a.noise=(e,t,a)=>{if(t??=0,a??=0,null==E){E=new Array(4096);for(var o=0;o<4096;o++)E[o]=Math.random()}e<0&&(e=-e),t<0&&(t=-t),a<0&&(a=-a);for(var n,i,r,s,l,c=Math.floor(e),h=Math.floor(t),d=Math.floor(a),u=e-c,g=t-h,_=a-d,p=0,m=.5,f=0;f<T;f++){var v=c+(h<<4)+(d<<8);n=O(u),i=O(g),r=E[v&I],r+=n*(E[v+1&I]-r),s=E[v+16&I],r+=i*((s+=n*(E[v+16+1&I]-s))-r),s=E[(v+=256)&I],s+=n*(E[v+1&I]-s),l=E[v+16&I],s+=i*((l+=n*(E[v+16+1&I]-l))-s),p+=(r+=O(_)*(s-r))*m,m*=A,c<<=1,h<<=1,d<<=1,(u*=2)>=1&&(c++,u--),(g*=2)>=1&&(h++,g--),(_*=2)>=1&&(d++,_--)}return p},a.noiseDetail=(e,t)=>{e>0&&(T=e),t>0&&(A=t)};const P=()=>{let e,t,a=4294967295;return{setSeed(o){e=t=(o??Math.random()*a)>>>0},getSeed:()=>t,rand:()=>(e^=e<<17,e^=e>>13,e^=e<<5,(e>>>0)/a)}};let k=P();k.setSeed(),a.noiseSeed=e=>{let t=void 0===e?4294967295*Math.random():e;E||(E=new Float32Array(4096));for(var a=0;a<4096;a++)t^=t<<17,t^=t>>13,t^=t<<5,E[a]=(t>>>0)/4294967295},a.randomSeed=e=>k.setSeed(e),a.random=(e,t)=>void 0===e?k.rand():"number"==typeof e?void 0!==t?k.rand()*(t-e)+e:k.rand()*e:e[Math.trunc(e.length*k.rand())],a.randomGenerator=e=>{e==a.LCG?k=(()=>{const e=4294967296;let t,a;return{setSeed(o){a=t=(o??Math.random()*e)>>>0},getSeed:()=>t,rand:()=>(a=(1664525*a+1013904223)%e,a/e)}})():e==a.SHR3&&(k=P()),k.setSeed()};var z=new function(){var e,t,a,o=new Array(128),n=new Array(256),i=new Array(128),r=new Array(128),s=new Array(256),l=new Array(256),c=()=>4294967296*k.rand()-2147483648,h=()=>.5+2.328306e-10*(c()|0),d=()=>{for(var t,n,s,l,d=3.44262;;){if(t=a*i[e],0==e){do{s=h(),l=h(),t=.2904764*-Math.log(s),n=-Math.log(l)}while(n+n<t*t);return a>0?d+t:-d-t}if(r[e]+h()*(r[e-1]-r[e])<Math.exp(-.5*t*t))return t;if(a=c(),e=127&a,Math.abs(a)<o[e])return a*i[e]}},u=()=>{for(var a;;){if(0==e)return 7.69711-Math.log(h());if(a=t*s[e],l[e]+h()*(l[e-1]-l[e])<Math.exp(-a))return a;if((t=c())<n[e=255&t])return t*s[e]}};this.SHR3=c,this.UNI=h,this.RNOR=()=>(a=c(),e=127&a,Math.abs(a)<o[e]?a*i[e]:d()),this.REXP=()=>(t=c()>>>0)<o[e=255&t]?t*s[e]:u(),this.zigset=()=>{var e,t,a=2147483648,c=4294967296,h=3.442619855899,d=h,u=.00991256303526217,g=7.697117470131487,_=g,p=.003949659822581572;for(e=u/Math.exp(-.5*h*h),o[0]=Math.floor(h/e*a),o[1]=0,i[0]=e/a,i[127]=h/a,r[0]=1,r[127]=Math.exp(-.5*h*h),t=126;t>=1;t--)h=Math.sqrt(-2*Math.log(u/h+Math.exp(-.5*h*h))),o[t+1]=Math.floor(h/d*a),d=h,r[t]=Math.exp(-.5*h*h),i[t]=h/a;for(e=p/Math.exp(-g),n[0]=Math.floor(g/e*c),n[1]=0,s[0]=e/c,s[255]=g/c,l[0]=1,l[255]=Math.exp(-g),t=254;t>=1;t--)g=-Math.log(p/g+Math.exp(-g)),n[t+1]=Math.floor(g/_*c),_=g,l[t]=Math.exp(-g),s[t]=g/c}};function Q(e){let t=e||performance.now();if(a._lastFrameTime??=t-a._targetFrameDuration,a._loop)u=F(Q);else if(a.frameCount&&!a._redraw)return;if(u&&a.frameCount){if(t-a._lastFrameTime<a._targetFrameDuration-1)return}a.deltaTime=t-a._lastFrameTime,a._frameRate=1e3/a.deltaTime,a.frameCount++,a._shouldResize&&(a.windowResized(),a._shouldResize=!1);let o=performance.now();for(let e of Q5.prototype._methods.pre)e.call(a);b(),g=!0,r&&r.save(),a.draw();for(let e of Q5.prototype._methods.post)e.call(a);r&&(r.restore(),a.resetMatrix()),a.pmouseX=a.mouseX,a.pmouseY=a.mouseY,a._lastFrameTime=t;let n=performance.now();a._fps=Math.round(1e3/(n-o))}function L(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}}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.Element=function(e){this.elt=e},a._elements=[],a.createCapture=e=>{var t=document.createElement("video");return t.playsinline="playsinline",t.autoplay="autoplay",navigator.mediaDevices.getUserMedia(e).then((e=>{t.srcObject=e})),t.style.position="absolute",t.style.opacity=1e-5,t.style.zIndex=-1e3,document.body.append(t),t},a.print=console.log,a.describe=()=>{},a.noLoop=()=>{a._loop=!1,u=null},a.loop=()=>{a._loop=!0,null==u&&Q()},a.redraw=e=>{e??=1,a._redraw=!0;for(let t=0;t<e;t++)Q();a._redraw=!1},a.remove=()=>{a.noLoop(),a.canvas.remove()},a.frameRate=e=>(e&&(a._targetFrameRate=e,a._targetFrameDuration=1e3/e),a._frameRate),a.getTargetFrameRate=()=>a._targetFrameRate,a.getFPS=()=>a._fps,"object"==typeof localStorage&&(a.storeItem=localStorage.setItem,a.getItem=localStorage.getItem,a.removeItem=localStorage.removeItem,a.clearStorage=localStorage.clear),a._updateMouse=e=>{if(e.changedTouches)return;let t=a.canvas.getBoundingClientRect(),o=a.canvas.scrollWidth/a.width||1,n=a.canvas.scrollHeight/a.height||1;a.mouseX=(e.clientX-t.left)/o,a.mouseY=(e.clientY-t.top)/n},a._onmousedown=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a.mouseButton=[a.LEFT,a.CENTER,a.RIGHT][e.button],a.mousePressed(e)},a._onmousemove=e=>{a._updateMouse(e),a.mouseIsPressed?a.mouseDragged(e):a.mouseMoved(e)},a._onmouseup=e=>{a._updateMouse(e),a.mouseIsPressed=!1,a.mouseReleased(e)},a._onclick=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a.mouseClicked(e),a.mouseIsPressed=!1},a.cursor=(e,t,o)=>{let n="";e.includes(".")&&(e=`url("${e}")`,n=", auto"),void 0!==t&&(e+=" "+t+" "+o),a.canvas.style.cursor=e+n},a.noCursor=()=>{a.canvas.style.cursor="none"},a._onkeydown=e=>{e.repeat||(a.keyIsPressed=!0,a.key=e.key,a.keyCode=e.keyCode,p[a.keyCode]=!0,a.keyPressed(e),1==e.key.length&&a.keyTyped(e))},a._onkeyup=e=>{a.keyIsPressed=!1,a.key=e.key,a.keyCode=e.keyCode,p[a.keyCode]=!1,a.keyReleased(e)},a._ontouchstart=e=>{a.touches=[...e.touches].map(L),a._isTouchAware||(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseIsPressed=!0,a.mouseButton=a.LEFT,a.mousePressed(e)||e.preventDefault()),a.touchStarted(e)||e.preventDefault(),"running"!=a.getAudioContext()?.state&&a.userStartAudio()},a._ontouchmove=e=>{a.touches=[...e.touches].map(L),a._isTouchAware||(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseDragged(e)||e.preventDefault()),a.touchMoved(e)||e.preventDefault()},a._ontouchend=e=>{a.touches=[...e.touches].map(L),a._isTouchAware||a.touches.length||(a.mouseIsPressed=!1,a.mouseReleased(e)||e.preventDefault()),a.touchEnded(e)||e.preventDefault()},"graphics"!=e&&(a.keyIsDown=e=>!!p[e],a.canvas.onmousedown=e=>a._onmousedown(e),a.canvas.onmouseup=e=>a._onmouseup(e),a.canvas.onclick=e=>a._onclick(e),a.canvas.ontouchstart=e=>a._ontouchstart(e),a.canvas.ontouchmove=e=>a._ontouchmove(e),a.canvas.ontouchcancel=a.canvas.ontouchend=e=>a._ontouchend(e)),a.hasSensorPermission=!window.DeviceOrientationEvent&&!window.DeviceMotionEvent||!(DeviceOrientationEvent.requestPermission||DeviceMotionEvent.requestPermission),a.requestSensorPermissions=()=>{DeviceOrientationEvent.requestPermission&&DeviceOrientationEvent.requestPermission().then((e=>{"granted"==e&&DeviceMotionEvent.requestPermission&&DeviceMotionEvent.requestPermission().then((e=>{"granted"==e&&(a.hasSensorPermission=!0)})).catch(alert)})).catch(alert)};window.ondeviceorientation=e=>{a.pRotationX=a.rotationX,a.pRotationY=a.rotationY,a.pRotationZ=a.rotationZ,a.pRelRotationX=a.relRotationX,a.pRelRotationY=a.relRotationY,a.pRelRotationZ=a.relRotationZ,a.rotationX=e.beta*(Math.PI/180),a.rotationY=e.gamma*(Math.PI/180),a.rotationZ=e.alpha*(Math.PI/180),a.relRotationX=[-a.rotationY,-a.rotationX,a.rotationY][Math.trunc(window.orientation/90)+1],a.relRotationY=[-a.rotationX,a.rotationY,a.rotationX][Math.trunc(window.orientation/90)+1],a.relRotationZ=a.rotationZ},window.ondevicemotion=e=>{if(a.pAccelerationX=a.accelerationX,a.pAccelerationY=a.accelerationY,a.pAccelerationZ=a.accelerationZ,!e.acceleration){let i=((e,t)=>[(e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]),(e[4]*t[0]+e[5]*t[1]+e[6]*t[2]+e[7])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]),(e[8]*t[0]+e[9]*t[1]+e[10]*t[2]+e[11])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15])])((n=a.rotationY,t=[a.cos(n),0,a.sin(n),0,0,1,0,0,-a.sin(n),0,a.cos(n),0,0,0,0,1],o=(e=>[1,0,0,0,0,a.cos(e),-a.sin(e),0,0,a.sin(e),a.cos(e),0,0,0,0,1])(a.rotationX),[t[0]*o[0]+t[1]*o[4]+t[2]*o[8]+t[3]*o[12],t[0]*o[1]+t[1]*o[5]+t[2]*o[9]+t[3]*o[13],t[0]*o[2]+t[1]*o[6]+t[2]*o[10]+t[3]*o[14],t[0]*o[3]+t[1]*o[7]+t[2]*o[11]+t[3]*o[15],t[4]*o[0]+t[5]*o[4]+t[6]*o[8]+t[7]*o[12],t[4]*o[1]+t[5]*o[5]+t[6]*o[9]+t[7]*o[13],t[4]*o[2]+t[5]*o[6]+t[6]*o[10]+t[7]*o[14],t[4]*o[3]+t[5]*o[7]+t[6]*o[11]+t[7]*o[15],t[8]*o[0]+t[9]*o[4]+t[10]*o[8]+t[11]*o[12],t[8]*o[1]+t[9]*o[5]+t[10]*o[9]+t[11]*o[13],t[8]*o[2]+t[9]*o[6]+t[10]*o[10]+t[11]*o[14],t[8]*o[3]+t[9]*o[7]+t[10]*o[11]+t[11]*o[15],t[12]*o[0]+t[13]*o[4]+t[14]*o[8]+t[15]*o[12],t[12]*o[1]+t[13]*o[5]+t[14]*o[9]+t[15]*o[13],t[12]*o[2]+t[13]*o[6]+t[14]*o[10]+t[15]*o[14],t[12]*o[3]+t[13]*o[7]+t[14]*o[11]+t[15]*o[15]]),[0,0,-9.80665]);a.accelerationX=e.accelerationIncludingGravity.x+i[0],a.accelerationY=e.accelerationIncludingGravity.y+i[1],a.accelerationZ=e.accelerationIncludingGravity.z-i[2]}var t,o,n},a.year=()=>(new Date).getFullYear(),a.day=()=>(new Date).getDay(),a.hour=()=>(new Date).getHours(),a.minute=()=>(new Date).getMinutes(),a.second=()=>(new Date).getSeconds(),a.millis=()=>performance.now()-m,a._loadFile=(e,t,a)=>{o++;let n={};return fetch(e).then((e=>"json"==a?e.json():"text"==a?e.text():void 0)).then((e=>{o--,Object.assign(n,e),t&&t(e)})),n},a.loadStrings=(e,t)=>a._loadFile(e,t,"text"),a.loadJSON=(e,t)=>a._loadFile(e,t,"json"),a.loadSound=(e,t)=>{o++;let a=new Audio(e);return a.addEventListener("canplaythrough",(()=>{o--,t&&t(a)})),a.load(),a.setVolume=e=>a.volume=e,a.setLoop=e=>a.loop=e,a},a.getAudioContext=()=>a.audioContext,a.userStartAudio=()=>(a.audioContext??=new window.AudioContext,a.audioContext.resume()),"global"==e&&(Object.assign(Q5,a),delete Q5.Q5),Q5.Image??=_Q5Image;for(let G of Q5.prototype._methods.init)G.call(a);for(let[V,Y]of Object.entries(Q5.prototype))"_"!=V[0]&&"function"==typeof a[V]&&(a[V]=Y.bind(a));if("global"==e){let j=Object.getOwnPropertyNames(a),H=Q5._nodejs?global:window;for(let X of j)"function"==typeof a[X]?H[X]=a[X]:Object.defineProperty(H,X,{get:()=>a[X],set:e=>a[X]=e})}if("function"==typeof e&&e(a),"image"==e||"graphics"==e)return;let F=window.requestAnimationFrame||function(e){const t=a._lastFrameTime+a._targetFrameDuration;return setTimeout((()=>{e(t)}),t-performance.now())},N="global"==e?Q5._nodejs?global:window:a,q=N.preload,B=["setup","draw","preload","mouseMoved","mousePressed","mouseReleased","mouseDragged","mouseClicked","keyPressed","keyReleased","keyTyped","touchStarted","touchMoved","touchEnded","windowResized"];for(let U of B)N[U]?a._isGlobal&&(a[U]=N[U]):a[U]=()=>{};function $(){if(a._startDone=!0,o>0)return F($);m=performance.now(),a.setup(),a.frameCount||(null===r&&a.createCanvas(100,100),a._setupDone=!0,r&&a.resetMatrix(),F(Q))}a._isTouchAware=a.touchStarted||a.touchMoved||a.mouseReleased,window&&"graphics"!=e&&(window.addEventListener("mousemove",(e=>a._onmousemove(e)),!1),window.addEventListener("keydown",(e=>a._onkeydown(e)),!1),window.addEventListener("keyup",(e=>a._onkeyup(e)),!1)),(a.setup||a.draw)&&(a._startDone=!1,arguments.length&&"namespace"!=e||q?(a.preload(),$()):(N.preload=a.preload=()=>{a._startDone||$()},setTimeout(a.preload,32)))}Q5.Color=class{constructor(){this._q5Color=!0}},Q5.ColorOKLCH=class extends Q5.Color{constructor(e,t,a,o){super(),this.l=e,this.c=t,this.h=a,this.a=o??1}toString(){return`color(oklch ${this.l} ${this.c} ${this.h} / ${this.a})`}},Q5.ColorRGBA=class extends Q5.Color{constructor(e,t,a,o){super(),this.r=e,this.g=t,this.b=a,this.a=o??255}setRed(e){this.r=e}setGreen(e){this.g=e}setBlue(e){this.b=e}setAlpha(e){this.a=e}get levels(){return[this.r,this.g,this.b,this.a]}toString(){return`rgb(${this.r} ${this.g} ${this.b} / ${this.a/255})`}},Q5.ColorRGBA_P3=class extends Q5.ColorRGBA{constructor(e,t,a,o){super(e,t,a,o),this._edited=!0}get r(){return this._r}set r(e){this._r=e,this._edited=!0}get g(){return this._g}set g(e){this._g=e,this._edited=!0}get b(){return this._b}set b(e){this._b=e,this._edited=!0}get a(){return this._a}set a(e){this._a=e,this._edited=!0}toString(){if(this._edited){let e=(this._r/255).toFixed(3),t=(this._g/255).toFixed(3),a=(this._b/255).toFixed(3),o=(this._a/255).toFixed(3);this._css=`color(display-p3 ${e} ${t} ${a} / ${o})`,this._edited=!1}return this._css}},Q5.Vector=class{constructor(e,t,a,o){this.x=e||0,this.y=t||0,this.z=a||0,this._$=o||window,this._cn=null,this._cnsq=null}set(e,t,a){this.x=e||0,this.y=t||0,this.z=a||0}copy(){return new Q5.Vector(this.x,this.y,this.z)}_arg2v(e,t,a){return void 0!==e.x?e:void 0!==t?{x:e,y:t,z:a||0}:{x:e,y:e,z:e}}_calcNorm(){this._cnsq=this.x*this.x+this.y*this.y+this.z*this.z,this._cn=Math.sqrt(this._cnsq)}add(){let e=this._arg2v(...arguments);return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}rem(){let e=this._arg2v(...arguments);return this.x%=e.x,this.y%=e.y,this.z%=e.z,this}sub(){let e=this._arg2v(...arguments);return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}mult(){let e=this._arg2v(...arguments);return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}div(){let e=this._arg2v(...arguments);return e.x?this.x/=e.x:this.x=0,e.y?this.y/=e.y:this.y=0,e.z?this.z/=e.z:this.z=0,this}mag(){return this._calcNorm(),this._cn}magSq(){return this._calcNorm(),this._cnsq}dot(){let e=this._arg2v(...arguments);return this.x*e.x+this.y*e.y+this.z*e.z}dist(){let e=this._arg2v(...arguments),t=this.x-e.x,a=this.y-e.y,o=this.z-e.z;return Math.sqrt(t*t+a*a+o*o)}cross(){let e=this._arg2v(...arguments),t=this.y*e.z-this.z*e.y,a=this.z*e.x-this.x*e.z,o=this.x*e.y-this.y*e.x;return this.x=t,this.y=a,this.z=o,this}normalize(){this._calcNorm();let e=this._cn;return 0!=e&&(this.x/=e,this.y/=e,this.z/=e),this._cn=1,this._cnsq=1,this}limit(e){this._calcNorm();let t=this._cn;if(t>e){let a=e/t;this.x*=a,this.y*=a,this.z*=a,this._cn=e,this._cnsq=e*e}return this}setMag(e){this._calcNorm();let t=e/this._cn;return this.x*=t,this.y*=t,this.z*=t,this._cn=e,this._cnsq=e*e,this}heading(){return this._$.atan2(this.y,this.x)}rotate(e){let t=this._$.cos(e),a=this._$.sin(e),o=this.x*t-this.y*a,n=this.x*a+this.y*t;return this.x=o,this.y=n,this}angleBetween(){let e=this._arg2v(...arguments),t=Q5.Vector.cross(this,e);return this._$.atan2(t.mag(),this.dot(e))*Math.sign(t.z||1)}lerp(){let e=[...arguments],t=this._arg2v(...e.slice(0,-1)),a=e[e.length-1];return this.x+=(t.x-this.x)*a,this.y+=(t.y-this.y)*a,this.z+=(t.z-this.z)*a,this}reflect(e){return e.normalize(),this.sub(e.mult(2*this.dot(e)))}array(){return[this.x,this.y,this.z]}equals(e,t){return t??=Number.EPSILON||0,Math.abs(e.x-this.x)<t&&Math.abs(e.y-this.y)<t&&Math.abs(e.z-this.z)<t}fromAngle(e,t){return void 0===t&&(t=1),this._cn=t,this._cnsq=t*t,this.x=t*this._$.cos(e),this.y=t*this._$.sin(e),this.z=0,this}fromAngles(e,t,a){void 0===a&&(a=1),this._cn=a,this._cnsq=a*a;const o=this._$.cos(t),n=this._$.sin(t),i=this._$.cos(e),r=this._$.sin(e);return this.x=a*r*n,this.y=-a*i,this.z=a*r*o,this}random2D(){return this._cn=this._cnsq=1,this.fromAngle(Math.random()*Math.PI*2)}random3D(){return this._cn=this._cnsq=1,this.fromAngles(Math.random()*Math.PI*2,Math.random()*Math.PI*2)}toString(){return`[${this.x}, ${this.y}, ${this.z}]`}},Q5.Vector.add=(e,t)=>e.copy().add(t),Q5.Vector.cross=(e,t)=>e.copy().cross(t),Q5.Vector.dist=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y,e.z-t.z),Q5.Vector.div=(e,t)=>e.copy().div(t),Q5.Vector.dot=(e,t)=>e.copy().dot(t),Q5.Vector.equals=(e,t,a)=>e.equals(t,a),Q5.Vector.lerp=(e,t,a)=>e.copy().lerp(t,a),Q5.Vector.limit=(e,t)=>e.copy().limit(t),Q5.Vector.heading=e=>this._$.atan2(e.y,e.x),Q5.Vector.magSq=e=>e.x*e.x+e.y*e.y+e.z*e.z,Q5.Vector.mag=e=>Math.sqrt(Q5.Vector.magSq(e)),Q5.Vector.mult=(e,t)=>e.copy().mult(t),Q5.Vector.normalize=e=>e.copy().normalize(),Q5.Vector.rem=(e,t)=>e.copy().rem(t),Q5.Vector.sub=(e,t)=>e.copy().sub(t);for(let e of["fromAngle","fromAngles","random2D","random3D"])Q5.Vector[e]=(t,a,o)=>(new Q5.Vector)[e](t,a,o);class _Q5Image extends Q5{constructor(e,t,a){super("image"),delete this.createCanvas,a??={},a.alpha??=!0,this._createCanvas(e,t,"2d",a),this._loop=!1}get w(){return this.width}get h(){return this.height}}"object"!=typeof window&&(window=0),Q5._nodejs="object"==typeof process,Q5.canvasOptions={alpha:!1,desynchronized:!1,colorSpace:"display-p3"},window.matchMedia&&matchMedia("(dynamic-range: high) and (color-gamut: p3)").matches?Q5.supportsHDR=!0:Q5.canvasOptions.colorSpace="srgb",Q5._instanceCount=0,Q5._friendlyError=(e,t)=>{throw t+": "+e},Q5._validateParameters=()=>!0,Q5.prototype._methods={init:[],pre:[],post:[],remove:[]},Q5.prototype.registerMethod=(e,t)=>Q5.prototype._methods[e].push(t),Q5.prototype.registerPreloadMethod=(e,t)=>Q5.prototype[e]=t[e],"object"==typeof module?(global.p5??=Q5,module.exports=global.Q5=Q5):(window.p5??=Q5,window.Q5=Q5),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{Q5._hasGlobal||new Q5("auto")}));
7
+ function Q5(e,t){let a=this;a._q5=!0;let o=0;if(e||(e="global"),"auto"==e){if(!window.setup&&!window.draw)return;e="global"}"global"==e&&(Q5._hasGlobal=a._isGlobal=!0);let n=window.OffscreenCanvas||function(){return document.createElement("canvas")},i=null,r=a.ctx=a.drawingContext=null;if(a.canvas=null,a.pixels=[],a.noCanvas=()=>{a.canvas?.remove&&a.canvas.remove(),a.canvas=0,r=a.ctx=a.drawingContext=0},Q5._nodejs?Q5._createNodeJSCanvas&&(a.canvas=Q5._createNodeJSCanvas(100,100)):"image"!=e&&"graphics"!=e||(a.canvas=new n(100,100)),a.canvas||("object"==typeof document?(a.canvas=document.createElement("canvas"),a.canvas.id="defaultCanvas"+Q5._instanceCount++,a.canvas.classList.add("p5Canvas","q5Canvas")):a.noCanvas()),a.canvas.width=a.width=100,a.canvas.height=a.height=100,a.canvas&&"graphics"!=e&&"image"!=e){function s(){t??=document.getElementsByTagName("main")[0],t||(t=document.createElement("main"),document.body.append(t)),a.canvas.parent(t)}a._setupDone=!1,a._resize=()=>{a.frameCount>1&&(a._shouldResize=!0)},t&&"string"==typeof t&&(t=document.getElementById(t)),a.canvas.parent=e=>{"string"==typeof e&&(e=document.getElementById(e)),e.append(a.canvas),"function"==typeof ResizeObserver?(a._ro&&a._ro.disconnect(),a._ro=new ResizeObserver(a._resize),a._ro.observe(t)):a.frameCount||window.addEventListener("resize",a._resize)},document.body?s():document.addEventListener("DOMContentLoaded",s)}function l(e,t){t??=e||a.canvas.height,e??=a.canvas.width,null==f&&(f=new n(e,t).getContext("2d",{colorSpace:a.canvas.colorSpace})),f.canvas.width==e&&f.canvas.height==t||(f.canvas.width=e,f.canvas.height=t)}function c(){let e=a.canvas.width*a.canvas.height*4;x&&e==x.length||(x=new Uint8ClampedArray(e))}function h(e,t){a._filters||(a._filters=[],a._filters[a.THRESHOLD]=(e,t)=>{void 0===t?t=127.5:t*=255;for(let a=0;a<e.length;a+=4){const o=.2126*e[a]+.7152*e[a+1]+.0722*e[a+2];e[a]=e[a+1]=e[a+2]=o>=t?255:0}},a._filters[a.GRAY]=e=>{for(let t=0;t<e.length;t+=4){const a=.2126*e[t]+.7152*e[t+1]+.0722*e[t+2];e[t]=e[t+1]=e[t+2]=a}},a._filters[a.OPAQUE]=e=>{for(let t=0;t<e.length;t+=4)e[t+3]=255},a._filters[a.INVERT]=e=>{for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]},a._filters[a.POSTERIZE]=(e,t=4)=>{let a=t-1;for(let o=0;o<e.length;o+=4)e[o]=255*(e[o]*t>>8)/a,e[o+1]=255*(e[o+1]*t>>8)/a,e[o+2]=255*(e[o+2]*t>>8)/a},a._filters[a.DILATE]=e=>{c(),x.set(e);let[t,o]=[a.canvas.width,a.canvas.height];for(let a=0;a<o;a++)for(let n=0;n<t;n++){let i=4*Math.max(n-1,0),r=4*Math.min(n+1,t-1),s=4*Math.max(a-1,0)*t,l=4*Math.min(a+1,o-1)*t,c=4*a*t,h=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+c;e[c+h+t]=Math.max(x[a+h],x[n+i],x[n+h],x[n+r],x[o+h])}}},a._filters[a.ERODE]=e=>{c(),x.set(e);let[t,o]=[a.canvas.width,a.canvas.height];for(let a=0;a<o;a++)for(let n=0;n<t;n++){let i=4*Math.max(n-1,0),r=4*Math.min(n+1,t-1),s=4*Math.max(a-1,0)*t,l=4*Math.min(a+1,o-1)*t,c=4*a*t,h=4*n;for(let t=0;t<4;t++){let a=t+s,o=t+l,n=t+c;e[c+h+t]=Math.min(x[a+h],x[n+i],x[n+h],x[n+r],x[o+h])}}},a._filters[a.BLUR]=(e,t)=>{t=t||1,t=Math.floor(t*a._pixelDensity),c(),x.set(e);let o=2*t+1,n=function(e){let a=new Float32Array(e),o=.3*t+.8,n=o*o*2;for(let t=0;t<e;t++){let i=t-e/2,r=Math.exp(-i*i/n)/(2.5066282746*o);a[t]=r}return a}(o),[i,r]=[a.canvas.width,a.canvas.height];for(let a=0;a<r;a++)for(let r=0;r<i;r++){let s=0,l=0,c=0,h=0;for(let e=0;e<o;e++){let o=4*(a*i+Math.min(Math.max(r-t+e,0),i-1));s+=x[o]*n[e],l+=x[o+1]*n[e],c+=x[o+2]*n[e],h+=x[o+3]*n[e]}let d=4*(a*i+r);e[d]=s,e[d+1]=l,e[d+2]=c,e[d+3]=h}x.set(e);for(let a=0;a<r;a++)for(let s=0;s<i;s++){let l=0,c=0,h=0,d=0;for(let e=0;e<o;e++){let o=4*(Math.min(Math.max(a-t+e,0),r-1)*i+s);l+=x[o]*n[e],c+=x[o+1]*n[e],h+=x[o+2]*n[e],d+=x[o+3]*n[e]}let u=4*(a*i+s);e[u]=l,e[u+1]=c,e[u+2]=h,e[u+3]=d}});let o=r.getImageData(0,0,a.canvas.width,a.canvas.height);a._filters[e](o.data,t),r.putImageData(o,0,0)}function d(e){f.clearRect(0,0,f.canvas.width,f.canvas.height),f.filter=e,f.drawImage(a.canvas,0,0),r.save(),r.resetTransform(),r.clearRect(0,0,a.canvas.width,a.canvas.height),r.drawImage(f.canvas,0,0),r.restore()}a.createCanvas=function(t,o,n,i){if("webgl"==n)throw"webgl renderer is not supported in q5, use '2d'";"object"==typeof n&&(i=n),a.width=a.canvas.width=t,a.height=a.canvas.height=o,a.canvas.renderer="2d";let s=Object.assign({},Q5.canvasOptions);if(i&&Object.assign(s,i),r=a.ctx=a.drawingContext=a.canvas.getContext("2d",s),Object.assign(a.canvas,s),"rgb"==a._colorMode&&a.colorMode("rgb"),r.fillStyle="white",r.strokeStyle="black",r.lineCap="round",r.lineJoin="miter",r.textAlign="left",r.save(),"image"!=e){let t=a.displayDensity();"graphics"==e&&(t=this._pixelDensity),a.pixelDensity(Math.ceil(t))}else this._pixelDensity=1;return a.canvas},a._createCanvas=a.createCanvas,a.loadPixels=()=>{i=r.getImageData(0,0,a.canvas.width,a.canvas.height),a.pixels=i.data},a.updatePixels=()=>{null!=i&&r.putImageData(i,0,0)},a.filter=(e,t)=>{if(!r.filter)return h(e,t);if(l(),"string"==typeof e)d(e);else if(e==a.THRESHOLD){t??=.5,t=Math.max(t,1e-5),d(`saturate(0%) brightness(${Math.floor(.5/t*100)}%) contrast(1000000%)`)}else e==a.GRAY?d("saturate(0%)"):e==a.OPAQUE?(f.fillStyle="black",f.fillRect(0,0,f.canvas.width,f.canvas.height),f.drawImage(a.canvas,0,0),r.save(),r.resetTransform(),r.drawImage(f.canvas,0,0),r.restore()):e==a.INVERT?d("invert(100%)"):e==a.BLUR?d(`blur(${Math.ceil(t*a._pixelDensity/1)||1}px)`):h(e,t)},a.resize=(e,t)=>{l(),f.drawImage(a.canvas,0,0),a.width=e,a.height=t,a.canvas.width=e*a._pixelDensity,a.canvas.height=t*a._pixelDensity,r.save(),r.resetTransform(),r.clearRect(0,0,a.canvas.width,a.canvas.height),r.drawImage(f.canvas,0,0,a.canvas.width,a.canvas.height),r.restore()},a.trim=()=>{let e=a._pixelDensity||1,t=r.getImageData(0,0,a.width*e,a.height*e).data,o=a.width,n=0,i=a.height,s=0;for(let r=0;r<a.height*e;r++)for(let l=0;l<a.width*e;l++){0!==t[4*(r*a.width*e+l)+3]&&(l<o&&(o=l),l>n&&(n=l),r<i&&(i=r),r>s&&(s=r))}return i=Math.floor(i/e),s=Math.floor(s/e),o=Math.floor(o/e),n=Math.floor(n/e),a.get(o,i,n-o+1,s-i+1)},a.get=(e,t,o,n)=>{let i=a._pixelDensity||1;if(void 0!==e&&void 0===o){let o=r.getImageData(e*i,t*i,1,1).data;return new a.Color(o[0],o[1],o[2],o[3]/255)}e=(e||0)*i,t=(t||0)*i;let s=o=o||a.width,l=n=n||a.height;o*=i,n*=i;let c=a.createImage(o,n),h=r.getImageData(e,t,o,n);return c.ctx.putImageData(h,0,0),c._pixelDensity=i,c.width=s,c.height=l,c},a.set=(e,t,o)=>{if(o._q5){let n=a._tint;return a._tint=null,a.image(o,e,t),void(a._tint=n)}a.pixels.length||a.loadPixels();let n=a._pixelDensity||1;for(let i=0;i<n;i++)for(let r=0;r<n;r++){let s=4*((t*n+i)*a.canvas.width+e*n+r);a.pixels[s]=o.r??o.l,a.pixels[s+1]=o.g??o.c,a.pixels[s+2]=o.b??o.h,a.pixels[s+3]=o.a}},a.tinted=function(e){let t=e.a;e.a=255,l(),f.clearRect(0,0,f.canvas.width,f.canvas.height),f.fillStyle=e.toString(),f.fillRect(0,0,f.canvas.width,f.canvas.height),f.globalCompositeOperation="multiply",f.drawImage(r.canvas,0,0),f.globalCompositeOperation="source-over",r.save(),r.resetTransform();let a=r.globalCompositeOperation;r.globalCompositeOperation="source-in",r.drawImage(f.canvas,0,0),r.globalCompositeOperation=a,r.restore(),f.globalAlpha=t/255,f.clearRect(0,0,f.canvas.width,f.canvas.height),f.drawImage(r.canvas,0,0),f.globalAlpha=1,r.save(),r.resetTransform(),r.clearRect(0,0,r.canvas.width,r.canvas.height),r.drawImage(f.canvas,0,0),r.restore()},a.tint=function(e){a._tint=e._q5Color?e:a.color(...arguments)},a.noTint=()=>a._tint=null,a.mask=e=>{r.save(),r.resetTransform();let t=r.globalCompositeOperation;r.globalCompositeOperation="destination-in",r.drawImage(e.canvas,0,0),r.globalCompositeOperation=t,r.restore()},a._save=async(e,t,a)=>{if(t=t||"untitled","jpg"==(a=a||"png")||"png"==a||"webp"==a)if(e instanceof OffscreenCanvas){const t=await e.convertToBlob({type:"image/"+a});e=await new Promise((e=>{const a=new FileReader;a.onloadend=()=>e(a.result),a.readAsDataURL(t)}))}else e=e.toDataURL("image/"+a);else{let t="text/plain";"json"==a&&("string"!=typeof e&&(e=JSON.stringify(e)),t="text/json"),e=new Blob([e],{type:t}),e=URL.createObjectURL(e)}let o=document.createElement("a");o.href=e,o.download=t+"."+a,document.body.append(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(o.href)},a.save=(e,t,o)=>{if((!e||"string"==typeof e&&(!t||!o&&t.length<5))&&(o=t,t=e,e=a.canvas),o)return a._save(e,t,o);t?(t=t.split("."),a._save(e,t[0],t.at(-1))):a._save(e)},a.canvas.save=a.save,a.saveCanvas=a.save,a.createImage=(e,t,a)=>new Q5.Image(e,t,a);let u=null,g=!0,_=[],p={},m=0,f=null,v=null,x=null;if(a.THRESHOLD=1,a.GRAY=2,a.OPAQUE=3,a.INVERT=4,a.POSTERIZE=5,a.DILATE=6,a.ERODE=7,a.BLUR=8,"image"==e)return;function y(e,t){a.width=e,a.height=t;let o=function(){let e={};for(let t in r)"function"!=typeof r[t]&&(e[t]=r[t]);return delete e.canvas,e}();a.canvas.width=Math.ceil(e*a._pixelDensity),a.canvas.height=Math.ceil(t*a._pixelDensity),!a.canvas.fullscreen&&a.canvas.style&&(a.canvas.style.width=e+"px",a.canvas.style.height=t+"px");for(let e in o)a.ctx[e]=o[e];r.scale(a._pixelDensity,a._pixelDensity)}a.BLEND="source-over",a.REMOVE="destination-out",a.ADD="lighter",a.DARKEST="darken",a.LIGHTEST="lighten",a.DIFFERENCE="difference",a.SUBTRACT="subtract",a.EXCLUSION="exclusion",a.MULTIPLY="multiply",a.SCREEN="screen",a.REPLACE="copy",a.OVERLAY="overlay",a.HARD_LIGHT="hard-light",a.SOFT_LIGHT="soft-light",a.DODGE="color-dodge",a.BURN="color-burn",a.RGB="rgb",a.RGBA="rgb",a.HSB="hsb",a.CHORD=0,a.PIE=1,a.OPEN=2,a.RADIUS="radius",a.CORNER="corner",a.CORNERS="corners",a.ROUND="round",a.SQUARE="butt",a.PROJECT="square",a.MITER="miter",a.BEVEL="bevel",a.CLOSE=1,a.NORMAL="normal",a.ITALIC="italic",a.BOLD="bold",a.BOLDITALIC="italic bold",a.CENTER="center",a.LEFT="left",a.RIGHT="right",a.TOP="top",a.BOTTOM="bottom",a.BASELINE="alphabetic",a.LANDSCAPE="landscape",a.PORTRAIT="portrait",a.ALT=18,a.BACKSPACE=8,a.CONTROL=17,a.DELETE=46,a.DOWN_ARROW=40,a.ENTER=13,a.ESCAPE=27,a.LEFT_ARROW=37,a.OPTION=18,a.RETURN=13,a.RIGHT_ARROW=39,a.SHIFT=16,a.TAB=9,a.UP_ARROW=38,a.DEGREES="degrees",a.RADIANS="radians",a.HALF_PI=Math.PI/2,a.PI=Math.PI,a.QUARTER_PI=Math.PI/4,a.TAU=2*Math.PI,a.TWO_PI=2*Math.PI,a.ARROW="default",a.CROSS="crosshair",a.HAND="pointer",a.MOVE="move",a.TEXT="text",a.VIDEO={video:!0,audio:!1},a.AUDIO={video:!1,audio:!0},a.SHR3=1,a.LCG=2,a.hint=(e,t)=>{a[e]=t},a.frameCount=0,a.deltaTime=16,a.mouseX=0,a.mouseY=0,a.touches=[],a.mouseButton=null,a.keyIsPressed=!1,a.mouseIsPressed=!1,a.key=null,a.keyCode=null,a.accelerationX=0,a.accelerationY=0,a.accelerationZ=0,a.rotationX=0,a.rotationY=0,a.rotationZ=0,a.relRotationX=0,a.relRotationY=0,a.relRotationZ=0,a.pmouseX=0,a.pmouseY=0,a.pAccelerationX=0,a.pAccelerationY=0,a.pAccelerationZ=0,a.pRotationX=0,a.pRotationY=0,a.pRotationZ=0,a.pRelRotationX=0,a.pRelRotationY=0,a.pRelRotationZ=0,Object.defineProperty(a,"deviceOrientation",{get:()=>window.screen?.orientation?.type}),Object.defineProperty(a,"windowWidth",{get:()=>window.innerWidth}),Object.defineProperty(a,"windowHeight",{get:()=>window.innerHeight}),a._colorMode="rgb",a._doStroke=!0,a._doFill=!0,a._strokeSet=!1,a._fillSet=!1,a._tint=null,a._ellipseMode=a.CENTER,a._rectMode=a.CORNER,a._curveDetail=20,a._curveAlpha=0,a._loop=!0,a._textFont="sans-serif",a._textSize=12,a._textLeading=15,a._textLeadDiff=3,a._textStyle="normal",a._pixelDensity=1,a._targetFrameRate=0,a._targetFrameDuration=16.666666666666668,a._frameRate=a._fps=60,a.resizeCanvas=(e,t)=>{e==a.width&&t==a.height||y(e,t)},a.createGraphics=function(e,t,o){let n=new Q5("graphics");return o??={},o.alpha??=!0,n._createCanvas.call(a,e,t,o),n},a.displayDensity=()=>window.devicePixelRatio,a.pixelDensity=e=>e&&e!=a._pixelDensity?(a._pixelDensity=e,y(a.width,a.height),e):a._pixelDensity,a.fullscreen=e=>{if(void 0===e)return document.fullscreenElement;e?document.body.requestFullscreen():document.body.exitFullscreen()},a.map=(e,t,a,o,n,i)=>{let r=o+1*(e-t)/(a-t)*(n-o);return i?o<n?Math.min(Math.max(r,o),n):Math.min(Math.max(r,n),o):r},a.lerp=(e,t,a)=>e*(1-a)+t*a,a.constrain=(e,t,a)=>Math.min(Math.max(e,t),a),a.dist=function(){let e=arguments;return 4==e.length?Math.hypot(e[0]-e[2],e[1]-e[3]):Math.hypot(e[0]-e[3],e[1]-e[4],e[2]-e[5])},a.norm=(e,t,o)=>a.map(e,t,o,0,1),a.sq=e=>e*e,a.fract=e=>e-Math.floor(e),a.angleMode=e=>a._angleMode=e,a._DEGTORAD=Math.PI/180,a._RADTODEG=180/Math.PI,a.degrees=e=>e*a._RADTODEG,a.radians=e=>e*a._DEGTORAD,a.abs=Math.abs,a.ceil=Math.ceil,a.exp=Math.exp,a.floor=Math.floor,a.log=Math.log,a.mag=Math.hypot,a.max=Math.max,a.min=Math.min,a.round=Math.round,a.pow=Math.pow,a.sqrt=Math.sqrt,a.sin=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.sin(e)),a.cos=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.cos(e)),a.tan=e=>("degrees"==a._angleMode&&(e=a.radians(e)),Math.tan(e)),a.asin=e=>{let t=Math.asin(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.acos=e=>{let t=Math.acos(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.atan=e=>{let t=Math.atan(e);return"degrees"==a._angleMode&&(t=a.degrees(t)),t},a.atan2=(e,t)=>{let o=Math.atan2(e,t);return"degrees"==a._angleMode&&(o=a.degrees(o)),o},a.nf=(e,t,a)=>{let o=e<0,n=(e=Math.abs(e)).toFixed(a).split(".");n[0]=n[0].padStart(t,"0");let i=n.join(".");return o&&(i="-"+i),i},a.createVector=(e,t,o)=>new Q5.Vector(e,t,o,a),a.curvePoint=(e,t,a,o,n)=>{const i=n*n*n,r=n*n;return e*(-.5*i+r-.5*n)+t*(1.5*i-2.5*r+1)+a*(-1.5*i+2*r+.5*n)+o*(.5*i-.5*r)},a.bezierPoint=(e,t,a,o,n)=>{const i=1-n;return Math.pow(i,3)*e+3*Math.pow(i,2)*n*t+3*i*Math.pow(n,2)*a+Math.pow(n,3)*o},a.curveTangent=(e,t,a,o,n)=>{const i=n*n;return e*(-3*i/2+2*n-.5)+t*(9*i/2-5*n)+a*(-9*i/2+4*n+.5)+o*(3*i/2-n)},a.bezierTangent=(e,t,a,o,n)=>{const i=1-n;return 3*o*Math.pow(n,2)-3*a*Math.pow(n,2)+6*a*i*n-6*t*i*n+3*t*Math.pow(i,2)-3*e*Math.pow(i,2)},Q5.supportsHDR?a.Color=Q5.ColorRGBA_P3:a.Color=Q5.ColorRGBA,a.colorMode=e=>{a._colorMode=e,"oklch"==e?a.Color=Q5.ColorOKLCH:"rgb"==e?"srgb"==a.canvas.colorSpace?a.Color=Q5.ColorRGBA:a.Color=Q5.ColorRGBA_P3:"srgb"==e&&(a.Color=Q5.ColorRGBA,a._colorMode="rgb")};let w={aqua:[0,255,255],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],crimson:[220,20,60],darkviolet:[148,0,211],gold:[255,215,0],green:[0,128,0],gray:[128,128,128],grey:[128,128,128],hotpink:[255,105,180],indigo:[75,0,130],khaki:[240,230,140],lightgreen:[144,238,144],lime:[0,255,0],magenta:[255,0,255],navy:[0,0,128],orange:[255,165,0],olive:[128,128,0],peachpuff:[255,218,185],pink:[255,192,203],purple:[128,0,128],red:[255,0,0],skyblue:[135,206,235],tan:[210,180,140],turquoise:[64,224,208],transparent:[0,0,0,0],white:[255,255,255],violet:[238,130,238],yellow:[255,255,0]};function M(e){let t=a._angleMode==a.DEGREES?180:Math.PI,o=2*t;if(0<=e&&e<=o)return e;for(;e<0;)e+=o;for(;e>=t;)e-=o;return e}function R(e,t,o,n,i,s,l,c){if(!a._doFill&&!a._doStroke)return;let h=M(i),d=M(s);if(h>d&&([h,d]=[d,h]),0==h){if(0==d)return;if(a._angleMode==a.DEGREES&&360==d||d==a.TAU)return a.ellipse(e,t,o,n)}r.beginPath();for(let i=0;i<c+1;i++){let s=i/c,l=a.lerp(h,d,s),u=a.cos(l)*o/2,g=a.sin(l)*n/2;r[i?"lineTo":"moveTo"](e+u,t+g)}l==a.CHORD?r.closePath():l==a.PIE&&(r.lineTo(e,t),r.closePath()),a._doFill&&r.fill(),a._doStroke&&r.stroke()}function S(e,t,o,n){(a._doFill||a._doStroke)&&(r.beginPath(),r.ellipse(e,t,o/2,n/2,0,0,a.TAU),a._doFill&&r.fill(),a._doStroke&&r.stroke())}function C(e,t,o,n,i,s,l,c){if(!a._doFill&&!a._doStroke)return;if(void 0===i)return function(e,t,o,n){a._doFill&&r.fillRect(e,t,o,n),a._doStroke&&r.strokeRect(e,t,o,n)}(e,t,o,n);if(void 0===s)return C(e,t,o,n,i,i,i,i);const h=Math.min(Math.abs(n),Math.abs(o))/2;i=Math.min(h,i),s=Math.min(h,s),c=Math.min(h,c),l=Math.min(h,l),r.beginPath(),r.moveTo(e+i,t),r.arcTo(e+o,t,e+o,t+n,s),r.arcTo(e+o,t+n,e,t+n,l),r.arcTo(e,t+n,e,t,c),r.arcTo(e,t,e+o,t,i),r.closePath(),a._doFill&&r.fill(),a._doStroke&&r.stroke()}function b(){_=[]}a.color=function(e,t,o,n){let i=a.Color;if(e._q5Color)return new i(...e.levels);let r=arguments;if(1==r.length){if("string"==typeof e)return"#"==e[0]?new i(parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16),9!=e.length?null:parseInt(e.slice(7,9),16)):w[e]?new i(...w[e]):new i(0,0,0);if(Array.isArray(e))return new i(...e)}if("rgb"==a._colorMode){if(1==r.length)return new i(e,e,e);if(2==r.length)return new i(e,e,e,t);if(3==r.length)return new i(e,t,o);if(4==r.length)return new i(e,t,o,n)}},a.red=e=>e.r,a.green=e=>e.g,a.blue=e=>e.b,a.alpha=e=>e.a,a.lightness=e=>100*(.2126*e.r+.7152*e.g+.0722*e.b)/255,a.lerpColor=(e,t,o)=>{if("rgb"==a._colorMode)return new a.Color(a.constrain(a.lerp(e.r,t.r,o),0,255),a.constrain(a.lerp(e.g,t.g,o),0,255),a.constrain(a.lerp(e.b,t.b,o),0,255),a.constrain(a.lerp(e.a,t.a,o),0,255));{let n=t.h-e.h;n>180&&(n-=360),n<-180&&(n+=360);let i=e.h+o*n;return i<0&&(i+=360),i>360&&(i-=360),new a.Color(a.constrain(a.lerp(e.l,t.l,o),0,100),a.constrain(a.lerp(e.c,t.c,o),0,100),i,a.constrain(a.lerp(e.a,t.a,o),0,255))}},a.strokeWeight=e=>{e||(a._doStroke=!1),r.lineWidth=e||1e-4},a.stroke=function(e){if(a._doStroke=!0,a._strokeSet=!0,e._q5Color||"string"==typeof e||(e=a.color(...arguments)),e.a<=0)return a._doStroke=!1;r.strokeStyle=e.toString()},a.noStroke=()=>a._doStroke=!1,a.fill=function(e){if(a._doFill=!0,a._fillSet=!0,e._q5Color||"string"==typeof e||(e=a.color(...arguments)),e.a<=0)return a._doFill=!1;r.fillStyle=e.toString()},a.noFill=()=>a._doFill=!1,a.smooth=()=>a._smooth=!0,a.noSmooth=()=>a._smooth=!1,a.blendMode=e=>r.globalCompositeOperation=e,a.strokeCap=e=>r.lineCap=e,a.strokeJoin=e=>r.lineJoin=e,a.ellipseMode=e=>a._ellipseMode=e,a.rectMode=e=>a._rectMode=e,a.curveDetail=e=>a._curveDetail=e,a.curveAlpha=e=>a._curveAlpha=e,a.curveTightness=e=>a._curveAlpha=e,a.clear=()=>{r.clearRect(0,0,a.canvas.width,a.canvas.height)},a.background=function(e){if(e._q5)return a.image(e,0,0,a.width,a.height);r.save(),r.resetTransform(),e._q5color||"string"==typeof e||(e=a.color(...arguments)),r.fillStyle=e.toString(),r.fillRect(0,0,a.canvas.width,a.canvas.height),r.restore()},a.line=(e,t,o,n)=>{a._doStroke&&(r.beginPath(),r.moveTo(e,t),r.lineTo(o,n),r.stroke())},a.arc=(e,t,o,n,i,r,s,l=25)=>{if(i==r)return a.ellipse(e,t,o,n);s??=a.PIE,a._ellipseMode==a.CENTER?R(e,t,o,n,i,r,s,l):a._ellipseMode==a.RADIUS?R(e,t,2*o,2*n,i,r,s,l):a._ellipseMode==a.CORNER?R(e+o/2,t+n/2,o,n,i,r,s,l):a._ellipseMode==a.CORNERS&&R((e+o)/2,(t+n)/2,o-e,n-t,i,r,s,l)},a.ellipse=(e,t,o,n)=>{n??=o,a._ellipseMode==a.CENTER?S(e,t,o,n):a._ellipseMode==a.RADIUS?S(e,t,2*o,2*n):a._ellipseMode==a.CORNER?S(e+o/2,t+n/2,o,n):a._ellipseMode==a.CORNERS&&S((e+o)/2,(t+n)/2,o-e,n-t)},a.circle=(e,t,o)=>a.ellipse(e,t,o,o),a.point=(e,t)=>{e.x&&(t=e.y,e=e.x),r.beginPath(),r.ellipse(e,t,.4,.4,0,0,a.TAU),r.stroke()},a.rect=(e,t,o,n,i,r,s,l)=>{a._rectMode==a.CENTER?C(e-o/2,t-n/2,o,n,i,r,s,l):a._rectMode==a.RADIUS?C(e-o,t-n,2*o,2*n,i,r,s,l):a._rectMode==a.CORNER?C(e,t,o,n,i,r,s,l):a._rectMode==a.CORNERS&&C(e,t,o-e,n-t,i,r,s,l)},a.square=(e,t,o,n,i,r,s)=>a.rect(e,t,o,o,n,i,r,s),a.beginShape=()=>{b(),r.beginPath(),g=!0},a.beginContour=()=>{r.closePath(),b(),g=!0},a.endContour=()=>{b(),g=!0},a.vertex=(e,t)=>{b(),g?r.moveTo(e,t):r.lineTo(e,t),g=!1},a.bezierVertex=(e,t,a,o,n,i)=>{b(),r.bezierCurveTo(e,t,a,o,n,i)},a.quadraticVertex=(e,t,a,o)=>{b(),r.quadraticCurveTo(e,t,a,o)},a.bezier=(e,t,o,n,i,r,s,l)=>{a.beginShape(),a.vertex(e,t),a.bezierVertex(o,n,i,r,s,l),a.endShape()},a.triangle=(e,t,o,n,i,r)=>{a.beginShape(),a.vertex(e,t),a.vertex(o,n),a.vertex(i,r),a.endShape(a.CLOSE)},a.quad=(e,t,o,n,i,r,s,l)=>{a.beginShape(),a.vertex(e,t),a.vertex(o,n),a.vertex(i,r),a.vertex(s,l),a.endShape(a.CLOSE)},a.endShape=e=>{b(),e&&r.closePath(),a._doFill&&r.fill(),a._doStroke&&r.stroke()},a.curveVertex=(e,t)=>{if(_.push([e,t]),_.length<4)return;let o=function(e,t,a,o,n,i,r,s,l,c){function h(e,t,a,o,n,i){let r=Math.pow(o-t,2)+Math.pow(n-a,2);return Math.pow(r,.5*i)+e}let d=[],u=h(0,e,t,a,o,c),g=h(u,a,o,n,i,c),_=h(g,n,i,r,s,c);for(let c=0;c<l;c++){let h=u+c/(l-1)*(g-u),p=[(u-h)/(u-0),(h-0)/(u-0),(g-h)/(g-u),(h-u)/(g-u),(_-h)/(_-g),(h-g)/(_-g),(g-h)/(g-0),(h-0)/(g-0),(_-h)/(_-u),(h-u)/(_-u)];for(let e=0;e<p.length;e+=2)isNaN(p[e])&&(p[e]=1,p[e+1]=0),isFinite(p[e])||(p[e]>0?(p[e]=1,p[e+1]=0):(p[e]=0,p[e+1]=1));let m=e*p[0]+a*p[1],f=t*p[0]+o*p[1],v=a*p[2]+n*p[3],x=o*p[2]+i*p[3],y=n*p[4]+r*p[5],w=i*p[4]+s*p[5],M=m*p[6]+v*p[7],R=f*p[6]+x*p[7],S=v*p[8]+y*p[9],C=x*p[8]+w*p[9],b=M*p[2]+S*p[3],D=R*p[2]+C*p[3];d.push([b,D])}return d}(..._[_.length-4],..._[_.length-3],..._[_.length-2],..._[_.length-1],a._curveDetail,a._curveAlpha);for(let e=0;e<o.length;e++)g?r.moveTo(...o[e]):r.lineTo(...o[e]),g=!1},a.curve=(e,t,o,n,i,r,s,l)=>{a.beginShape(),a.curveVertex(e,t),a.curveVertex(o,n),a.curveVertex(i,r),a.curveVertex(s,l),a.endShape()},a.opacity=e=>r.globalAlpha=e,a.translate=(e,t)=>r.translate(e,t),a.rotate=e=>{"degrees"==a._angleMode&&(e=a.radians(e)),r.rotate(e)},a.scale=(e,t)=>{t??=e,r.scale(e,t)},a.applyMatrix=(e,t,a,o,n,i)=>r.transform(e,t,a,o,n,i),a.shearX=e=>r.transform(1,0,a.tan(e),1,0,0),a.shearY=e=>r.transform(1,a.tan(e),0,1,0,0),a.resetMatrix=()=>{r.resetTransform(),r.scale(a._pixelDensity,a._pixelDensity)},a._styleNames=["_doStroke","_doFill","_strokeSet","_fillSet","_tint","_imageMode","_rectMode","_ellipseMode","_textFont","_textLeading","_leadingSet","_textSize","_textAlign","_textBaseline","_textStyle","_textWrap"],a._styles=[],a.push=a.pushMatrix=()=>{r.save();let e={};for(let t of a._styleNames)e[t]=a[t];a._styles.push(e)},a.pop=a.popMatrix=()=>{r.restore();let e=a._styles.pop();for(let t of a._styleNames)a[t]=e[t]},a.imageMode=e=>a._imageMode=e,a.image=(e,t,o,i,s,l=0,c=0,h,d)=>{let u=e._q5?e.canvas:e;var g,_;Q5._createNodeJSCanvas&&(u=u.context.canvas),e._q5&&null!=a._tint&&(g=e.canvas.width,_=e.canvas.height,_??=g||a.canvas.height,g??=a.canvas.width,null==v&&(v=new n(g,_).getContext("2d",{colorSpace:a.canvas.colorSpace})),v.canvas.width==g&&v.canvas.height==_||(v.canvas.width=g,v.canvas.height=_),v.drawImage(e.canvas,0,0),e.tinted(a._tint)),i??=e.width||e.videoWidth,s??=e.height||e.videoHeight,"center"==a._imageMode&&(t-=.5*i,o-=.5*s);let p=e._pixelDensity||1;h?h*=p:h=u.width||u.videoWidth,d?d*=p:d=u.height||u.videoHeight,r.drawImage(u,l*p,c*p,h,d,t,o,i,s),function(){if(!e._q5||!a._tint)return;let t=e.ctx;t.save(),t.resetTransform(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(v.canvas,0,0),t.restore()}()},a._incrementPreload=()=>o++,a._decrementPreload=()=>o--,a.loadImage=function(e,t,n){o++;let i=[...arguments].at(-1);n="object"!=typeof i||i;let r=a.createImage(1,1,n.alpha),s=r.ctx;if(Q5._nodejs&&global.CairoCanvas)CairoCanvas.loadImage(e).then((e=>{r.width=s.canvas.width=e.width,r.height=s.canvas.height=e.height,s.drawImage(e,0,0),o--,t&&t(r)})).catch((e=>{throw o--,e}));else{let a=new window.Image;a.src=e,a.crossOrigin="Anonymous",a._pixelDensity=1,a.onload=()=>{r.width=s.canvas.width=a.naturalWidth,r.height=s.canvas.height=a.naturalHeight,s.drawImage(a,0,0),o--,t&&t(r)},a.onerror=e=>{throw o--,e}}return r},a._clearTemporaryBuffers=()=>{f=null,v=null,x=null},a.loadFont=(e,t)=>{o++;let a=e.split("/"),n=a[a.length-1].split(".")[0].replace(" ",""),i=new FontFace(n,"url("+e+")");return document.fonts.add(i),i.load().then((()=>{o--,t&&t(n)})),n},a.textFont=e=>a._textFont=e,a.textSize=e=>{if(void 0===e)return a._textSize;a._textSize=e,a._leadingSet||(a._textLeading=1.25*e,a._textLeadDiff=a._textLeading-e)},a.textLeading=e=>{if(void 0===e)return a._textLeading;a._textLeading=e,a._textLeadDiff=e-a._textSize,a._leadingSet=!0},a.textStyle=e=>a._textStyle=e,a.textAlign=(e,t)=>{r.textAlign=e,t&&(r.textBaseline=t==a.CENTER?"middle":t)},a.textWidth=e=>(r.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,r.measureText(e).width),a.textAscent=e=>(r.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,r.measureText(e).actualBoundingBoxAscent),a.textDescent=e=>(r.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`,r.measureText(e).actualBoundingBoxDescent),a._textCache=!0,a._TimedCache=class extends Map{constructor(){super(),this.maxSize=500}set(e,t){t.lastAccessed=Date.now(),super.set(e,t),this.size>this.maxSize&&this.gc()}get(e){const t=super.get(e);return t&&(t.lastAccessed=Date.now()),t}gc(){let e,t=1/0,a=0;for(const[o,n]of this.entries())n.lastAccessed<t&&(t=n.lastAccessed,e=a),a++;a=e;for(const t of this.keys()){if(0==a){e=t;break}a--}this.delete(e)}},a._tic=new a._TimedCache,a.textCache=(e,t)=>(t&&(a._tic.maxSize=t),void 0!==e&&(a._textCache=e),a._textCache),a._genTextImageKey=(e,t,o)=>e.slice(0,200)+a._textStyle+a._textSize+a._textFont+(a._doFill?r.fillStyle:"")+"_"+(a._doStroke&&a._strokeSet?r.lineWidth+r.strokeStyle+"_":"")+(t||"")+(o?"x"+o:""),a.createTextImage=(e,t,o)=>{let n=a._textCache;a._textCache=!0,a._genTextImage=!0,a.text(e,0,0,t,o),a._genTextImage=!1;let i=a._genTextImageKey(e,t,o);return a._textCache=n,a._tic.get(i)},a.text=(e,t,o,n,i)=>{if(void 0===e)return;if(e=e.toString(),!a._doFill&&!a._doStroke)return;let s,l,c,h,d,u,g,_,p=1,m=r.getTransform(),f=a._genTextImage||a._textCache&&(0!=m.b||0!=m.c);if(f){if(h=a._genTextImageKey(e,n,i),l=a._tic.get(h),l&&!a._genTextImage)return void a.textImage(l,t,o);c=a.createGraphics.call(a,1,1),s=c.ctx,p=a._pixelDensity}else s=r,d=t,u=o;s.font=`${a._textStyle} ${a._textSize}px ${a._textFont}`;let v=e.split("\n");if(f){d=0,u=a._textLeading*v.length;let t=s.measureText(" ");g=t.fontBoundingBoxAscent,_=t.fontBoundingBoxDescent,i??=u+_,c.resizeCanvas(Math.ceil(s.measureText(e).width),Math.ceil(i)),s.fillStyle=r.fillStyle,s.strokeStyle=r.strokeStyle,s.lineWidth=r.lineWidth}let x=s.fillStyle;a._fillSet||(s.fillStyle="black");for(let e=0;e<v.length&&(a._doStroke&&a._strokeSet&&s.strokeText(v[e],d,u),a._doFill&&s.fillText(v[e],d,u),u+=a._textLeading,!(u>i));e++);a._fillSet||(s.fillStyle=x),f&&(l=c.get(),l._ascent=g,l._descent=_,a._tic.set(h,l),a._genTextImage||a.textImage(l,t,o))},a.textImage=(e,t,o)=>{let n=a._imageMode;a._imageMode="corner","center"==r.textAlign?t-=.5*e.width:"right"==r.textAlign&&(t-=e.width),"alphabetic"==r.textBaseline&&(o-=a._textLeading),"middle"==r.textBaseline?o-=e._descent+.5*e._ascent+a._textLeadDiff:"bottom"==r.textBaseline?o-=e._ascent+e._descent+a._textLeadDiff:"top"==r.textBaseline&&(o-=e._descent+a._textLeadDiff),a.image(e,t,o),a._imageMode=n};var D,I=4095,E=4,T=.5,A=e=>.5*(1-Math.cos(e*Math.PI));a.noise=(e=0,t=0,a)=>{if(null==D){D=new Array(4096);for(var o=0;o<4096;o++)D[o]=Math.random()}e<0&&(e=-e),t<0&&(t=-t),a<0&&(a=-a);for(var n,i,r,s,l,c=Math.floor(e),h=Math.floor(t),d=Math.floor(a),u=e-c,g=t-h,_=a-d,p=0,m=.5,f=0;f<E;f++){var v=c+(h<<4)+(d<<8);n=A(u),i=A(g),r=D[v&I],r+=n*(D[v+1&I]-r),s=D[v+16&I],r+=i*((s+=n*(D[v+16+1&I]-s))-r),s=D[(v+=256)&I],s+=n*(D[v+1&I]-s),l=D[v+16&I],s+=i*((l+=n*(D[v+16+1&I]-l))-s),p+=(r+=A(_)*(s-r))*m,m*=T,c<<=1,h<<=1,d<<=1,(u*=2)>=1&&(c++,u--),(g*=2)>=1&&(h++,g--),(_*=2)>=1&&(d++,_--)}return p},a.noiseDetail=(e,t)=>{e>0&&(E=e),t>0&&(T=t)};const O=()=>{let e,t,a=4294967295;return{setSeed(o){e=t=(o??Math.random()*a)>>>0},getSeed:()=>t,rand:()=>(e^=e<<17,e^=e>>13,e^=e<<5,(e>>>0)/a)}};let P=O();P.setSeed(),a.noiseSeed=e=>{let t=void 0===e?4294967295*Math.random():e;D||(D=new Float32Array(4096));for(var a=0;a<4096;a++)t^=t<<17,t^=t>>13,t^=t<<5,D[a]=(t>>>0)/4294967295},a.randomSeed=e=>P.setSeed(e),a.random=(e,t)=>void 0===e?P.rand():"number"==typeof e?void 0!==t?P.rand()*(t-e)+e:P.rand()*e:e[Math.trunc(e.length*P.rand())],a.randomGenerator=e=>{e==a.LCG?P=(()=>{const e=4294967296;let t,a;return{setSeed(o){a=t=(o??Math.random()*e)>>>0},getSeed:()=>t,rand:()=>(a=(1664525*a+1013904223)%e,a/e)}})():e==a.SHR3&&(P=O()),P.setSeed()};var k=new function(){var e,t,a,o=new Array(128),n=new Array(256),i=new Array(128),r=new Array(128),s=new Array(256),l=new Array(256),c=()=>4294967296*P.rand()-2147483648,h=()=>.5+2.328306e-10*(c()|0),d=()=>{for(var t,n,s,l,d=3.44262;;){if(t=a*i[e],0==e){do{s=h(),l=h(),t=.2904764*-Math.log(s),n=-Math.log(l)}while(n+n<t*t);return a>0?d+t:-d-t}if(r[e]+h()*(r[e-1]-r[e])<Math.exp(-.5*t*t))return t;if(a=c(),e=127&a,Math.abs(a)<o[e])return a*i[e]}},u=()=>{for(var a;;){if(0==e)return 7.69711-Math.log(h());if(a=t*s[e],l[e]+h()*(l[e-1]-l[e])<Math.exp(-a))return a;if((t=c())<n[e=255&t])return t*s[e]}};this.SHR3=c,this.UNI=h,this.RNOR=()=>(a=c(),e=127&a,Math.abs(a)<o[e]?a*i[e]:d()),this.REXP=()=>(t=c()>>>0)<o[e=255&t]?t*s[e]:u(),this.zigset=()=>{var e,t,a=2147483648,c=4294967296,h=3.442619855899,d=h,u=.00991256303526217,g=7.697117470131487,_=g,p=.003949659822581572;for(e=u/Math.exp(-.5*h*h),o[0]=Math.floor(h/e*a),o[1]=0,i[0]=e/a,i[127]=h/a,r[0]=1,r[127]=Math.exp(-.5*h*h),t=126;t>=1;t--)h=Math.sqrt(-2*Math.log(u/h+Math.exp(-.5*h*h))),o[t+1]=Math.floor(h/d*a),d=h,r[t]=Math.exp(-.5*h*h),i[t]=h/a;for(e=p/Math.exp(-g),n[0]=Math.floor(g/e*c),n[1]=0,s[0]=e/c,s[255]=g/c,l[0]=1,l[255]=Math.exp(-g),t=254;t>=1;t--)g=-Math.log(p/g+Math.exp(-g)),n[t+1]=Math.floor(g/_*c),_=g,l[t]=Math.exp(-g),s[t]=g/c}};function z(e){let t=e||performance.now();if(a._lastFrameTime??=t-a._targetFrameDuration,a._loop)u=L(z);else if(a.frameCount&&!a._redraw)return;if(u&&a.frameCount){if(t-a._lastFrameTime<a._targetFrameDuration-1)return}a.deltaTime=t-a._lastFrameTime,a._frameRate=1e3/a.deltaTime,a.frameCount++,a._shouldResize&&(a.windowResized(),a._shouldResize=!1);let o=performance.now();for(let e of Q5.prototype._methods.pre)e.call(a);b(),g=!0,r&&r.save();try{a.draw()}catch(e){console.error(e)}for(let e of Q5.prototype._methods.post)e.call(a);r&&(r.restore(),a.resetMatrix()),a.pmouseX=a.mouseX,a.pmouseY=a.mouseY,a._lastFrameTime=t;let n=performance.now();a._fps=Math.round(1e3/(n-o))}function Q(e){const t=a.canvas.getBoundingClientRect(),o=a.canvas.scrollWidth/a.width||1,n=a.canvas.scrollHeight/a.height||1;return{x:(e.clientX-t.left)/o,y:(e.clientY-t.top)/n,id:e.identifier}}k.hasInit=!1,a.randomGaussian=(e,t)=>(k.hasInit||(k.zigset(),k.hasInit=!0),k.RNOR()*t+e),a.randomExponential=()=>(k.hasInit||(k.zigset(),k.hasInit=!0),k.REXP()),a.Element=function(e){this.elt=e},a._elements=[],a.createCapture=e=>{var t=document.createElement("video");return t.playsinline="playsinline",t.autoplay="autoplay",navigator.mediaDevices.getUserMedia(e).then((e=>{t.srcObject=e})),t.style.position="absolute",t.style.opacity=1e-5,t.style.zIndex=-1e3,document.body.append(t),t},a.print=console.log,a.describe=()=>{},a.noLoop=()=>{a._loop=!1,u=null},a.loop=()=>{a._loop=!0,null==u&&z()},a.redraw=(e=1)=>{a._redraw=!0;for(let t=0;t<e;t++)z();a._redraw=!1},a.remove=()=>{a.noLoop(),a.canvas.remove()},a.frameRate=e=>(e&&(a._targetFrameRate=e,a._targetFrameDuration=1e3/e),a._frameRate),a.getTargetFrameRate=()=>a._targetFrameRate,a.getFPS=()=>a._fps,"object"==typeof localStorage&&(a.storeItem=localStorage.setItem,a.getItem=localStorage.getItem,a.removeItem=localStorage.removeItem,a.clearStorage=localStorage.clear),a._updateMouse=e=>{if(e.changedTouches)return;let t=a.canvas.getBoundingClientRect(),o=a.canvas.scrollWidth/a.width||1,n=a.canvas.scrollHeight/a.height||1;a.mouseX=(e.clientX-t.left)/o,a.mouseY=(e.clientY-t.top)/n},a._onmousedown=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a.mouseButton=[a.LEFT,a.CENTER,a.RIGHT][e.button],a.mousePressed(e)},a._onmousemove=e=>{a._updateMouse(e),a.mouseIsPressed?a.mouseDragged(e):a.mouseMoved(e)},a._onmouseup=e=>{a._updateMouse(e),a.mouseIsPressed=!1,a.mouseReleased(e)},a._onclick=e=>{a._updateMouse(e),a.mouseIsPressed=!0,a.mouseClicked(e),a.mouseIsPressed=!1},a.cursor=(e,t,o)=>{let n="";e.includes(".")&&(e=`url("${e}")`,n=", auto"),void 0!==t&&(e+=" "+t+" "+o),a.canvas.style.cursor=e+n},a.noCursor=()=>{a.canvas.style.cursor="none"},a._onkeydown=e=>{e.repeat||(a.keyIsPressed=!0,a.key=e.key,a.keyCode=e.keyCode,p[a.keyCode]=!0,a.keyPressed(e),1==e.key.length&&a.keyTyped(e))},a._onkeyup=e=>{a.keyIsPressed=!1,a.key=e.key,a.keyCode=e.keyCode,p[a.keyCode]=!1,a.keyReleased(e)},a._ontouchstart=e=>{a.touches=[...e.touches].map(Q),a._isTouchAware||(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseIsPressed=!0,a.mouseButton=a.LEFT,a.mousePressed(e)||e.preventDefault()),a.touchStarted(e)||e.preventDefault(),"running"!=a.getAudioContext()?.state&&a.userStartAudio()},a._ontouchmove=e=>{a.touches=[...e.touches].map(Q),a._isTouchAware||(a.mouseX=a.touches[0].x,a.mouseY=a.touches[0].y,a.mouseDragged(e)||e.preventDefault()),a.touchMoved(e)||e.preventDefault()},a._ontouchend=e=>{a.touches=[...e.touches].map(Q),a._isTouchAware||a.touches.length||(a.mouseIsPressed=!1,a.mouseReleased(e)||e.preventDefault()),a.touchEnded(e)||e.preventDefault()},"graphics"!=e&&(a.keyIsDown=e=>!!p[e],a.canvas.onmousedown=e=>a._onmousedown(e),a.canvas.onmouseup=e=>a._onmouseup(e),a.canvas.onclick=e=>a._onclick(e),a.canvas.ontouchstart=e=>a._ontouchstart(e),a.canvas.ontouchmove=e=>a._ontouchmove(e),a.canvas.ontouchcancel=a.canvas.ontouchend=e=>a._ontouchend(e)),a.hasSensorPermission=!window.DeviceOrientationEvent&&!window.DeviceMotionEvent||!(DeviceOrientationEvent.requestPermission||DeviceMotionEvent.requestPermission),a.requestSensorPermissions=()=>{DeviceOrientationEvent.requestPermission&&DeviceOrientationEvent.requestPermission().then((e=>{"granted"==e&&DeviceMotionEvent.requestPermission&&DeviceMotionEvent.requestPermission().then((e=>{"granted"==e&&(a.hasSensorPermission=!0)})).catch(alert)})).catch(alert)};window.ondeviceorientation=e=>{a.pRotationX=a.rotationX,a.pRotationY=a.rotationY,a.pRotationZ=a.rotationZ,a.pRelRotationX=a.relRotationX,a.pRelRotationY=a.relRotationY,a.pRelRotationZ=a.relRotationZ,a.rotationX=e.beta*(Math.PI/180),a.rotationY=e.gamma*(Math.PI/180),a.rotationZ=e.alpha*(Math.PI/180),a.relRotationX=[-a.rotationY,-a.rotationX,a.rotationY][Math.trunc(window.orientation/90)+1],a.relRotationY=[-a.rotationX,a.rotationY,a.rotationX][Math.trunc(window.orientation/90)+1],a.relRotationZ=a.rotationZ},window.ondevicemotion=e=>{if(a.pAccelerationX=a.accelerationX,a.pAccelerationY=a.accelerationY,a.pAccelerationZ=a.accelerationZ,!e.acceleration){let i=((e,t)=>[(e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]),(e[4]*t[0]+e[5]*t[1]+e[6]*t[2]+e[7])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]),(e[8]*t[0]+e[9]*t[1]+e[10]*t[2]+e[11])/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15])])((n=a.rotationY,t=[a.cos(n),0,a.sin(n),0,0,1,0,0,-a.sin(n),0,a.cos(n),0,0,0,0,1],o=(e=>[1,0,0,0,0,a.cos(e),-a.sin(e),0,0,a.sin(e),a.cos(e),0,0,0,0,1])(a.rotationX),[t[0]*o[0]+t[1]*o[4]+t[2]*o[8]+t[3]*o[12],t[0]*o[1]+t[1]*o[5]+t[2]*o[9]+t[3]*o[13],t[0]*o[2]+t[1]*o[6]+t[2]*o[10]+t[3]*o[14],t[0]*o[3]+t[1]*o[7]+t[2]*o[11]+t[3]*o[15],t[4]*o[0]+t[5]*o[4]+t[6]*o[8]+t[7]*o[12],t[4]*o[1]+t[5]*o[5]+t[6]*o[9]+t[7]*o[13],t[4]*o[2]+t[5]*o[6]+t[6]*o[10]+t[7]*o[14],t[4]*o[3]+t[5]*o[7]+t[6]*o[11]+t[7]*o[15],t[8]*o[0]+t[9]*o[4]+t[10]*o[8]+t[11]*o[12],t[8]*o[1]+t[9]*o[5]+t[10]*o[9]+t[11]*o[13],t[8]*o[2]+t[9]*o[6]+t[10]*o[10]+t[11]*o[14],t[8]*o[3]+t[9]*o[7]+t[10]*o[11]+t[11]*o[15],t[12]*o[0]+t[13]*o[4]+t[14]*o[8]+t[15]*o[12],t[12]*o[1]+t[13]*o[5]+t[14]*o[9]+t[15]*o[13],t[12]*o[2]+t[13]*o[6]+t[14]*o[10]+t[15]*o[14],t[12]*o[3]+t[13]*o[7]+t[14]*o[11]+t[15]*o[15]]),[0,0,-9.80665]);a.accelerationX=e.accelerationIncludingGravity.x+i[0],a.accelerationY=e.accelerationIncludingGravity.y+i[1],a.accelerationZ=e.accelerationIncludingGravity.z-i[2]}var t,o,n},a.year=()=>(new Date).getFullYear(),a.day=()=>(new Date).getDay(),a.hour=()=>(new Date).getHours(),a.minute=()=>(new Date).getMinutes(),a.second=()=>(new Date).getSeconds(),a.millis=()=>performance.now()-m,a._loadFile=(e,t,a)=>{o++;let n={};return fetch(e).then((e=>"json"==a?e.json():"text"==a?e.text():void 0)).then((e=>{o--,Object.assign(n,e),t&&t(e)})),n},a.loadStrings=(e,t)=>a._loadFile(e,t,"text"),a.loadJSON=(e,t)=>a._loadFile(e,t,"json"),a.loadSound=(e,t)=>{o++;let a=new Audio(e);return a.addEventListener("canplaythrough",(()=>{o--,t&&t(a)})),a.load(),a.setVolume=e=>a.volume=e,a.setLoop=e=>a.loop=e,a},a.getAudioContext=()=>a.audioContext,a.userStartAudio=()=>(a.audioContext??=new window.AudioContext,a.audioContext.resume()),"global"==e&&(Object.assign(Q5,a),delete Q5.Q5),Q5.Image??=_Q5Image;for(let $ of Q5.prototype._methods.init)$.call(a);for(let[G,V]of Object.entries(Q5.prototype))"_"!=G[0]&&"function"==typeof a[G]&&(a[G]=V.bind(a));if("global"==e){let Y=Object.getOwnPropertyNames(a),j=Q5._nodejs?global:window;for(let H of Y)"function"==typeof a[H]?j[H]=a[H]:Object.defineProperty(j,H,{get:()=>a[H],set:e=>a[H]=e})}if("function"==typeof e&&e(a),"image"==e||"graphics"==e)return;let L=window.requestAnimationFrame||function(e){const t=a._lastFrameTime+a._targetFrameDuration;return setTimeout((()=>{e(t)}),t-performance.now())},F="global"==e?Q5._nodejs?global:window:a,N=F.preload,q=["setup","draw","preload","mouseMoved","mousePressed","mouseReleased","mouseDragged","mouseClicked","keyPressed","keyReleased","keyTyped","touchStarted","touchMoved","touchEnded","windowResized"];for(let U of q)F[U]?a._isGlobal&&(a[U]=F[U]):a[U]=()=>{};function B(){if(a._startDone=!0,o>0)return L(B);m=performance.now(),a.setup(),a.frameCount||(null===r&&a.createCanvas(100,100),a._setupDone=!0,r&&a.resetMatrix(),L(z))}a._isTouchAware=a.touchStarted||a.touchMoved||a.mouseReleased,window&&"graphics"!=e&&(window.addEventListener("mousemove",(e=>a._onmousemove(e)),!1),window.addEventListener("keydown",(e=>a._onkeydown(e)),!1),window.addEventListener("keyup",(e=>a._onkeyup(e)),!1)),(a.setup||a.draw)&&(a._startDone=!1,arguments.length&&"namespace"!=e||N?(a.preload(),B()):(F.preload=a.preload=()=>{a._startDone||B()},setTimeout(a.preload,32)))}Q5.Color=class{constructor(){this._q5Color=!0}},Q5.ColorOKLCH=class extends Q5.Color{constructor(e,t,a,o){super(),this.l=e,this.c=t,this.h=a,this.a=o??1}toString(){return`color(oklch ${this.l} ${this.c} ${this.h} / ${this.a})`}},Q5.ColorRGBA=class extends Q5.Color{constructor(e,t,a,o){super(),this.r=e,this.g=t,this.b=a,this.a=o??255}setRed(e){this.r=e}setGreen(e){this.g=e}setBlue(e){this.b=e}setAlpha(e){this.a=e}get levels(){return[this.r,this.g,this.b,this.a]}toString(){return`rgb(${this.r} ${this.g} ${this.b} / ${this.a/255})`}},Q5.ColorRGBA_P3=class extends Q5.ColorRGBA{constructor(e,t,a,o){super(e,t,a,o),this._edited=!0}get r(){return this._r}set r(e){this._r=e,this._edited=!0}get g(){return this._g}set g(e){this._g=e,this._edited=!0}get b(){return this._b}set b(e){this._b=e,this._edited=!0}get a(){return this._a}set a(e){this._a=e,this._edited=!0}toString(){if(this._edited){let e=(this._r/255).toFixed(3),t=(this._g/255).toFixed(3),a=(this._b/255).toFixed(3),o=(this._a/255).toFixed(3);this._css=`color(display-p3 ${e} ${t} ${a} / ${o})`,this._edited=!1}return this._css}},Q5.Vector=class{constructor(e,t,a,o){this.x=e||0,this.y=t||0,this.z=a||0,this._$=o||window,this._cn=null,this._cnsq=null}set(e,t,a){this.x=e||0,this.y=t||0,this.z=a||0}copy(){return new Q5.Vector(this.x,this.y,this.z)}_arg2v(e,t,a){return void 0!==e.x?e:void 0!==t?{x:e,y:t,z:a||0}:{x:e,y:e,z:e}}_calcNorm(){this._cnsq=this.x*this.x+this.y*this.y+this.z*this.z,this._cn=Math.sqrt(this._cnsq)}add(){let e=this._arg2v(...arguments);return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}rem(){let e=this._arg2v(...arguments);return this.x%=e.x,this.y%=e.y,this.z%=e.z,this}sub(){let e=this._arg2v(...arguments);return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}mult(){let e=this._arg2v(...arguments);return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}div(){let e=this._arg2v(...arguments);return e.x?this.x/=e.x:this.x=0,e.y?this.y/=e.y:this.y=0,e.z?this.z/=e.z:this.z=0,this}mag(){return this._calcNorm(),this._cn}magSq(){return this._calcNorm(),this._cnsq}dot(){let e=this._arg2v(...arguments);return this.x*e.x+this.y*e.y+this.z*e.z}dist(){let e=this._arg2v(...arguments),t=this.x-e.x,a=this.y-e.y,o=this.z-e.z;return Math.sqrt(t*t+a*a+o*o)}cross(){let e=this._arg2v(...arguments),t=this.y*e.z-this.z*e.y,a=this.z*e.x-this.x*e.z,o=this.x*e.y-this.y*e.x;return this.x=t,this.y=a,this.z=o,this}normalize(){this._calcNorm();let e=this._cn;return 0!=e&&(this.x/=e,this.y/=e,this.z/=e),this._cn=1,this._cnsq=1,this}limit(e){this._calcNorm();let t=this._cn;if(t>e){let a=e/t;this.x*=a,this.y*=a,this.z*=a,this._cn=e,this._cnsq=e*e}return this}setMag(e){this._calcNorm();let t=e/this._cn;return this.x*=t,this.y*=t,this.z*=t,this._cn=e,this._cnsq=e*e,this}heading(){return this._$.atan2(this.y,this.x)}rotate(e){let t=this._$.cos(e),a=this._$.sin(e),o=this.x*t-this.y*a,n=this.x*a+this.y*t;return this.x=o,this.y=n,this}angleBetween(){let e=this._arg2v(...arguments),t=Q5.Vector.cross(this,e);return this._$.atan2(t.mag(),this.dot(e))*Math.sign(t.z||1)}lerp(){let e=[...arguments],t=this._arg2v(...e.slice(0,-1)),a=e[e.length-1];return this.x+=(t.x-this.x)*a,this.y+=(t.y-this.y)*a,this.z+=(t.z-this.z)*a,this}reflect(e){return e.normalize(),this.sub(e.mult(2*this.dot(e)))}array(){return[this.x,this.y,this.z]}equals(e,t){return t??=Number.EPSILON||0,Math.abs(e.x-this.x)<t&&Math.abs(e.y-this.y)<t&&Math.abs(e.z-this.z)<t}fromAngle(e,t){return void 0===t&&(t=1),this._cn=t,this._cnsq=t*t,this.x=t*this._$.cos(e),this.y=t*this._$.sin(e),this.z=0,this}fromAngles(e,t,a){void 0===a&&(a=1),this._cn=a,this._cnsq=a*a;const o=this._$.cos(t),n=this._$.sin(t),i=this._$.cos(e),r=this._$.sin(e);return this.x=a*r*n,this.y=-a*i,this.z=a*r*o,this}random2D(){return this._cn=this._cnsq=1,this.fromAngle(Math.random()*Math.PI*2)}random3D(){return this._cn=this._cnsq=1,this.fromAngles(Math.random()*Math.PI*2,Math.random()*Math.PI*2)}toString(){return`[${this.x}, ${this.y}, ${this.z}]`}},Q5.Vector.add=(e,t)=>e.copy().add(t),Q5.Vector.cross=(e,t)=>e.copy().cross(t),Q5.Vector.dist=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y,e.z-t.z),Q5.Vector.div=(e,t)=>e.copy().div(t),Q5.Vector.dot=(e,t)=>e.copy().dot(t),Q5.Vector.equals=(e,t,a)=>e.equals(t,a),Q5.Vector.lerp=(e,t,a)=>e.copy().lerp(t,a),Q5.Vector.limit=(e,t)=>e.copy().limit(t),Q5.Vector.heading=e=>this._$.atan2(e.y,e.x),Q5.Vector.magSq=e=>e.x*e.x+e.y*e.y+e.z*e.z,Q5.Vector.mag=e=>Math.sqrt(Q5.Vector.magSq(e)),Q5.Vector.mult=(e,t)=>e.copy().mult(t),Q5.Vector.normalize=e=>e.copy().normalize(),Q5.Vector.rem=(e,t)=>e.copy().rem(t),Q5.Vector.sub=(e,t)=>e.copy().sub(t);for(let e of["fromAngle","fromAngles","random2D","random3D"])Q5.Vector[e]=(t,a,o)=>(new Q5.Vector)[e](t,a,o);class _Q5Image extends Q5{constructor(e,t,a){super("image"),delete this.createCanvas,a??={},a.alpha??=!0,this._createCanvas(e,t,"2d",a),this._loop=!1}get w(){return this.width}get h(){return this.height}}"object"!=typeof window&&(window=0),Q5._nodejs="object"==typeof process,Q5.canvasOptions={alpha:!1,desynchronized:!1,colorSpace:"display-p3"},window.matchMedia&&matchMedia("(dynamic-range: high) and (color-gamut: p3)").matches?Q5.supportsHDR=!0:Q5.canvasOptions.colorSpace="srgb",Q5._instanceCount=0,Q5._friendlyError=(e,t)=>{throw t+": "+e},Q5._validateParameters=()=>!0,Q5.prototype._methods={init:[],pre:[],post:[],remove:[]},Q5.prototype.registerMethod=(e,t)=>Q5.prototype._methods[e].push(t),Q5.prototype.registerPreloadMethod=(e,t)=>Q5.prototype[e]=t[e],"object"==typeof module?(global.p5??=Q5,module.exports=global.Q5=Q5):(window.p5??=Q5,window.Q5=Q5),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{Q5._hasGlobal||new Q5("auto")}));