2013-06-26 22:42:24 -04:00
/ * !
2013-11-02 16:29:09 -04:00
* Paper . js v0 . 9.11 - 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-11-02 16:29:09 -04:00
* Date : Sat Nov 2 21 : 26 : 32 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-11-02 16:29:09 -04:00
var paper = new function ( t ) { var e = new function ( ) { function i ( e , i , n , r , a , o ) { function u ( r , s , o , u ) { var s = s || ( s = _ ( i , r ) ) && ( s . get ? s : s . value ) ; "string" == typeof s && "#" === s [ 0 ] && ( s = e [ s . substring ( 1 ) ] || s ) ; var c , d = "function" == typeof s , f = s , v = a || d ? s && s . get ? r in e : e [ r ] : null ; ! ( o || s !== t && i . hasOwnProperty ( r ) ) || a && v || ( d && v && ( s . base = v ) , d && l && 0 === s . length && ( c = r . match ( /^(get|is)(([A-Z])(.*))$/ ) ) && l . push ( [ c [ 3 ] . toLowerCase ( ) + c [ 4 ] , c [ 2 ] ] ) , f && ! d && f . get && "function" == typeof f . get && 0 === f . get . length || ( f = { value : f , writable : ! 0 } ) , ( _ ( e , r ) || { configurable : ! 0 } ) . configurable && ( f . configurable = ! 0 , f . enumerable = n ) , g ( e , r , f ) ) , ! u || ! d || a && u [ r ] || ( u [ r ] = function ( t ) { return t && e [ r ] . apply ( t , h . call ( arguments , 1 ) ) } ) } var l ; if ( i ) { l = [ ] ; for ( var c in i ) i . hasOwnProperty ( c ) && ! s . test ( c ) && u ( c , null , ! 0 , o ) ; u ( "toString" ) , u ( "valueOf" ) ; for ( var d = 0 , f = l . length ; f > d ; d ++ ) { var v = l [ d ] , m = v [ 1 ] ; u ( v [ 0 ] , { get : e [ "get" + m ] || e [ "is" + m ] , set : e [ "set" + m ] } , ! 0 ) } } return e } function n ( i , n , r , s ) { try { i && ( s || t === s && c ( i ) ? u : l ) . call ( i , n , r = r || i ) } catch ( a ) { if ( a !== e . stop ) throw a } return r } function r ( t ) { return n ( t , function ( t , e ) { this [ e ] = t } , new t . constructor ) } var s = /^(statics|generics|preserve|enumerable|prototype|toString|valueOf)$/ , a = Object . prototype . toString , o = Array . prototype , h = o . slice , u = o . forEach || function ( t , e ) { for ( var i = 0 , n = this . length ; n > i ; i ++ ) t . call ( e , this [ i ] , i , this ) } , l = function ( t , e ) { for ( var i in this ) this . hasOwnProperty ( i ) && t . call ( e , this [ i ] , i , this ) } , c = Array . isArray = Array . isArray || function ( t ) { return "[object Array]" === a . call ( t ) } , d = Object . create || function ( t ) { return { _ _proto _ _ : t } } , _ = 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 } , f = 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 } , g = function ( t , e , i ) { return delete t [ e ] , f ( t , e , i ) } ; return i ( function ( ) { } , { 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 = d ( this . prototype ) , g ( 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 = d ( this ) ; return t . inject . apply ( t , arguments ) } , each : function ( t , e ) { return n ( this , t , e ) } , clone : function ( ) { return r ( this ) } , statics : { each : n , clone : r , create : d , define : g , describe : _ , 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 } , stop : { } } } ) } ; "undefined" != typeof module && ( module . exports = e ) , e . inject ( { generics : ! 0 , clone : function ( ) { return new this . constructor ( this ) } , 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 )
} , getValues : function ( ) { return [ this . _a , this . _c , this . _b , this . _d , this . _tx , this . _ty ] } , getTranslation : function ( ) { return new h ( this . _tx , this . _ty ) } , getScaling : function ( ) { return ( this . decompose ( ) || { } ) . scaling } , getRotation : function ( ) { return ( this . decompose ( ) || { } ) . rotation } , 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 } } , { } ) } ) , 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 E , 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 = [ ] } , 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 } , 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 [ e ] = t ) : i [ e ] === t && ( this . _selectedItemCount -- , delete i [ e ] ) } , selectAll : function ( ) { for ( var t = this . layers , e = 0 , i = t . length ; i > e ; e ++ ) t [ e ] . setFullySelected ( ! 0 ) } , deselectAll : function ( ) { var t = this . _selectedItems ; for ( var e in t ) t [ e ] . setFullySelected ( ! 1 ) } , hitTest : function ( t , i ) { t = h . read ( arguments ) , i = P . getOptions ( e . read ( arguments ) ) ; for ( var n = this . layers . length - 1 ; n >= 0 ; n -- ) { var r = this . layers [ n ] . hitTest ( t , i ) ; if ( r ) return r } return null } } , new function ( ) { function t ( t , e , i ) { for ( var n = t . layers , r = i && [ ] , s = 0 , a = n . length ; a > s ; s ++ ) { var o = n [ s ] [ i ? "getItems" : "getItem" ] ( e ) ; if ( i ) r . push . apply ( r , o ) ; else if ( o ) return o } return i ? r : null } return { getItems : function ( e ) { return t ( this , e , ! 0 ) } , getItem : function ( e ) { return t ( this , e , ! 1 ) } } } , { importJSON : function ( t ) { return this . activate ( ) , e . importJSON ( t ) } , draw : function ( t , i ) { this . _drawCount ++ , t . save ( ) , i . applyToContext ( t ) ; for ( var n = e . merge ( { offset : new h ( 0 , 0 ) , transforms : [ i ] , trackTransforms : ! 0 } ) , r = 0 , s = this . layers . length ; s > r ; r ++ ) this . layers [ r ] . draw ( t , n ) ; if ( t . restore ( ) , this . _selectedItemCount > 0 ) { t . save ( ) , t . strokeWidth = 1 ; for ( var a in this . _selectedItems ) { var o = this . _selectedItems [ a ] ; if ( o . _drawCount
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 , e . merge ( { 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 ? N . read ( l ) : null } , getPixel : function ( t ) { t = h . read ( arguments ) ; var e = this . getContext ( ) . getImageData ( t . x , t . y , 1 , 1 ) . data ; return new N ( "rgb" , [ e [ 0 ] / 255 , e [ 1 ] / 255 , e [ 2 ] / 255 ] , e [ 3 ] / 255 ) } , setPixel : function ( ) { var t = h . read ( arguments ) , e = N . 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 . _getCachedBounds ( t , e ) } , _hitTest : function ( t , e , i ) { var n = this . _symbol . _definition . _hitTest ( t , e , i ) ; return n && ( n . item = this ) , n } , _draw : function ( t , e ) { this . symbol . _definition . draw ( t , e ) } } ) , P = e . extend ( { _class : "HitResult" , initialize : function ( t , e , i ) { this . type = t , this . item = e , i && ( i . enumerable = ! 0 , this . inject ( i ) ) } , statics : { getOptions : function ( t ) { return t && t . _merged ? t : e . merge ( { type : null , tolerance : paper . project . options . hitTolerance || 2 , fill : ! t , stroke : ! t , segments : ! t , handles : ! 1 , ends : ! 1 , center : ! 1 , bounds : ! 1 , guides : ! 1 , selected : ! 1 , _merged : ! 0 } , t ) } } } ) , z = e . extend ( { _class : "Segment" , initialize : function ( e , i , n , r , s , a ) { var o , h , u , l = arguments . length ; 0 === l || ( 1 === l ? e . point ? ( o = e . point , h = e . handleIn , u = e . handleOut ) : o = e : 2 === l && "number" == typeof e ? o = arguments : 3 >= l ? ( o = e , h = i , u = n ) : ( o = e !== t ? [ e , i ] : null , h = n !== t ? [ n , r ] : null , u = s !== t ? [ s , a ] : null ) ) , new M ( o , this , "_point" ) , new M ( h , this , "_handleIn" ) , new M ( u , this , "_handleOut" ) } , _serialize : function ( t ) { return e . serialize ( this . isLinear ( ) ? this . _point : [ this . _point , this . _handleIn , this . _handleOut ] , t , ! 0 ) } , _changed : function ( t ) { if ( this . _path ) { var e , i = this . _path . _curves && this . getCurve ( ) ; i && ( i . _changed ( ) , ( e = i [ t == this . _point || t == this . _handleIn && i . _segment1 == this ? "getPrevious" : "getNext" ] ( ) ) && e . _changed ( ) ) , this . _path . _changed ( 5 ) } } , getPoint : function ( ) { return this . _point } , setPoint : function ( t ) { t = h . read
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 = 0 , u = i . length ; u > h ; h ++ ) { var l = i [ h ] . getValues ( ) , c = l [ 0 ] , d = l [ 1 ] ; ( c !== l [ 2 ] || d !== l [ 3 ] || c !== l [ 4 ] || d !== l [ 5 ] || c !== l [ 6 ] || d !== l [ 7 ] ) && ( r += I . _getWinding ( l , t . x , t . y , s , a ) ) } return e || ( r += I . _getWinding ( o , 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 = [ ] , n = [ ] , r = 0 , s = 0 ; e > s ; s ++ ) r += I . _getWinding ( a ( s ) , t . x , t . y , i , n ) ; return ! ! r } 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 . getDistance ( t . _point ) <= y } var u , l , c , d , _ , f , g = this . getStyle ( ) , v = this . _segments , m = this . _closed , p = i . tolerance , y = 0 , w = this ; if ( i . stroke && ( y = g . getStrokeWidth ( ) / 2 , y > 0 ? ( u = g . getStrokeJoin ( ) , l = g . getStrokeCap ( ) , c = y * g . getMiterLimit ( ) ) : u = l = "round" , y += p ) , ! i . ends || i . segments || m ) { if ( i . segments || i . handles ) for ( var x = 0 , b = v . length ; b > x ; x ++ ) if ( f = r ( v [ x ] ) ) return f } else if ( f = r ( v [ 0 ] , ! 0 ) || r ( v [ v . length - 1 ] , ! 0 ) ) return f ; if ( y > 0 ) { if ( _ = this . getNearestLocation ( e ) ) { var C = _ . getParameter ( ) ; 0 === C || 1 === C ? h ( _ . getSegment ( ) ) || ( _ = null ) : _ . _distance > y && ( _ = null ) } if ( ! _ && "miter" === u ) for ( var x = 0 , b = v . length ; b > x ; x ++ ) { var S = v [ x ] ; if ( e . getDistance ( S . _point ) <= c && h ( S ) ) { _ = S . getLocation ( ) ; break } } } return ! _ && i . fill && this . hasFill ( ) && this . contains ( e ) ? new P ( "fill" , this ) : _ ? new P ( "stroke" , this , { location : _ } ) : null } } , new function ( ) { function t ( t , e , i , n ) { function r ( e ) { var i = a [ e ] , n = a [ e + 1 ] ; ( d != i || _ != n ) && ( t . beginPath ( ) , t . moveTo ( d , _ ) , t . lineTo ( i , n ) , t . stroke ( ) , t . beginPath ( ) , t . arc ( i , n , s , 0 , 2 * Math . PI , ! 0 ) , t . fill ( ) ) } for ( var s = n / 2 , a = Array ( 6 ) , o = 0 , h = e . length ; h > o ; o ++ ) { var u = e [ o ] ; u . _transformCoordinates ( i , a , ! 1 ) ; var l = u . _selectionState , c = 4 & l , d = a [ 0 ] , _ = a [ 1 ] ; ( c || 1 & l ) && r ( 2 ) , ( c || 2 & l ) && r ( 4 ) , t . save ( ) , t . beginPath ( ) , t . rect ( d - s , _ - s , n , n ) , t . fill ( ) , c || ( t . beginPath ( ) , t . rect ( d - s + 1 , _ - s + 1 , n - 2 , n - 2 ) , t . fillStyle = "#ffffff" , t . fill ( ) ) , t . restore ( ) } } function e ( t , e , i ) { function n ( e ) { var n = d [ e ] ; if ( i ) n . _transformCoordinates ( i , f , ! 1 ) , r = f [ 0 ] , s = f [ 1 ] ; else { var _ = n . _point ; r = _ . _x , s = _ . _y } if ( g ) t . moveTo ( r , s ) , g = ! 1 ; else { if ( i ) h = f [ 2 ] , u = f [ 3 ] ; else { var v = n . _handleIn ; h = r + v . _x , u = s + v . _y } h == r && u == s && l == a && c == o ? t . lineTo ( r , s ) : t . bezierCurveTo ( l , c , h , u , r , s ) } if ( a = r , o = s , i ) l = f [ 4 ] , c = f [ 5 ] ; else { var v = n . _handleOut ; l = a + v . _x , c = o + v .
} , _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 this . constructor ( 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 = N . 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 } } ) , E = e . extend ( new function ( ) { var i = { fillColor : t , strokeColor : t , strokeWidth : 1 , strokeCap : "butt" , strokeJoin : "miter" , miterLimit : 10 , dashOffset : 0 , dashArray : [ ] , windingRule : "nonzero" , shadowColor : t , shadowBlur : 0 , shadowOffset : new h , selectedColor : t , font : "sans-serif" , fontSize : 12 , leading : null , justification : "left" } , n = { strokeWidth : 25 , strokeCap : 25 , strokeJoin : 25 , miterLimit : 25 , font : 5 , fontSize : 5 , leading : 5 , justification : 5 } , r = { } , s = { _defaults : i , _textDefaults : e . merge ( i , { fillColor : new N } ) } ; return e . each ( i , function ( i , a ) { var o = /Color$/ . test ( a ) , h = e . capitalize ( a ) , u = n [ a ] , l = "set" + h , c = "get" + h ; s [ l ] = function ( t ) { var e = this . _item && this . _item . _children ; if ( e && e . length > 0 && "compound-path" !== this . _item . _type ) for ( var i = 0 , n = e . length ; n > i ; i ++ ) e [ i ] . _style [ l ] ( t ) ; else { var r = this . _values [ a ] ; r != t && ( o && ( r && delete r . _owner , t && t . constructor === N && ( t . _owner && ( t = t . clone ( ) ) , t . _owner = this . _item ) ) , this . _values [ a ] = t , this . _item && this . _item . _changed ( u || 17 ) ) } } , s [ c ] = function ( ) { var i , n = this . _item && this . _item . _children ; if ( ! n || 0 === n . length || arguments [ 0 ] || "compound-path" === this . _item . _type ) { var i = this . _values [ a ] ; return i === t ? ( i = this . _defaults [ a ] , i && i . clone && ( i = i . clone ( ) ) , this . _values [ a ] = i ) : ! o || i && i . constructor === N || ( this . _values [ a ] = i = N . read ( [ i ] , 0 , 0 , { readNull : ! 0 , clone : ! 0 } ) , i && ( i . _owner = this . _item ) ) , i } for ( var r = 0 , s = n . length ; s > r ; r ++ ) { var h = n [ r ] . _style [ c ] ( ) ; if ( 0 === r ) i = h ; else if ( ! e . equals ( i , h ) ) return t } return i } , r [ c ] = function ( ) { return this . _style [ c ] ( ) } , r [ l ] = function ( t ) { this . _style [ l ] ( t ) } } ) , y . inject ( r ) , s } , { _class : "Style" , initialize : function ( t , e ) { this . _values = { } , this . _item = e , e instanceof j && ( this . _defaults = this . _textDefaults ) , t && this . set ( t ) } , set : function ( t ) { var e = t instanceof E , i = e ? t . _values : t ; if ( i ) for ( var n in i ) if ( n in this . _defaults ) { var r = i [ n ] ; this [ n ] = r && e && r . clone ? r . clone ( ) : r } } , equals : function ( t ) { return t === this || t && this . _class === t . _class && e . equals ( this . _values , t . _values ) || ! 1 } , hasFill : function ( ) { return ! ! this . getFillColor ( ) } , hasStroke : function ( ) { return ! ! this . getStrokeColor ( ) && this . getStrokeWidth ( ) > 0 } , hasShadow
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 ) { if ( i || ( i = { } ) , "string" == typeof t ) { if ( e && ! /^.*</ . test ( t ) ) { "function" == typeof i && ( i = { onLoad : i } ) ; var n = paper ; return $ . request ( "get" , t , function ( t ) { paper = n ; var r = P ( t , e , i ) , s = i . onLoad , a = n . project && n . project . view ; s && s . call ( this , r ) , a . draw ( ! 0 ) } ) } t = ( new DOMParser ) . parseFromString ( t , "image/svg+xml" ) } var r = t . nodeName . toLowerCase ( ) , s = z [ r ] , a = s && s ( t , r , e , i ) , o = "#document" !== r && t . getAttribute ( "data-paper-data" ) ; return a && ( a instanceof w || ( a = x ( a , t , e ) ) , i . expandShapes && a instanceof b && ( a . remove ( ) , a = a . toPath ( ) ) , o && ( a . _data = JSON . parse ( o ) ) ) , e && ( I = { } ) , a } var z = { "#document" : function ( t , e , i , n ) { return P ( t . childNodes [ 0 ] , i , n ) } , g : a , svg : a , clippath : a , polygon : o , polyline : o , path : u , lineargradient : l , radialgradient : l , image : function ( t ) { var e = new C ( i ( t , "href" , ! 0 ) ) ; return e . attach ( "load" , function ( ) { var e = r ( t , "width" , "height" ) ; this . setSize ( e ) , this . translate ( n ( t , "x" , "y" ) . add ( e . divide ( 2 ) ) ) } ) , e } , symbol : function ( t , e , i , n ) { return new p ( a ( t , e , i , n ) , ! 0 ) } , defs : a , use : function ( t ) { var e = ( i ( t , "href" , ! 0 ) || "" ) . substring ( 1 ) , r = I [ e ] , s = n ( t , "x" , "y" ) ; return r ? r instanceof p ? r . place ( s ) : r . clone ( ) . translate ( s ) : null } , circle : function ( t ) { return new b . Circle ( n ( t , "cx" , "cy" ) , i ( t , "r" ) ) } , ellipse : function ( t ) { return new b . Ellipse ( { center : n ( t , "cx" , "cy" ) , radius : r ( t , "rx" , "ry" ) } ) } , rect : function ( t ) { var e = n ( t , "x" , "y" ) , i = r ( t , "width" , "height" ) , s = r ( t , "rx" , "ry" ) ; return new b . Rectangle ( new _ ( e , i ) , s ) } , line : function ( t ) { return new O . Line ( n ( t , "x1" , "y1" ) , n ( t , "x2" , "y2" ) ) } , text : function ( t ) { var e = new B ( n ( t , "x" , "y" ) . add ( n ( t , "dx" , "dy" ) ) ) ; return e . setContent ( t . textContent . trim ( ) || "" ) , e } } , M = e . merge ( e . each ( te , function ( t ) { this [ t . attribute ] = function ( e , i ) { if ( e [ t . set ] ( s ( i , t . type , t . fromSVG ) ) , "color" === t . type && e instanceof b ) { var n = e [ t . get ] ( ) ; n && n . transform ( ( new g ) . translate ( e . getPosition ( ! 0 ) . negate ( ) ) ) } } } , { } ) , { id : function ( t , e ) { I [ e ] = t , t . setName && t . setName ( e ) } , "clip-path" : function ( t , e ) { var i = S ( e ) ; if ( i ) { if ( i = i . clone ( ) , i . setClipMask ( ! 0 ) , ! ( t instanceof w ) ) return new w ( i , t ) ; t . insertChild ( 0 , i ) } } , gradientTransform : d , transform : d , "fill-opacity" : f , "stroke-opacity" : f , visibility : function ( t , e ) { t . setVisible ( "visible" === e ) } , "stop-color" : function ( t , e ) { t . setColor && t . setColor ( e ) } , "stop-opacity" : function ( t , e ) { t . _color && t . _color . setAlpha ( parseFloat ( e ) ) } , offset : function ( t , e ) { var i = e . match ( /(.*)%$/ ) ; t . setRampPoint ( i ? i [ 1 ] / 100 : parseFloat ( e ) ) } , viewBox : function ( t , e , i , n , a ) { var o = new _ ( s ( e , "array" ) ) , h = r ( n , "width" , "height" , ! 0 ) ; if ( t instanceof w ) { var u = h ? o . getSize ( ) . divide ( h ) : 1 , l = ( new g ) . translate ( o . getPoint ( ) ) . scale ( u ) ; t . transform ( l . inverted ( ) ) } else if ( t instanceof p ) { h && o . setSize ( h ) ; var c = "visible" != v ( n , "overflow" , a ) , d = t . _definition ; c && ! o . contains ( d . getBounds ( ) ) && ( c = new b . Rectangle ( o ) . transform ( d . _matrix ) , c . setClipMask ( ! 0 ) , d . addChild ( c ) ) } } } ) , I = { } ; y . inject ( { importSVG : function ( t , e ) { return this . addChild ( P ( t , ! 0 , e ) ) } } ) , m . inject ( { importSVG : function ( t , e ) { return this . activate ( ) , P ( t , ! 0 , e ) } } ) } , paper = new ( r . inject ( e . merge ( e . exports , { enumerable : ! 0 , Base : e , Numerical : o , DomElement : R , DomEvent : V , Key : X } ) ) ) , "function" == typeof define && define . amd && define ( "paper" , paper ) , paper } ;