2013-06-26 22:42:24 -04:00
/ * !
2013-10-29 17:00:23 -04:00
* Paper . js v0 . 9.10 - 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-10-29 17:00:23 -04:00
* Date : Tue Oct 29 21 : 56 : 00 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-10-29 17:00:23 -04:00
var paper = new function ( t ) { var e = new function ( ) { function n ( e , n , i , r , a , o ) { function u ( r , s , o , u ) { var s = s || ( s = f ( n , r ) ) && ( s . get ? s : s . value ) ; "string" == typeof s && "#" === s [ 0 ] && ( s = e [ s . substring ( 1 ) ] || s ) ; var c , d = "function" == typeof s , _ = s , p = a || d ? s && s . get ? r in e : e [ r ] : null ; ! ( o || s !== t && n . hasOwnProperty ( r ) ) || a && p || ( d && p && ( s . base = p ) , d && l && 0 === s . length && ( c = r . match ( /^(get|is)(([A-Z])(.*))$/ ) ) && l . push ( [ c [ 3 ] . toLowerCase ( ) + c [ 4 ] , c [ 2 ] ] ) , _ && ! d && _ . get && "function" == typeof _ . get && 0 === _ . get . length || ( _ = { value : _ , writable : ! 0 } ) , ( f ( e , r ) || { configurable : ! 0 } ) . configurable && ( _ . configurable = ! 0 , _ . enumerable = i ) , g ( e , r , _ ) ) , ! u || ! d || a && u [ r ] || ( u [ r ] = function ( t ) { return t && e [ r ] . apply ( t , h . call ( arguments , 1 ) ) } ) } var l ; if ( n ) { l = [ ] ; for ( var c in n ) n . hasOwnProperty ( c ) && ! s . test ( c ) && u ( c , null , ! 0 , o ) ; u ( "toString" ) , u ( "valueOf" ) ; for ( var d = 0 , _ = l . length ; _ > d ; d ++ ) { var p = l [ d ] , v = p [ 1 ] ; u ( p [ 0 ] , { get : e [ "get" + v ] || e [ "is" + v ] , set : e [ "set" + v ] } , ! 0 ) } } return e } function i ( n , i , r , s ) { try { n && ( s || t === s && c ( n ) ? u : l ) . call ( n , i , r = r || n ) } catch ( a ) { if ( a !== e . stop ) throw a } return r } function r ( t ) { return i ( 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 n = 0 , i = this . length ; i > n ; n ++ ) t . call ( e , this [ n ] , n , this ) } , l = function ( t , e ) { for ( var n in this ) this . hasOwnProperty ( n ) && t . call ( e , this [ n ] , n , this ) } , c = Array . isArray = Array . isArray || function ( t ) { return "[object Array]" === a . call ( t ) } , d = Object . create || function ( t ) { return { _ _proto _ _ : t } } , f = Object . getOwnPropertyDescriptor || function ( t , e ) { var n = t . _ _lookupGetter _ _ && t . _ _lookupGetter _ _ ( e ) ; return n ? { get : n , set : t . _ _lookupSetter _ _ ( e ) , enumerable : ! 0 , configurable : ! 0 } : t . hasOwnProperty ( e ) ? { value : t [ e ] , enumerable : ! 0 , configurable : ! 0 , writable : ! 0 } : null } , _ = Object . defineProperty || function ( t , e , n ) { return ( n . get || n . set ) && t . _ _defineGetter _ _ ? ( n . get && t . _ _defineGetter _ _ ( e , n . get ) , n . set && t . _ _defineSetter _ _ ( e , n . set ) ) : t [ e ] = n . value , t } , g = function ( t , e , n ) { return delete t [ e ] , _ ( t , e , n ) } ; return n ( function ( ) { } , { inject : function ( t ) { if ( t ) { var e = this . prototype , i = Object . getPrototypeOf ( e ) . constructor , r = t . statics === ! 0 ? t : t . statics ; r != t && n ( e , t , t . enumerable , i && i . prototype , t . preserve , t . generics && this ) , n ( this , r , ! 0 , i , 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 , i = 0 , r = arguments . length ; r > i && ! ( t = arguments [ i ] . initialize ) ; i ++ ) ; return t = t || function ( ) { e . apply ( this , arguments ) } , t . prototype = d ( this . prototype ) , g ( t . prototype , "constructor" , { value : t , writable : ! 0 , configurable : ! 0 } ) , n ( 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 ++ ) n ( 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 i ( this , t , e ) } , clone : function ( ) { return r ( this ) } , statics : { each : i , clone : r , create : d , define : g , describe : f , isPlainObject : function ( t ) { var n = null != t && t . constructor ; return n && ( n === Object || n === e || "Object" === n . name ) } , pick : function ( ) { for ( var e = 0 , n = arguments . length ; n > 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 n = typeof t ; this . push ( e + ": " + ( "number" === n ? a . instance . number ( t ) : "string" === n ? "'" + t + "'" : t ) ) } } , [ ] ) . join ( ", " ) + " }" } , exportJSON : function ( t ) { return e . exportJSON ( this , t ) } , toJSON : function ( ) { return e . serialize ( this ) } , _set : function ( n , i ) { if ( n && e . isPlainObject ( n ) ) { var r = n . _filtering || n ; for ( var s in r ) if ( s in this && r . hasOwnProperty ( s ) && ( ! i || ! i [ s ] ) ) { var a = n [ s ] ; a !== t && ( this [ s ] = a ) } return ! 0 } } , statics : { exports : { } , extend : function ne ( ) { var t = ne . base . apply ( this , arguments ) , n = t . prototype . _class ; return n && ! e . exports [ n ] && ( e . exports [ n ] = t ) , t } , equals : function ( t , n ) { function i ( t , e ) { for ( var n in t ) if ( t . hasOwnProperty ( n ) && ! e . hasOwnProperty ( n ) ) return ! 1 ; return ! 0 } if ( t === n ) return ! 0 ; if ( t && t . equals ) return t . equals ( n )
} , 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 , n ) { n = e . capitalize ( n ) , this [ "get" + n ] = function ( ) { return this [ t ] } , this [ "set" + n ] = function ( e ) { this [ t ] = e } } , { } ) } ) , p = e . extend ( { _class : "Line" , initialize : function ( t , e , n , i , r ) { var s = ! 1 ; arguments . length >= 4 ? ( this . _px = t , this . _py = e , this . _vx = n , this . _vy = i , s = r ) : ( this . _px = t . x , this . _py = t . y , this . _vx = e . x , this . _vy = e . y , s = n ) , s || ( this . _vx -= this . _px , this . _vy -= this . _py ) } , getPoint : function ( ) { return new 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 p . intersect ( this . _px , this . _py , this . _vx , this . _vy , t . _px , t . _py , t . _vx , t . _vy , ! 0 , e ) } , getSide : function ( t ) { return p . getSide ( this . _px , this . _py , this . _vx , this . _vy , t . x , t . y , ! 0 ) } , getDistance : function ( t ) { return Math . abs ( p . getSignedDistance ( this . _px , this . _py , this . _vx , this . _vy , t . x , t . y , ! 0 ) ) } , statics : { intersect : function ( t , e , n , i , r , s , a , u , l , c ) { l || ( n -= t , i -= e , a -= r , u -= s ) ; var d = u * n - a * i ; if ( ! o . isZero ( d ) ) { var f = t - r , _ = e - s , g = ( a * _ - u * f ) / d , p = ( n * _ - i * f ) / d ; if ( ( c || g >= 0 && 1 >= g ) && ( c || p >= 0 && 1 >= p ) ) return new h ( t + g * n , e + g * i ) } } , getSide : function ( t , e , n , i , r , s , a ) { a || ( n -= t , i -= e ) ; var o = r - t , h = s - e , u = o * i - h * n ; return 0 === u && ( u = o * n + h * i , u > 0 && ( o -= n , h -= i , u = o * n + h * i , 0 > u && ( u = 0 ) ) ) , 0 > u ? - 1 : u > 0 ? 1 : 0 } , getSignedDistance : function ( t , e , n , i , r , s , a ) { a || ( n -= t , i -= e ) ; var o = i / n , h = e - o * t ; return ( s - o * r - h ) / Math . sqrt ( o * o + 1 ) } } } ) , v = s . extend ( { _class : "Project" , _list : "projects" , _reference : "project" , initialize : function ( t ) { s . call ( this , ! 0 ) , this . layers = [ ] , this . symbols = [ ] , this . _currentStyle = new F , 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 , n ) { return e . serialize ( this . layers , t , ! 0 , n ) } , 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 n = this . _selectedItems [ e ] ; n . isInserted ( ) && t . push ( n ) } return t } , _updateSelection : function ( t ) { var e = t . _id , n = this . _selectedItems ; t . _selected ? n [ e ] !== t && ( this . _selectedItemCount ++ , n [ e ] = t ) : n [ e ] === t && ( this . _selectedItemCount -- , delete n [ e ] ) } , selectAll : function ( ) { for ( var t = this . layers , e = 0 , n = t . length ; n > e ; e ++ ) t [ e ] . setFullySelected ( ! 0 ) } , deselectAll : function ( ) { var t = this . _selectedItems ; for ( var e in t ) t [ e ] . setFullySelected ( ! 1 ) } , hitTest : function ( t , n ) { t = h . read ( arguments ) , n = P . getOptions ( e . read ( arguments ) ) ; for ( var i = this . layers . length - 1 ; i >= 0 ; i -- ) { var r = this . layers [ i ] . hitTest ( t , n ) ; if ( r ) return r } return null } } , new function ( ) { function t ( t , e , n ) { for ( var i = t . layers , r = n && [ ] , s = 0 , a = i . length ; a > s ; s ++ ) { var o = i [ s ] [ n ? "getItems" : "getItem" ] ( e ) ; if ( n ) r . push . apply ( r , o ) ; else if ( o ) return o } return n ? 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 , n ) { this . _drawCount ++ , t . save ( ) , n . applyToContext ( t ) ; for ( var i = e . merge ( { offset : new h ( 0 , 0 ) , transforms : [ n ] , trackTransforms : ! 0 } ) , r = 0 , s = this . layers . length ; s > r ; r ++ ) this . layers [ r ] . draw ( t , i ) ; 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
} , getAverageColor : function ( t ) { var n , i ; t ? t instanceof A ? ( i = t , n = t . getBounds ( ) ) : t . width ? n = new f ( t ) : t . x && ( n = new f ( t . x - . 5 , t . y - . 5 , 1 , 1 ) ) : n = this . getBounds ( ) ; var r = 32 , s = Math . min ( n . width , r ) , a = Math . min ( n . 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 / n . width , a / n . height ) . translate ( - n . x , - n . y ) ; h . applyToContext ( o ) , i && i . 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 , _ = 0 , p = u . length ; p > _ ; _ += 4 ) { var v = u [ _ + 3 ] ; d += v , v /= 255 , l [ 0 ] += u [ _ ] * v , l [ 1 ] += u [ _ + 1 ] * v , l [ 2 ] += u [ _ + 2 ] * v } for ( var _ = 0 ; 3 > _ ; _ ++ ) l [ _ ] /= d ; return d ? B . read ( l ) : null } , getPixel : function ( t ) { t = h . read ( arguments ) ; var e = this . getContext ( ) . getImageData ( t . x , t . y , 1 , 1 ) . data ; return new B ( "rgb" , [ e [ 0 ] / 255 , e [ 1 ] / 255 , e [ 2 ] / 255 ] , e [ 3 ] / 255 ) } , setPixel : function ( ) { var t = h . read ( arguments ) , e = B . read ( arguments ) , n = e . _convert ( "rgb" ) , i = e . _alpha , r = this . getContext ( ! 0 ) , s = r . createImageData ( 1 , 1 ) , a = s . data ; a [ 0 ] = 255 * n [ 0 ] , a [ 1 ] = 255 * n [ 1 ] , a [ 2 ] = 255 * n [ 2 ] , a [ 3 ] = null != i ? 255 * i : 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 = f . read ( arguments ) , t . isEmpty ( ) && ( t = new f ( 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 n = new f ( this . _size ) . setCenter ( 0 , 0 ) ; return e ? e . _transformBounds ( n ) : n } , _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 , n ) { this . _initialize ( e , n !== t && h . read ( arguments , 1 ) ) || this . setSymbol ( e instanceof m ? e : new m ( 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 , n ) { var i = this . _symbol . _definition . _hitTest ( t , e , n ) ; return i && ( i . item = this ) , i } , _draw : function ( t , e ) { this . symbol . _definition . draw ( t , e ) } } ) , P = e . extend ( { _class : "HitResult" , initialize : function ( t , e , n ) { this . type = t , this . item = e , n && ( n . enumerable = ! 0 , this . inject ( n ) ) } , 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 ) } } } ) , k = e . extend ( { _class : "Segment" , initialize : function ( e , n , i , 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 = n , u = i ) : ( o = e !== t ? [ e , n ] : null , h = i !== t ? [ i , r ] : null , u = s !== t ? [ s , a ] : null ) ) , new z ( o , this , "_point" ) , new z ( h , this , "_handleIn" ) , new z ( 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 , n = this . _path . _curves && this . getCurve ( ) ; n && ( n . _changed ( ) , ( e = n [ t == this . _point || t == this . _handleIn && n . _segment1 == this ? "getPrevious" : "getNext" ] ( ) ) && e . _changed ( ) ) , this . _path . _changed ( 5 ) } } , getPoint : function ( ) { return this . _point } , setPoint : function ( t ) { t = h . read ( arguments ) , this . _point . set ( t . x , t . y ) } , getHandleIn : function ( ) { return this . _handleIn } , setHandleIn : function ( t ) { t = h . read ( arguments ) , this . _handleIn . set ( t . x , t . y ) } , getHandleO
a . _distance < n && ( n = a . _distance , i = a ) } return i } , 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 n ( t , e ) { return d [ t ] . isColinear ( d [ e ] ) } function i ( 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 && n ( 0 , 2 ) && n ( 1 , 3 ) && i ( 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 ) && n ( 1 , 5 ) && n ( 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 f = this . getPosition ( ! 0 ) , _ = new a ( { center : f , size : h , radius : u , insert : ! 1 } ) ; return _ . rotate ( l . subtract ( f ) . getAngle ( ) + 90 ) , _ . setStyle ( this . _style ) , ( e || e === t ) && _ . insertAbove ( this ) , _ } return null } , _getWinding : function ( t ) { var e = this . _closed ; if ( ! e && ! this . hasFill ( ) || ! this . _getBounds ( "getRoughBounds" ) . _containsPoint ( t ) ) return 0 ; for ( var n = this . getCurves ( ) , i = this . _segments , r = 0 , s = [ ] , a = [ ] , o = ( e ? n [ n . length - 1 ] : new M ( i [ i . length - 1 ] . _point , i [ 0 ] . _point ) ) . getValues ( ) , h = 0 , u = n . length ; u > h ; h ++ ) { var l = n [ 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 += M . _getWinding ( l , t . x , t . y , s , a ) ) } return e || ( r += M . _getWinding ( o , t . x , t . y , s , a ) ) , r } , _hitTest : function ( e , n ) { function i ( n , i , r ) { return e . getDistance ( i ) < m ? new P ( r , w , { segment : n , point : i } ) : t } function r ( t , e ) { var r = t . _point ; return ( e || n . segments ) && i ( t , r , "segment" ) || ! e && n . handles && ( i ( t , r . add ( t . _handleIn ) , "handle-in" ) || i ( t , r . add ( t . _handleOut ) , "handle-out" ) ) } function s ( t ) { d . push ( t ) } function a ( t ) { var e = d [ t ] , n = d [ ( t + 1 ) % d . length ] ; return [ e . x , e . y , e . x , e . y , n . x , n . y , n . x , n . y ] } function o ( t ) { for ( var e = d . length , n = [ ] , i = [ ] , r = 0 , s = 0 ; e > s ; s ++ ) r += M . _getWinding ( a ( s ) , t . x , t . y , n , i ) ; return ! ! r } function h ( t ) { return ( "round" !== u || "round" !== l ) && ( d = [ ] , v || t . _index > 0 && t . _index < p . 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 ( ) , p = this . _segments , v = this . _closed , m = n . tolerance , y = 0 , w = this ; if ( n . stroke && ( y = g . getStrokeWidth ( ) / 2 , y > 0 ? ( u = g . getStrokeJoin ( ) , l = g . getStrokeCap ( ) , c = y * g . getMiterLimit ( ) ) : u = l = "round" , y += m ) , ! n . ends || n . segments || v ) { if ( n . segments || n . handles ) for ( var x = 0 , b = p . length ; b > x ; x ++ ) if ( _ = r ( p [ x ] ) ) return _ } else if ( _ = r ( p [ 0 ] , ! 0 ) || r ( p [ p . length - 1 ] , ! 0 ) ) return _ ; if ( y > 0 ) { if ( f = this . getNearestLocation ( e ) ) { var C = f . getParameter ( ) ; 0 === C || 1 === C ? h ( f . getSegment ( ) ) || ( f = null ) : f . _distance > y && ( f = null ) } if ( ! f && "miter" === u ) for ( var x = 0 , b = p . length ; b > x ; x ++ ) { var S = p [ x ] ; if ( e . getDistance ( S . _point ) <= c && h ( S ) ) { f = S . getLocation ( ) ; break } } } return ! f && n . fill && this . hasFill ( ) && this . contains ( e ) ? new P ( "fill" , this ) : f ? new P ( "stroke" , this , { location : f } ) : null } } , new function ( ) { function t ( t , e , n , i ) { function r ( e ) { var n = a [ e ] , i = a [ e + 1 ] ; ( d != n || f != i ) && ( t . beginPath ( ) , t . moveTo ( d , f ) , t . lineTo ( n , i ) , t . stroke ( ) , t . beginPath ( ) , t . arc ( n , i , s , 0 , 2 * Math . PI , ! 0 ) , t . fill ( ) ) } for ( var s = i / 2 , a = Array ( 6 ) , o = 0 , h = e . length ; h > o ; o ++ ) { var u = e [ o ] ; u . _transformCoordinates ( n , a , ! 1 ) ; var l = u . _selectionState , c = 4 & l , d = a [ 0 ] , f = a [ 1 ] ; ( c || 1 & l ) && r ( 2 ) , ( c || 2 & l ) && r ( 4 ) , t . save ( ) , t . beginPath ( ) , t . rect ( d - s , f - s , i , i ) , t . fill ( ) , c || ( t . beginPath ( ) , t . rect ( d - s + 1 , f - s + 1 , i - 2 , i - 2 ) , t . fillStyle = "#ffffff" , t . fill ( ) ) , t . restore ( ) } } function e ( t , e , n ) { function i ( e ) { var i = d [ e ] ; if ( n ) i . _transformCoordinates ( n , _ , ! 1 ) , r = _ [ 0 ] , s = _ [ 1 ] ; else { var f = i . _point ; r = f . _x , s = f . _y } if ( g ) t . moveTo ( r , s ) , g = ! 1 ; else { if ( n ) h = _ [ 2 ] , u = _ [ 3 ] ; else { var p = i . _handleIn ; h = r + p . _x , u = s + p . _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 , n ) l = _ [ 4 ] , c = _ [ 5 ] ; else { var p = i . _handleOut ; l = a + p . _x , c = o + p . _y } } for ( var r , s , a , o , h , u , l , c , d = e . _segments , f = d . length , _ = Array ( 6 ) , g = ! 0 , p = 0 ; f > p ; p ++ ) i ( p ) ; e . _closed && f > 1 && i ( 0 ) } return { _draw : function ( t , n ) { function i ( t ) { return u [ ( t % l + l ) % l ] } var r
} , getStops : function ( ) { return this . _stops } , setStops : function ( t ) { if ( this . stops ) for ( var e = 0 , n = this . _stops . length ; n > 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 = R . readAll ( t , 0 , ! 1 , ! 0 ) ; for ( var e = 0 , n = this . _stops . length ; n > e ; e ++ ) { var i = this . _stops [ e ] ; i . _owner = this , i . _defaultRamp && i . setRampPoint ( e / ( n - 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 , n = this . _stops . length ; n > e ; e ++ ) if ( ! this . _stops [ e ] . equals ( t . _stops [ e ] ) ) return ! 1 ; return ! 0 } return ! 1 } } ) , R = e . extend ( { _class : "GradientStop" , initialize : function ( e , n ) { if ( e ) { var i , r ; n === t && Array . isArray ( e ) ? ( i = e [ 0 ] , r = e [ 1 ] ) : e . color ? ( i = e . color , r = e . rampPoint ) : ( i = e , r = n ) , this . setColor ( i ) , this . setRampPoint ( r ) } } , clone : function ( ) { return new R ( this . _color . clone ( ) , this . _rampPoint ) } , _serialize : function ( t , n ) { return e . serialize ( [ this . _color , this . _rampPoint ] , t , ! 0 , n ) } , _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 = B . 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 } } ) , F = e . extend ( new function ( ) { var n = { 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" } , i = { strokeWidth : 25 , strokeCap : 25 , strokeJoin : 25 , miterLimit : 25 , font : 5 , fontSize : 5 , leading : 5 , justification : 5 } , r = { } , s = { _defaults : n , _textDefaults : e . merge ( n , { fillColor : new B } ) } ; return e . each ( n , function ( n , a ) { var o = /Color$/ . test ( a ) , h = e . capitalize ( a ) , u = i [ 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 n = 0 , i = e . length ; i > n ; n ++ ) e [ n ] . _style [ l ] ( t ) ; else { var r = this . _values [ a ] ; r != t && ( o && ( r && delete r . _owner , t && t . constructor === B && ( t . _owner = this . _item ) ) , this . _values [ a ] = t , this . _item && this . _item . _changed ( u || 17 ) ) } } , s [ c ] = function ( ) { var n , i = this . _item && this . _item . _children ; if ( ! i || 0 === i . length || arguments [ 0 ] || "compound-path" === this . _item . _type ) { var n = this . _values [ a ] ; return n === t ? ( n = this . _defaults [ a ] , n && n . clone && ( n = n . clone ( ) ) , this . _values [ a ] = n ) : ! o || n && n . constructor === B || ( this . _values [ a ] = n = B . read ( [ n ] , 0 , 0 , { readNull : ! 0 , clone : ! 0 } ) , n && ( n . _owner = this . _item ) ) , n } for ( var r = 0 , s = i . length ; s > r ; r ++ ) { var h = i [ r ] . _style [ c ] ( ) ; if ( 0 === r ) n = h ; else if ( ! e . equals ( n , h ) ) return t } return n } , 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 E && ( this . _defaults = this . _textDefaults ) , t && this . set ( t ) } , set : function ( t ) { var e = t instanceof F , n = e ? t . _values : t ; if ( n ) for ( var i in n ) if ( i in this . _defaults ) { var r = n [ i ] ; this [ i ] = 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 } , getLeading : function be ( ) { var t = be . base . call ( this ) ; return null != t ? t : 1.2 * this . getFontSize ( ) } , getFontStyle : function ( ) { var t = this . getFontSize ( ) ; return t + ( /[a-z]/i . test ( t + "" ) ? " " : "px " ) + this . getFont ( ) } } ) , q = new function ( ) { function n ( t , i ) { for ( var r = [ ] , s = 0 , a = t && t . length ; a > s ; ) { var o = t [ s ++ ] ; if ( "string" == typeof o ) o = document . createElement ( o ) ; else if ( ! o || ! o . nodeType ) continue ; e . isPlainObject ( t [ s ] ) && q . set ( o , t [ s ++ ] ) , Array . isArray ( t [ s ] ) && n ( t [ s ++ ] , o ) , i && i . appendChild ( o ) , r . push ( o ) } return r } var i = /^(checked|value|selected|disabled)$/i , r = { text : "textContent" , html : "innerHTML" } , s = { lineHeight : 1 , zoom : 1 , zIndex : 1 , opaci
} } ) , v . 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 ] ) ) ; return x ( r , t ) } } ) } , new function ( ) { function n ( t , e , n , i ) { var r = ee [ e ] , s = r ? t . getAttributeNS ( r , e ) : t . getAttribute ( e ) ; return "null" === s && ( s = null ) , null == s ? i ? null : n ? "" : 0 : n ? s : parseFloat ( s ) } function i ( t , e , i , r ) { return e = n ( t , e , ! 1 , r ) , i = n ( t , i , ! 1 , r ) , r && null == e && null == i ? null : new h ( e || 0 , i || 0 ) } function r ( t , e , i , r ) { return e = n ( t , e , ! 1 , r ) , i = n ( t , i , ! 1 , r ) , r && null == e && null == i ? null : new c ( e || 0 , i || 0 ) } function s ( t , e , n ) { return "none" === t ? null : "number" === e ? parseFloat ( t ) : "array" === e ? t ? t . split ( /[\s,]+/g ) . map ( parseFloat ) : [ ] : "color" === e ? S ( t ) || t : "lookup" === e ? n [ t ] : t } function a ( t , e , n ) { var i = t . childNodes , r = "clippath" === e , s = new w , a = s . _project , o = a . _currentStyle , h = [ ] ; r || ( s . _transformContent = ! 1 , s = x ( s , t ) , a . _currentStyle = s . _style . clone ( ) ) ; for ( var u = 0 , l = i . length ; l > u ; u ++ ) { var c , d = i [ u ] ; 1 !== d . nodeType || ! ( c = P ( d , n ) ) || c instanceof m || h . push ( c ) } return s . addChildren ( h ) , r && ( s = x ( s . reduce ( ) , t ) ) , a . _currentStyle = o , ( r || "defs" === e ) && ( s . remove ( ) , s = null ) , s } function o ( t , e ) { var n = new O , i = t . points ; n . moveTo ( i . getItem ( 0 ) ) ; for ( var r = 1 , s = i . numberOfItems ; s > r ; r ++ ) n . lineTo ( i . getItem ( r ) ) ; return "polygon" === e && n . closePath ( ) , n } function u ( t ) { var e = t . getAttribute ( "d" ) , n = e . match ( /m/gi ) . length > 1 ? new L : new O ; return n . setPathData ( e ) , n } 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 R , h ) ) } var u , l , c , d = "radialgradient" === e , f = new N ( s , d ) ; return d ? ( u = i ( t , "cx" , "cy" ) , l = u . add ( n ( t , "r" ) , 0 ) , c = i ( t , "fx" , "fy" , ! 0 ) ) : ( u = i ( t , "x1" , "y1" ) , l = i ( t , "x2" , "y2" ) ) , x ( new B ( f , u , l , c ) , t ) , null } function d ( t , e , n , i ) { for ( var r = ( i . getAttribute ( n ) || "" ) . 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 , f = c . length ; f > 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 ) , _ = "skewX" == l ; s . shear ( _ ? e : 0 , _ ? 0 : e ) } } t . transform ( s ) } function _ ( t , e , n ) { var i = t [ "fill-opacity" === n ? "getFillColor" : "getStrokeColor" ] ( ) ; i && i . setAlpha ( parseFloat ( e ) ) } function p ( n , i , r ) { var s = n . attributes [ i ] , a = s && s . value ; if ( ! a ) { var o = e . camelize ( i ) ; a = n . style [ o ] , a || r . node [ o ] === r . parent [ o ] || ( a = r . node [ o ] ) } return a ? "none" === a ? null : a : t } function x ( n , i ) { var r = { node : q . getStyles ( i ) || { } , parent : q . getStyles ( i . parentNode ) || { } } ; return e . each ( z , function ( s , a ) { var o = p ( i , a , r ) ; o !== t && ( n = e . pick ( s ( n , o , a , i , r ) , n ) ) } ) , n } function S ( t ) { var e = t && t . match ( /\((?:#|)([^)']+)/ ) ; return e && M [ e [ 1 ] ] } function P ( t , e , n ) { e || ( e = { } ) , "string" == typeof t && ( t = ( new DOMParser ) . parseFromString ( t , "image/svg+xml" ) ) ; var i = t . nodeName . toLowerCase ( ) , r = k [ i ] , s = r && r ( t , i , e ) , a = "#document" !== i && t . getAttribute ( "data-paper-data" ) ; return e . expandShapes && s instanceof b && ( s . remove ( ) , s = s . toPath ( ) ) , ! s || s instanceof w || ( s = x ( s , t ) ) , s && a && ( s . _data = JSON . parse ( a ) ) , n && ( M = { } ) , s } var k = { "#document" : function ( t , e , n ) { return P ( t . childNodes [ 0 ] , n ) } , g : a , svg : a , clippath : a , polygon : o , polyline : o , path : u , lineargradient : l , radialgradient : l , image : function ( t ) { var e = new C ( n ( t , "href" , ! 0 ) ) ; return e . attach ( "load" , function ( ) { var e = r ( t , "width" , "height" ) ; this . setSize ( e ) , this . translate ( i ( t , "x" , "y" ) . add ( e . divide ( 2 ) ) ) } ) , e } , symbol : function ( t , e ) { return new m ( a ( t , e ) , ! 0 ) } , defs : a , use : function ( t ) { var e = ( n ( t , "href" , ! 0 ) || "" ) . substring ( 1 ) , r = M [ e ] , s = i ( t , "x" , "y" ) ; return r ? r instanceof m ? r . place ( s ) : r . clone ( ) . translate ( s ) : null } , circle : function ( t ) { return new b . Circle ( i ( t , "cx" , "cy" ) , n ( t , "r" ) ) } , ellipse : function ( t ) { return new b . Ellipse ( { center : i ( t , "cx" , "cy" ) , radius : r ( t , "rx" , "ry" ) } ) } , rect : function ( t ) { var e = i ( t , "x" , "y" ) , n = r ( t , "width" , "height" ) , s = r ( t , "rx" , "ry" ) ; return new b . Rectangle ( new f ( e , n ) , s ) } , line : function ( t ) { return new O . Line ( i ( t , "x1" , "y1" ) , i ( t , "x2" , "y2" ) ) } , text : function ( t ) { var e = new j ( i ( t , "x" , "y" ) . add ( i ( t , "dx" , "dy" ) ) ) ; return e . setContent ( t . textContent . trim ( ) || "" ) , e } } , z = e . merge ( e
} , Qn = t . isIdentifierChar = function ( t ) { return 48 > t ? 36 === t : 58 > t ? ! 0 : 65 > t ? ! 1 : 91 > t ? ! 0 : 97 > t ? 95 === t : 123 > t ? ! 0 : t >= 170 && Jn . test ( String . fromCharCode ( t ) ) } , ti = { kind : "loop" } , ei = { kind : "switch" } } ) ; var binaryOperators = { "+" : "_add" , "-" : "_subtract" , "*" : "_multiply" , "/" : "_divide" , "%" : "_modulo" , "==" : "equals" , "!=" : "equals" } , unaryOperators = { "-" : "_negate" , "+" : null } , fields = Base . each ( "add,subtract,multiply,divide,modulo,negate" . split ( "," ) , function ( t ) { this [ "_" + t ] = "#" + t } , { } ) ; return paper . Point . inject ( fields ) , paper . Size . inject ( fields ) , paper . Color . inject ( fields ) , "complete" === document . readyState ? setTimeout ( load ) : paper . DomEvent . add ( window , { load : load } ) , { compile : compile , evaluate : evaluate , load : load } } ( this ) ;