2016-01-30 07:48:16 -05:00
|
|
|
/*!
|
2016-01-30 10:57:46 -05:00
|
|
|
* Paper.js v0.9.25-develop - The Swiss Army Knife of Vector Graphics Scripting.
|
2016-01-30 07:48:16 -05:00
|
|
|
* 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.
|
|
|
|
*
|
2016-01-31 08:43:24 -05:00
|
|
|
* Date: Sun Jan 31 14:41:09 2016 +0100
|
2016-01-30 07:48:16 -05:00
|
|
|
*
|
|
|
|
***
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
2016-01-30 10:57:46 -05:00
|
|
|
var paper=function(t,e){t=t||require("./node/window");var n=t.document,i=new function(){function t(t,e,n,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&&i.isPlainObject(_)||(_={value:_,writable:!0}),(u(t,s)||{configurable:!0}).configurable&&(_.configurable=!0,_.enumerable=n),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 n(t,e,n){return t&&("length"in t&&!t.getLength&&"number"==typeof t.length?a:o).call(t,e,n=n||t),n}function r(t,e,n){for(var i in e)!e.hasOwnProperty(i)||n&&n[i]||(t[i]=e[i]);return t}var s=/^(statics|enumerable|beans|preserve)$/,a=[].forEach||function(t,e){for(var n=0,i=this.length;i>n;n++)t.call(e,this[n],n,this)},o=function(t,e){for(var n in this)this.hasOwnProperty(n)&&t.call(e,this[n],n,this)},h=Object.create||function(t){return{__proto__:t}},u=Object.getOwnPropertyDescriptor||function(t,e){var n=t.__lookupGetter__&&t.__lookupGetter__(e);return n?{get:n,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,n){return(n.get||n.set)&&t.__defineGetter__?(n.get&&t.__defineGetter__(e,n.get),n.set&&t.__defineSetter__(e,n.set)):t[e]=n.value,t},c=function(t,e,n){return delete t[e],l(t,e,n)};return t(function(){for(var t=0,e=arguments.length;e>t;t++)r(this,arguments[t])},{inject:function(e){if(e){var n=e.statics===!0?e:e.statics,i=e.beans,r=e.preserve;n!==e&&t(this.prototype,e,e.enumerable,i,r),t(this,n,!0,i,r)}for(var s=1,a=arguments.length;a>s;s++)this.inject(arguments[s]);return this},extend:function(){for(var e,n,i,r=this,s=0,a=arguments.length;a>s&&(!e||!n);s++)i=arguments[s],e=e||i.initialize,n=n||i.prototype;return e=e||function(){r.apply(this,arguments)},n=e.prototype=n||h(this.prototype),c(n,"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,n=arguments.length;n>e;e++){var i=arguments[e];i&&t(this,i,i.enumerable,i.beans,i.preserve)}return this},extend:function(){var t=h(this);return t.inject.apply(t,arguments)},each:function(t,e){return n(this,t,e)},set:function(t){return r(this,t)},clone:function(){return new this.constructor(this)},statics:{each:n,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===i||"Object"===e.name)},pick:function(t,n){return t!==e?t:n}}})};"undefined"!=typeof module&&(module.exports=i),i.inject({toString:function(){return null!=this._id?(this._class||"Object")+(this._name?" '"+this._name+"'":" @"+this._id):"{ "+i.each(this,function(t,e){if(!/^_/.test(e)){var n=typeof t;this.push(e+": "+("number"===n?o.instance.number(t):"string"===n?"'"+t+"'":t))}},[]).join(", ")+" }"},getClassName:function(){return this._class||""},exportJSON:function(t){return i.exportJSON(this,t)},toJSON:function(){return i.serialize(this)},_set:function(t,n,r){if(t&&(r||i.isPlainObject(t))){for(var s=Object.keys(t._filtering||t),a=0,o=s.length;o>a;a++){var h=s[a];if(!n||!n[h]){var u=t[h];u!==e&&(this[h]=u)}}return!0}},statics:{exports:{enumerable:!0},extend:function nt(){var t=nt.base.apply(this,arguments),e=t.prototype._class;return e&&!i.exports[e]&&(i.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 n=t.length;if(n!==e.length)return!1;for(;n--;)if(!i.equals(t[n],e[n]))return!1}else{var r=Object.keys(t),n=r.length;if(n!==Object.keys(e).length)retu
|
2016-01-30 07:48:16 -05:00
|
|
|
var t=l.read(arguments),e=l.read(arguments,0,{readNull:!0}),n=Math.PI/180,i=new l(Math.tan(t.x*n),Math.tan(t.y*n));return this.shear(i,e)},append:function(t){var e=this._a,n=this._b,i=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*n,this._b=a*e+h*n,this._c=s*i+o*r,this._d=a*i+h*r,this._tx+=u*e+l*n,this._ty+=u*i+l*r,this._changed(),this},appended:function(t){return this.clone().append(t)},prepend:function(t){var e=this._a,n=this._b,i=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*i,this._b=o*n+h*r,this._c=u*e+l*i,this._d=u*n+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,n=this._c,i=this._d,r=this._tx,s=this._ty,a=t*i-e*n,o=null;return a&&!isNaN(a)&&isFinite(r)&&isFinite(s)&&(this._a=i/a,this._b=-e/a,this._c=-n/a,this._d=t/a,this._tx=(e*s-i*r)/a,this._ty=(n*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,n){return arguments.length<3?this._transformPoint(l.read(arguments)):this._transformCoordinates(t,e,n)},_transformPoint:function(t,e,n){var i=t.x,r=t.y;return e||(e=new l),e.set(i*this._a+r*this._b+this._tx,i*this._c+r*this._d+this._ty,n)},_transformCoordinates:function(t,e,n){for(var i=0,r=2*n;r>i;i+=2){var s=t[i],a=t[i+1];e[i]=s*this._a+a*this._b+this._tx,e[i+1]=s*this._c+a*this._d+this._ty}return e},_transformCorners:function(t){var e=t.x,n=t.y,i=e+t.width,r=n+t.height,s=[e,n,i,n,i,r,e,r];return this._transformCoordinates(s,s,4)},_transformBounds:function(t,e,n){for(var i=this._transformCorners(t),r=i.slice(0,2),s=r.slice(),a=2;8>a;a++){var o=i[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],n)},inverseTransform:function(){return this._inverseTransform(l.read(arguments))},_inverseTransform:function(t,e,n){var i=this._a,r=this._b,s=this._c,a=this._d,o=this._tx,h=this._ty,u=i*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,(_*i-d*s)/u,n)}return c},decompose:function(){var t=this._a,e=this._b,n=this._c,i=this._d;if(h.isZero(t*i-e*n))return null;var r=Math.sqrt(t*t+e*e);t/=r,e/=r;var s=t*n+e*i;n-=t*s,i-=e*s;var a=Math.sqrt(n*n+i*i);return n/=a,i/=a,s/=a,e*n>t*i&&(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)}},i.each(["a","c","b","d","tx","ty"],function(t){var e=i.capitalize(t),n="_"+t;this["get"+e]=function(){return this[n]},this["set"+e]=function(t){this[n]=t,this._changed()}},{})),p=i.extend({_class:"Line",initialize:function(t,e,n,i,r){var s=!1;arguments.length>=4?(this._px=t,this._py=e,this._vx=n,this._vy=i,s=r):(this._px=t.x,this._py=t.y,this._vx=e.x,this._vy=e.y,s=n),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,!
|
2016-01-30 10:57:46 -05:00
|
|
|
t=n[i];break}this._clipItem=t}return t},isClipped:function(){return!!this._getClipItem()},setClipped:function(t){var e=this.getFirstChild();e&&e.setClipMask(t)},_draw:function(t,e){var n=e.clip,i=!n&&this._getClipItem();e=e.extend({clipItem:i,clip:!1}),n?(t.beginPath(),e.dontStart=e.dontFinish=!0):i&&i.draw(t,e.extend({clip:!0}));for(var r=this._children,s=0,a=r.length;a>s;s++){var o=r[s];o!==i&&o.draw(t,e)}}}),b=x.extend({_class:"Layer",initialize:function(){x.apply(this,arguments)},_getOwner:function(){return this._parent||null!=this._index&&this._project},isInserted:function ct(){return this._parent?ct.base.call(this):null!=this._index},activate:function(){this._project._activeLayer=this},_hitTestSelf:function(){return null}}),S=w.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)&&i.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,n=t.width,i=t.height;if("rectangle"===e){var r=d.min(this._radius,t.divide(2));this._radius.set(r.width,r.height)}else"circle"===e?(n=i=(n+i)/2,this._radius=n/2):"ellipse"===e&&this._radius.set(n/2,i/2);this._size.set(n,i),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 n=2*t;this._radius=t,this._size.set(n,n)}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 n=d.max(this._size,t.multiply(2));this._size.set(n.width,n.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 n=new(T[i.capitalize(this._type)])({center:new l,size:this._size,radius:this._radius,insert:!1});return n.copyAttributes(this),paper.settings.applyMatrix&&n.setApplyMatrix(!0),(t===e||t)&&n.insertAbove(this),n},toShape:"#clone",_draw:function(t,e,n){var i=this._style,r=i.hasFill(),s=i.hasStroke(),a=e.dontFinish||e.clip,o=!n;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];n&&n.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(i.getFillRule()),t.shadowBlur=0),s&&t.stroke())},_canComposite:function(){return!(this.hasFill()&&this.hasStroke())},_getBounds:function(t,e,n,i){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(T._getStrokePadding(a,this._getStrokeMatrix(e,i))):r}},new function(){function t(t,e,n){var i=t._radius;if(!i.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(i)),u=new f(o,h);if((n?u.expand(n):u).contains(e))return h}}function e(t,e,n,i){var r=t.divide(e);return
|
|
|
|
L>N&&(N=L,z=O[T])}var B=k.subdivide(t,z);i.excludeEnd=!0,i.renormalize=function(t,e){return[t*z,e*(1-z)+z]},k._getIntersections(B[0],B[1],e,e,n,i)}}return n},getOverlaps:function(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=4e-7,s=2e-7,a=k.isStraight(t),o=k.isStraight(e),h=a&&o,u=n(t)<n(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=k.getParameterOf(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||i(w[0]-g[0][0])>r&&i(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=k.getPart(t,g[0][0],g[1][0]),b=k.getPart(e,g[0][1],g[1][1]);(i(b[2]-x[2])>s||i(b[3]-x[3])>s||i(b[4]-x[4])>s||i(b[5]-x[5])>s)&&(g=null)}return g}}}}),O=i.extend({_class:"CurveLocation",beans:!0,initialize:function dt(t,e,n,i,r){if(e>.9999996){var s=t.getNext();s&&(e=0,t=s)}this._id=u.get(dt),this._setCurve(t),this._parameter=e,this._point=n||t.getPointAt(e,!0),this._overlap=i,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._parameter=t===this._segment1?0:1,this._point=t._point.clone()},getSegment:function(){var t=this.getCurve(),e=this._segment;if(!e){var n=this.getParameter();0===n?e=t._segment1:1===n?e=t._segment2:null!=n&&(e=t.getPartLength(0,n)<t.getPartLength(n,1)?t._segment1:t._segment2),this._segment=e}return e},getCurve:function(){function t(t){var e=t&&t.getCurve();return e&&null!=(n._parameter=e.getParameterOf(n._point))?(n._setCurve(e),n._segment=t,e):void 0}var e=this._path,n=this;return e&&e._version!==this._version&&(this._parameter=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()},getParameter:function(){var t=this.getCurve(),e=this._parameter;return t&&null==e?this._parameter=t.getParameterOf(this._point):e},getPoint:function(){return this._point},getOffset:function(){var t=this._offset;if(null==t){t=0;var e=this.getPath(),n=this.getIndex();if(e&&null!=n)for(var i=e.getCurves(),r=0;n>r;r++)t+=i[r].getLength();this._offset=t+=this.getCurveOffset()}return t},getCurveOffset:function(){var t=this.getCurve(),e=this.getParameter();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.divide(this.getParameter(),!0),e&&this._setSegment(e._segment1)),e},split:function(){var t=this.getCurve();return t?t.split(this.getParameter(),!0):null},equals:function(t,e){var n=this===t,i=2e-7;if(!n&&t instanceof O&&this.getPath()===t.getPath()&&this.getPoint().isClose(t.getPoint(),i)){var r=this.getCurve(),s=t.getCurve(),a=Math.abs,o=a((r.isLast()&&s.isFirst()?-1:r.getIndex())+this.getParameter()-((s.isLast()&&r.isFirst()?-1:s.getIndex())+t.getParameter()));n=(4e-7>o||(o=a(this.getOffset()-t.getOffset()))<i||a(this.getPath().getLength()-o)<i)&&(e||!this._intersection&&!t._intersection||this._intersection&&this._intersection.equals(t._intersection,!0))}return n},toString:function(){var t=[],e=this.getPoint(),n=o.instance;e&&t.push("point: "+e);var i=this.getIndex();null!=i&&t.push("index: "+i);var r=this.getParameter();return null!=r&&t.push("parameter: "+n.number(r)),null!=this._distance&&t.push("distance: "+n.number(this._distance)),"{ "+t.join(", ")+" }"},isTouching:function(){var t=this._intersection;if(t&&this.getT
|
|
|
|
s instanceof N&&(n=n.slice(),n.splice.apply(n,[r,1].concat(s.removeChildren())),s.remove())}n=gt.base.call(this,t,n,i,T);for(var r=0,a=!i&&n&&n.length;a>r;r++){var s=n[r];s._clockwise===e&&s.setClockwise(0===s._index)}return n},reverse:function(){for(var t=this._children,e=0,n=t.length;n>e;e++)t[e].reverse()},reduce:function vt(t){for(var e=this._children,n=e.length-1;n>=0;n--){var i=e[n].reduce(t);i.isEmpty()&&i.remove()}if(0===e.length){var i=new T(w.NO_INSERT);return i.copyAttributes(this),i.insertAbove(this),this.remove(),i}return vt.base.call(this)},smooth:function(t){for(var e=this._children,n=0,i=e.length;i>n;n++)e[n].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=[],n=0,i=t.length;i>n;n++)e.push.apply(e,t[n].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,n=0,i=t.length;i>n;n++)e+=t[n].getArea();return e}},{beans:!0,getPathData:function(t,e){for(var n=this._children,i=[],r=0,s=n.length;s>r;r++){var a=n[r],o=a._matrix;i.push(a.getPathData(t&&!o.isIdentity()?t.appended(o):t,e))}return i.join(" ")}},{_getChildHitTestOptions:function(t){return t["class"]===T||"path"===t.type?t:new i(t,{fill:!1})},_draw:function(t,e,n){var i=this._children;if(0!==i.length){e=e.extend({dontStart:!0,dontFinish:!0}),t.beginPath();for(var r=0,s=i.length;s>r;r++)i[r].draw(t,e,n);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,n){for(var i=this._children,r=0,s=i.length;s>r;r++){var a=i[r],o=a._matrix;n[a._id]||a._drawSelected(t,o.isIdentity()?e:e.appended(o))}}},new function(){function t(t,e){var n=t._children;if(e&&0===n.length)throw new Error("Use a moveTo() command first");return n[n.length-1]}var e={moveTo:function(){var e=t(this),n=e&&e.isEmpty()?e:new T(w.NO_INSERT);n!==e&&this.addChild(n),n.moveTo.apply(n,arguments)},moveBy:function(){var e=t(this,!0),n=e&&e.getLastSegment(),i=l.read(arguments);this.moveTo(n?i.add(n._point):i)},closePath:function(e){t(this,!0).closePath(e)}};return i.each(["lineTo","cubicCurveTo","quadraticCurveTo","curveTo","arcTo","lineBy","cubicCurveBy","quadraticCurveBy","curveBy","arcBy"],function(n){e[n]=function(){var e=t(this,!0);e[n].apply(e,arguments)}}),e});A.inject(new function(){function t(t,e){var n=t.clone(!1).reduce({simplify:!0}).transform(null,!0,!0);return e?n.resolveCrossings():n}function e(t,e,n){return t.insertAbove(n&&e.isSibling(n)&&e.getIndex()<n.getIndex()?n:e),t.copyAttributes(e,!0),t}function n(t,e,n){var i=new t(w.NO_INSERT);return i.addChildren(e,!0),n&&(i=i.reduce({simplify:!0})),i}function r(i,r,a){function h(t){for(var e=0,n=t.length;n>e;e++){var i=t[e];v.push.apply(v,i._segments),p.push.apply(p,i._getMonoCurves())}}var u=_[a];if(u[a]=!0,!i._children&&!i._closed)return s(i,r,u);var l=t(i,!0),f=r&&i!==r&&t(r,!0);f&&(u.subtract||u.exclude)^(f.isClockwise()^l.isClockwise())&&f.reverse();var g=o(O.expand(l.getCrossings(f))),v=[],p=[],m=!0,y=!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]&&(y=!1))}return e(m?(u.unite||u.intersect)&&i.getArea()?i.clone(!1):new T(w.NO_INSERT):n(N,d(v,u,y),!m),i,r)}function s(i,r,s){function a(t){return h.contains(t.getPointAt(t.getLength()/2))^l?(c.unshift(t),!0):void 0}if(!r||!r._children&&!r._closed||!s.subtract&&!s.intersect)return null;for(var o=t(i,!1),h=t(r,!1),u=o.getCrossings(h),l=s.subtract,c=[],d=u.length-1;d>=0;d--){var _=u[d].split();_&&(a(_)&&_.getFirstSegment().s
|
|
|
|
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:i.each(w._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 i({delta:e,time:this._time+=e,count:this._count++})),this._stats&&this._stats.update()},_animateItem:function(t,e){var n=this._frameItems;e?(n[t._id]={item:t,time:0,count:0},1===++this._frameItemCount&&this.on("frame",this._handleFrameItems)):(delete n[t._id],0===--this._frameItemCount&&this.off("frame",this._handleFrameItems))},_handleFrameItems:function(t){for(var e in this._frameItems){var n=this._frameItems[e];n.item.emit("frame",new i(t,{time:n.time+=t.delta,count:n.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,n=t.height,i=t.subtract(this._viewSize);i.isZero()||(this._viewSize.set(e,n),this._setViewSize(e,n),this.emit("resize",{size:t,delta:i}),this._changed(),this._autoUpdate&&this.requestUpdate())},_setViewSize:function(t,e){var n=this._element;n.width!==t&&(n.width=t),n.height!==e&&(n.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)}},i.each(["rotate","scale","shear","skew"],function(t){var e="rotate"===t;this[t]=function(){var n=(e?i:l).read(arguments),r=l.read(arguments,0,{readNull:!0});return this.transform((new v)[t](n,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=n.getElementById(e)),new G(t,e)}}},new function(){function i(t){var e=H.getTarget(t);return e.getAttribute&&Z._viewsById[e.getAttribute("id")]}function r(){var t=Z._focused;if(!t||!t.isVisible())for(var e=0,n=Z._views.length;n>e;e++)if((t=Z._views[e]).isVisible()){Z._focused=u=t;break}}function s(t,e,n){t._handleMouseEvent("mousemove",e,n)}function a(t,e,n,i,r,s){function a(t,e){if(t.responds(e)){if(o||(o=new X(e,n,i,h,r?i.subtract(r):null)),t.emit(e,o)&&(I=!0,
|