/*! * Paper.js v0.12.11-develop - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey * http://juerglehni.com/ & https://puckey.studio/ * * Distributed under the MIT license. See LICENSE file for details. * * All rights reserved. * * Date: Mon Jun 22 15:17:43 2020 +0200 * *** * * Straps.js - Class inheritance library with support for bean-style accessors * * Copyright (c) 2006 - 2020 Jürg Lehni * http://juerglehni.com/ * * Distributed under the MIT license. * *** * * Acorn.js * https://marijnhaverbeke.nl/acorn/ * * Acorn is a tiny, fast JavaScript parser written in JavaScript, * created by Marijn Haverbeke and released under an MIT license. * */ var paper=function(u,q){var O=(u=u||require("./node/self.js")).window,k=u.document,H=new function(){function n(t,e,n){var i;return t&&((i=d(t,"length"))&&"number"==typeof i.value?r:function(t,e){for(var n in this)this.hasOwnProperty(n)&&t.call(e,this[n],n,this)}).call(t,e,n=n||t),n}var s=/^(statics|enumerable|beans|preserve)$/,t=[],i=t.slice,a=Object.create,d=Object.getOwnPropertyDescriptor,_=Object.defineProperty,r=t.forEach||function(t,e){for(var n=0,i=this.length;nt.length&&(n=t.length);for(var a=0;a>>1;a[t[s]][e]=k[d]-n&&T<=k[_]+n)&&(b&&A&&S.push(s?O:O-o),C&&z&&p[O].push(x))}}b&&(t===e&&S.push(y),p[y]=S),v.length?(m=u(v,c,w[c]),v.splice(m+1,0,y)):v.push(y)}for(g=0;g>1,l=1&i?s[h++]*t(o):0;hb(s/o)&&(h=((u=-s/o)-r)/o)}}var w=Z.solveQuadratic(n,h,u,t,e,a),x=null==e;return isFinite(o)&&(0===w||0=this.x&&n>=this.y&&e<=this.x+this.width&&n<=this.y+this.height},_containsRectangle:function(t){var e=t.x,n=t.y;return e>=this.x&&n>=this.y&&e+t.width<=this.x+this.width&&n+t.height<=this.y+this.height},intersects:function(){var t=T.read(arguments),e=H.read(arguments)||0;return t.x+t.width>this.x-e&&t.y+t.height>this.y-e&&t.xs[h]&&(s[h]=o)}return(e=e||new T)._set(r[0],r[1],s[0]-r[0],s[1]-r[1],n)},inverseTransform:function(){return this._inverseTransform(U.read(arguments))},_inverseTransform:function(t,e,n){var i,r,s=this._a,a=this._b,o=this._c,h=this._d,u=this._tx,l=this._ty,c=s*h-a*o,d=null;return c&&!isNaN(c)&&isFinite(u)&&isFinite(l)&&(i=t.x-this._tx,r=t.y-this._ty,d=(e=e||new U)._set((i*h-r*o)/c,(r*s-i*a)/c,n)),d},decompose:function(){var t,e,n,i,r,s=this._a,a=this._b,o=this._c,h=this._d,u=s*h-a*o,l=Math.sqrt,c=Math.atan2,d=180/Math.PI;return i=0!==s||0!==a?(t=l(s*s+a*a),e=Math.acos(s/t)*(0o[r]&&(o[r]=i)}s/=2;var l=a[r]+s,c=o[r]-s;if(t(t||0)},isCollinear:function(t){return t&&this.isStraight()&&t.isStraight()&&this.getLine().isCollinear(t.getLine())},isHorizontal:function(){return this.isStraight()&&Math.abs(this.getTangentAtTime(.5).y)<1e-8},isVertical:function(){return this.isStraight()&&Math.abs(this.getTangentAtTime(.5).x)<1e-8}}),{beans:!1,getLocationAt:function(t,e){return this.getLocationAtTime(e?t:this.getTimeAt(t))},getLocationAtTime:function(t){return null!=t&&0<=t&&t<=1?new Q(this,t):null},getTimeAt:function(t,e){return K.getTimeAt(this.getValues(),t,e)},getParameterAt:"#getTimeAt",getTimesWithTangent:function(){var t=U.read(arguments);return t.isZero()?[]:K.getTimesWithTangent(this.getValues(),t)},getOffsetAtTime:function(t){return this.getPartLength(0,t)},getLocationOf:function(){return this.getLocationAtTime(this.getTimeOf(U.read(arguments)))},getOffsetOf:function(){var t=this.getLocationOf.apply(this,arguments);return t?t.getOffset():null},getTimeOf:function(){return K.getTimeOf(this.getValues(),U.read(arguments))},getParameterOf:"#getTimeOf",getNearestLocation:function(){var t=U.read(arguments),e=this.getValues(),n=K.getNearestTime(e,t),i=K.getPoint(e,n);return new Q(this,n,i,null,t.getDistance(i))},getNearestPoint:function(){var t=this.getNearestLocation.apply(this,arguments);return t?t.getPoint():t}},new function(){var t=["getPoint","getTangent","getNormal","getWeightedTangent","getWeightedNormal","getCurvature"];return H.each(t,function(i){this[i+"At"]=function(t,e){var n=this.getValues();return K[i](n,e?t:K.getTimeAt(n,t))},this[i+"AtTime"]=function(t){return K[i](this.getValues(),t)}},{statics:{_evaluateMethods:t}})},new function(){function d(t){var e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],h=t[7],u=9*(i-s)+3*(o-e),l=6*(e+s)-12*i,c=3*(i-e),d=9*(r-a)+3*(h-n),_=6*(n+a)-12*r,f=3*(r-n);return function(t){var e=(u*t+l)*t+c,n=(d*t+_)*t+f;return Math.sqrt(e*e+n*n)}}function _(t,e){return Math.max(2,Math.min(16,Math.ceil(32*Math.abs(e-t))))}function n(t,e,n,i){if(null==e||e<0||1i?r(e,!1,i):t[0][0]}function r(t,e,n){for(var i=t[0][0],r=t[0][1],s=1,a=t.length;so(e[0],e[2],e[4],e[6])&&o(t[0],t[2],t[4],t[6])-ao(e[1],e[3],e[5],e[7])&&o(t[1],t[3],t[5],t[7])-a>1,m=1&l,y=6*p,w=6*m,x=new U(t[y],t[1+y]),b=new U(e[w],e[1+w]);x.isClose(b,a)&&F(r,s,n,p,i,m)}}}return r}function b(t,e,n,i){var r,s=K.classify(t);return"loop"===s.type&&F(n,i,e,(r=s.roots)[0],e,r[1]),n}function S(t,e){function n(t){var e=t[6]-t[0],n=t[7]-t[1];return e*e+n*n}var i=Math.abs,r=$.getDistance,s=1e-7,a=K.isStraight(t),o=K.isStraight(e),h=a&&o,u=n(t)>1,P=K.getTimeOf(m[b],new U(m[C][S?6:0],m[C][S?7:1]));if(null!=P&&(x=b?[S,P]:[P,S],(!y.length||1e-8s||i(p[3]-v[3])>s||i(p[4]-v[4])>s||i(p[5]-v[5])>s)&&(y=null)),y}return{getIntersections:function(t){var e=this.getValues(),n=t&&t!==this&&t.getValues();return n?x(e,n,this,t,[]):b(e,this,[])},statics:{getOverlaps:S,getIntersections:function(t,e,n,i,r,s){var a=!e;a&&(e=t);for(var o=t.length,h=e.length,u=new Array(o),l=a?u:new Array(h),c=[],d=0;d>>1,u=r[h];if(t&&(o=s.equals(u)?u:i(h,-1)||i(h,1)))return s._overlap&&(o._overlap=o._intersection._overlap=!0),o;var l=s.getPath(),c=u.getPath();(l!==c?l._id-c._id:s.getIndex()+s.getTime()-(u.getIndex()+u.getTime()))<0?n=h-1:e=1+h}return r.splice(e,0,s),s}return{statics:{insert:i,expand:function(t){for(var e=t.slice(),n=t.length-1;0<=n;n--)i(e,t[n]._intersection,!1);return e}}}}),A=R.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,beans:!0,initialize:function(){},statics:{create:function(t){var e,n,i,r;return H.isPlainObject(t)?(n=t.segments,e=t.pathData):Array.isArray(t)?n=t:"string"==typeof t&&(e=t),n?r=(i=n[0])&&Array.isArray(i[0]):e&&(r=1<(e.match(/m/gi)||[]).length||/z\s*\S+/i.test(e)),new(r?Y:X)(t)}},_asPathItem:function(){return this},isClockwise:function(){return 0<=this.getArea()},setClockwise:function(t){this.isClockwise()!=(t=!!t)&&this.reverse()},setPathData:function(t){var e,n,i=t&&t.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),r=!1,s=new U,a=new U;function o(t,e){var n=+c[t];return r&&(n+=s[e]),n}function h(t){return new U(o(t,"x"),o(t+1,"y"))}this.clear();for(var u=0,l=i&&i.length;u=s&&(a=0),_=u[a]||i[a].getValues(),o=0),!h)return f[0]===a&&f[1]===o;continue}}break}return!1},_hitTestSelf:function(i,r,t,s){var a,o,h,u,e,n,l,c=this,d=this.getStyle(),_=this._segments,f=_.length,g=this._closed,v=r._tolerancePadding,p=v,m=r.stroke&&d.hasStroke(),y=r.fill&&d.hasFill(),w=r.curves,x=m?d.getStrokeWidth()/2:y&&0=L(e,n,i,r))for(var s,a=t[y+0],o=t[y+2],h=t[y+4],u=t[y+6],l=S>N(a,o,h,u)||PN(e,n))){var i=t[y+0],r=t[y+2],s=t[y+4],a=t[y+6];if(e!==n){var o=b===e?0:b!==n&&!(S>N(i,r,s,a)||Pm[w+6]?1:-1,c=m[y+6];return b!==e?(hu.quality&&(u=C);break}c-=g}for(d=s.length-1;0<=d;d--)s[d].segment._winding=u}function D(t,n){var u,e=[];function l(t){var e;return!(!t||t._visited||n&&(!n[(e=t._winding||{}).winding]||n.unite&&2===e.winding&&e.windingL&&e.windingR))}function c(t){if(t)for(var e=0,n=u.length;e=L(h,u,l,c)&&n<=N(h,u,l,c))for(var d=K.getMonoCurves(o),_=0,f=d.length;_=t){var a=n[(this.index=e)-1],o=a&&a.index===s.index?a.time:0,h=a?a.offset:0;return{index:s.index,time:o+(s.time-o)*(t-h)/(s.offset-h)}}}return{index:n[i-1].index,time:1}},drawPart:function(t,e,n){for(var i=this._get(e),r=this._get(n),s=i.index,a=r.index;s<=a;s++){var o=K.getPart(this.curves[s],s===i.index?i.time:0,s===r.index?r.time:1);s===i.index&&t.moveTo(o[0],o[1]),t.bezierCurveTo.apply(t,o.slice(2))}}},H.each(K._evaluateMethods,function(n){this[n+"At"]=function(t){var e=this._get(t);return K[n](this.curves[e.index],e.time)}},{})),i=H.extend({initialize:function(t){for(var e,n=this.points=[],i=t._segments,r=t._closed,s=0,a=i.length;s=u)break;l=this.reparameterize(n,i,h,d),u=_.error}var f=a[o-1].subtract(a[o+1]);this.fitCubic(t,e,n,o,r,f),this.fitCubic(t,e,o,i,f.negate(),s)}else{var g=a[n],v=a[i],p=g.getDistance(v)/3;this.addCurve(t,[g,g.add(r.normalize(p)),v.add(s.normalize(p)),v])}},addCurve:function(t,e){t[t.length-1].setHandleOut(e[1].subtract(e[0])),t.push(new J(e[3],e[2].subtract(e[3])))},generateBezier:function(t,e,n,i,r){for(var s=Math.abs,a=this.points,o=a[t],h=a[e],u=[[0,0],[0,0]],l=[0,0],c=0,d=e-t+1;cA*A&&(S=P=A/3,k=z=null)),[o,o.add(k||i.normalize(S)),h.add(z||r.normalize(P)),h]},reparameterize:function(t,e,n,i){for(var r=t;r<=e;r++)n[r-t]=this.findRoot(i,this.points[r],n[r-t]);for(var r=1,s=n.length;ro&&(n=H.slice(n,0,o))}else if("string"===a){var u,l=function(t){var e=t.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?$/i)||t.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])?$/i),n="rgb";if(e)for(var i=e[4]?4:3,r=new Array(i),s=0;sn&&(c=u.add(i.normalize(n-.1))),r=c||u,t.createRadialGradient(r.x,r.y,0,u.x,u.y,n)):t.createLinearGradient(u.x,u.y,l.x,l.y);for(var _=0,f=h.length;_this._maxDistance&&(this._maxDistance=t)},getMaxDistance:function(){return this._maxDistance},setMaxDistance:function(t){this._maxDistance=t,null!=this._minDistance&&null!=t&&tr[a]?(r[o]=(r[o]-r[a])*i/(r[s]-r[a]),r[s]=i):r[o]=r[s]=0,r[a]=0,C=r[0],S=r[1],P=r[2]}var I={multiply:function(){C=y*g/255,S=w*v/255,P=x*p/255},screen:function(){C=y+g-y*g/255,S=w+v-w*v/255,P=x+p-x*p/255},overlay:function(){C=y<128?2*y*g/255:255-2*(255-y)*(255-g)/255,S=w<128?2*w*v/255:255-2*(255-w)*(255-v)/255,P=x<128?2*x*p/255:255-2*(255-x)*(255-p)/255},"soft-light":function(){var t=g*y/255;C=t+y*(255-(255-y)*(255-g)/255-t)/255,S=(t=v*w/255)+w*(255-(255-w)*(255-v)/255-t)/255,P=(t=p*x/255)+x*(255-(255-x)*(255-p)/255-t)/255},"hard-light":function(){C=g<128?2*g*y/255:255-2*(255-g)*(255-y)/255,S=v<128?2*v*w/255:255-2*(255-v)*(255-w)/255,P=p<128?2*p*x/255:255-2*(255-p)*(255-x)/255},"color-dodge":function(){C=0===y?0:255===g?255:l(255,255*y/(255-g)),S=0===w?0:255===v?255:l(255,255*w/(255-v)),P=0===x?0:255===p?255:l(255,255*x/(255-p))},"color-burn":function(){C=255===y?255:0===g?0:c(0,255-255*(255-y)/g),S=255===w?255:0===v?0:c(0,255-255*(255-w)/v),P=255===x?255:0===p?0:c(0,255-255*(255-x)/p)},darken:function(){C=y