Mix Youtube videos like a true DJ!
https://dj.tflcl.xyz
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
33 KiB
22 lines
33 KiB
/** |
|
* Minified by jsDelivr using Terser v5.10.0. |
|
* Original file: /npm/p5.js-svg@1.3.3/dist/p5.svg.cjs.js |
|
* |
|
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files |
|
*/ |
|
"use strict";function toString(t){return t?"string"==typeof t?t:t+"":t}class ImageUtils{async svg2canvas(t,e,r){const i=await new Promise((e=>{var r=new Image;r.onload=function(){e(r)},r.src=t}));var n=document.createElement("canvas");n.width=e,n.height=r;return n.getContext("2d").drawImage(i,0,0),n}toDataURL(t,e,r,i,n,a){var s=(new XMLSerializer).serializeToString(t);if(document.documentMode){/xmlns="http:\/\/www\.w3\.org\/2000\/svg".+xmlns="http:\/\/www\.w3\.org\/2000\/svg/gi.test(s)&&(s=s.replace('xmlns="http://www.w3.org/2000/svg','xmlns:xlink="http://www.w3.org/1999/xlink'))}a||(a={});var o="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(s);if("image/svg+xml"===i||!i)return a.async?Promise.resolve(o):o;if("image/jpeg"===i||"image/png"===i){if(!a.async)throw new Error("svgcanvas: options.async must be set to true if type is image/jpeg | image/png");return(async()=>{const t=await this.svg2canvas(o,e,r),a=t.toDataURL(i,n);return t.remove(),a})()}throw new Error("svgcanvas: Unknown type for toDataURL, please use image/jpeg | image/png | image/svg+xml.")}getImageData(t,e,r,i,n,a,s,o){if(o||(o={}),!o.async)throw new Error("svgcanvas: options.async must be set to true for getImageData");const l=this.toDataURL(t,e,r,"image/svg+xml");return(async()=>{const t=await this.svg2canvas(l,e,r),o=t.getContext("2d").getImageData(i,n,a,s);return t.remove(),o})()}}const utils=new ImageUtils; |
|
/*!! |
|
* SVGCanvas v2.0.3 |
|
* Draw on SVG using Canvas's 2D Context API. |
|
* |
|
* Licensed under the MIT license: |
|
* http://www.opensource.org/licenses/mit-license.php |
|
* |
|
* Author: |
|
* Kerry Liu |
|
* Zeno Zeng |
|
* |
|
* Copyright (c) 2014 Gliffy Inc. |
|
* Copyright (c) 2021 Zeno Zeng |
|
*/var Context=function(){var t,e,r,i,n;function a(t,e){var r,i=Object.keys(e);for(r=0;r<i.length;r++)t=t.replace(new RegExp("\\{"+i[r]+"\\}","gi"),e[i[r]]);return t}function s(t){var e,r,i;if(!t)throw new Error("cannot create a random attribute name for an undefined object");e="ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",r="";do{for(r="",i=0;i<12;i++)r+=e[Math.floor(Math.random()*e.length)]}while(t[r]);return r}function o(t){var e={alphabetic:"alphabetic",hanging:"hanging",top:"text-before-edge",bottom:"text-after-edge",middle:"central"};return e[t]||e.alphabetic}n=function(t,e){var r,i,n,a={};for(t=t.split(","),e=e||10,r=0;r<t.length;r+=2)i="&"+t[r+1]+";",n=parseInt(t[r],e),a[i]="&#"+n+";";return a["\\xa0"]=" ",a}("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32),t={strokeStyle:{svgAttr:"stroke",canvas:"#000000",svg:"none",apply:"stroke"},fillStyle:{svgAttr:"fill",canvas:"#000000",svg:null,apply:"fill"},lineCap:{svgAttr:"stroke-linecap",canvas:"butt",svg:"butt",apply:"stroke"},lineJoin:{svgAttr:"stroke-linejoin",canvas:"miter",svg:"miter",apply:"stroke"},miterLimit:{svgAttr:"stroke-miterlimit",canvas:10,svg:4,apply:"stroke"},lineWidth:{svgAttr:"stroke-width",canvas:1,svg:1,apply:"stroke"},globalAlpha:{svgAttr:"opacity",canvas:1,svg:1,apply:"fill stroke"},font:{canvas:"10px sans-serif"},shadowColor:{canvas:"#000000"},shadowOffsetX:{canvas:0},shadowOffsetY:{canvas:0},shadowBlur:{canvas:0},textAlign:{canvas:"start"},textBaseline:{canvas:"alphabetic"},lineDash:{svgAttr:"stroke-dasharray",canvas:[],svg:null,apply:"stroke"}},(r=function(t,e){this.__root=t,this.__ctx=e}).prototype.addColorStop=function(t,e){var r,i=this.__ctx.__createElement("stop");i.setAttribute("offset",t),-1!==toString(e).indexOf("rgba")?(r=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(e),i.setAttribute("stop-color",a("rgb({r},{g},{b})",{r:r[1],g:r[2],b:r[3]})),i.setAttribute("stop-opacity",r[4])):i.setAttribute("stop-color",toString(e)),this.__root.appendChild(i)},i=function(t,e){this.__root=t,this.__ctx=e},e=function(t){var r,i={width:500,height:500,enableMirroring:!1};if(arguments.length>1?((r=i).width=arguments[0],r.height=arguments[1]):r=t||i,!(this instanceof e))return new e(r);this.width=r.width||i.width,this.height=r.height||i.height,this.enableMirroring=void 0!==r.enableMirroring?r.enableMirroring:i.enableMirroring,this.canvas=this,this.__document=r.document||document,r.ctx?this.__ctx=r.ctx:(this.__canvas=this.__document.createElement("canvas"),this.__ctx=this.__canvas.getContext("2d")),this.__setDefaultStyles(),this.__styleStack=[this.__getStyleState()],this.__groupStack=[],this.__root=this.__document.createElementNS("http://www.w3.org/2000/svg","svg"),this.__root.setAttribute("version",1.1),this.__root.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.__root.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),this.__root.setAttribute("width",this.width),this.__root.setAttribute("height",this.height),this.__ids={},this.__defs=this.__document.createElementNS("http://www.w3.org/2000/svg","defs"),this.__root.appendChild(this.__defs),this.__currentElement=this.__document.createElementNS("http://www.w3.org/2000/svg","g"),this.__root.appendChild(this.__currentElement),this.resetTransform(),this.__options=r,this.__id=Math.random().toString(16).substring(2,8),this.__debug("new",t)},e.prototype.__debug=function(...t){this.__options.debug&&console.debug(`svgcanvas#${this.__id}:`,...t)},e.prototype.__createElement=function(t,e,r){void 0===e&&(e={});var i,n,a=this.__document.createElementNS("http://www.w3.org/2000/svg",t),s=Object.keys(e);for(r&&(a.setAttribute("fill","none"),a.setAttribute("stroke","none")),i=0;i<s.length;i++)n=s[i],a.setAttribute(n,e[n]);return a},e.prototype.__setDefaultStyles=function(){var e,r,i=Object.keys(t);for(e=0;e<i.length;e++)this[r=i[e]]=t[r].canvas},e.prototype.__applyStyleState=function(t){var e,r,i=Object.keys(t);for(e=0;e<i.length;e++)this[r=i[e]]=t[r]},e.prototype.__getStyleState=function(){var e,r,i={},n=Object.keys(t);for(e=0;e<n.length;e++)i[r=n[e]]=this[r];return i},e.prototype.__applyTransformation=function(t,e){const{a:r,b:i,c:n,d:a,e:s,f:o}=e||this.getTransform();t.setAttribute("transform",`matrix(${r} ${i} ${n} ${a} ${s} ${o})`)},e.prototype.__applyStyleToCurrentElement=function(e){var n=this.__currentElement,s=this.__currentElementsToStyle;s&&(n.setAttribute(e,""),n=s.element,s.children.forEach((function(t){t.setAttribute(e,"")})));var o,l,h,p,c,u,d,_=Object.keys(t);for(o=0;o<_.length;o++)if(l=t[_[o]],h=this[_[o]],l.apply)if(h instanceof i){if(h.__ctx)for(u=0;u<h.__ctx.__defs.childNodes.length;u++)c=(d=h.__ctx.__defs.childNodes[u]).getAttribute("id"),this.__ids[c]=c,this.__defs.appendChild(d);n.setAttribute(l.apply,a("url(#{id})",{id:h.__root.getAttribute("id")}))}else if(h instanceof r)n.setAttribute(l.apply,a("url(#{id})",{id:h.__root.getAttribute("id")}));else if(-1!==l.apply.indexOf(e)&&l.svg!==h)if("stroke"!==l.svgAttr&&"fill"!==l.svgAttr||-1===h.indexOf("rgba")){var f=l.svgAttr;if("globalAlpha"===_[o]&&(f=e+"-"+l.svgAttr,n.getAttribute(f)))continue;n.setAttribute(f,h)}else{p=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(h),n.setAttribute(l.svgAttr,a("rgb({r},{g},{b})",{r:p[1],g:p[2],b:p[3]}));var g=p[4],m=this.globalAlpha;null!=m&&(g*=m),n.setAttribute(l.svgAttr+"-opacity",g)}},e.prototype.__closestGroupOrSvg=function(t){return"g"===(t=t||this.__currentElement).nodeName||"svg"===t.nodeName?t:this.__closestGroupOrSvg(t.parentNode)},e.prototype.getSerializedSvg=function(t){var e,r,i,a,s,o=(new XMLSerializer).serializeToString(this.__root);if(/xmlns="http:\/\/www\.w3\.org\/2000\/svg".+xmlns="http:\/\/www\.w3\.org\/2000\/svg/gi.test(o)&&(o=o.replace('xmlns="http://www.w3.org/2000/svg','xmlns:xlink="http://www.w3.org/1999/xlink')),t)for(e=Object.keys(n),r=0;r<e.length;r++)i=e[r],a=n[i],(s=new RegExp(i,"gi")).test(o)&&(o=o.replace(s,a));return o},e.prototype.getSvg=function(){return this.__root},e.prototype.save=function(){var t=this.__createElement("g"),e=this.__closestGroupOrSvg();this.__groupStack.push(e),e.appendChild(t),this.__currentElement=t;const r=this.__getStyleState();this.__debug("save style",r),this.__styleStack.push(r),this.__transformMatrixStack||(this.__transformMatrixStack=[]),this.__transformMatrixStack.push(this.getTransform())},e.prototype.restore=function(){this.__currentElement=this.__groupStack.pop(),this.__currentElementsToStyle=null,this.__currentElement||(this.__currentElement=this.__root.childNodes[1]);var t=this.__styleStack.pop();this.__debug("restore style",t),this.__applyStyleState(t),this.__transformMatrixStack&&this.__transformMatrixStack.length>0&&this.setTransform(this.__transformMatrixStack.pop())},e.prototype.beginPath=function(){var t;this.__currentDefaultPath="",this.__currentPosition={},t=this.__createElement("path",{},!0),this.__closestGroupOrSvg().appendChild(t),this.__currentElement=t},e.prototype.__applyCurrentDefaultPath=function(){var t=this.__currentElement;"path"===t.nodeName?t.setAttribute("d",this.__currentDefaultPath):console.error("Attempted to apply path command to node",t.nodeName)},e.prototype.__addPathCommand=function(t){this.__currentDefaultPath+=" ",this.__currentDefaultPath+=t},e.prototype.moveTo=function(t,e){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.__currentPosition={x:t,y:e},this.__addPathCommand(a("M {x} {y}",{x:this.__matrixTransform(t,e).x,y:this.__matrixTransform(t,e).y}))},e.prototype.closePath=function(){this.__currentDefaultPath&&this.__addPathCommand("Z")},e.prototype.lineTo=function(t,e){this.__currentPosition={x:t,y:e},this.__currentDefaultPath.indexOf("M")>-1?this.__addPathCommand(a("L {x} {y}",{x:this.__matrixTransform(t,e).x,y:this.__matrixTransform(t,e).y})):this.__addPathCommand(a("M {x} {y}",{x:this.__matrixTransform(t,e).x,y:this.__matrixTransform(t,e).y}))},e.prototype.bezierCurveTo=function(t,e,r,i,n,s){this.__currentPosition={x:n,y:s},this.__addPathCommand(a("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",{cp1x:this.__matrixTransform(t,e).x,cp1y:this.__matrixTransform(t,e).y,cp2x:this.__matrixTransform(r,i).x,cp2y:this.__matrixTransform(r,i).y,x:this.__matrixTransform(n,s).x,y:this.__matrixTransform(n,s).y}))},e.prototype.quadraticCurveTo=function(t,e,r,i){this.__currentPosition={x:r,y:i},this.__addPathCommand(a("Q {cpx} {cpy} {x} {y}",{cpx:this.__matrixTransform(t,e).x,cpy:this.__matrixTransform(t,e).y,x:this.__matrixTransform(r,i).x,y:this.__matrixTransform(r,i).y}))};var l=function(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]};return e.prototype.arcTo=function(t,e,r,i,n){var a=this.__currentPosition&&this.__currentPosition.x,s=this.__currentPosition&&this.__currentPosition.y;if(void 0!==a&&void 0!==s){if(n<0)throw new Error("IndexSizeError: The radius provided ("+n+") is negative.");if(a===t&&s===e||t===r&&e===i||0===n)this.lineTo(t,e);else{var o=l([a-t,s-e]),h=l([r-t,i-e]);if(o[0]*h[1]!=o[1]*h[0]){var p=o[0]*h[0]+o[1]*h[1],c=Math.acos(Math.abs(p)),u=l([o[0]+h[0],o[1]+h[1]]),d=n/Math.sin(c/2),_=t+d*u[0],f=e+d*u[1],g=[-o[1],o[0]],m=[h[1],-h[0]],v=function(t){var e=t[0];return t[1]>=0?Math.acos(e):-Math.acos(e)},y=v(g),x=v(m);this.lineTo(_+g[0]*n,f+g[1]*n),this.arc(_,f,n,y,x)}else this.lineTo(t,e)}}},e.prototype.stroke=function(){"path"===this.__currentElement.nodeName&&this.__currentElement.setAttribute("paint-order","fill stroke markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("stroke")},e.prototype.fill=function(){"path"===this.__currentElement.nodeName&&this.__currentElement.setAttribute("paint-order","stroke fill markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("fill")},e.prototype.rect=function(t,e,r,i){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.moveTo(t,e),this.lineTo(t+r,e),this.lineTo(t+r,e+i),this.lineTo(t,e+i),this.lineTo(t,e),this.closePath()},e.prototype.fillRect=function(t,e,r,i){let{a:n,b:a,c:s,d:o,e:l,f:h}=this.getTransform();var p;JSON.stringify([n,a,s,o,l,h])===JSON.stringify([1,0,0,1,0,0])&&0===t&&0===e&&r===this.width&&i===this.height&&this.__clearCanvas(),p=this.__createElement("rect",{x:t,y:e,width:r,height:i},!0),this.__closestGroupOrSvg().appendChild(p),this.__currentElement=p,this.__applyTransformation(p),this.__applyStyleToCurrentElement("fill")},e.prototype.strokeRect=function(t,e,r,i){var n;n=this.__createElement("rect",{x:t,y:e,width:r,height:i},!0),this.__closestGroupOrSvg().appendChild(n),this.__currentElement=n,this.__applyTransformation(n),this.__applyStyleToCurrentElement("stroke")},e.prototype.__clearCanvas=function(){var t=this.__root.childNodes[1];this.__root.removeChild(t),this.__currentElement=this.__document.createElementNS("http://www.w3.org/2000/svg","g"),this.__root.appendChild(this.__currentElement),this.__groupStack=[]},e.prototype.clearRect=function(t,e,r,i){let{a:n,b:a,c:s,d:o,e:l,f:h}=this.getTransform();if(JSON.stringify([n,a,s,o,l,h])!==JSON.stringify([1,0,0,1,0,0])||0!==t||0!==e||r!==this.width||i!==this.height){var p,c=this.__closestGroupOrSvg();p=this.__createElement("rect",{x:t,y:e,width:r,height:i,fill:"#FFFFFF"},!0),this.__applyTransformation(p),c.appendChild(p)}else this.__clearCanvas()},e.prototype.createLinearGradient=function(t,e,i,n){var a=this.__createElement("linearGradient",{id:s(this.__ids),x1:t+"px",x2:i+"px",y1:e+"px",y2:n+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(a),new r(a,this)},e.prototype.createRadialGradient=function(t,e,i,n,a,o){var l=this.__createElement("radialGradient",{id:s(this.__ids),cx:n+"px",cy:a+"px",r:o+"px",fx:t+"px",fy:e+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(l),new r(l,this)},e.prototype.__parseFont=function(){var t=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-,\'\"\sa-z0-9]+?)\s*$/i.exec(this.font),e={style:t[1]||"normal",size:t[4]||"10px",family:t[6]||"sans-serif",weight:t[3]||"normal",decoration:t[2]||"normal",href:null};return"underline"===this.__fontUnderline&&(e.decoration="underline"),this.__fontHref&&(e.href=this.__fontHref),e},e.prototype.__wrapTextLink=function(t,e){if(t.href){var r=this.__createElement("a");return r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t.href),r.appendChild(e),r}return e},e.prototype.__applyText=function(t,e,r,i){var n,a,s=this.__parseFont(),l=this.__closestGroupOrSvg(),h=this.__createElement("text",{"font-family":s.family,"font-size":s.size,"font-style":s.style,"font-weight":s.weight,"text-decoration":s.decoration,x:e,y:r,"text-anchor":(n=this.textAlign,a={left:"start",right:"end",center:"middle",start:"start",end:"end"},a[n]||a.start),"dominant-baseline":o(this.textBaseline)},!0);h.appendChild(this.__document.createTextNode(t)),this.__currentElement=h,this.__applyTransformation(h),this.__applyStyleToCurrentElement(i),l.appendChild(this.__wrapTextLink(s,h))},e.prototype.fillText=function(t,e,r){this.__applyText(t,e,r,"fill")},e.prototype.strokeText=function(t,e,r){this.__applyText(t,e,r,"stroke")},e.prototype.measureText=function(t){return this.__ctx.font=this.font,this.__ctx.measureText(t)},e.prototype.arc=function(t,e,r,i,n,s){if(i!==n){(i%=2*Math.PI)===(n%=2*Math.PI)&&(n=(n+2*Math.PI-.001*(s?-1:1))%(2*Math.PI));var o=t+r*Math.cos(n),l=e+r*Math.sin(n),h=t+r*Math.cos(i),p=e+r*Math.sin(i),c=s?0:1,u=0,d=n-i;d<0&&(d+=2*Math.PI),u=s?d>Math.PI?0:1:d>Math.PI?1:0,this.lineTo(h,p),this.__addPathCommand(a("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:r,ry:r,xAxisRotation:0,largeArcFlag:u,sweepFlag:c,endX:this.__matrixTransform(o,l).x,endY:this.__matrixTransform(o,l).y})),this.__currentPosition={x:o,y:l}}},e.prototype.clip=function(){var t=this.__closestGroupOrSvg(),e=this.__createElement("clipPath"),r=s(this.__ids),i=this.__createElement("g");this.__applyCurrentDefaultPath(),t.removeChild(this.__currentElement),e.setAttribute("id",r),e.appendChild(this.__currentElement),this.__defs.appendChild(e),t.setAttribute("clip-path",a("url(#{id})",{id:r})),t.appendChild(i),this.__currentElement=i},e.prototype.drawImage=function(){var t,r,i,n,a,s,o,l,h,p,c,u,d,_=Array.prototype.slice.call(arguments),f=_[0],g=0,m=0;if(3===_.length)t=_[1],r=_[2],i=a=f.width,n=s=f.height;else if(5===_.length)t=_[1],r=_[2],i=_[3],n=_[4],a=f.width,s=f.height;else{if(9!==_.length)throw new Error("Invalid number of arguments passed to drawImage: "+arguments.length);g=_[1],m=_[2],a=_[3],s=_[4],t=_[5],r=_[6],i=_[7],n=_[8]}o=this.__closestGroupOrSvg();const v=this.getTransform().translate(t,r);if(f instanceof e){if((l=f.getSvg().cloneNode(!0)).childNodes&&l.childNodes.length>1){for(h=l.childNodes[0];h.childNodes.length;)d=h.childNodes[0].getAttribute("id"),this.__ids[d]=d,this.__defs.appendChild(h.childNodes[0]);(p=l.childNodes[1])&&(this.__applyTransformation(p,v),o.appendChild(p))}}else"CANVAS"!==f.nodeName&&"IMG"!==f.nodeName||((c=this.__createElement("image")).setAttribute("width",i),c.setAttribute("height",n),c.setAttribute("preserveAspectRatio","none"),(g||m||a!==f.width||s!==f.height)&&((u=this.__document.createElement("canvas")).width=i,u.height=n,u.getContext("2d").drawImage(f,g,m,a,s,0,0,i,n),f=u),this.__applyTransformation(c,v),c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===f.nodeName?f.toDataURL():f.getAttribute("src")),o.appendChild(c))},e.prototype.createPattern=function(t,r){var n,a=this.__document.createElementNS("http://www.w3.org/2000/svg","pattern"),o=s(this.__ids);return a.setAttribute("id",o),a.setAttribute("width",t.width),a.setAttribute("height",t.height),a.setAttribute("patternUnits","userSpaceOnUse"),"CANVAS"===t.nodeName||"IMG"===t.nodeName?((n=this.__document.createElementNS("http://www.w3.org/2000/svg","image")).setAttribute("width",t.width),n.setAttribute("height",t.height),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===t.nodeName?t.toDataURL():t.getAttribute("src")),a.appendChild(n),this.__defs.appendChild(a)):t instanceof e&&(a.appendChild(t.__root.childNodes[1]),this.__defs.appendChild(a)),new i(a,this)},e.prototype.setLineDash=function(t){t&&t.length>0?this.lineDash=t.join(","):this.lineDash=null},e.prototype.setTransform=function(t,e,r,i,n,a){t instanceof DOMMatrix?this.__transformMatrix=new DOMMatrix([t.a,t.b,t.c,t.d,t.e,t.f]):this.__transformMatrix=new DOMMatrix([t,e,r,i,n,a])},e.prototype.getTransform=function(){let{a:t,b:e,c:r,d:i,e:n,f:a}=this.__transformMatrix;return new DOMMatrix([t,e,r,i,n,a])},e.prototype.resetTransform=function(){this.setTransform(1,0,0,1,0,0)},e.prototype.scale=function(t,e){if(void 0===e&&(e=t),isNaN(t)||isNaN(e)||!isFinite(t)||!isFinite(e))return;let r=this.getTransform().scale(t,e);this.setTransform(r)},e.prototype.rotate=function(t){let e=this.getTransform().multiply(new DOMMatrix([Math.cos(t),Math.sin(t),-Math.sin(t),Math.cos(t),0,0]));this.setTransform(e)},e.prototype.translate=function(t,e){const r=this.getTransform().translate(t,e);this.setTransform(r)},e.prototype.transform=function(t,e,r,i,n,a){const s=this.getTransform().multiply(new DOMMatrix([t,e,r,i,n,a]));this.setTransform(s)},e.prototype.__matrixTransform=function(t,e){return new DOMPoint(t,e).matrixTransform(this.__transformMatrix)},e.prototype.getImageData=function(t,e,r,i,n){return utils.getImageData(this.getSvg(),this.width,this.height,t,e,r,i,n)},e.prototype.drawFocusRing=function(){},e.prototype.createImageData=function(){},e.prototype.putImageData=function(){},e.prototype.globalCompositeOperation=function(){},e}();function SVGCanvasElement(t){this.ctx=new Context(t),this.svg=this.ctx.__root;var e=this.svg,r=this,i=document.createElement("div");i.style.display="inline-block",i.appendChild(e),this.wrapper=i,Object.defineProperty(this,"className",{get:function(){return i.getAttribute("class")||""},set:function(t){return i.setAttribute("class",t)}}),["width","height"].forEach((function(t){Object.defineProperty(r,t,{get:function(){return 0|e.getAttribute(t)},set:function(n){if(!isNaN(n)&&void 0!==n)return r.ctx[t]=n,e.setAttribute(t,n),i[t]=n}})})),["style","id"].forEach((function(t){Object.defineProperty(r,t,{get:function(){return i[t]},set:function(e){if(void 0!==e)return i[t]=e}})})),["getBoundingClientRect"].forEach((function(t){r[t]=function(){return e[t]()}}))}SVGCanvasElement.prototype.getContext=function(t){if("2d"!==t)throw new Error("Unsupported type of context for SVGCanvas");return this.ctx},SVGCanvasElement.prototype.toObjectURL=function(){var t=(new XMLSerializer).serializeToString(this.svg),e=new Blob([t],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(e)},SVGCanvasElement.prototype.toDataURL=function(t,e,r){return utils.toDataURL(this.svg,this.width,this.height,t,e,r)},SVGCanvasElement.prototype.addEventListener=function(){return this.svg.addEventListener.apply(this.svg,arguments)},SVGCanvasElement.prototype.getElement=function(){return this.wrapper};var Element$1=SVGCanvasElement;const DEBUG=!1;function RendererSVG(t){function e(e,r,i){var n=new Element$1({debug:false}),a=n.svg,s=e.parentNode,o=e.id,l=e.className;s.replaceChild(n.getElement(),e),n.id=o,n.className=l,(e=n).parentNode={removeChild:function(t){if(t===e){var r=n.getElement();r.parentNode.removeChild(r)}}};const h=new Proxy(r,{get:function(t,e){return"_pixelDensity"===e?1:t[e]}});return t.Renderer2D.call(this,e,h,i),this.isSVG=!0,this.svg=a,this}e.prototype=Object.create(t.Renderer2D.prototype),e.prototype._applyDefaults=function(){t.Renderer2D.prototype._applyDefaults.call(this),this.drawingContext.lineWidth=1},e.prototype.resize=function(e,r){e&&r&&(this.width===e&&this.height===r||this.drawingContext.__clearCanvas(),t.Renderer2D.prototype.resize.call(this,e,r),this.svg.setAttribute("viewBox",[0,0,e,r].join(" ")))},e.prototype.appendChild=function(t){t&&t.elt&&(t=t.elt),this.drawingContext.__closestGroupOrSvg().appendChild(t)},e.prototype.image=function(e,r,i,n,a,s,o,l,h){if(!e)throw new Error("Invalid image: "+e);var p=e._renderer&&e._renderer.svg;(p=(p=p||e.elt&&e.elt.nodeName&&"svg"===e.elt.nodeName.toLowerCase()&&e.elt)||e.nodeName&&"svg"==e.nodeName.toLowerCase()&&e)?((p=p.cloneNode(!0)).setAttribute("width",l),p.setAttribute("height",h),p.setAttribute("x",s),p.setAttribute("y",o),(r||i||n||a)&&(n/=this._pInst._pixelDensity,a/=this._pInst._pixelDensity,p.setAttribute("viewBox",[r,i,n,a].join(", "))),this.appendChild(p)):t.Renderer2D.prototype.image.apply(this,arguments)},e.prototype.parent=function(){const e={elt:this.elt.getElement()};return t.Element.prototype.parent.apply(e,arguments)},e.prototype.loadPixels=async function(){const t=this._pixelsState,e=t._pixelDensity,r=this.width*e,i=this.height*e,n=await this.drawingContext.getImageData(0,0,r,i,{async:!0});t._setProperty("imageData",n),t._setProperty("pixels",n.data)},t.RendererSVG=e}var constants={SVG:"svg"};function Rendering(t){var e=t.Graphics;t.Graphics=function(r,i,n,a){const s=n===constants.SVG;if(e.apply(this,[r,i,s?t.P2D:n,a]),s){var o=this._renderer.elt;this._renderer=new t.RendererSVG(o,this,!1),o=this._renderer.elt,this.elt=o,this._renderer.resize(r,i),this._renderer._applyDefaults()}return this},t.Graphics.prototype=e.prototype;var r=t.prototype.createCanvas;t.prototype.createCanvas=function(e,i,n){var a=r.apply(this,arguments);if(n===constants.SVG){var s=a.canvas;this._setProperty("_renderer",new t.RendererSVG(s,this,!0)),this._isdefaultGraphics=!0,this._renderer.resize(e,i),this._renderer._applyDefaults()}return this._renderer},t.prototype.createGraphics=function(e,r,i){return new t.Graphics(e,r,i,this)}}function IO(t){t.prototype._makeSVGFrame=function(t){var e=t.filename||"untitled",r=t.extension;r=r||this._checkFileExtension(e,r)[1];var i=new RegExp("\\."+r+"$");e=e.replace(i,""),""===r&&(r="svg");var n={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpeg",svg:"image/svg+xml"}[r];if(!n)throw new Error("Fail to getFrame, invalid extension: "+r+", please use png | jpeg | jpg | svg.");!function(t,e,r){if(t=(new XMLSerializer).serializeToString(t),t="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(t),"image/svg+xml"!=e){var i=new Image,n=document.createElement("canvas"),a=n.getContext("2d");i.onload=function(){n.width=i.width,n.height=i.height,a.drawImage(i,0,0);var t=n.toDataURL(e);r(null,t)},i.src=t}else r(null,t)}(t.svg||this._renderer.svg,n,(function(i,a){a=a.replace(n,"image/octet-stream"),t.callback(i,{imageData:a,filename:e,ext:r})}))},t.prototype.saveSVG=function(){var e,r=arguments;(r=[r[0],r[1],r[2]])[0]instanceof t.Graphics&&(e=r[0]._renderer.svg,r.shift()),r[0]&&r[0].elt&&(e=r[0].elt,r.shift()),"object"==typeof r[0]&&(e=r[0],r.shift());var i=r[0],n=r[1],a=this;this._makeSVGFrame({svg:e,filename:i,extension:n,callback:function(t,e){a.downloadFile(e.imageData,e.filename,e.ext)}})};var e=t.prototype.saveFrames;t.prototype.saveFrames=function(r,i,n,a,s){var o=arguments;if(this._renderer.svg){n=n||3,n=t.prototype.constrain(n,0,15),n*=1e3,a=a||15,a=t.prototype.constrain(a,0,22);var l=0,h=[],p=0,c=this,u=setInterval((function(){!function(t){p++,c._makeSVGFrame({filename:r+t,extension:i,callback:function(e,r){h[t]=r,p--}})}(l),l++}),1e3/a),d=function(){p>0?setTimeout((function(){d()}),10):s?s(h):h.forEach((function(t){c.downloadFile(t.imageData,t.filename,t.ext)}))};setTimeout((function(){clearInterval(u),d()}),n+.01)}else e.apply(this,o)};var r=t.prototype.save;t.prototype.save=function(){var e,i=arguments;if((i=[i[0],i[1]])[0]instanceof t.Graphics){var n=i[0].elt;e=n.svg,i.shift()}i[0]&&i[0].elt&&(e=i[0].elt,i.shift()),"object"==typeof i[0]&&(e=i[0],i.shift()),e=e||this._renderer&&this._renderer.svg;var a=i[0],s=["jpeg","png","jpg","svg",""],o=this._checkFileExtension(a,"")[1],l=e&&e.nodeName&&"svg"===e.nodeName.toLowerCase()&&s.indexOf(o)>-1;if(!l)return r.apply(this,arguments);this.saveSVG(e,a)},t.prototype._svg_get=function(t,e,r){if(0===t.indexOf("data:")){if(-1===t.indexOf(","))return void r(new Error("Fail to parse dataurl: "+t));var i=t.split(",").pop();return setTimeout((function(){i=t.indexOf(";base64,")>-1?atob(i):decodeURIComponent(i),e(i)}),1),i}return this.httpGet(t,e),null},t.prototype.loadSVG=function(e,r,i){var n=document.createElement("div"),a=new t.SVGElement(n);return this._incrementPreload(),new Promise(((t,r)=>{this._svg_get(e,(function(e){n.innerHTML=e,(e=n.querySelector("svg"))?(a.elt=e,t(a)):r("Fail to create <svg>.")}),r)})).then((t=>{r&&r(t)})).catch((t=>{i&&i(t)})).finally((()=>{this._decrementPreload()})),a},t.prototype.getDataURL=function(){return this._renderer.elt.toDataURL("image/svg+xml")}}function Element(t){function e(e){return e?t.Element.apply(this,arguments):null}t.prototype.querySVG=function(e){var r=this._renderer&&this._renderer.svg;return r?t.SVGElement.prototype.query.call({elt:r},e):null},e.prototype=Object.create(t.Element.prototype),e.prototype.query=function(t){for(var r=this.elt.querySelectorAll(t),i=[],n=0;n<r.length;n++)i[n]=new e(r[n]);return i},e.prototype.append=function(t){var e=t.elt||t;return this.elt.appendChild(e),this},e.prototype.attribute=function(){var t=arguments;return 3===t.length&&this.elt.setAttributeNS.apply(this.elt,t),2===t.length&&this.elt.setAttribute.apply(this.elt,t),1===t.length?this.elt.getAttribute.apply(this.elt,t):this},e.prototype._filter=function(e,r,i){return t.SVGFilters.apply(this,e,r,i),this},e.create=function(t,r){r=r||{};var i=document.createElementNS("http://www.w3.org/2000/svg",t);return Object.keys(r).forEach((function(t){i.setAttribute(t,r[t])})),new e(i)},e.prototype.parentNode=function(t){if(!t)return new e(this.elt.parentNode);for(var r=this;r;)if((r=this.parentNode())&&r.matches(t))return r;return null},t.SVGElement=e}function P5SVGFilters(t){var e=function(){},r=t.SVGElement;return e.apply=function(t,i,n,a){var s=t.attribute("data-p5-svg-filters")||"[]";if(s=JSON.parse(s),i&&s.push([i,n]),t.attribute("data-p5-svg-filters",JSON.stringify(s)),0!==s.length){s=s.map((function(t,r){var i=0===r?"SourceGraphic":"result-"+(r-1),n="result-"+r;return e[t[0]].call(null,i,n,t[1])}));var o=t.attribute("data-p5-svg-filter-id");o||(o="p5-svg-"+(Date.now().toString()+Math.random().toString().replace(/0\./,"")),t.attribute("data-p5-svg-filter-id",o)),t.attribute("filter","url(#"+o+")");var l=r.create("filter",{id:o});s.forEach((function(t){Array.isArray(t)||(t=[t]),t.forEach((function(t){l.append(t)}))}));var h=a.querySelectorAll("#"+o)[0];h?h.elt.parentNode.replaceChild(l.elt,h):a.appendChild(l.elt)}else t.attribute("filter",null)},e.blur=function(t,e,i){return r.create("feGaussianBlur",{stdDeviation:i,in:t,result:e,"color-interpolation-filters":"sRGB"})},e.colorMatrix=function(t,e,i){return r.create("feColorMatrix",{type:"matrix",values:i.join(" "),"color-interpolation-filters":"sRGB",in:t,result:e})},e.gray=function(t,r){return e.colorMatrix(t,r,[.2126,.7152,.0722,0,0,.2126,.7152,.0722,0,0,.2126,.7152,.0722,0,0,0,0,0,1,0])},e.threshold=function(t,i,n){var a=[];a.push(e.gray(t,i+"-tmp"));var s=r.create("feComponentTransfer",{in:i+"-tmp",result:i}),o=Math.floor(255*n);return["R","G","B"].forEach((function(t){var e=r.create("feFunc"+t,{type:"linear",slope:255,intercept:-1*(o-1)});s.append(e)})),a.push(s),a},e.invert=function(t,r){return e.colorMatrix(t,r,[-1,0,0,0,1,0,-1,0,0,1,0,0,-1,0,1,0,0,0,1,0])},e.opaque=function(t,r){return e.colorMatrix(t,r,[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1])},e._discreteTableValues=function(t){for(var e=[],r=0;r<256;r++){var i=t(r);e.push(i/255)}return e},e.posterize=function(t,i,n){if((n=parseInt(n,10))<2||n>255)throw new Error("Level must be greater than 2 and less than 255 for posterize");var a=e._discreteTableValues((function(t){return 255*(t*n>>8)/(n-1)})),s=r.create("feComponentTransfer",{in:t,result:i,"color-interpolation-filters":"sRGB"});return["R","G","B"].forEach((function(t){var e=r.create("feFunc"+t,{type:"discrete",tableValues:a.join(" ")});s.append(e)})),s},e._blendOffset=function(t,e,i){var n=[];return[["left",-1,0],["right",1,0],["up",0,-1],["down",0,1]].forEach((function(i){n.push(r.create("feOffset",{in:t,result:e+"-"+i[0],dx:i[1],dy:i[2]}))})),[[null,t],[e+"-left",e+"-tmp-0"],[e+"-right",e+"-tmp-1"],[e+"-up",e+"-tmp-2"],[e+"-down",e+"-tmp-3"]].forEach((function(t,e,a){0!==e&&n.push(r.create("feBlend",{in:a[e-1][1],in2:t[0],result:t[1],mode:i}))})),n},e.erode=function(t,r){return e._blendOffset(t,r,"darken")},e.dilate=function(t,r){return e._blendOffset(t,r,"lighten")},t.SVGFilters=e,e}function Filters(t){var e=t.prototype.filter,r=P5SVGFilters(t);t.prototype.registerSVGFilter=function(t,e){r[t]=e},t.prototype.filter=function(r,i){var n=this._renderer.svg;if(n){const e=this._renderer.drawingContext,n=e.__root.querySelectorAll("defs")[0],a=e.__root.childNodes[1];let s=t.SVGElement.create("g");for(;a.childNodes.length>0;)s.elt.appendChild(a.childNodes[0]);a.appendChild(s.elt),s._filter(r,i,n),s=t.SVGElement.create("g"),a.appendChild(s.elt),e.__currentElement=s.elt}else e.apply(this,arguments)}}function Image$1(t){t.prototype.loadPixels=function(...e){return t._validateParameters("loadPixels",e),this._renderer.loadPixels()}}function init(t){RendererSVG(t),Rendering(t),IO(t),Element(t),Filters(t),Image$1(t),Object.keys(constants).forEach((function(e){t.prototype[e]=constants[e]}))}void 0!==window.p5&&init(window.p5),module.exports=init; |
|
//# sourceMappingURL=/sm/cb1c75a18a0f8f09eec5854a495246671ba16e7adac58a5d25edacc9f5ce3111.map
|