paper.js/dist/paper-core.min.js

37 lines
187 KiB
JavaScript
Raw Normal View History

/*!
* Paper.js v0.9.25-develop - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
*
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
* http://scratchdisk.com/ & http://jonathanpuckey.com/
*
* Distributed under the MIT license. See LICENSE file for details.
*
* All rights reserved.
*
* Date: Tue Feb 2 13:56:08 2016 +0100
*
***
*
* Straps.js - Class inheritance library with support for bean-style accessors
*
* Copyright (c) 2006 - 2016 Juerg Lehni
* http://scratchdisk.com/
*
* Distributed under the MIT license.
*
***
*
* Acorn.js
* http://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(t,e){t=t||require("./node/window");var i=t.document,n=new function(){function t(t,e,i,r,a){function o(s,o){o=o||(o=u(e,s))&&(o.get?o:o.value),"string"==typeof o&&"#"===o[0]&&(o=t[o.substring(1)]||o);var l,d="function"==typeof o,_=o,f=a||d&&!o.base?o&&o.get?s in t:t[s]:null;a&&f||(d&&f&&(o.base=f),d&&r!==!1&&(l=s.match(/^([gs]et|is)(([A-Z])(.*))$/))&&(h[l[3].toLowerCase()+l[4]]=l[2]),_&&!d&&_.get&&"function"==typeof _.get&&n.isPlainObject(_)||(_={value:_,writable:!0}),(u(t,s)||{configurable:!0}).configurable&&(_.configurable=!0,_.enumerable=i),c(t,s,_))}var h={};if(e){for(var l in e)e.hasOwnProperty(l)&&!s.test(l)&&o(l);for(var l in h){var d=h[l],_=t["set"+d],f=t["get"+d]||_&&t["is"+d];!f||r!==!0&&0!==f.length||o(l,{get:f,set:_})}}return t}function i(t,e,i){return t&&("length"in t&&!t.getLength&&"number"==typeof t.length?a:o).call(t,e,i=i||t),i}function r(t,e,i){for(var n in e)!e.hasOwnProperty(n)||i&&i[n]||(t[n]=e[n]);return t}var s=/^(statics|enumerable|beans|preserve)$/,a=[].forEach||function(t,e){for(var i=0,n=this.length;n>i;i++)t.call(e,this[i],i,this)},o=function(t,e){for(var i in this)this.hasOwnProperty(i)&&t.call(e,this[i],i,this)},h=Object.create||function(t){return{__proto__:t}},u=Object.getOwnPropertyDescriptor||function(t,e){var i=t.__lookupGetter__&&t.__lookupGetter__(e);return i?{get:i,set:t.__lookupSetter__(e),enumerable:!0,configurable:!0}:t.hasOwnProperty(e)?{value:t[e],enumerable:!0,configurable:!0,writable:!0}:null},l=Object.defineProperty||function(t,e,i){return(i.get||i.set)&&t.__defineGetter__?(i.get&&t.__defineGetter__(e,i.get),i.set&&t.__defineSetter__(e,i.set)):t[e]=i.value,t},c=function(t,e,i){return delete t[e],l(t,e,i)};return t(function(){for(var t=0,e=arguments.length;e>t;t++)r(this,arguments[t])},{inject:function(e){if(e){var i=e.statics===!0?e:e.statics,n=e.beans,r=e.preserve;i!==e&&t(this.prototype,e,e.enumerable,n,r),t(this,i,!0,n,r)}for(var s=1,a=arguments.length;a>s;s++)this.inject(arguments[s]);return this},extend:function(){for(var e,i,n,r=this,s=0,a=arguments.length;a>s&&(!e||!i);s++)n=arguments[s],e=e||n.initialize,i=i||n.prototype;return e=e||function(){r.apply(this,arguments)},i=e.prototype=i||h(this.prototype),c(i,"constructor",{value:e,writable:!0,configurable:!0}),t(e,this,!0),arguments.length&&this.inject.apply(e,arguments),e.base=r,e}},!0).inject({inject:function(){for(var e=0,i=arguments.length;i>e;e++){var n=arguments[e];n&&t(this,n,n.enumerable,n.beans,n.preserve)}return this},extend:function(){var t=h(this);return t.inject.apply(t,arguments)},each:function(t,e){return i(this,t,e)},set:function(t){return r(this,t)},clone:function(){return new this.constructor(this)},statics:{each:i,create:h,define:c,describe:u,set:r,clone:function(t){return r(new t.constructor,t)},isPlainObject:function(t){var e=null!=t&&t.constructor;return e&&(e===Object||e===n||"Object"===e.name)},pick:function(t,i){return t!==e?t:i}}})};"undefined"!=typeof module&&(module.exports=n),n.inject({toString:function(){return null!=this._id?(this._class||"Object")+(this._name?" '"+this._name+"'":" @"+this._id):"{ "+n.each(this,function(t,e){if(!/^_/.test(e)){var i=typeof t;this.push(e+": "+("number"===i?o.instance.number(t):"string"===i?"'"+t+"'":t))}},[]).join(", ")+" }"},getClassName:function(){return this._class||""},exportJSON:function(t){return n.exportJSON(this,t)},toJSON:function(){return n.serialize(this)},_set:function(t,i,r){if(t&&(r||n.isPlainObject(t))){for(var s=Object.keys(t._filtering||t),a=0,o=s.length;o>a;a++){var h=s[a];if(!i||!i[h]){var u=t[h];u!==e&&(this[h]=u)}}return!0}},statics:{exports:{enumerable:!0},extend:function it(){var t=it.base.apply(this,arguments),e=t.prototype._class;return e&&!n.exports[e]&&(n.exports[e]=t),t},equals:function(t,e){if(t===e)return!0;if(t&&t.equals)return t.equals(e);if(e&&e.equals)return e.equals(t);if(t&&e&&"object"==typeof t&&"object"==typeof e){if(Array.isArray(t)&&Array.isArray(e)){var i=t.length;if(i!==e.length)return!1;for(;i--;)if(!n.equals(t[i],e[i]))return!1}else{var r=Object.keys(t),i=r.length;if(i!==Object.keys(e).length)retu
var t=l.read(arguments),e=l.read(arguments,0,{readNull:!0}),i=Math.PI/180,n=new l(Math.tan(t.x*i),Math.tan(t.y*i));return this.shear(n,e)},append:function(t){var e=this._a,i=this._b,n=this._c,r=this._d,s=t._a,a=t._b,o=t._c,h=t._d,u=t._tx,l=t._ty;return this._a=s*e+o*i,this._b=a*e+h*i,this._c=s*n+o*r,this._d=a*n+h*r,this._tx+=u*e+l*i,this._ty+=u*n+l*r,this._changed(),this},appended:function(t){return this.clone().append(t)},prepend:function(t){var e=this._a,i=this._b,n=this._c,r=this._d,s=this._tx,a=this._ty,o=t._a,h=t._b,u=t._c,l=t._d,c=t._tx,d=t._ty;return this._a=o*e+h*n,this._b=o*i+h*r,this._c=u*e+l*n,this._d=u*i+l*r,this._tx=o*s+h*a+c,this._ty=u*s+l*a+d,this._changed(),this},prepended:function(t){return this.clone().prepend(t)},invert:function(){var t=this._a,e=this._b,i=this._c,n=this._d,r=this._tx,s=this._ty,a=t*n-e*i,o=null;return a&&!isNaN(a)&&isFinite(r)&&isFinite(s)&&(this._a=n/a,this._b=-e/a,this._c=-i/a,this._d=t/a,this._tx=(e*s-n*r)/a,this._ty=(i*r-t*s)/a,o=this),o},inverted:function(){return this.clone().invert()},concatenate:"#append",preConcatenate:"#prepend",chain:"#appended",_shiftless:function(){return new v(this._a,this._c,this._b,this._d,0,0)},_orNullIfIdentity:function(){return this.isIdentity()?null:this},isIdentity:function(){return 1===this._a&&0===this._c&&0===this._b&&1===this._d&&0===this._tx&&0===this._ty},isInvertible:function(){var t=this._a*this._d-this._b*this._c;return t&&!isNaN(t)&&isFinite(this._tx)&&isFinite(this._ty)},isSingular:function(){return!this.isInvertible()},transform:function(t,e,i){return arguments.length<3?this._transformPoint(l.read(arguments)):this._transformCoordinates(t,e,i)},_transformPoint:function(t,e,i){var n=t.x,r=t.y;return e||(e=new l),e.set(n*this._a+r*this._b+this._tx,n*this._c+r*this._d+this._ty,i)},_transformCoordinates:function(t,e,i){for(var n=0,r=2*i;r>n;n+=2){var s=t[n],a=t[n+1];e[n]=s*this._a+a*this._b+this._tx,e[n+1]=s*this._c+a*this._d+this._ty}return e},_transformCorners:function(t){var e=t.x,i=t.y,n=e+t.width,r=i+t.height,s=[e,i,n,i,n,r,e,r];return this._transformCoordinates(s,s,4)},_transformBounds:function(t,e,i){for(var n=this._transformCorners(t),r=n.slice(0,2),s=r.slice(),a=2;8>a;a++){var o=n[a],h=1&a;o<r[h]?r[h]=o:o>s[h]&&(s[h]=o)}return e||(e=new f),e.set(r[0],r[1],s[0]-r[0],s[1]-r[1],i)},inverseTransform:function(){return this._inverseTransform(l.read(arguments))},_inverseTransform:function(t,e,i){var n=this._a,r=this._b,s=this._c,a=this._d,o=this._tx,h=this._ty,u=n*a-r*s,c=null;if(u&&!isNaN(u)&&isFinite(o)&&isFinite(h)){var d=t.x-this._tx,_=t.y-this._ty;e||(e=new l),c=e.set((d*a-_*r)/u,(_*n-d*s)/u,i)}return c},decompose:function(){var t=this._a,e=this._b,i=this._c,n=this._d;if(h.isZero(t*n-e*i))return null;var r=Math.sqrt(t*t+e*e);t/=r,e/=r;var s=t*i+e*n;i-=t*s,n-=e*s;var a=Math.sqrt(i*i+n*n);return i/=a,n/=a,s/=a,e*i>t*n&&(t=-t,e=-e,s=-s,r=-r),{scaling:new l(r,a),rotation:180*-Math.atan2(e,t)/Math.PI,shearing:s}},getValues:function(){return[this._a,this._c,this._b,this._d,this._tx,this._ty]},getTranslation:function(){return new l(this._tx,this._ty)},getScaling:function(){return(this.decompose()||{}).scaling},getRotation:function(){return(this.decompose()||{}).rotation},applyToContext:function(t){this.isIdentity()||t.transform(this._a,this._c,this._b,this._d,this._tx,this._ty)}},n.each(["a","c","b","d","tx","ty"],function(t){var e=n.capitalize(t),i="_"+t;this["get"+e]=function(){return this[i]},this["set"+e]=function(t){this[i]=t,this._changed()}},{})),p=n.extend({_class:"Line",initialize:function(t,e,i,n,r){var s=!1;arguments.length>=4?(this._px=t,this._py=e,this._vx=i,this._vy=n,s=r):(this._px=t.x,this._py=t.y,this._vx=e.x,this._vy=e.y,s=i),s||(this._vx-=this._px,this._vy-=this._py)},getPoint:function(){return new l(this._px,this._py)},getVector:function(){return new l(this._vx,this._vy)},getLength:function(){return this.getVector().getLength()},intersect:function(t,e){return p.intersect(this._px,this._py,this._vx,this._vy,t._px,t._py,t._vx,t._vy,!0,e)},getSide:function(t,e){return p.getSide(this._px,this._py,this._vx,this._vy,t.x,t.y,!
return this._parent?ct.base.call(this):null!=this._index},activate:function(){this._project._activeLayer=this},_hitTestSelf:function(){return null}}),b=y.extend({_class:"Shape",_applyMatrix:!1,_canApplyMatrix:!1,_canScaleStroke:!0,_boundsSelected:!0,_serializeFields:{type:null,size:null,radius:null},initialize:function(t){this._initialize(t)},_equals:function(t){return this._type===t._type&&this._size.equals(t._size)&&n.equals(this._radius,t._radius)},copyContent:function(t){this.setType(t._type),this.setSize(t._size),this.setRadius(t._radius)},getType:function(){return this._type},setType:function(t){this._type=t},getShape:"#getType",setShape:"#setType",getSize:function(){var t=this._size;return new _(t.width,t.height,this,"setSize")},setSize:function(){var t=d.read(arguments);if(this._size){if(!this._size.equals(t)){var e=this._type,i=t.width,n=t.height;if("rectangle"===e){var r=d.min(this._radius,t.divide(2));this._radius.set(r.width,r.height)}else"circle"===e?(i=n=(i+n)/2,this._radius=i/2):"ellipse"===e&&this._radius.set(i/2,n/2);this._size.set(i,n),this._changed(9)}}else this._size=t.clone()},getRadius:function(){var t=this._radius;return"circle"===this._type?t:new _(t.width,t.height,this,"setRadius")},setRadius:function(t){var e=this._type;if("circle"===e){if(t===this._radius)return;var i=2*t;this._radius=t,this._size.set(i,i)}else if(t=d.read(arguments),this._radius){if(this._radius.equals(t))return;if(this._radius.set(t.width,t.height),"rectangle"===e){var i=d.max(this._size,t.multiply(2));this._size.set(i.width,i.height)}else"ellipse"===e&&this._size.set(2*t.width,2*t.height)}else this._radius=t.clone();this._changed(9)},isEmpty:function(){return!1},toPath:function(t){var i=new(O[n.capitalize(this._type)])({center:new l,size:this._size,radius:this._radius,insert:!1});return i.copyAttributes(this),paper.settings.applyMatrix&&i.setApplyMatrix(!0),(t===e||t)&&i.insertAbove(this),i},toShape:"#clone",_draw:function(t,e,i){var n=this._style,r=n.hasFill(),s=n.hasStroke(),a=e.dontFinish||e.clip,o=!i;if(r||s||a){var h=this._type,u=this._radius,l="circle"===h;if(e.dontStart||t.beginPath(),o&&l)t.arc(0,0,u,0,2*Math.PI,!0);else{var c=l?u:u.width,d=l?u:u.height,_=this._size,f=_.width,g=_.height;if(o&&"rectangle"===h&&0===c&&0===d)t.rect(-f/2,-g/2,f,g);else{var v=f/2,p=g/2,m=.44771525016920644,y=c*m,w=d*m,x=[-v,-p+d,-v,-p+w,-v+y,-p,-v+c,-p,v-c,-p,v-y,-p,v,-p+w,v,-p+d,v,p-d,v,p-w,v-y,p,v-c,p,-v+c,p,-v+y,p,-v,p-w,-v,p-d];i&&i.transform(x,x,32),t.moveTo(x[0],x[1]),t.bezierCurveTo(x[2],x[3],x[4],x[5],x[6],x[7]),v!==c&&t.lineTo(x[8],x[9]),t.bezierCurveTo(x[10],x[11],x[12],x[13],x[14],x[15]),p!==d&&t.lineTo(x[16],x[17]),t.bezierCurveTo(x[18],x[19],x[20],x[21],x[22],x[23]),v!==c&&t.lineTo(x[24],x[25]),t.bezierCurveTo(x[26],x[27],x[28],x[29],x[30],x[31])}}t.closePath()}a||!r&&!s||(this._setStyles(t),r&&(t.fill(n.getFillRule()),t.shadowBlur=0),s&&t.stroke())},_canComposite:function(){return!(this.hasFill()&&this.hasStroke())},_getBounds:function(t,e,i,n){var r=new f(this._size).setCenter(0,0),s=this._style,a=s.hasStroke()&&/^get(?:Stroke|Rough)Bounds$/.test(t)&&s.getStrokeWidth();return e&&(r=e._transformBounds(r)),a?r.expand(O._getStrokePadding(a,this._getStrokeMatrix(e,n))):r}},new function(){function t(t,e,i){var n=t._radius;if(!n.isZero())for(var r=t._size.divide(2),s=0;4>s;s++){var a=new l(1&s?1:-1,s>1?1:-1),o=a.multiply(r),h=o.subtract(a.multiply(n)),u=new f(o,h);if((i?u.expand(i):u).contains(e))return h}}function e(t,e,i,n){var r=t.divide(e);return(!n||r.quadrant===n)&&r.subtract(r.normalize()).multiply(e).divide(i).length<=1}return{_contains:function i(e){if("rectangle"===this._type){var n=t(this,e);return n?e.subtract(n).divide(this._radius).getLength()<=1:i.base.call(this,e)}return e.divide(this.size).getLength()<=.5},_hitTestSelf:function n(i,r){var s=!1,a=this._style;if(r.stroke&&a.hasStroke()){var o=this._type,h=this._radius,u=a.getStrokeWidth(),l=r._tolerancePadding.add(O._getStrokePadding(u/2,!a.getStrokeScaling()&&r._strokeMatrix));if("rectangle"===o){var c=l.multiply(2),d=t(this,i,c);if(d)s=e(i.subtract(d),h,l,d.getQ
h},_getSelfIntersection:function(t,e,i,n){var r=t[0],s=t[1],a=t[2],o=t[3],u=t[4],c=t[5],d=t[6],_=t[7],f=new p(r,s,d,_,!1),g=f.getSide(new l(a,o),!0),v=f.getSide(new l(u,c),!0);if(g===v){var m=(r-u)*(o-_)+(a-d)*(c-s);if(m*g>0)return i}var y=d-3*u+3*a-r,w=u-2*a+r,x=a-r,b=_-3*c+3*o-s,S=c-2*o+s,C=o-s,P=b*x-y*C,M=b*w-y*S,I=S*x-w*C;if(0>P*P-4*M*I){var T,k=[],A=h.solveCubic(y*y+b*b,3*(y*w+b*S),2*(w*w+S*S)+y*x+b*C,w*x+S*C,k,0,1);if(A>0){for(var O=0,N=0;A>O;O++){var L=Math.abs(e.getCurvatureAtTime(k[O]));L>N&&(N=L,T=k[O])}var B=z.subdivide(t,T);n.excludeEnd=!0,n.renormalize=function(t,e){return[t*T,e*(1-T)+T]},z._getIntersections(B[0],B[1],e,e,i,n)}}return i},getOverlaps:function(t,e){function i(t){var e=t[6]-t[0],i=t[7]-t[1];return e*e+i*i}var n=Math.abs,r=4e-7,s=2e-7,a=z.isStraight(t),o=z.isStraight(e),h=a&&o,u=i(t)<i(e),c=u?e:t,d=u?t:e,_=new p(c[0],c[1],c[6],c[7]);if(_.getDistance(new l(d[0],d[1]))<s&&_.getDistance(new l(d[6],d[7]))<s)!h&&_.getDistance(new l(c[2],c[3]))<s&&_.getDistance(new l(c[4],c[5]))<s&&_.getDistance(new l(d[2],d[3]))<s&&_.getDistance(new l(d[4],d[5]))<s&&(a=o=h=!0);else if(h)return null;if(a^o)return null;for(var f=[t,e],g=[],v=0,m=0;2>v&&g.length<2;v+=0===m?0:1,m=1^m){var y=z.getTimeOf(f[1^v],new l(f[v][0===m?0:6],f[v][0===m?1:7]));if(null!=y){var w=0===v?[m,y]:[y,m];(0===g.length||n(w[0]-g[0][0])>r&&n(w[1]-g[0][1])>r)&&g.push(w)}if(1===v&&0===g.length)break}if(2!==g.length)g=null;else if(!h){var x=z.getPart(t,g[0][0],g[1][0]),b=z.getPart(e,g[0][1],g[1][1]);(n(b[2]-x[2])>s||n(b[3]-x[3])>s||n(b[4]-x[4])>s||n(b[5]-x[5])>s)&&(g=null)}return g}}}}),k=n.extend({_class:"CurveLocation",beans:!0,initialize:function dt(t,e,i,n,r){if(e>.9999996){var s=t.getNext();s&&(e=0,t=s)}this._id=u.get(dt),this._setCurve(t),this._time=e,this._point=i||t.getPointAtTime(e),this._overlap=n,this._distance=r,this._intersection=this._next=this._prev=null},_setCurve:function(t){var e=t._path;this._path=e,this._version=e?e._version:0,this._curve=t,this._segment=null,this._segment1=t._segment1,this._segment2=t._segment2},_setSegment:function(t){this._setCurve(t.getCurve()),this._segment=t,this._time=t===this._segment1?0:1,this._point=t._point.clone()},getSegment:function(){var t=this.getCurve(),e=this._segment;if(!e){var i=this.getTime();0===i?e=t._segment1:1===i?e=t._segment2:null!=i&&(e=t.getPartLength(0,i)<t.getPartLength(i,1)?t._segment1:t._segment2),this._segment=e}return e},getCurve:function(){function t(t){var e=t&&t.getCurve();return e&&null!=(i._time=e.getTimeOf(i._point))?(i._setCurve(e),i._segment=t,e):void 0}var e=this._path,i=this;return e&&e._version!==this._version&&(this._time=this._curve=this._offset=null),this._curve||t(this._segment)||t(this._segment1)||t(this._segment2.getPrevious())},getPath:function(){var t=this.getCurve();return t&&t._path},getIndex:function(){var t=this.getCurve();return t&&t.getIndex()},getTime:function(){var t=this.getCurve(),e=this._time;return t&&null==e?this._time=t.getTimeOf(this._point):e},getParameter:"#getTime",getPoint:function(){return this._point},getOffset:function(){var t=this._offset;if(null==t){t=0;var e=this.getPath(),i=this.getIndex();if(e&&null!=i)for(var n=e.getCurves(),r=0;i>r;r++)t+=n[r].getLength();this._offset=t+=this.getCurveOffset()}return t},getCurveOffset:function(){var t=this.getCurve(),e=this.getTime();return null!=e&&t&&t.getPartLength(0,e)},getIntersection:function(){return this._intersection},getDistance:function(){return this._distance},divide:function(){var t=this.getCurve(),e=null;return t&&(e=t.divideAtTime(this.getTime()),e&&this._setSegment(e._segment1)),e},split:function(){var t=this.getCurve();return t?t.splitAtTime(this.getTime()):null},equals:function(t,e){var i=this===t,n=2e-7;if(!i&&t instanceof k&&this.getPath()===t.getPath()&&this.getPoint().isClose(t.getPoint(),n)){var r=this.getCurve(),s=t.getCurve(),a=Math.abs,o=a((r.isLast()&&s.isFirst()?-1:r.getIndex())+this.getTime()-((s.isLast()&&r.isFirst()?-1:s.getIndex())+t.getTime()));i=(4e-7>o||(o=a(this.getOffset()-t.getOffset()))<n||a(this.getPath().getLength()-o)<n)&&(e||!this._intersection&&!t._int
}}}});var N=A.extend({_class:"CompoundPath",_serializeFields:{children:[]},initialize:function(t){this._children=[],this._namedChildren={},this._initialize(t)||("string"==typeof t?this.setPathData(t):this.addChildren(Array.isArray(t)?t:arguments))},insertChildren:function gt(t,i,n){for(var r=i.length-1;r>=0;r--){var s=i[r];s instanceof N&&(i=i.slice(),i.splice.apply(i,[r,1].concat(s.removeChildren())),s.remove())}i=gt.base.call(this,t,i,n,O);for(var r=0,a=!n&&i&&i.length;a>r;r++){var s=i[r];s._clockwise===e&&s.setClockwise(0===s._index)}return i},reverse:function(){for(var t=this._children,e=0,i=t.length;i>e;e++)t[e].reverse()},reduce:function vt(t){for(var e=this._children,i=e.length-1;i>=0;i--){var n=e[i].reduce(t);n.isEmpty()&&n.remove()}if(0===e.length){var n=new O(y.NO_INSERT);return n.copyAttributes(this),n.insertAbove(this),this.remove(),n}return vt.base.call(this)},smooth:function(t){for(var e=this._children,i=0,n=e.length;n>i;i++)e[i].smooth(t)},isClockwise:function(){var t=this.getFirstChild();return t&&t.isClockwise()},setClockwise:function(t){this.isClockwise()^!!t&&this.reverse()},getFirstSegment:function(){var t=this.getFirstChild();return t&&t.getFirstSegment()},getLastSegment:function(){var t=this.getLastChild();return t&&t.getLastSegment()},getCurves:function(){for(var t=this._children,e=[],i=0,n=t.length;n>i;i++)e.push.apply(e,t[i].getCurves());return e},getFirstCurve:function(){var t=this.getFirstChild();return t&&t.getFirstCurve()},getLastCurve:function(){var t=this.getLastChild();return t&&t.getFirstCurve()},getArea:function(){for(var t=this._children,e=0,i=0,n=t.length;n>i;i++)e+=t[i].getArea();return e}},{beans:!0,getPathData:function(t,e){for(var i=this._children,n=[],r=0,s=i.length;s>r;r++){var a=i[r],o=a._matrix;n.push(a.getPathData(t&&!o.isIdentity()?t.appended(o):t,e))}return n.join(" ")}},{_getChildHitTestOptions:function(t){return t["class"]===O||"path"===t.type?t:new n(t,{fill:!1})},_draw:function(t,e,i){var n=this._children;if(0!==n.length){e=e.extend({dontStart:!0,dontFinish:!0}),t.beginPath();for(var r=0,s=n.length;s>r;r++)n[r].draw(t,e,i);if(!e.clip){this._setStyles(t);var a=this._style;a.hasFill()&&(t.fill(a.getFillRule()),t.shadowBlur=0),a.hasStroke()&&t.stroke()}}},_drawSelected:function(t,e,i){for(var n=this._children,r=0,s=n.length;s>r;r++){var a=n[r],o=a._matrix;i[a._id]||a._drawSelected(t,o.isIdentity()?e:e.appended(o))}}},new function(){function t(t,e){var i=t._children;if(e&&0===i.length)throw new Error("Use a moveTo() command first");return i[i.length-1]}var e={moveTo:function(){var e=t(this),i=e&&e.isEmpty()?e:new O(y.NO_INSERT);i!==e&&this.addChild(i),i.moveTo.apply(i,arguments)},moveBy:function(){var e=t(this,!0),i=e&&e.getLastSegment(),n=l.read(arguments);this.moveTo(i?n.add(i._point):n)},closePath:function(e){t(this,!0).closePath(e)}};return n.each(["lineTo","cubicCurveTo","quadraticCurveTo","curveTo","arcTo","lineBy","cubicCurveBy","quadraticCurveBy","curveBy","arcBy"],function(i){e[i]=function(){var e=t(this,!0);e[i].apply(e,arguments)}}),e});A.inject(new function(){function t(t,e){var i=t.clone(!1).reduce({simplify:!0}).transform(null,!0,!0);return e?i.resolveCrossings():i}function e(t,e,i){return t.insertAbove(i&&e.isSibling(i)&&e.getIndex()<i.getIndex()?i:e),t.copyAttributes(e,!0),t}function i(t,e,i){var n=new t(y.NO_INSERT);return n.addChildren(e,!0),i&&(n=n.reduce({simplify:!0})),n}function r(n,r,a){function h(t){for(var e=0,i=t.length;i>e;e++){var n=t[e];v.push.apply(v,n._segments),p.push.apply(p,n._getMonoCurves())}}var u=_[a];if(u[a]=!0,!n._children&&!n._closed)return s(n,r,u);var l=t(n,!0),f=r&&n!==r&&t(r,!0);f&&(u.subtract||u.exclude)^(f.isClockwise()^l.isClockwise())&&f.reverse();var g=o(k.expand(l.getCrossings(f))),v=[],p=[],m=!0,w=!0;h(l._children||[l]),f&&h(f._children||[f]);for(var x=0,b=g.length;b>x;x++)c(g[x]._segment,l,f,p,u);for(var x=0,b=v.length;b>x;x++){var S=v[x],C=S._intersection;null==S._winding&&c(S,l,f,p,u),C&&C._overlap||(m=!1,u[S._winding]&&(w=!1))}return e(m?(u.unite||u.intersect)&&n.getArea()?n.clone(!1):new O(y.NO_INSERT):i(N,d(v,u,w),!m
this._frameItems={},this._frameItemCount=0,this._itemEvents={"native":{},virtual:{}},this._autoUpdate=!paper.agent.node},remove:function(){if(!this._project)return!1;Z._focused===this&&(Z._focused=null),Z._views.splice(Z._views.indexOf(this),1),delete Z._viewsById[this._id];var e=this._project;return e._view===this&&(e._view=null),H.remove(this._element,this._viewEvents),H.remove(t,this._windowEvents),this._element=this._project=null,this.off("frame"),this._animate=!1,this._frameItems={},!0},_events:n.each(y._itemHandlers.concat(["onResize","onKeyDown","onKeyUp"]),function(t){this[t]={}},{onFrame:{install:function(){this.play()},uninstall:function(){this.pause()}}}),_animate:!1,_time:0,_count:0,getAutoUpdate:function(){return this._autoUpdate},setAutoUpdate:function(t){this._autoUpdate=t,t&&this.requestUpdate()},draw:function(){this.update()},requestUpdate:function(){if(!this._requested){var t=this;H.requestAnimationFrame(function(){t._requested=!1,t._animate&&(t.requestUpdate(),t._handleFrame()),t._autoUpdate&&t.update()},this._element),this._requested=!0}},play:function(){this._animate=!0,this.requestUpdate()},pause:function(){this._animate=!1},_handleFrame:function(){paper=this._scope;var t=Date.now()/1e3,e=this._last?t-this._last:0;this._last=t,this.emit("frame",new n({delta:e,time:this._time+=e,count:this._count++})),this._stats&&this._stats.update()},_animateItem:function(t,e){var i=this._frameItems;e?(i[t._id]={item:t,time:0,count:0},1===++this._frameItemCount&&this.on("frame",this._handleFrameItems)):(delete i[t._id],0===--this._frameItemCount&&this.off("frame",this._handleFrameItems))},_handleFrameItems:function(t){for(var e in this._frameItems){var i=this._frameItems[e];i.item.emit("frame",new n(t,{time:i.time+=t.delta,count:i.count++}))}},_changed:function(){this._project._changed(2049),this._bounds=null},getElement:function(){return this._element},getPixelRatio:function(){return this._pixelRatio},getResolution:function(){return 72*this._pixelRatio},getViewSize:function(){var t=this._viewSize;return new _(t.width,t.height,this,"setViewSize")},setViewSize:function(){var t=d.read(arguments),e=t.width,i=t.height,n=t.subtract(this._viewSize);n.isZero()||(this._viewSize.set(e,i),this._setViewSize(e,i),this.emit("resize",{size:t,delta:n}),this._changed(),this._autoUpdate&&this.requestUpdate())},_setViewSize:function(t,e){var i=this._element;i.width!==t&&(i.width=t),i.height!==e&&(i.height=e)},getBounds:function(){return this._bounds||(this._bounds=this._matrix.inverted()._transformBounds(new f(new l,this._viewSize))),this._bounds},getSize:function(){return this.getBounds().getSize()},getCenter:function(){return this.getBounds().getCenter()},setCenter:function(){var t=l.read(arguments);this.translate(this.getCenter().subtract(t))},getZoom:function(){return this._zoom},setZoom:function(t){this.transform((new v).scale(t/this._zoom,this.getCenter())),this._zoom=t},getMatrix:function(){return this._matrix},setMatrix:function(){var t=this._matrix;t.initialize.apply(t,arguments)},isVisible:function(){return V.isInView(this._element)},isInserted:function(){return V.isInserted(this._element)}},n.each(["rotate","scale","shear","skew"],function(t){var e="rotate"===t;this[t]=function(){var i=(e?n:l).read(arguments),r=l.read(arguments,0,{readNull:!0});return this.transform((new v)[t](i,r||this.getCenter(!0)))}},{translate:function(){var t=new v;return this.transform(t.translate.apply(t,arguments))},transform:function(t){this._matrix.append(t)},scrollBy:function(){this.translate(l.read(arguments).negate())}}),{projectToView:function(){return this._matrix._transformPoint(l.read(arguments))},viewToProject:function(){return this._matrix._inverseTransform(l.read(arguments))},getEventPoint:function(t){return this.viewToProject(H.getOffset(t,this._element))}},{statics:{_views:[],_viewsById:{},_id:0,create:function(t,e){return"string"==typeof e&&(e=i.getElementById(e)),new W(t,e)}}},new function(){function n(t){var e=H.getTarget(t);return e.getAttribute&&Z._viewsById[e.getAttribute("id")]}function r(){var t=Z._focused;if(!t||!t.isVisib