diff --git a/dist/docs/assets/js/paper.js b/dist/docs/assets/js/paper.js index 22b3ea8c..94c123ba 100644 --- a/dist/docs/assets/js/paper.js +++ b/dist/docs/assets/js/paper.js @@ -9,7 +9,7 @@ * * All rights reserved. * - * Date: Tue Jul 19 10:24:37 2016 +0200 + * Date: Tue Jul 19 13:08:21 2016 +0200 * *** * @@ -39,8 +39,13 @@ var window = self.window, var Base = new function() { var hidden = /^(statics|enumerable|beans|preserve)$/, + array = [], + slice = array.slice, + create = Object.create, + describe = Object.getOwnPropertyDescriptor, + define = Object.defineProperty, - forEach = [].forEach || function(iter, bind) { + forEach = array.forEach || function(iter, bind) { for (var i = 0, l = this.length; i < l; i++) { iter.call(bind, this[i], i, this); } @@ -53,10 +58,6 @@ var Base = new function() { } }, - create = Object.create, - describe = Object.getOwnPropertyDescriptor, - define = Object.defineProperty, - set = Object.assign || function(dst) { for (var i = 1, l = arguments.length; i < l; i++) { var src = arguments[i]; @@ -76,6 +77,7 @@ var Base = new function() { } return bind; }; + function inject(dest, src, enumerable, beans, preserve) { var beansNames = {}; @@ -216,6 +218,10 @@ var Base = new function() { pick: function(a, b) { return a !== undefined ? a : b; + }, + + slice: function(list, begin, end) { + return slice.call(list, begin, end); } } }); @@ -309,7 +315,7 @@ Base.inject({ return false; }, - read: function(list, start, options, length) { + read: function(list, start, options, amount) { if (this === Base) { var value = this.peek(list, start); list.__index++; @@ -317,24 +323,24 @@ Base.inject({ } var proto = this.prototype, readIndex = proto._readIndex, - index = start || readIndex && list.__index || 0; - if (!length) - length = list.length - index; - var obj = list[index]; + begin = start || readIndex && list.__index || 0, + length = list.length, + obj = list[begin]; + amount = amount || length - begin; if (obj instanceof this - || options && options.readNull && obj == null && length <= 1) { + || options && options.readNull && obj == null && amount <= 1) { if (readIndex) - list.__index = index + 1; + list.__index = begin + 1; return obj && options && options.clone ? obj.clone() : obj; } obj = Base.create(this.prototype); if (readIndex) obj.__read = true; - obj = obj.initialize.apply(obj, index > 0 || length < list.length - ? Array.prototype.slice.call(list, index, index + length) - : list) || obj; + obj = obj.initialize.apply(obj, begin > 0 || begin + amount < length + ? Base.slice(list, begin, begin + amount) + : list) || obj; if (readIndex) { - list.__index = index + obj.__read; + list.__index = begin + obj.__read; obj.__read = undefined; } return obj; @@ -348,10 +354,12 @@ Base.inject({ return list.length - (list.__index || 0); }, - readAll: function(list, start, options) { + readList: function(list, start, options, amount) { var res = [], - entry; - for (var i = start || 0, l = list.length; i < l; i++) { + entry, + begin = start || 0, + end = amount ? begin + amount : list.length; + for (var i = begin; i < end; i++) { res.push(Array.isArray(entry = list[i]) ? this.read(entry, 0, options) : this.read(list, i, options, 1)); @@ -359,7 +367,7 @@ Base.inject({ return res; }, - readNamed: function(list, name, start, options, length) { + readNamed: function(list, name, start, options, amount) { var value = this.getNamed(list, name), hasObject = value !== undefined; if (hasObject) { @@ -370,7 +378,7 @@ Base.inject({ } filtered[name] = undefined; } - return this.read(hasObject ? [value] : list, start, options, length); + return this.read(hasObject ? [value] : list, start, options, amount); }, getNamed: function(list, name) { @@ -622,7 +630,7 @@ var Emitter = { var handlers = this._callbacks && this._callbacks[type]; if (!handlers) return false; - var args = [].slice.call(arguments, 1), + var args = Base.slice(arguments, 1), setTarget = event && event.target && !event.currentTarget; handlers = handlers.slice(); if (setTarget) @@ -3860,13 +3868,13 @@ new function() { return this.insertChildren(this._children.length, items, _preserve); }, - insertChildren: function(index, items, _preserve, _proto) { + insertChildren: function(index, items, _preserve) { var children = this._children; if (children && items && items.length > 0) { - items = Array.prototype.slice.apply(items); + items = Base.slice(items); for (var i = items.length - 1; i >= 0; i--) { var item = items[i]; - if (!item || _proto && !(item instanceof _proto)) { + if (!item) { items.splice(i, 1); } else { item._remove(false, true); @@ -5432,27 +5440,25 @@ var Segment = Base.extend({ initialize: function Segment(arg0, arg1, arg2, arg3, arg4, arg5) { var count = arguments.length, - point, handleIn, handleOut, - selection; - if (count === 0) { - } else if (count === 1) { - if (arg0 && 'point' in arg0) { - point = arg0.point; - handleIn = arg0.handleIn; - handleOut = arg0.handleOut; - selection = arg0.selection; + point, handleIn, handleOut, selection; + if (count > 0) { + if (arg0 == null || typeof arg0 === 'object') { + if (count === 1 && arg0 && 'point' in arg0) { + point = arg0.point; + handleIn = arg0.handleIn; + handleOut = arg0.handleOut; + selection = arg0.selection; + } else { + point = arg0; + handleIn = arg1; + handleOut = arg2; + selection = arg3; + } } else { - point = arg0; + point = [ arg0, arg1 ]; + handleIn = arg2 !== undefined ? [ arg2, arg3 ] : null; + handleOut = arg4 !== undefined ? [ arg4, arg5 ] : null; } - } else if (arg0 == null || typeof arg0 === 'object') { - point = arg0; - handleIn = arg1; - handleOut = arg2; - selection = arg3; - } else { - point = arg0 !== undefined ? [ arg0, arg1 ] : null; - handleIn = arg2 !== undefined ? [ arg2, arg3 ] : null; - handleOut = arg4 !== undefined ? [ arg4, arg5 ] : null; } new SegmentPoint(point, this, '_point'); new SegmentPoint(handleIn, this, '_handleIn'); @@ -7364,10 +7370,28 @@ var PathItem = Item.extend({ }, statics: { - create: function(pathData) { - var ctor = (pathData && pathData.match(/m/gi) || []).length > 1 - || /z\s*\S+/i.test(pathData) ? CompoundPath : Path; - return new ctor(pathData); + + create: function(arg) { + var data, + segments, + compound; + if (Base.isPlainObject(arg)) { + segments = arg.segments; + data = arg.pathData; + } else if (Array.isArray(arg)) { + segments = arg; + } else if (typeof arg === 'string') { + data = arg; + } + if (segments) { + var first = segments[0]; + compound = first && Array.isArray(first[0]); + } else if (data) { + compound = (data.match(/m/gi) || []).length > 1 + || /z\s*\S+/i.test(data); + } + var ctor = compound ? CompoundPath : Path; + return new ctor(arg); } }, @@ -7676,12 +7700,19 @@ var Path = PathItem.extend({ }, setSegments: function(segments) { - var fullySelected = this.isFullySelected(); + var fullySelected = this.isFullySelected(), + length = segments && segments.length; this._segments.length = 0; this._segmentSelection = 0; this._curves = undefined; - if (segments && segments.length > 0) - this._add(Segment.readAll(segments)); + if (length) { + var last = segments[length - 1]; + if (typeof last === 'boolean') { + this.setClosed(last); + length--; + } + this._add(Segment.readList(segments, 0, {}, length)); + } if (fullySelected) this.setFullySelected(true); }, @@ -7764,13 +7795,13 @@ var Path = PathItem.extend({ dy = curY - prevY; parts.push( dx === 0 ? 'v' + f.number(dy) - : dy === 0 ? 'h' + f.number(dx) + : dy === 0 ? 'h' + f.number(dx) : 'l' + f.pair(dx, dy)); } } else { parts.push('c' + f.pair(outX - prevX, outY - prevY) - + ' ' + f.pair(inX - prevX, inY - prevY) - + ' ' + f.pair(curX - prevX, curY - prevY)); + + ' ' + f.pair( inX - prevX, inY - prevY) + + ' ' + f.pair(curX - prevX, curY - prevY)); } } prevX = curX; @@ -7872,13 +7903,13 @@ var Path = PathItem.extend({ add: function(segment1 ) { return arguments.length > 1 && typeof segment1 !== 'number' - ? this._add(Segment.readAll(arguments)) + ? this._add(Segment.readList(arguments)) : this._add([ Segment.read(arguments) ])[0]; }, insert: function(index, segment1 ) { return arguments.length > 2 && typeof segment1 !== 'number' - ? this._add(Segment.readAll(arguments, 1), index) + ? this._add(Segment.readList(arguments, 1), index) : this._add([ Segment.read(arguments, 1) ], index)[0]; }, @@ -7891,11 +7922,11 @@ var Path = PathItem.extend({ }, addSegments: function(segments) { - return this._add(Segment.readAll(segments)); + return this._add(Segment.readList(segments)); }, insertSegments: function(index, segments) { - return this._add(Segment.readAll(segments), index); + return this._add(Segment.readList(segments), index); }, removeSegment: function(index) { @@ -9282,21 +9313,30 @@ var CompoundPath = PathItem.extend({ }, insertChildren: function insertChildren(index, items, _preserve) { + var list = items, + first = list[0]; + if (first && typeof first[0] === 'number') + list = [list]; for (var i = items.length - 1; i >= 0; i--) { - var item = items[i]; - if (item instanceof CompoundPath) { - items = items.slice(); - items.splice.apply(items, [i, 1].concat(item.removeChildren())); + var item = list[i]; + if (list === items && !(item instanceof Path)) + list = Base.slice(list); + if (Array.isArray(item)) { + var path = new Path({ segments: item, insert: false }); + path.setClockwise(path.isClockwise()); + list[i] = path; + } else if (item instanceof CompoundPath) { + list.splice.apply(list, [i, 1].concat(item.removeChildren())); item.remove(); } } - items = insertChildren.base.call(this, index, items, _preserve, Path); - for (var i = 0, l = !_preserve && items && items.length; i < l; i++) { - var item = items[i]; + list = insertChildren.base.call(this, index, list, _preserve); + for (var i = 0, l = !_preserve && list && list.length; i < l; i++) { + var item = list[i]; if (item._clockwise === undefined) item.setClockwise(item._index === 0); } - return items; + return list; }, reduce: function reduce(options) { @@ -10793,8 +10833,7 @@ var Color = Base.extend(new function() { _readIndex: true, initialize: function Color(arg) { - var slice = Array.prototype.slice, - args = arguments, + var args = arguments, reading = this.__read, read = 0, type, @@ -10815,7 +10854,7 @@ var Color = Base.extend(new function() { } else { if (reading) read = 1; - args = slice.call(args, 1); + args = Base.slice(args, 1); argType = typeof arg; } } @@ -10838,7 +10877,7 @@ var Color = Base.extend(new function() { : 1; } if (values.length > length) - values = slice.call(values, 0, length); + values = Base.slice(values, 0, length); } else if (argType === 'string') { type = 'rgb'; components = fromCSS(arg); @@ -11180,7 +11219,7 @@ var Gradient = Base.extend({ for (var i = 0, l = _stops.length; i < l; i++) _stops[i]._owner = undefined; } - _stops = this._stops = GradientStop.readAll(stops, 0, { clone: true }); + _stops = this._stops = GradientStop.readList(stops, 0, { clone: true }); for (var i = 0, l = _stops.length; i < l; i++) _stops[i]._owner = this; this._changed(); @@ -12363,7 +12402,7 @@ var CanvasView = View.extend({ if (size.isZero()) throw new Error( 'Cannot create CanvasView with the provided argument: ' - + [].slice.call(arguments, 1)); + + Base.slice(arguments, 1)); canvas = CanvasProvider.getCanvas(size); } var ctx = this._context = canvas.getContext('2d'); diff --git a/dist/docs/classes/CompoundPath.html b/dist/docs/classes/CompoundPath.html index 1dbd8617..16184eb6 100644 --- a/dist/docs/classes/CompoundPath.html +++ b/dist/docs/classes/CompoundPath.html @@ -42,7 +42,7 @@
u.CURVETIME_EPSILON)&&t(s,a,e,n,O,o?z:M,i,r,A,o?M:z)}}}function a(e,i,n,r,s,a){var o=m.intersect(e[0],e[1],e[6],e[7],i[0],i[1],i[6],i[7]);o&&t(s,a,e,n,null,o,i,r,null,o)}return{statics:{_getIntersections:function(i,n,r,o,h,u){if(!n)return k._getSelfIntersection(i,r,h,u);var l=2e-7,f=i[0],d=i[1],_=i[6],g=i[7],v=n[0],p=n[1],m=n[6],y=n[7],w=(3*i[2]+f)/4,x=(3*i[3]+d)/4,b=(3*i[4]+_)/4,C=(3*i[5]+g)/4,S=(3*n[2]+v)/4,P=(3*n[3]+p)/4,I=(3*n[4]+m)/4,M=(3*n[5]+y)/4,T=Math.min,z=Math.max;if(!(z(f,w,b,_)+l>T(v,S,I,m)&&T(f,w,b,_)-l =2&&!t.hasHandles())if(h>2){s=t._closed?"polygon":"polyline";for(var l=[],c=0;c u.CURVETIME_EPSILON)&&t(s,a,e,n,O,o?z:M,i,r,A,o?M:z)}}}function a(e,i,n,r,s,a){var o=m.intersect(e[0],e[1],e[6],e[7],i[0],i[1],i[6],i[7]);o&&t(s,a,e,n,null,o,i,r,null,o)}return{statics:{_getIntersections:function(i,n,r,o,h,u){if(!n)return k._getSelfIntersection(i,r,h,u);var l=2e-7,f=i[0],d=i[1],_=i[6],g=i[7],v=n[0],p=n[1],m=n[6],y=n[7],w=(3*i[2]+f)/4,x=(3*i[3]+d)/4,b=(3*i[4]+_)/4,C=(3*i[5]+g)/4,S=(3*n[2]+v)/4,P=(3*n[3]+p)/4,I=(3*n[4]+m)/4,M=(3*n[5]+y)/4,T=Math.min,z=Math.max;if(!(z(f,w,b,_)+l>T(v,S,I,m)&&T(f,w,b,_)-l =2&&!t.hasHandles())if(h>2){s=t._closed?"polygon":"polyline";for(var l=[],c=0;cr&&n=s&&(h=h.getNext()),n>=s&&(l=l.getNext()),!(u&&h&&c&&l))return!1;var f=[];a||f.push(u.getLength(),h.getLength()),o||f.push(c.getLength(),l.getLength());var d=this.getPoint(),_=Math.min.apply(Math,f)/64,g=a?h.getTangentAtTime(i):h.getPointAt(_).subtract(d),v=a?g.negate():u.getPointAt(-_).subtract(d),p=o?l.getTangentAtTime(n):l.getPointAt(_).subtract(d),m=o?p.negate():c.getPointAt(-_).subtract(d),y=v.getAngle(),w=g.getAngle(),x=m.getAngle(),b=p.getAngle();return!!(a?t(y,x,b)^t(w,x,b)&&t(y,b,x)^t(w,b,x):t(x,y,w)^t(b,y,w)&&t(x,w,y)^t(b,w,y))},hasOverlap:function(){return!!this._overlap}},r.each(k._evaluateMethods,function(t){var e=t+"At";this[t]=function(){var t=this.getCurve(),i=this.getTime();return null!=i&&t&&t[e](i,!0)}},{preserve:!0}),new function(){function t(t,e,i){function n(i,n){for(var s=i+n;s>=-1&&s<=r;s+=n){var a=t[(s%r+r)%r];if(!e.getPoint().isClose(a.getPoint(),2e-7))break;if(e.equals(a))return a}return null}for(var r=t.length,s=0,a=r-1;s<=a;){var o,h=s+a>>>1,u=t[h];if(i&&(o=e.equals(u)?u:n(h,-1)||n(h,1)))return e._overlap&&(o._overlap=o._intersection._overlap=!0),o;var l=e.getPath(),c=u.getPath(),f=l===c?e.getIndex()+e.getTime()-(u.getIndex()+u.getTime()):l._id-c._id;f<0?a=h-1:s=h+1}return t.splice(s,0,e),e}return{statics:{insert:t,expand:function(e){for(var i=e.slice(),n=e.length-1;n>=0;n--)t(i,e[n]._intersection,!1);return i}}}}),A=w.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,initialize:function(){},statics:{create:function(t){var e=(t&&t.match(/m/gi)||[]).length>1||/z\s*\S+/i.test(t)?L:N;return new e(t)}},_asPathItem:function(){return this},setPathData:function(t){function e(t,e){var i=+n[t];return o&&(i+=h[e]),i}function i(t){return new c(e(t,"x"),e(t+1,"y"))}var n,r,s,a=t&&t.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),o=!1,h=new c,u=new c;this.clear();for(var l=0,f=a&&a.length;lP&&(h+=O))),b=O,C=m[6]}else(r-m[0])*(r-m[6])<=0&&(T=!0);T&&(p>=u-1||e[p+1].last)&&(I+=1,M-=1)}0===a&&0===h&&(a=I,h=M)}return{winding:Math.max(f(a),f(h)),contour:!a^!h}}function h(t,e,i,n,r){var s,a=[],h=t,u=0;do{var l=t.getCurve(),c=l.getLength();a.push({segment:t,curve:l,length:c}),u+=c,t=t.getNext()}while(t&&!t._intersection&&t!==h);for(var c=u/2,f=0,d=a.length;f=s&&(s=u,r=a)}return{error:s,index:r}}}),D=w.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(t){this._content="",this._lines=[];var i=t&&r.isPlainObject(t)&&t.x===e&&t.y===e;this._initialize(i&&t,!i&&c.read(arguments))},_equals:function(t){return this._content===t._content},copyContent:function(t){this.setContent(t._content)},getContent:function(){return this._content},setContent:function(t){this._content=""+t,this._lines=this._content.split(/\r\n|\n|\r/gm),this._changed(265)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),j=D.extend({_class:"PointText",initialize:function(){D.apply(this,arguments)},getPoint:function(){var t=this._matrix.getTranslation();return new f(t.x,t.y,this,"setPoint")},setPoint:function(){var t=c.read(arguments);this.translate(t.subtract(this._matrix.getTranslation()))},_draw:function(t,e,i){if(this._content){this._setStyles(t,e,i);var n=this._lines,r=this._style,s=r.hasFill(),a=r.hasStroke(),o=r.getLeading(),h=t.shadowColor;t.font=r.getFontStyle(),t.textAlign=r.getJustification();for(var u=0,l=n.length;us?u:s,_=l>a?l:a,g=c>o?c:o},difference:function(){d=u-s,d<0&&(d=-d),_=l-a,_<0&&(_=-_),g=c-o,g<0&&(g=-g)},exclusion:function(){d=u+s*(255-u-u)/255,_=l+a*(255-l-l)/255,g=c+o*(255-c-c)/255},hue:function(){n(s,a,o,i(u,l,c)),e(d,_,g,t(u,l,c))},saturation:function(){n(u,l,c,i(s,a,o)),e(d,_,g,t(u,l,c))},luminosity:function(){e(u,l,c,t(s,a,o))},color:function(){e(s,a,o,t(u,l,c))},add:function(){d=v(u+s,255),_=v(l+a,255),g=v(c+o,255)},subtract:function(){d=p(u-s,0),_=p(l-a,0),g=p(c-o,0)},average:function(){d=(u+s)/2,_=(l+a)/2,g=(c+o)/2},negation:function(){d=255-m(255-s-u),_=255-m(255-a-l),g=255-m(255-o-c)}},w=this.nativeModes=r.each(["source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","darker","copy","xor"],function(t){this[t]=!0},{}),x=Q.getContext(1,1);x&&(r.each(y,function(t,e){var i="darken"===e,n=!1;x.save();try{x.fillStyle=i?"#300":"#a00",x.fillRect(0,0,1,1),x.globalCompositeOperation=e,x.globalCompositeOperation===e&&(x.fillStyle=i?"#a00":"#300",x.fillRect(0,0,1,1),n=x.getImageData(0,0,1,1).data[0]!==i?170:51)}catch(r){}x.restore(),w[e]=n}),Q.release(x)),this.process=function(t,e,i,n,r){var v=e.canvas,p="normal"===t;if(p||w[t])i.save(),i.setTransform(1,0,0,1,0,0),i.globalAlpha=n,p||(i.globalCompositeOperation=t),i.drawImage(v,r.x,r.y),i.restore();else{var m=y[t];if(!m)return;for(var x=i.getImageData(r.x,r.y,v.width,v.height),b=x.data,C=e.getImageData(0,0,v.width,v.height).data,S=0,P=b.length;S0){var s=e[r],a=s&&s[n];a&&a.call(this,r)}},statics:{inject:function rt(t){var e=t._events;if(e){var i={};r.each(e,function(e,n){var s="string"==typeof e,a=s?e:n,o=r.capitalize(a),h=a.substring(2).toLowerCase();i[h]=s?{}:e,a="_"+a,t["get"+o]=function(){return this[a]},t["set"+o]=function(t){var e=this[a];e&&this.off(h,e),t&&this.on(h,t),this[a]=t}}),t._eventTypes=i}return rt.base.apply(this,arguments)}}},a=r.extend({_class:"PaperScope",initialize:function st(){paper=this,this.settings=new r({applyMatrix:!0,insertItems:!0,handleSize:4,hitTolerance:0}),this.project=null,this.projects=[],this.tools=[],this.palettes=[],this._id=st._id++,st._scopes[this._id]=this;var e=st.prototype;if(!this.support){var i=Q.getContext(1,1)||{};e.support={nativeDash:"setLineDash"in i||"mozDash"in i,nativeBlendModes:tt.nativeModes},Q.release(i)}if(!this.agent){var n=t.navigator.userAgent.toLowerCase(),s=(/(darwin|win|mac|linux|freebsd|sunos)/.exec(n)||[])[0],a="darwin"===s?"mac":s,o=e.agent=e.browser={platform:a};a&&(o[a]=!0),n.replace(/(opera|chrome|safari|webkit|firefox|msie|trident|atom|node)\/?\s*([.\d]+)(?:.*version\/([.\d]+))?(?:.*rv\:v?([.\d]+))?/g,function(t,e,i,n,r){if(!o.chrome){var s="opera"===e?n:/^(node|trident)$/.test(e)?r:i;o.version=s,o.versionNumber=parseFloat(s),e="trident"===e?"msie":e,o.name=e,o[e]=!0}}),o.chrome&&delete o.webkit,o.atom&&delete o.chrome}},version:"0.10.2-develop",getView:function(){var t=this.project;return t&&t._view},getPaper:function(){return this},execute:function(t,e){paper.PaperScript.execute(t,this,e),U.updateFocus()},install:function(t){var e=this;r.each(["project","view","tool"],function(i){r.define(t,i,{configurable:!0,get:function(){return e[i]}})});for(var i in this)!/^_/.test(i)&&this[i]&&(t[i]=this[i])},setup:function(t){return paper=this,this.project=new y(t),this},createCanvas:function(t,e){return Q.getCanvas(t,e)},activate:function(){paper=this},clear:function(){for(var t=this.projects,e=this.tools,i=this.palettes,n=t.length-1;n>=0;n--)t[n].remove();for(var n=e.length-1;n>=0;n--)e[n].remove();for(var n=i.length-1;n>=0;n--)i[n].remove()},remove:function(){this.clear(),delete a._scopes[this._id]},statics:new function(){function t(t){return t+="Attribute",function(e,i){return e[t](i)||e[t]("data-paper-"+i)}}return{_scopes:{},_id:0,get:function(t){return this._scopes[t]||null},getAttribute:t("get"),hasAttribute:t("has")}}}),o=r.extend(s,{initialize:function(t){this._scope=paper,this._index=this._scope[this._list].push(this)-1,!t&&this._scope[this._reference]||this.activate()},activate:function(){if(!this._scope)return!1;var t=this._scope[this._reference];return t&&t!==this&&t.emit("deactivate"),this._scope[this._reference]=this,this.emit("activate",t),!0},isActive:function(){return this._scope[this._reference]===this},remove:function(){return null!=this._index&&(r.splice(this._scope[this._list],null,this._index,1),this._scope[this._reference]==this&&(this._scope[this._reference]=null),this._scope=null,!0)},getView:function(){return this._scope.getView()}}),h=r.extend({initialize:function(t){this.precision=r.pick(t,5),this.multiplier=Math.pow(10,this.precision)},number:function(t){return this.precision<16?Math.round(t*this.multiplier)/this.multiplier:t},pair:function(t,e,i){return this.number(t)+(i||",")+this.number(e)},point:function(t,e){return this.number(t.x)+(e||",")+this.number(t.y)},size:function(t,e){return this.number(t.width)+(e||",")+this.number(t.height)},rectangle:function(t,e){return this.point(t,e)+(e||",")+this.size(t,e)}});h.instance=new h;var u=new function(){function t(t,e,i){return tr:nr&&n=s&&(h=h.getNext()),n>=s&&(l=l.getNext()),!(u&&h&&c&&l))return!1;var f=[];a||f.push(u.getLength(),h.getLength()),o||f.push(c.getLength(),l.getLength());var d=this.getPoint(),_=Math.min.apply(Math,f)/64,g=a?h.getTangentAtTime(i):h.getPointAt(_).subtract(d),v=a?g.negate():u.getPointAt(-_).subtract(d),p=o?l.getTangentAtTime(n):l.getPointAt(_).subtract(d),m=o?p.negate():c.getPointAt(-_).subtract(d),y=v.getAngle(),w=g.getAngle(),x=m.getAngle(),b=p.getAngle();return!!(a?t(y,x,b)^t(w,x,b)&&t(y,b,x)^t(w,b,x):t(x,y,w)^t(b,y,w)&&t(x,w,y)^t(b,w,y))},hasOverlap:function(){return!!this._overlap}},r.each(k._evaluateMethods,function(t){var e=t+"At";this[t]=function(){var t=this.getCurve(),i=this.getTime();return null!=i&&t&&t[e](i,!0)}},{preserve:!0}),new function(){function t(t,e,i){function n(i,n){for(var s=i+n;s>=-1&&s<=r;s+=n){var a=t[(s%r+r)%r];if(!e.getPoint().isClose(a.getPoint(),2e-7))break;if(e.equals(a))return a}return null}for(var r=t.length,s=0,a=r-1;s<=a;){var o,h=s+a>>>1,u=t[h];if(i&&(o=e.equals(u)?u:n(h,-1)||n(h,1)))return e._overlap&&(o._overlap=o._intersection._overlap=!0),o;var l=e.getPath(),c=u.getPath(),f=l===c?e.getIndex()+e.getTime()-(u.getIndex()+u.getTime()):l._id-c._id;f<0?a=h-1:s=h+1}return t.splice(s,0,e),e}return{statics:{insert:t,expand:function(e){for(var i=e.slice(),n=e.length-1;n>=0;n--)t(i,e[n]._intersection,!1);return i}}}}),A=w.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,initialize:function(){},statics:{create:function(t){var e,i,n;if(r.isPlainObject(t)?(i=t.segments,e=t.pathData):Array.isArray(t)?i=t:"string"==typeof t&&(e=t),i){var s=i[0];n=s&&Array.isArray(s[0])}else e&&(n=(e.match(/m/gi)||[]).length>1||/z\s*\S+/i.test(e));var a=n?N:L;return new a(t)}},_asPathItem:function(){return this},setPathData:function(t){function e(t,e){var i=+n[t];return o&&(i+=h[e]),i}function i(t){return new c(e(t,"x"),e(t+1,"y"))}var n,r,s,a=t&&t.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),o=!1,h=new c,u=new c;this.clear();for(var l=0,f=a&&a.length;lP&&(h+=O))),b=O,C=m[6]}else(r-m[0])*(r-m[6])<=0&&(T=!0);T&&(p>=u-1||e[p+1].last)&&(I+=1,M-=1)}0===a&&0===h&&(a=I,h=M)}return{winding:Math.max(f(a),f(h)),contour:!a^!h}}function h(t,e,i,n,r){var s,a=[],h=t,u=0;do{var l=t.getCurve(),c=l.getLength();a.push({segment:t,curve:l,length:c}),u+=c,t=t.getNext()}while(t&&!t._intersection&&t!==h);for(var c=u/2,f=0,d=a.length;f=s&&(s=u,r=a)}return{error:s,index:r}}}),D=w.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(t){this._content="",this._lines=[];var i=t&&r.isPlainObject(t)&&t.x===e&&t.y===e;this._initialize(i&&t,!i&&c.read(arguments))},_equals:function(t){return this._content===t._content},copyContent:function(t){this.setContent(t._content)},getContent:function(){return this._content},setContent:function(t){this._content=""+t,this._lines=this._content.split(/\r\n|\n|\r/gm),this._changed(265)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),j=D.extend({_class:"PointText",initialize:function(){D.apply(this,arguments)},getPoint:function(){var t=this._matrix.getTranslation();return new f(t.x,t.y,this,"setPoint")},setPoint:function(){var t=c.read(arguments);this.translate(t.subtract(this._matrix.getTranslation()))},_draw:function(t,e,i){if(this._content){this._setStyles(t,e,i);var n=this._lines,r=this._style,s=r.hasFill(),a=r.hasStroke(),o=r.getLeading(),h=t.shadowColor;t.font=r.getFontStyle(),t.textAlign=r.getJustification();for(var u=0,l=n.length;us?u:s,_=l>a?l:a,g=c>o?c:o},difference:function(){d=u-s,d<0&&(d=-d),_=l-a,_<0&&(_=-_),g=c-o,g<0&&(g=-g)},exclusion:function(){d=u+s*(255-u-u)/255,_=l+a*(255-l-l)/255,g=c+o*(255-c-c)/255},hue:function(){n(s,a,o,i(u,l,c)),e(d,_,g,t(u,l,c))},saturation:function(){n(u,l,c,i(s,a,o)),e(d,_,g,t(u,l,c))},luminosity:function(){e(u,l,c,t(s,a,o))},color:function(){e(s,a,o,t(u,l,c))},add:function(){d=v(u+s,255),_=v(l+a,255),g=v(c+o,255)},subtract:function(){d=p(u-s,0),_=p(l-a,0),g=p(c-o,0)},average:function(){d=(u+s)/2,_=(l+a)/2,g=(c+o)/2},negation:function(){d=255-m(255-s-u),_=255-m(255-a-l),g=255-m(255-o-c)}},w=this.nativeModes=r.each(["source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","darker","copy","xor"],function(t){this[t]=!0},{}),x=Q.getContext(1,1);x&&(r.each(y,function(t,e){var i="darken"===e,n=!1;x.save();try{x.fillStyle=i?"#300":"#a00",x.fillRect(0,0,1,1),x.globalCompositeOperation=e,x.globalCompositeOperation===e&&(x.fillStyle=i?"#a00":"#300",x.fillRect(0,0,1,1),n=x.getImageData(0,0,1,1).data[0]!==i?170:51)}catch(r){}x.restore(),w[e]=n}),Q.release(x)),this.process=function(t,e,i,n,r){var v=e.canvas,p="normal"===t;if(p||w[t])i.save(),i.setTransform(1,0,0,1,0,0),i.globalAlpha=n,p||(i.globalCompositeOperation=t),i.drawImage(v,r.x,r.y),i.restore();else{var m=y[t];if(!m)return;for(var x=i.getImageData(r.x,r.y,v.width,v.height),b=x.data,C=e.getImageData(0,0,v.width,v.height).data,S=0,P=b.length;S0){var s=e[r],a=s&&s[i];a&&a.call(this,r)}},statics:{inject:function st(t){var e=t._events;if(e){var n={};r.each(e,function(e,i){var s="string"==typeof e,a=s?e:i,o=r.capitalize(a),h=a.substring(2).toLowerCase();n[h]=s?{}:e,a="_"+a,t["get"+o]=function(){return this[a]},t["set"+o]=function(t){var e=this[a];e&&this.off(h,e),t&&this.on(h,t),this[a]=t}}),t._eventTypes=n}return st.base.apply(this,arguments)}}},a=r.extend({_class:"PaperScope",initialize:function at(){paper=this,this.settings=new r({applyMatrix:!0,insertItems:!0,handleSize:4,hitTolerance:0}),this.project=null,this.projects=[],this.tools=[],this.palettes=[],this._id=at._id++,at._scopes[this._id]=this;var e=at.prototype;if(!this.support){var n=tt.getContext(1,1)||{};e.support={nativeDash:"setLineDash"in n||"mozDash"in n,nativeBlendModes:et.nativeModes},tt.release(n)}if(!this.agent){var i=t.navigator.userAgent.toLowerCase(),s=(/(darwin|win|mac|linux|freebsd|sunos)/.exec(i)||[])[0],a="darwin"===s?"mac":s,o=e.agent=e.browser={platform:a};a&&(o[a]=!0),i.replace(/(opera|chrome|safari|webkit|firefox|msie|trident|atom|node)\/?\s*([.\d]+)(?:.*version\/([.\d]+))?(?:.*rv\:v?([.\d]+))?/g,function(t,e,n,i,r){if(!o.chrome){var s="opera"===e?i:/^(node|trident)$/.test(e)?r:n;o.version=s,o.versionNumber=parseFloat(s),e="trident"===e?"msie":e,o.name=e,o[e]=!0}}),o.chrome&&delete o.webkit,o.atom&&delete o.chrome}},version:"0.10.2-develop",getView:function(){var t=this.project;return t&&t._view},getPaper:function(){return this},execute:function(t,e){paper.PaperScript.execute(t,this,e),Z.updateFocus()},install:function(t){var e=this;r.each(["project","view","tool"],function(n){r.define(t,n,{configurable:!0,get:function(){return e[n]}})});for(var n in this)!/^_/.test(n)&&this[n]&&(t[n]=this[n])},setup:function(t){return paper=this,this.project=new y(t),this},createCanvas:function(t,e){return tt.getCanvas(t,e)},activate:function(){paper=this},clear:function(){for(var t=this.projects,e=this.tools,n=this.palettes,i=t.length-1;i>=0;i--)t[i].remove();for(var i=e.length-1;i>=0;i--)e[i].remove();for(var i=n.length-1;i>=0;i--)n[i].remove()},remove:function(){this.clear(),delete a._scopes[this._id]},statics:new function(){function t(t){return t+="Attribute",function(e,n){return e[t](n)||e[t]("data-paper-"+n)}}return{_scopes:{},_id:0,get:function(t){return this._scopes[t]||null},getAttribute:t("get"),hasAttribute:t("has")}}}),o=r.extend(s,{initialize:function(t){this._scope=paper,this._index=this._scope[this._list].push(this)-1,!t&&this._scope[this._reference]||this.activate()},activate:function(){if(!this._scope)return!1;var t=this._scope[this._reference];return t&&t!==this&&t.emit("deactivate"),this._scope[this._reference]=this,this.emit("activate",t),!0},isActive:function(){return this._scope[this._reference]===this},remove:function(){return null!=this._index&&(r.splice(this._scope[this._list],null,this._index,1),this._scope[this._reference]==this&&(this._scope[this._reference]=null),this._scope=null,!0)},getView:function(){return this._scope.getView()}}),h=r.extend({initialize:function(t){this.precision=r.pick(t,5),this.multiplier=Math.pow(10,this.precision)},number:function(t){return this.precision<16?Math.round(t*this.multiplier)/this.multiplier:t},pair:function(t,e,n){return this.number(t)+(n||",")+this.number(e)},point:function(t,e){return this.number(t.x)+(e||",")+this.number(t.y)},size:function(t,e){return this.number(t.width)+(e||",")+this.number(t.height)},rectangle:function(t,e){return this.point(t,e)+(e||",")+this.size(t,e)}});h.instance=new h;var u=new function(){function t(t,e,n){return tr:ir&&i=s&&(h=h.getNext()),i>=s&&(l=l.getNext()),!(u&&h&&c&&l))return!1;var f=[];a||f.push(u.getLength(),h.getLength()),o||f.push(c.getLength(),l.getLength());var d=this.getPoint(),_=Math.min.apply(Math,f)/64,g=a?h.getTangentAtTime(n):h.getPointAt(_).subtract(d),v=a?g.negate():u.getPointAt(-_).subtract(d),p=o?l.getTangentAtTime(i):l.getPointAt(_).subtract(d),m=o?p.negate():c.getPointAt(-_).subtract(d),y=v.getAngle(),w=g.getAngle(),x=m.getAngle(),b=p.getAngle();return!!(a?t(y,x,b)^t(w,x,b)&&t(y,b,x)^t(w,b,x):t(x,y,w)^t(b,y,w)&&t(x,w,y)^t(b,w,y))},hasOverlap:function(){return!!this._overlap}},r.each(T._evaluateMethods,function(t){var e=t+"At";this[t]=function(){var t=this.getCurve(),n=this.getTime();return null!=n&&t&&t[e](n,!0)}},{preserve:!0}),new function(){function t(t,e,n){function i(n,i){for(var s=n+i;s>=-1&&s<=r;s+=i){var a=t[(s%r+r)%r];if(!e.getPoint().isClose(a.getPoint(),2e-7))break;if(e.equals(a))return a}return null}for(var r=t.length,s=0,a=r-1;s<=a;){var o,h=s+a>>>1,u=t[h];if(n&&(o=e.equals(u)?u:i(h,-1)||i(h,1)))return e._overlap&&(o._overlap=o._intersection._overlap=!0),o;var l=e.getPath(),c=u.getPath(),f=l===c?e.getIndex()+e.getTime()-(u.getIndex()+u.getTime()):l._id-c._id;f<0?a=h-1:s=h+1}return t.splice(s,0,e),e}return{statics:{insert:t,expand:function(e){for(var n=e.slice(),i=e.length-1;i>=0;i--)t(n,e[i]._intersection,!1);return n}}}}),O=w.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,initialize:function(){},statics:{create:function(t){var e=(t&&t.match(/m/gi)||[]).length>1||/z\s*\S+/i.test(t)?L:E;return new e(t)}},_asPathItem:function(){return this},setPathData:function(t){function e(t,e){var n=+i[t];return o&&(n+=h[e]),n}function n(t){return new c(e(t,"x"),e(t+1,"y"))}var i,r,s,a=t&&t.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),o=!1,h=new c,u=new c;this.clear();for(var l=0,f=a&&a.length;lk&&(h+=z))),b=z,C=m[6]}else(r-m[0])*(r-m[6])<=0&&(M=!0);M&&(p>=u-1||e[p+1].last)&&(I+=1,P-=1)}0===a&&0===h&&(a=I,h=P)}return{winding:Math.max(f(a),f(h)),contour:!a^!h}}function h(t,e,n,i,r){var s,a=[],h=t,u=0;do{var l=t.getCurve(),c=l.getLength();a.push({segment:t,curve:l,length:c}),u+=c,t=t.getNext()}while(t&&!t._intersection&&t!==h);for(var c=u/2,f=0,d=a.length;f