2013-06-26 22:42:24 -04:00
/ * !
2013-12-02 04:00:44 -05:00
* Paper . js v0 . 9.15 - The Swiss Army Knife of Vector Graphics Scripting .
2013-06-26 22:42:24 -04:00
* http : //paperjs.org/
*
* Copyright ( c ) 2011 - 2013 , Juerg Lehni & Jonathan Puckey
* http : //lehni.org/ & http://jonathanpuckey.com/
*
* Distributed under the MIT license . See LICENSE file for details .
*
* All rights reserved .
*
2013-12-02 04:00:44 -05:00
* Date : Sun Dec 1 23 : 54 : 52 2013 + 0100
2013-06-26 22:42:24 -04:00
*
* * *
*
* straps . js - Class inheritance library with support for bean - style accessors
*
* Copyright ( c ) 2006 - 2013 Juerg Lehni
* http : //lehni.org/
*
* 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 .
*
* /
2013-12-02 04:00:44 -05:00
var paper = new function ( t ) { var e = new function ( ) { function i ( e , i , n , r , o , h ) { function u ( r , s , h , u ) { var s = s || ( s = l ( i , r ) ) && ( s . get ? s : s . value ) ; "string" == typeof s && "#" === s [ 0 ] && ( s = e [ s . substring ( 1 ) ] || s ) ; var _ , f = "function" == typeof s , g = s , v = o || f ? s && s . get ? r in e : e [ r ] : null ; ! ( h || s !== t && i . hasOwnProperty ( r ) ) || o && v || ( f && v && ( s . base = v ) , f && c && 0 === s . length && ( _ = r . match ( /^(get|is)(([A-Z])(.*))$/ ) ) && c . push ( [ _ [ 3 ] . toLowerCase ( ) + _ [ 4 ] , _ [ 2 ] ] ) , g && ! f && g . get && "function" == typeof g . get && 0 === g . get . length || ( g = { value : g , writable : ! 0 } ) , ( l ( e , r ) || { configurable : ! 0 } ) . configurable && ( g . configurable = ! 0 , g . enumerable = n ) , d ( e , r , g ) ) , ! u || ! f || o && u [ r ] || ( u [ r ] = function ( t ) { return t && e [ r ] . apply ( t , a . call ( arguments , 1 ) ) } ) } var c ; if ( i ) { c = [ ] ; for ( var _ in i ) i . hasOwnProperty ( _ ) && ! s . test ( _ ) && u ( _ , null , ! 0 , h ) ; u ( "toString" ) , u ( "valueOf" ) ; for ( var f = 0 , g = c . length ; g > f ; f ++ ) { var v = c [ f ] , m = v [ 1 ] ; u ( v [ 0 ] , { get : e [ "get" + m ] || e [ "is" + m ] , set : e [ "set" + m ] } , ! 0 ) } } return e } function n ( t , e , i ) { return t && ( "length" in t && ! t . getLength && "number" == typeof t . length ? o : h ) . call ( t , e , i = i || t ) , i } function r ( t , e ) { for ( var i in e ) e . hasOwnProperty ( i ) && ( t [ i ] = e [ i ] ) ; return t } var s = /^(statics|generics|preserve|enumerable|prototype|toString|valueOf)$/ , a = [ ] . slice , o = [ ] . forEach || function ( t , e ) { for ( var i = 0 , n = this . length ; n > i ; i ++ ) t . call ( e , this [ i ] , i , this ) } , h = function ( t , e ) { for ( var i in this ) this . hasOwnProperty ( i ) && t . call ( e , this [ i ] , i , this ) } , u = Object . create || function ( t ) { return { _ _proto _ _ : t } } , l = 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 } , c = 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 } , d = function ( t , e , i ) { return delete t [ e ] , c ( t , e , i ) } ; return i ( function ( ) { for ( var t = 0 , e = arguments . length ; e > t ; t ++ ) r ( this , arguments [ t ] ) } , { inject : function ( t ) { if ( t ) { var e = this . prototype , n = Object . getPrototypeOf ( e ) . constructor , r = t . statics === ! 0 ? t : t . statics ; r != t && i ( e , t , t . enumerable , n && n . prototype , t . preserve , t . generics && this ) , i ( this , r , ! 0 , n , t . preserve ) } for ( var s = 1 , a = arguments . length ; a > s ; s ++ ) this . inject ( arguments [ s ] ) ; return this } , extend : function ( ) { for ( var t , e = this , n = 0 , r = arguments . length ; r > n && ! ( t = arguments [ n ] . initialize ) ; n ++ ) ; return t = t || function ( ) { e . apply ( this , arguments ) } , t . prototype = u ( this . prototype ) , d ( t . prototype , "constructor" , { value : t , writable : ! 0 , configurable : ! 0 } ) , i ( t , this , ! 0 ) , arguments . length ? this . inject . apply ( t , arguments ) : t } } , ! 0 ) . inject ( { inject : function ( ) { for ( var t = 0 , e = arguments . length ; e > t ; t ++ ) i ( this , arguments [ t ] , arguments [ t ] . enumerable ) ; return this } , extend : function ( ) { var t = u ( this ) ; return t . inject . apply ( t , arguments ) } , each : function ( t , e ) { return n ( this , t , e ) } , clone : function ( ) { return new this . constructor ( this ) } , statics : { each : n , create : u , define : d , describe : l , copy : r , clone : function ( t ) { return r ( new t . constructor , t ) } , isPlainObject : function ( t ) { var i = null != t && t . constructor ; return i && ( i === Object || i === e || "Object" === i . name ) } , pick : function ( ) { for ( var e = 0 , i = arguments . length ; i > e ; e ++ ) if ( arguments [ e ] !== t ) return arguments [ e ] ; return null } } } ) } ; "undefined" != typeof module && ( module . exports = e ) , e . inject ( { generics : ! 0 , toString : function ( ) { return null != this . _id ? ( this . _class || "Object" ) + ( this . _name ? " '" + this . _name + "'" : " @" + this . _id ) : "{ " + e . each ( this , function ( t , e ) { if ( ! /^_/ . test ( e ) ) { var i = typeof t ; this . push ( e + ": " + ( "number" === i ? a . instance . number ( t ) : "string" === i ? "'" + t + "'" : t ) ) } } , [ ] ) . join ( ", " ) + " }" } , exportJSON : function ( t ) { return e . exportJSON ( this , t ) } , toJSON : function ( ) { return e . serialize ( this ) } , _set : function ( i , n ) { if ( i && e . isPlainObject ( i ) ) { var r = i . _filtering || i ; for ( var s in r ) if ( s in this && r . hasOwnProperty ( s ) && ( ! n || ! n [ s ] ) ) { var a = i [ s ] ; a !== t && ( this [ s ] = a ) } return ! 0 } } , statics : { exports : { } , extend : function ie ( ) { var t = ie . base . apply ( this , arguments ) , i = t . prototype . _class ; return i && ! e . exports [ i ] && ( e . exports [ i ] = t ) , t } , equals : function ( t , i ) { function n ( t , e ) { for ( var i in t ) if ( t . hasOwnProperty ( i ) && ! e . hasOwnProperty ( i ) ) return ! 1 ; return ! 0 } if ( t === i ) return ! 0 ; if ( t && t . equals ) return t . equals ( i ) ; if ( i && i . equals ) return i . equals ( t ) ; if ( Array . isArray
if ( ! n ) return null ; var r = t . x - this . _tx , s = t . y - this . _ty ; return e || ( e = new h ) , e . set ( ( r * this . _d - s * this . _b ) / n , ( s * this . _a - r * this . _c ) / n , i ) } , decompose : function ( ) { var t = this . _a , e = this . _b , i = this . _c , n = this . _d ; if ( o . 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 ) , { translation : this . getTranslation ( ) , scaling : new h ( 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 h ( this . _tx , this . _ty ) } , setTranslation : function ( ) { var t = h . read ( arguments ) ; this . _tx = t . x , this . _ty = t . y , this . _changed ( ) } , getScaling : function ( ) { return ( this . decompose ( ) || { } ) . scaling } , setScaling : function ( ) { var t = this . getScaling ( ) ; if ( null != t ) { var e = h . read ( arguments ) ; ( this . _owner || this ) . scale ( e . x / t . x , e . y / t . y ) } } , getRotation : function ( ) { return ( this . decompose ( ) || { } ) . rotation } , setRotation : function ( t ) { var e = this . getRotation ( ) ; null != e && ( this . _owner || this ) . rotate ( t - e ) } , inverted : function ( ) { var t = this . _getDeterminant ( ) ; return t && new g ( this . _d / t , - this . _c / t , - this . _b / t , this . _a / t , ( this . _b * this . _ty - this . _d * this . _tx ) / t , ( this . _c * this . _tx - this . _a * this . _ty ) / t ) } , shiftless : function ( ) { return new g ( this . _a , this . _c , this . _b , this . _d , 0 , 0 ) } , applyToContext : function ( t ) { t . transform ( this . _a , this . _c , this . _b , this . _d , this . _tx , this . _ty ) } } , new function ( ) { return e . each ( { scaleX : "_a" , scaleY : "_d" , translateX : "_tx" , translateY : "_ty" , shearX : "_b" , shearY : "_c" } , function ( t , i ) { i = e . capitalize ( i ) , this [ "get" + i ] = function ( ) { return this [ t ] } , this [ "set" + i ] = function ( e ) { this [ t ] = e , this . _changed ( ) } } , { } ) } ) , v = e . 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 h ( this . _px , this . _py ) } , getVector : function ( ) { return new h ( this . _vx , this . _vy ) } , getLength : function ( ) { return this . getVector ( ) . getLength ( ) } , intersect : function ( t , e ) { return v . intersect ( this . _px , this . _py , this . _vx , this . _vy , t . _px , t . _py , t . _vx , t . _vy , ! 0 , e ) } , getSide : function ( t ) { return v . getSide ( this . _px , this . _py , this . _vx , this . _vy , t . x , t . y , ! 0 ) } , getDistance : function ( t ) { return Math . abs ( v . getSignedDistance ( this . _px , this . _py , this . _vx , this . _vy , t . x , t . y , ! 0 ) ) } , statics : { intersect : function ( t , e , i , n , r , s , a , u , l , c ) { l || ( i -= t , n -= e , a -= r , u -= s ) ; var d = u * i - a * n ; if ( ! o . isZero ( d ) ) { var _ = t - r , f = e - s , g = ( a * f - u * _ ) / d , v = ( i * f - n * _ ) / d ; if ( ( c || g >= 0 && 1 >= g ) && ( c || v >= 0 && 1 >= v ) ) return new h ( t + g * i , e + g * n ) } } , getSide : function ( t , e , i , n , r , s , a ) { a || ( i -= t , n -= e ) ; var o = r - t , h = s - e , u = o * n - h * i ; return 0 === u && ( u = o * i + h * n , u > 0 && ( o -= i , h -= n , u = o * i + h * n , 0 > u && ( u = 0 ) ) ) , 0 > u ? - 1 : u > 0 ? 1 : 0 } , getSignedDistance : function ( t , e , i , n , r , s , a ) { a || ( i -= t , n -= e ) ; var o = n / i , h = e - o * t ; return ( s - o * r - h ) / Math . sqrt ( o * o + 1 ) } } } ) , m = s . extend ( { _class : "Project" , _list : "projects" , _reference : "project" , initialize : function ( t ) { s . call ( this , ! 0 ) , this . layers = [ ] , this . symbols = [ ] , this . _currentStyle = new q , this . activeLayer = new x , t && ( this . view = t instanceof Z ? t : Z . create ( t ) ) , this . _selectedItems = { } , this . _selectedItemCount = 0 , this . _drawCount = 0 , this . options = { } } , _serialize : function ( t , i ) { return e . serialize ( this . layers , t , ! 0 , i ) } , clear : function ( ) { for ( var t = this . layers . length - 1 ; t >= 0 ; t -- ) this . layers [ t ] . remove ( ) ; this . symbols = [ ] } , isEmpty : function ( ) { return this . layers . length <= 1 && ( ! this . activeLayer || this . activeLayer . isEmpty ( ) ) } , remove : function ae ( ) { return ae . base . call ( this ) ? ( this . view && this . view . remove ( ) , ! 0 ) : ! 1 } , getCurrentStyle : function ( ) { return this . _currentStyle } , setCurrentStyle : function ( t ) { this . _currentStyle . initialize ( t ) } , getIndex : function ( ) { return this . _index } , addChild : function ( t ) { return t instanceof x ? ( e . splice ( this . layers , [ t ] ) , this . activeLayer || ( this . activeLayer = t ) ) : t instanceof y ? ( this . activeLayer || this . addChild ( new x ( { insert : ! 1 } ) ) ) . addChild ( t ) : t = null , t } , getSelectedItems : function ( ) { var t = [ ] ; for ( var e in this . _selectedItems ) { var i = this . _selectedItems [ e ] ; i . isInserted ( ) && t . push ( i ) } return t } , _updateSelection : function ( t ) { var e = t . _id , i = this . _selectedItems ; t . _selected ? i [ e ] !== t && ( this . _selectedItemCount ++ , i [
} , getCanvas : function ( ) { if ( ! this . _canvas ) { var t = K . getContext ( this . _size ) ; try { this . _image && t . drawImage ( this . _image , 0 , 0 ) , this . _canvas = t . canvas } catch ( e ) { K . release ( t ) } } return this . _canvas } , setCanvas : "#setImage" , getContext : function ( ) { return this . _context || ( this . _context = this . getCanvas ( ) . getContext ( "2d" ) ) , arguments [ 0 ] && ( this . _image = null , this . _changed ( 129 ) ) , this . _context } , setContext : function ( t ) { this . _context = t } , getSource : function ( ) { return this . _image && this . _image . src || this . toDataURL ( ) } , setSource : function ( t ) { function e ( ) { var t = i . _project . view ; t && ( paper = t . _scope ) , i . fire ( "load" ) , t && t . draw ( ! 0 ) } var i = this , n = document . getElementById ( t ) || new Image ; n . naturalWidth && n . naturalHeight ? setTimeout ( e , 0 ) : ( V . add ( n , { load : function ( ) { i . setImage ( n ) , e ( ) } } ) , n . src || ( n . src = t ) ) , this . setImage ( n ) } , getElement : function ( ) { return this . _canvas || this . _image } , getSubCanvas : function ( t ) { t = _ . read ( arguments ) ; var e = K . getContext ( t . getSize ( ) ) ; return e . drawImage ( this . getCanvas ( ) , t . x , t . y , t . width , t . height , 0 , 0 , t . width , t . height ) , e . canvas } , getSubRaster : function ( t ) { t = _ . read ( arguments ) ; var e = new C ( { canvas : this . getSubCanvas ( t ) , insert : ! 1 } ) ; return e . translate ( t . getCenter ( ) . subtract ( this . getSize ( ) . divide ( 2 ) ) ) , e . _matrix . preConcatenate ( this . _matrix ) , e . insertAbove ( this ) , e } , toDataURL : function ( ) { var t = this . _image && this . _image . src ; if ( /^data:/ . test ( t ) ) return t ; var e = this . getCanvas ( ) ; return e ? e . toDataURL ( ) : null } , drawImage : function ( t , e ) { e = h . read ( arguments , 1 ) , this . getContext ( ! 0 ) . drawImage ( t , e . x , e . y ) } , getAverageColor : function ( t ) { var i , n ; t ? t instanceof A ? ( n = t , i = t . getBounds ( ) ) : t . width ? i = new _ ( t ) : t . x && ( i = new _ ( t . x - . 5 , t . y - . 5 , 1 , 1 ) ) : i = this . getBounds ( ) ; var r = 32 , s = Math . min ( i . width , r ) , a = Math . min ( i . height , r ) , o = C . _sampleContext ; o ? o . clearRect ( 0 , 0 , r + 1 , r + 1 ) : o = C . _sampleContext = K . getContext ( new c ( r ) ) , o . save ( ) ; var h = ( new g ) . scale ( s / i . width , a / i . height ) . translate ( - i . x , - i . y ) ; h . applyToContext ( o ) , n && n . draw ( o , new e ( { clip : ! 0 , transforms : [ h ] } ) ) , this . _matrix . applyToContext ( o ) , o . drawImage ( this . getElement ( ) , - this . _size . width / 2 , - this . _size . height / 2 ) , o . restore ( ) ; for ( var u = o . getImageData ( . 5 , . 5 , Math . ceil ( s ) , Math . ceil ( a ) ) . data , l = [ 0 , 0 , 0 ] , d = 0 , f = 0 , v = u . length ; v > f ; f += 4 ) { var m = u [ f + 3 ] ; d += m , m /= 255 , l [ 0 ] += u [ f ] * m , l [ 1 ] += u [ f + 1 ] * m , l [ 2 ] += u [ f + 2 ] * m } for ( var f = 0 ; 3 > f ; f ++ ) l [ f ] /= d ; return d ? j . read ( l ) : null } , getPixel : function ( t ) { t = h . read ( arguments ) ; var e = this . getContext ( ) . getImageData ( t . x , t . y , 1 , 1 ) . data ; return new j ( "rgb" , [ e [ 0 ] / 255 , e [ 1 ] / 255 , e [ 2 ] / 255 ] , e [ 3 ] / 255 ) } , setPixel : function ( ) { var t = h . read ( arguments ) , e = j . read ( arguments ) , i = e . _convert ( "rgb" ) , n = e . _alpha , r = this . getContext ( ! 0 ) , s = r . createImageData ( 1 , 1 ) , a = s . data ; a [ 0 ] = 255 * i [ 0 ] , a [ 1 ] = 255 * i [ 1 ] , a [ 2 ] = 255 * i [ 2 ] , a [ 3 ] = null != n ? 255 * n : 255 , r . putImageData ( s , t . x , t . y ) } , createImageData : function ( t ) { return t = c . read ( arguments ) , this . getContext ( ) . createImageData ( t . width , t . height ) } , getImageData : function ( t ) { return t = _ . read ( arguments ) , t . isEmpty ( ) && ( t = new _ ( this . _size ) ) , this . getContext ( ) . getImageData ( t . x , t . y , t . width , t . height ) } , setImageData : function ( t , e ) { e = h . read ( arguments , 1 ) , this . getContext ( ! 0 ) . putImageData ( t , e . x , e . y ) } , _getBounds : function ( t , e ) { var i = new _ ( this . _size ) . setCenter ( 0 , 0 ) ; return e ? e . _transformBounds ( i ) : i } , _hitTest : function ( t ) { if ( this . _contains ( t ) ) { var e = this ; return new P ( "pixel" , e , { offset : t . add ( e . _size . divide ( 2 ) ) . round ( ) , color : { get : function ( ) { return e . getPixel ( this . offset ) } } } ) } } , _draw : function ( t ) { var e = this . getElement ( ) ; e && ( t . globalAlpha = this . _opacity , t . drawImage ( e , - this . _size . width / 2 , - this . _size . height / 2 ) ) } , _canComposite : function ( ) { return ! 0 } } ) , S = y . extend ( { _class : "PlacedSymbol" , _transformContent : ! 1 , _boundsGetter : { getBounds : "getStrokeBounds" } , _boundsSelected : ! 0 , _serializeFields : { symbol : null } , initialize : function ( e , i ) { this . _initialize ( e , i !== t && h . read ( arguments , 1 ) ) || this . setSymbol ( e instanceof p ? e : new p ( e ) ) } , _equals : function ( t ) { return this . _symbol === t . _symbol } , getSymbol : function ( ) { return this . _symbol } , setSymbol : function ( t ) { this . _symbol && delete this . _symbol . _instances [ this . _id ] , this . _symbol = t , t . _instances [ this . _id ] = this } , clone : function ( t ) { return this . _clone ( new S ( { symbol : this . symbol , insert : ! 1 } ) , t ) } , isEmpty : function ( ) { return this . _symbol . _definition . isEmpty ( ) } , _getBounds : function ( t , e ) { return this . symbol . _definition . _getCachedBou
return i . _point . equals ( s . _point ) ? ( i . setHandleOut ( s . _handleOut ) , this . _add ( e . slice ( 1 ) ) ) : ( r = this . getFirstSegment ( ) , r . _point . equals ( s . _point ) && t . reverse ( ) , n = t . getLastSegment ( ) , r . _point . equals ( n . _point ) ? ( r . setHandleIn ( n . _handleIn ) , this . _add ( e . slice ( 0 , e . length - 1 ) , 0 ) ) : this . _add ( e . slice ( ) ) ) , t . closed && this . _add ( [ e [ 0 ] ] ) , t . remove ( ) , r = this . getFirstSegment ( ) , i = this . getLastSegment ( ) , i . _point . equals ( r . _point ) && ( r . setHandleIn ( i . _handleIn ) , i . remove ( ) , this . setClosed ( ! 0 ) ) , this . _changed ( 5 ) , ! 0 } return ! 1 } , getLength : function ( ) { if ( null == this . _length ) { var t = this . getCurves ( ) ; this . _length = 0 ; for ( var e = 0 , i = t . length ; i > e ; e ++ ) this . _length += t [ e ] . getLength ( ) } return this . _length } , getArea : function ( ) { for ( var t = this . getCurves ( ) , e = 0 , i = 0 , n = t . length ; n > i ; i ++ ) e += t [ i ] . getArea ( ) ; return e } , _getOffset : function ( t ) { var e = t && t . getIndex ( ) ; if ( null != e ) { for ( var i = this . getCurves ( ) , n = 0 , r = 0 ; e > r ; r ++ ) n += i [ r ] . getLength ( ) ; var s = i [ e ] ; return n + s . getLength ( 0 , t . getParameter ( ) ) } return null } , getLocationOf : function ( t ) { t = h . read ( arguments ) ; for ( var e = this . getCurves ( ) , i = 0 , n = e . length ; n > i ; i ++ ) { var r = e [ i ] . getLocationOf ( t ) ; if ( r ) return r } return null } , getLocationAt : function ( t , e ) { var i = this . getCurves ( ) , n = 0 ; if ( e ) { var r = ~ ~ t ; return i [ r ] . getLocationAt ( t - r , ! 0 ) } for ( var s = 0 , a = i . length ; a > s ; s ++ ) { var o = n , h = i [ s ] ; if ( n += h . getLength ( ) , n >= t ) return h . getLocationAt ( t - o ) } return t <= this . getLength ( ) ? new k ( i [ i . length - 1 ] , 1 ) : null } , getPointAt : function ( t , e ) { var i = this . getLocationAt ( t , e ) ; return i && i . getPoint ( ) } , getTangentAt : function ( t , e ) { var i = this . getLocationAt ( t , e ) ; return i && i . getTangent ( ) } , getNormalAt : function ( t , e ) { var i = this . getLocationAt ( t , e ) ; return i && i . getNormal ( ) } , getNearestLocation : function ( t ) { t = h . read ( arguments ) ; for ( var e = this . getCurves ( ) , i = 1 / 0 , n = null , r = 0 , s = e . length ; s > r ; r ++ ) { var a = e [ r ] . getNearestLocation ( t ) ; a . _distance < i && ( i = a . _distance , n = a ) } return n } , getNearestPoint : function ( t ) { return t = h . read ( arguments ) , this . getNearestLocation ( t ) . getPoint ( ) } , getStyle : function ( ) { var t = this . _parent ; return ( t && "compound-path" === t . _type ? t : this ) . _style } , toShape : function ( e ) { function i ( t , e ) { return d [ t ] . isColinear ( d [ e ] ) } function n ( t ) { return d [ t ] . isOrthogonal ( ) } function r ( t ) { return d [ t ] . isArc ( ) } function s ( t , e ) { return d [ t ] . _point . getDistance ( d [ e ] . _point ) } if ( ! this . _closed ) return null ; var a , h , u , l , d = this . _segments ; if ( this . isPolygon ( ) && 4 === d . length && i ( 0 , 2 ) && i ( 1 , 3 ) && n ( 1 ) ? ( a = b . Rectangle , h = new c ( s ( 0 , 3 ) , s ( 0 , 1 ) ) , l = d [ 1 ] . _point . add ( d [ 2 ] . _point ) . divide ( 2 ) ) : 8 === d . length && r ( 0 ) && r ( 2 ) && r ( 4 ) && r ( 6 ) && i ( 1 , 5 ) && i ( 3 , 7 ) ? ( a = b . Rectangle , h = new c ( s ( 1 , 6 ) , s ( 0 , 3 ) ) , u = h . subtract ( new c ( s ( 0 , 7 ) , s ( 1 , 2 ) ) ) . divide ( 2 ) , l = d [ 3 ] . _point . add ( d [ 4 ] . _point ) . divide ( 2 ) ) : 4 === d . length && r ( 0 ) && r ( 1 ) && r ( 2 ) && r ( 3 ) && ( o . isZero ( s ( 0 , 2 ) - s ( 1 , 3 ) ) ? ( a = b . Circle , u = s ( 0 , 2 ) / 2 ) : ( a = b . Ellipse , u = new c ( s ( 2 , 0 ) / 2 , s ( 3 , 1 ) / 2 ) ) , l = d [ 1 ] . _point ) , a ) { var _ = this . getPosition ( ! 0 ) , f = new a ( { center : _ , size : h , radius : u , insert : ! 1 } ) ; return f . rotate ( l . subtract ( _ ) . getAngle ( ) + 90 ) , f . setStyle ( this . _style ) , ( e || e === t ) && f . insertAbove ( this ) , f } return null } , _getWinding : function ( t ) { var e = this . _closed ; if ( ! e && ! this . hasFill ( ) || ! this . _getBounds ( "getRoughBounds" ) . _containsPoint ( t ) ) return 0 ; for ( var i = this . getCurves ( ) , n = this . _segments , r = 0 , s = [ ] , a = [ ] , o = ( e ? i [ i . length - 1 ] : new I ( n [ n . length - 1 ] . _point , n [ 0 ] . _point ) ) . getValues ( ) , h = o , u = 0 , l = i . length ; l > u ; u ++ ) { var c = i [ u ] . getValues ( ) , d = c [ 0 ] , _ = c [ 1 ] ; ( d !== c [ 2 ] || _ !== c [ 3 ] || d !== c [ 4 ] || _ !== c [ 5 ] || d !== c [ 6 ] || _ !== c [ 7 ] ) && ( r += I . _getWinding ( c , h , t . x , t . y , s , a ) , h = c ) } return e || ( r += I . _getWinding ( o , h , t . x , t . y , s , a ) ) , r } , _hitTest : function ( e , i ) { function n ( i , n , r ) { return e . getDistance ( n ) < p ? new P ( r , w , { segment : i , point : n } ) : t } function r ( t , e ) { var r = t . _point ; return ( e || i . segments ) && n ( t , r , "segment" ) || ! e && i . handles && ( n ( t , r . add ( t . _handleIn ) , "handle-in" ) || n ( t , r . add ( t . _handleOut ) , "handle-out" ) ) } function s ( t ) { d . push ( t ) } function a ( t ) { var e = d [ t ] , i = d [ ( t + 1 ) % d . length ] ; return [ e . x , e . y , e . x , e . y , i . x , i . y , i . x , i . y ] } function o ( t ) { for ( var e = d . length , i = a ( e - 1 ) , n = [ ] , r = [ ] , s = 0 , o = 0 ; e > o ; o ++ ) { var h = a ( o ) ; s += I . _getWinding ( h , i , t . x , t . y , n , r ) , i = h } return ! ! s } function h ( t ) { return ( "round" !== u || "round" !== l ) && ( d = [ ] , m || t . _index > 0 && t . _index < v . length - 1 ? "round" !== u && ( t . _handleIn . isZero ( ) || t . _handleOut . isZero ( ) ) && O . _addSquareJoin ( t , u , y , c , s , ! 0 ) : "round" !== l && O . _addSquareCap ( t , l , y , s , ! 0 ) , d . length > 0 ) ? o ( e ) : e
} , toCanvasStyle : function ( t ) { if ( this . _canvasStyle ) return this . _canvasStyle ; if ( "gradient" !== this . _type ) return this . _canvasStyle = this . toCSS ( ) ; var e , i = this . _components , n = i [ 0 ] , r = n . _stops , s = i [ 1 ] , a = i [ 2 ] ; if ( n . _radial ) { var o = a . getDistance ( s ) , h = i [ 3 ] ; if ( h ) { var u = h . subtract ( s ) ; u . getLength ( ) > o && ( h = s . add ( u . normalize ( o - . 1 ) ) ) } var l = h || s ; e = t . createRadialGradient ( l . x , l . y , 0 , s . x , s . y , o ) } else e = t . createLinearGradient ( s . x , s . y , a . x , a . y ) ; for ( var c = 0 , d = r . length ; d > c ; c ++ ) { var _ = r [ c ] ; e . addColorStop ( _ . _rampPoint , _ . _color . toCanvasStyle ( ) ) } return this . _canvasStyle = e } , transform : function ( t ) { if ( "gradient" === this . _type ) { for ( var e = this . _components , i = 1 , n = e . length ; n > i ; i ++ ) { var r = e [ i ] ; t . _transformPoint ( r , r , ! 0 ) } this . _changed ( ) } } , statics : { _types : n , random : function ( ) { var t = Math . random ; return new j ( t ( ) , t ( ) , t ( ) ) } } } ) } , new function ( ) { function t ( t , e ) { return 0 > t ? 0 : e && t > 360 ? 360 : ! e && t > 1 ? 1 : t } var i = { add : function ( e , i , n ) { return t ( e + i , n ) } , subtract : function ( e , i , n ) { return t ( e - i , n ) } , multiply : function ( e , i , n ) { return t ( e * i , n ) } , divide : function ( e , i , n ) { return t ( e / i , n ) } } ; return e . each ( i , function ( t , e ) { var i = { dontParse : /^(multiply|divide)$/ . test ( e ) } ; this [ e ] = function ( e ) { e = j . read ( arguments , 0 , 0 , i ) ; for ( var n = this . _type , r = this . _properties , s = this . _components , a = e . _convert ( n ) , o = 0 , h = s . length ; h > o ; o ++ ) a [ o ] = t ( s [ o ] , a [ o ] , "hue" === r [ o ] ) ; return new j ( n , a , null != this . _alpha ? t ( this . _alpha , e . getAlpha ( ) ) : null ) } } , { } ) } ) ; e . each ( j . _types , function ( t , i ) { var n = this [ e . capitalize ( i ) + "Color" ] = function ( t ) { var e = null != t && typeof t , n = "object" === e && null != t . length ? t : "string" === e ? null : arguments ; return n ? new j ( i , n ) : new j ( t ) } ; if ( 3 == i . length ) { var r = i . toUpperCase ( ) ; j [ r ] = this [ r + "Color" ] = n } } , e . exports ) ; var E = e . extend ( { _class : "Gradient" , initialize : function xe ( t , e ) { this . _id = xe . _id = ( xe . _id || 0 ) + 1 , t && this . _set ( t ) && ( t = e = null ) , this . _stops || this . setStops ( t || [ "white" , "black" ] ) , null == this . _radial && this . setRadial ( "string" == typeof e && "radial" === e || e || ! 1 ) } , _serialize : function ( t , i ) { return i . add ( this , function ( ) { return e . serialize ( [ this . _stops , this . _radial ] , t , ! 0 , i ) } ) } , _changed : function ( ) { for ( var t = 0 , e = this . _owners && this . _owners . length ; e > t ; t ++ ) this . _owners [ t ] . _changed ( ) } , _addOwner : function ( t ) { this . _owners || ( this . _owners = [ ] ) , this . _owners . push ( t ) } , _removeOwner : function ( t ) { var e = this . _owners ? this . _owners . indexOf ( t ) : - 1 ; - 1 != e && ( this . _owners . splice ( e , 1 ) , 0 === this . _owners . length && delete this . _owners ) } , clone : function ( ) { for ( var t = [ ] , e = 0 , i = this . _stops . length ; i > e ; e ++ ) t [ e ] = this . _stops [ e ] . clone ( ) ; return new E ( t ) } , getStops : function ( ) { return this . _stops } , setStops : function ( t ) { if ( this . stops ) for ( var e = 0 , i = this . _stops . length ; i > e ; e ++ ) delete this . _stops [ e ] . _owner ; if ( t . length < 2 ) throw Error ( "Gradient stop list needs to contain at least two stops." ) ; this . _stops = F . readAll ( t , 0 , ! 1 , ! 0 ) ; for ( var e = 0 , i = this . _stops . length ; i > e ; e ++ ) { var n = this . _stops [ e ] ; n . _owner = this , n . _defaultRamp && n . setRampPoint ( e / ( i - 1 ) ) } this . _changed ( ) } , getRadial : function ( ) { return this . _radial } , setRadial : function ( t ) { this . _radial = t , this . _changed ( ) } , equals : function ( t ) { if ( t === this ) return ! 0 ; if ( t && this . _class === t . _class && this . _stops . length === t . _stops . length ) { for ( var e = 0 , i = this . _stops . length ; i > e ; e ++ ) if ( ! this . _stops [ e ] . equals ( t . _stops [ e ] ) ) return ! 1 ; return ! 0 } return ! 1 } } ) , F = e . extend ( { _class : "GradientStop" , initialize : function ( e , i ) { if ( e ) { var n , r ; i === t && Array . isArray ( e ) ? ( n = e [ 0 ] , r = e [ 1 ] ) : e . color ? ( n = e . color , r = e . rampPoint ) : ( n = e , r = i ) , this . setColor ( n ) , this . setRampPoint ( r ) } } , clone : function ( ) { return new F ( this . _color . clone ( ) , this . _rampPoint ) } , _serialize : function ( t , i ) { return e . serialize ( [ this . _color , this . _rampPoint ] , t , ! 0 , i ) } , _changed : function ( ) { this . _owner && this . _owner . _changed ( 17 ) } , getRampPoint : function ( ) { return this . _rampPoint } , setRampPoint : function ( t ) { this . _defaultRamp = null == t , this . _rampPoint = t || 0 , this . _changed ( ) } , getColor : function ( ) { return this . _color } , setColor : function ( t ) { this . _color = j . read ( arguments ) , this . _color === t && ( this . _color = t . clone ( ) ) , this . _color . _owner = this , this . _changed ( ) } , equals : function ( t ) { return t === this || t && this . _class === t . _class && this . _color . equals ( t . _color ) && this . _rampPoint == t . _rampPoint || ! 1 } } ) , q = e . extend ( new function ( ) { var i = { fillColor : t , strokeColor : t , strokeWidth : 1 , strokeCap : "butt" , strokeJoin : "miter" , miterLimit : 10 , d
} var S , P , z = { group : s , layer : s , raster : h , path : u , shape : c , "compound-path" : d , "placed-symbol" : _ , "point-text" : g } ; y . inject ( { exportSVG : function ( t ) { return t = C ( t ) , x ( b ( this , t ) , t ) } } ) , m . inject ( { exportSVG : function ( t ) { t = C ( t ) ; for ( var e = this . layers , i = this . view . getSize ( ) , r = n ( "svg" , { x : 0 , y : 0 , width : i . width , height : i . height , version : "1.1" , xmlns : "http://www.w3.org/2000/svg" , "xmlns:xlink" : "http://www.w3.org/1999/xlink" } ) , s = 0 , a = e . length ; a > s ; s ++ ) r . appendChild ( b ( e [ s ] , t ) ) ; return x ( r , t ) } } ) } , new function ( ) { function i ( t , e , i , n ) { var r = ee [ e ] , s = r ? t . getAttributeNS ( r , e ) : t . getAttribute ( e ) ; return "null" === s && ( s = null ) , null == s ? n ? null : i ? "" : 0 : i ? s : parseFloat ( s ) } function n ( t , e , n , r ) { return e = i ( t , e , ! 1 , r ) , n = i ( t , n , ! 1 , r ) , ! r || null != e && null != n ? new h ( e , n ) : null } function r ( t , e , n , r ) { return e = i ( t , e , ! 1 , r ) , n = i ( t , n , ! 1 , r ) , ! r || null != e && null != n ? new c ( e , n ) : null } function s ( t , e , i ) { return "none" === t ? null : "number" === e ? parseFloat ( t ) : "array" === e ? t ? t . split ( /[\s,]+/g ) . map ( parseFloat ) : [ ] : "color" === e ? S ( t ) || t : "lookup" === e ? i [ t ] : t } function a ( t , e , i , n ) { var r = t . childNodes , s = "clippath" === e , a = new w , o = a . _project , h = o . _currentStyle , u = [ ] ; s || ( a . _transformContent = ! 1 , a = x ( a , t , i ) , o . _currentStyle = a . _style . clone ( ) ) ; for ( var l = 0 , c = r . length ; c > l ; l ++ ) { var d , _ = r [ l ] ; 1 !== _ . nodeType || ! ( d = P ( _ , ! 1 , n ) ) || d instanceof p || u . push ( d ) } return a . addChildren ( u ) , s && ( a = x ( a . reduce ( ) , t , i ) ) , o . _currentStyle = h , ( s || "defs" === e ) && ( a . remove ( ) , a = null ) , a } function o ( t , e ) { var i = new O , n = t . points ; i . moveTo ( n . getItem ( 0 ) ) ; for ( var r = 1 , s = n . numberOfItems ; s > r ; r ++ ) i . lineTo ( n . getItem ( r ) ) ; return "polygon" === e && i . closePath ( ) , i } function u ( t ) { var e = t . getAttribute ( "d" ) , i = e . match ( /m/gi ) . length > 1 ? new L : new O ; return i . setPathData ( e ) , i } function l ( t , e ) { for ( var r = t . childNodes , s = [ ] , a = 0 , o = r . length ; o > a ; a ++ ) { var h = r [ a ] ; 1 === h . nodeType && s . push ( x ( new F , h ) ) } var u , l , c , d = "radialgradient" === e , _ = new E ( s , d ) ; return d ? ( u = n ( t , "cx" , "cy" ) , l = u . add ( i ( t , "r" ) , 0 ) , c = n ( t , "fx" , "fy" , ! 0 ) ) : ( u = n ( t , "x1" , "y1" ) , l = n ( t , "x2" , "y2" ) ) , x ( new j ( _ , u , l , c ) , t ) , null } function d ( t , e , i , n ) { for ( var r = ( n . getAttribute ( i ) || "" ) . split ( /\)\s*/g ) , s = new g , a = 0 , o = r . length ; o > a ; a ++ ) { var h = r [ a ] ; if ( ! h ) break ; for ( var u = h . split ( "(" ) , l = u [ 0 ] , c = u [ 1 ] . split ( /[\s,]+/g ) , d = 0 , _ = c . length ; _ > d ; d ++ ) c [ d ] = parseFloat ( c [ d ] ) ; switch ( l ) { case "matrix" : s . concatenate ( new g ( c [ 0 ] , c [ 1 ] , c [ 2 ] , c [ 3 ] , c [ 4 ] , c [ 5 ] ) ) ; break ; case "rotate" : s . rotate ( c [ 0 ] , c [ 1 ] , c [ 2 ] ) ; break ; case "translate" : s . translate ( c [ 0 ] , c [ 1 ] ) ; break ; case "scale" : s . scale ( c ) ; break ; case "skewX" : case "skewY" : var e = Math . tan ( c [ 0 ] * Math . PI / 180 ) , f = "skewX" == l ; s . shear ( f ? e : 0 , f ? 0 : e ) } } t . transform ( s ) } function f ( t , e , i ) { var n = t [ "fill-opacity" === i ? "getFillColor" : "getStrokeColor" ] ( ) ; n && n . setAlpha ( parseFloat ( e ) ) } function v ( i , n , r ) { var s = i . attributes [ n ] , a = s && s . value ; if ( ! a ) { var o = e . camelize ( n ) ; a = i . style [ o ] , a || r . node [ o ] === r . parent [ o ] || ( a = r . node [ o ] ) } return a ? "none" === a ? null : a : t } function x ( i , n , r ) { var s = { node : R . getStyles ( n ) || { } , parent : ! r && R . getStyles ( n . parentNode ) || { } } ; return e . each ( M , function ( r , a ) { var o = v ( n , a , s ) ; o !== t && ( i = e . pick ( r ( i , o , a , n , s ) , i ) ) } ) , i } function S ( t ) { var e = t && t . match ( /\((?:#|)([^)']+)/ ) ; return e && I [ e [ 1 ] ] } function P ( t , e , i ) { function n ( t ) { paper = s ; var n = P ( t , e , i ) , r = i . onLoad , a = s . project && s . project . view ; r && r . call ( this , n ) , a . draw ( ! 0 ) } if ( ! t ) return null ; i ? "function" == typeof i && ( i = { onLoad : i } ) : i = { } ; var r = t , s = paper ; if ( e ) if ( "string" != typeof t || /^.*</ . test ( t ) ) { if ( "undefined" != typeof File && t instanceof File ) { var a = new FileReader ; return a . onload = function ( ) { n ( a . result ) } , a . readAsText ( t ) } } else { if ( r = document . getElementById ( t ) , ! r ) return $ . request ( "get" , t , n ) ; t = null } if ( "string" == typeof t && ( r = ( new DOMParser ) . parseFromString ( t , "image/svg+xml" ) ) , ! r . nodeName ) throw Error ( "Unsupported SVG source: " + t ) ; var o = r . nodeName . toLowerCase ( ) , h = z [ o ] , u = h && h ( r , o , e , i ) || null , l = r . getAttribute && r . getAttribute ( "data-paper-data" ) ; return u && ( u instanceof w || ( u = x ( u , r , e ) ) , i . expandShapes && u instanceof b && ( u . remove ( ) , u = u . toPath ( ) ) , l && ( u . _data = JSON . parse ( l ) ) ) , e && ( I = { } ) , u } var z = { "#document" : function ( t , e , i , n ) { for ( var r = t . childNodes , s = 0 , a = r . length ; a > s ; s ++ ) { var o = r [ s ] ; if ( 1 === o . nodeType ) { var h = o . nextSibling ; document . body . appendChild ( o ) ; var u = P ( o , i , n ) ; return h ? t . insertBefore ( o , h ) : t . appendChild ( o ) , u } } } , g : a , svg : a , clippath : a , polygon : o , polyline : o , path : u , lineargradient : l , radialgradient : l , image : functi