2014-03-28 13:02:58 +08:00
/*! KineticJS v5.1.0 2014-03-27 http://www.kineticjs.com by Eric Rowell @ericdrowell - MIT License https://github.com/ericdrowell/KineticJS/wiki/License*/
2014-03-28 14:34:06 +08:00
var Kinetic = { } ; ! function ( a ) { var b = Math . PI / 180 ; Kinetic = { version : "5.1.0" , stages : [ ] , idCounter : 0 , ids : { } , names : { } , shapes : { } , listenClickTap : ! 1 , inDblClickWindow : ! 1 , enableTrace : ! 1 , traceArrMax : 100 , dblClickWindow : 400 , pixelRatio : void 0 , dragDistance : 0 , angleDeg : ! 0 , UA : function ( ) { var b = a . navigator && a . navigator . userAgent || "" , c = b . toLowerCase ( ) , d = /(chrome)[ \/]([\w.]+)/ . exec ( c ) || /(webkit)[ \/]([\w.]+)/ . exec ( c ) || /(opera)(?:.*version|)[ \/]([\w.]+)/ . exec ( c ) || /(msie) ([\w.]+)/ . exec ( c ) || c . indexOf ( "compatible" ) < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/ . exec ( c ) || [ ] , e = ! ! b . match ( /Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i ) ; return { browser : d [ 1 ] || "" , version : d [ 2 ] || "0" , mobile : e } } ( ) , Filters : { } , Node : function ( a ) { this . _init ( a ) } , Shape : function ( a ) { this . _ _init ( a ) } , Container : function ( a ) { this . _ _init ( a ) } , Stage : function ( a ) { this . _ _ _init ( a ) } , BaseLayer : function ( a ) { this . _ _ _init ( a ) } , Layer : function ( a ) { this . _ _ _ _init ( a ) } , FastLayer : function ( a ) { this . _ _ _ _init ( a ) } , Group : function ( a ) { this . _ _ _init ( a ) } , isDragging : function ( ) { var a = Kinetic . DD ; return a ? a . isDragging : ! 1 } , isDragReady : function ( ) { var a = Kinetic . DD ; return a ? ! ! a . node : ! 1 } , _addId : function ( a , b ) { void 0 !== b && ( this . ids [ b ] = a ) } , _removeId : function ( a ) { void 0 !== a && delete this . ids [ a ] } , _addName : function ( a , b ) { void 0 !== b && ( void 0 === this . names [ b ] && ( this . names [ b ] = [ ] ) , this . names [ b ] . push ( a ) ) } , _removeName : function ( a , b ) { if ( void 0 !== a ) { var c = this . names [ a ] ; if ( void 0 !== c ) { for ( var d = 0 ; d < c . length ; d ++ ) { var e = c [ d ] ; e . _id === b && c . splice ( d , 1 ) } 0 === c . length && delete this . names [ a ] } } } , getAngle : function ( a ) { return this . angleDeg ? a * b : a } } } ( this ) , function ( a , b ) { if ( "object" == typeof exports ) { var c = require ( "canvas" ) , d = require ( "jsdom" ) . jsdom , e = d ( "<!DOCTYPE html><html><head></head><body></body></html>" ) , f = b ( ) ; return Kinetic . document = e , Kinetic . window = Kinetic . document . createWindow ( ) , Kinetic . window . Image = c . Image , Kinetic . root = a , Kinetic . _nodeCanvas = c , void ( module . exports = f ) } "function" == typeof define && define . amd && define ( b ) , Kinetic . document = document , Kinetic . window = window , Kinetic . root = a } ( ( 1 , eval ) ( "this" ) , function ( ) { return Kinetic } ) , function ( ) { Kinetic . Collection = function ( ) { var a = [ ] . slice . call ( arguments ) , b = a . length , c = 0 ; for ( this . length = b ; b > c ; c ++ ) this [ c ] = a [ c ] ; return this } , Kinetic . Collection . prototype = [ ] , Kinetic . Collection . prototype . each = function ( a ) { for ( var b = 0 ; b < this . length ; b ++ ) a ( this [ b ] , b ) } , Kinetic . Collection . prototype . toArray = function ( ) { var a , b = [ ] , c = this . length ; for ( a = 0 ; c > a ; a ++ ) b . push ( this [ a ] ) ; return b } , Kinetic . Collection . toCollection = function ( a ) { var b , c = new Kinetic . Collection , d = a . length ; for ( b = 0 ; d > b ; b ++ ) c . push ( a [ b ] ) ; return c } , Kinetic . Collection . _mapMethod = function ( a ) { Kinetic . Collection . prototype [ a ] = function ( ) { var b , c = this . length , d = [ ] . slice . call ( arguments ) ; for ( b = 0 ; c > b ; b ++ ) this [ b ] [ a ] . apply ( this [ b ] , d ) ; return this } } , Kinetic . Collection . mapMethods = function ( a ) { var b = a . prototype ; for ( var c in b ) Kinetic . Collection . _mapMethod ( c ) } , Kinetic . Transform = function ( a ) { this . m = a && a . slice ( ) || [ 1 , 0 , 0 , 1 , 0 , 0 ] } , Kinetic . Transform . prototype = { copy : function ( ) { return new Kinetic . Transform ( this . m ) } , point : function ( a ) { var b = this . m ; return { x : b [ 0 ] * a . x + b [ 2 ] * a . y + b [ 4 ] , y : b [ 1 ] * a . x + b [ 3 ] * a . y + b [ 5 ] } } , translate : function ( a , b ) { return this . m [ 4 ] += this . m [ 0 ] * a + this . m [ 2 ] * b , this . m [ 5 ] += this . m [ 1 ] * a + this . m [ 3 ] * b , this } , scale : function ( a , b ) { return this . m [ 0 ] *= a , this . m [ 1 ] *= a , this . m [ 2 ] *= b , this . m [ 3 ] *= b , this } , rotate : function ( a ) { var b = Math . cos ( a ) , c = Math . sin ( a ) , d = this . m [ 0 ] * b + this . m [ 2 ] * c , e = this . m [ 1 ] * b + this . m [ 3 ] * c , f = this . m [ 0 ] * - c + this . m [ 2 ] * b , g = this . m [ 1 ] * - c + this . m [ 3 ] * b ; return this . m [ 0 ] = d , this . m [ 1 ] = e , this . m [ 2 ] = f , this . m [ 3 ] = g , this } , getTranslation : function ( ) { return { x : this . m [ 4 ] , y : this . m [ 5 ] } } , skew : function ( a , b ) { var c = this . m [ 0 ] + this . m [ 2 ] * b , d = this . m [ 1 ] + this . m [ 3 ] * b , e = this . m [ 2 ] + this . m [ 0 ] * a , f = this . m [ 3 ] + this . m [ 1 ] * a ; return this . m [ 0 ] = c , this . m [ 1 ] = d , this . m [ 2 ] = e , this . m [ 3 ] = f , this } , multiply : function ( a ) { var b = this . m [ 0 ] * a . m [ 0 ] + this . m [ 2 ] * a . m [ 1 ] , c = this . m [ 1 ] * a . m [ 0 ] + this . m [ 3 ] * a . m [ 1 ] , d = this . m [ 0 ] * a . m [ 2 ] + this . m [ 2 ] * a . m [ 3 ] , e = this . m [ 1 ] * a . m [ 2 ] + this . m [ 3 ] * a . m [ 3 ] , f = this . m [ 0 ] * a . m [ 4 ] + this . m [ 2 ] * a . m [ 5 ] + this . m [ 4 ] , g = this . m [ 1 ] * a . m [ 4 ] + this . m [ 3 ] * a . m [ 5 ] + this . m [ 5 ] ; return this . m [ 0 ] = b , this . m [ 1 ] = c , this . m [ 2 ] = d , this . m [ 3 ] = e , this . m [ 4 ] = f , this . m [ 5 ] = g , this } , invert : function ( ) { var a = 1 / ( this . m [ 0 ] * this . m [
} , setName : function ( a ) { var b = this . getName ( ) ; return Kinetic . _removeName ( b , this . _id ) , Kinetic . _addName ( this , a ) , this . _setAttr ( m , a ) , this } , setAttr : function ( ) { var a = Array . prototype . slice . call ( arguments ) , b = a [ 0 ] , c = a [ 1 ] , d = n + Kinetic . Util . _capitalize ( b ) , e = this [ d ] ; return Kinetic . Util . _isFunction ( e ) ? e . call ( this , c ) : this . _setAttr ( b , c ) , this } , _setAttr : function ( a , b ) { var c ; void 0 !== b && ( c = this . attrs [ a ] , this . attrs [ a ] = b , this . _fireChangeEvent ( a , c , b ) ) } , _setComponentAttr : function ( a , b , c ) { var d ; void 0 !== c && ( d = this . attrs [ a ] , d || ( this . attrs [ a ] = this . getAttr ( a ) ) , this . attrs [ a ] [ b ] = c , this . _fireChangeEvent ( a , d , c ) ) } , _fireAndBubble : function ( a , b , c ) { var d = ! 0 ; b && this . nodeType === o && ( b . target = this ) , a === k && c && this . _id === c . _id ? d = ! 1 : a === l && c && this . _id === c . _id && ( d = ! 1 ) , d && ( this . _fire ( a , b ) , b && ! b . cancelBubble && this . parent && ( c && c . parent ? this . _fireAndBubble . call ( this . parent , a , b , c . parent ) : this . _fireAndBubble . call ( this . parent , a , b ) ) ) } , _fire : function ( a , b ) { var c , d = this . eventListeners [ a ] ; if ( b . type = a , d ) for ( c = 0 ; c < d . length ; c ++ ) d [ c ] . handler . call ( this , b ) } , draw : function ( ) { return this . drawScene ( ) , this . drawHit ( ) , this } } ) , Kinetic . Node . create = function ( a , b ) { return this . _createNode ( JSON . parse ( a ) , b ) } , Kinetic . Node . _createNode = function ( a , b ) { var c , d , e , f = Kinetic . Node . prototype . getClassName . call ( a ) , g = a . children ; if ( b && ( a . attrs . container = b ) , c = new Kinetic [ f ] ( a . attrs ) , g ) for ( d = g . length , e = 0 ; d > e ; e ++ ) c . add ( this . _createNode ( g [ e ] ) ) ; return c } , Kinetic . Factory . addOverloadedGetterSetter ( Kinetic . Node , "position" ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "x" , 0 ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "y" , 0 ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "opacity" , 1 ) , Kinetic . Factory . addGetter ( Kinetic . Node , "name" ) , Kinetic . Factory . addOverloadedGetterSetter ( Kinetic . Node , "name" ) , Kinetic . Factory . addGetter ( Kinetic . Node , "id" ) , Kinetic . Factory . addOverloadedGetterSetter ( Kinetic . Node , "id" ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "rotation" , 0 ) , Kinetic . Factory . addComponentsGetterSetter ( Kinetic . Node , "scale" , [ "x" , "y" ] ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "scaleX" , 1 ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "scaleY" , 1 ) , Kinetic . Factory . addComponentsGetterSetter ( Kinetic . Node , "skew" , [ "x" , "y" ] ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "skewX" , 0 ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "skewY" , 0 ) , Kinetic . Factory . addComponentsGetterSetter ( Kinetic . Node , "offset" , [ "x" , "y" ] ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "offsetX" , 0 ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "offsetY" , 0 ) , Kinetic . Factory . addSetter ( Kinetic . Node , "dragDistance" ) , Kinetic . Factory . addOverloadedGetterSetter ( Kinetic . Node , "dragDistance" ) , Kinetic . Factory . addSetter ( Kinetic . Node , "width" , 0 ) , Kinetic . Factory . addOverloadedGetterSetter ( Kinetic . Node , "width" ) , Kinetic . Factory . addSetter ( Kinetic . Node , "height" , 0 ) , Kinetic . Factory . addOverloadedGetterSetter ( Kinetic . Node , "height" ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "listening" , "inherit" ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "filters" , void 0 , function ( a ) { return this . _filterUpToDate = ! 1 , a } ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "visible" , "inherit" ) , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "transformsEnabled" , "all" ) , Kinetic . Factory . addOverloadedGetterSetter ( Kinetic . Node , "size" ) , Kinetic . Factory . backCompat ( Kinetic . Node , { rotateDeg : "rotate" , setRotationDeg : "setRotation" , getRotationDeg : "getRotation" } ) , Kinetic . Collection . mapMethods ( Kinetic . Node ) } ( ) , function ( ) { Kinetic . Filters . Grayscale = function ( a ) { var b , c , d = a . data , e = d . length ; for ( b = 0 ; e > b ; b += 4 ) c = . 34 * d [ b ] + . 5 * d [ b + 1 ] + . 16 * d [ b + 2 ] , d [ b ] = c , d [ b + 1 ] = c , d [ b + 2 ] = c } } ( ) , function ( ) { Kinetic . Filters . Brighten = function ( a ) { var b , c = 255 * this . brightness ( ) , d = a . data , e = d . length ; for ( b = 0 ; e > b ; b += 4 ) d [ b ] += c , d [ b + 1 ] += c , d [ b + 2 ] += c } , Kinetic . Factory . addGetterSetter ( Kinetic . Node , "brightness" , 0 , null , Kinetic . Factory . afterSetFilter ) } ( ) , function ( ) { Kinetic . Filters . Invert = function ( a ) { var b , c = a . data , d = c . length ; for ( b = 0 ; d > b ; b += 4 ) c [ b ] = 255 - c [ b ] , c [ b + 1 ] = 255 - c [ b + 1 ] , c [ b + 2 ] = 255 - c [ b + 2 ] } } ( ) , function ( ) { function a ( ) { this . r = 0 , this . g = 0 , this . b = 0 , this . a = 0 , this . next = null } function b ( b , e ) { var f , g , h , i , j , k , l , m , n , o , p , q , r , s , t , u , v , w , x , y , z , A , B , C , D = b . data , E = b . width , F = b . height , G = e + e + 1 , H = E - 1 , I = F - 1 , J = e + 1 , K = J * ( J + 1
} , drawHit : function ( a , b ) { var c = this . getLayer ( ) , d = a || c && c . hitCanvas , e = d && d . getContext ( ) , f = this . _cache . canvas , g = f && f . hit ; return this . shouldDrawHit ( ) && ( g ? this . _drawCachedHitCanvas ( e ) : this . _drawChildren ( d , "drawHit" , b ) ) , this } , _drawChildren : function ( a , b , c ) { var d , e , f = this . getLayer ( ) , g = a && a . getContext ( ) , h = this . getClipWidth ( ) , i = this . getClipHeight ( ) , j = h && i ; j && f && ( d = this . getClipX ( ) , e = this . getClipY ( ) , g . save ( ) , f . _applyTransform ( this , g ) , g . beginPath ( ) , g . rect ( d , e , h , i ) , g . clip ( ) , g . reset ( ) ) , this . children . each ( function ( d ) { d [ b ] ( a , c ) } ) , j && g . restore ( ) } } ) , Kinetic . Util . extend ( Kinetic . Container , Kinetic . Node ) , Kinetic . Container . prototype . get = Kinetic . Container . prototype . find , Kinetic . Factory . addComponentsGetterSetter ( Kinetic . Container , "clip" , [ "x" , "y" , "width" , "height" ] ) , Kinetic . Factory . addGetterSetter ( Kinetic . Container , "clipX" ) , Kinetic . Factory . addGetterSetter ( Kinetic . Container , "clipY" ) , Kinetic . Factory . addGetterSetter ( Kinetic . Container , "clipWidth" ) , Kinetic . Factory . addGetterSetter ( Kinetic . Container , "clipHeight" ) , Kinetic . Collection . mapMethods ( Kinetic . Container ) } ( ) , function ( ) { function a ( a ) { a . fill ( ) } function b ( a ) { a . stroke ( ) } function c ( a ) { a . fill ( ) } function d ( a ) { a . stroke ( ) } function e ( ) { this . _clearCache ( f ) } var f = "hasShadow" ; Kinetic . Util . addMethods ( Kinetic . Shape , { _ _init : function ( f ) { this . nodeType = "Shape" , this . _fillFunc = a , this . _strokeFunc = b , this . _fillFuncHit = c , this . _strokeFuncHit = d ; for ( var g , h = Kinetic . shapes ; ; ) if ( g = Kinetic . Util . getRandomColor ( ) , g && ! ( g in h ) ) break ; this . colorKey = g , h [ g ] = this , Kinetic . Node . call ( this , f ) , this . on ( "shadowColorChange.kinetic shadowBlurChange.kinetic shadowOffsetChange.kinetic shadowOpacityChange.kinetic shadowEnabledChange.kinetic" , e ) } , hasChildren : function ( ) { return ! 1 } , getChildren : function ( ) { return [ ] } , getContext : function ( ) { return this . getLayer ( ) . getContext ( ) } , getCanvas : function ( ) { return this . getLayer ( ) . getCanvas ( ) } , hasShadow : function ( ) { return this . _getCache ( f , this . _hasShadow ) } , _hasShadow : function ( ) { return this . getShadowEnabled ( ) && 0 !== this . getShadowOpacity ( ) && ! ! ( this . getShadowColor ( ) || this . getShadowBlur ( ) || this . getShadowOffsetX ( ) || this . getShadowOffsetY ( ) ) } , hasFill : function ( ) { return ! ! ( this . getFill ( ) || this . getFillPatternImage ( ) || this . getFillLinearGradientColorStops ( ) || this . getFillRadialGradientColorStops ( ) ) } , hasStroke : function ( ) { return ! ! ( this . stroke ( ) || this . strokeRed ( ) || this . strokeGreen ( ) || this . strokeBlue ( ) ) } , _get : function ( a ) { return this . className === a || this . nodeType === a ? [ this ] : [ ] } , intersects : function ( a ) { var b , c = this . getStage ( ) , d = c . bufferHitCanvas ; return d . getContext ( ) . clear ( ) , this . drawScene ( d ) , b = d . context . getImageData ( Math . round ( a . x ) , Math . round ( a . y ) , 1 , 1 ) . data , b [ 3 ] > 0 } , destroy : function ( ) { Kinetic . Node . prototype . destroy . call ( this ) , delete Kinetic . shapes [ this . colorKey ] } , _useBufferCanvas : function ( ) { return ( this . hasShadow ( ) || 1 !== this . getAbsoluteOpacity ( ) ) && this . hasFill ( ) && this . hasStroke ( ) && this . getStage ( ) } , drawScene : function ( a , b ) { var c , d , e , f = this . getLayer ( ) , g = a || f . getCanvas ( ) , h = g . getContext ( ) , i = this . _cache . canvas , j = this . sceneFunc ( ) , k = this . hasShadow ( ) ; return this . isVisible ( ) && ( i ? this . _drawCachedSceneCanvas ( h ) : j && ( h . save ( ) , this . _useBufferCanvas ( ) ? ( c = this . getStage ( ) , d = c . bufferCanvas , e = d . getContext ( ) , e . clear ( ) , e . save ( ) , e . _applyLineJoin ( this ) , f . _applyTransform ( this , e , b ) , j . call ( this , e ) , e . restore ( ) , k && ( h . save ( ) , h . _applyShadow ( this ) , h . drawImage ( d . _canvas , 0 , 0 ) , h . restore ( ) ) , h . _applyOpacity ( this ) , h . drawImage ( d . _canvas , 0 , 0 ) ) : ( h . _applyLineJoin ( this ) , f . _applyTransform ( this , h , b ) , k && ( h . save ( ) , h . _applyShadow ( this ) , j . call ( this , h ) , h . restore ( ) ) , h . _applyOpacity ( this ) , j . call ( this , h ) ) , h . restore ( ) ) ) , this } , drawHit : function ( a , b ) { var c = this . getLayer ( ) , d = a || c . hitCanvas , e = d . getContext ( ) , f = this . hitFunc ( ) || this . sceneFunc ( ) , g = this . _cache . canvas , h = g && g . hit ; return this . shouldDrawHit ( ) && ( h ? this . _drawCachedHitCanvas ( e ) : f && ( e . save ( ) , e . _applyLineJoin ( this ) , c . _applyTransform ( this , e , b ) , f . call ( this , e ) , e . restore ( ) ) ) , this } , drawHitFromCache : function ( a ) { var b , c , d , e , f , g , h , i , j = a || 0 , k = this . _cache . canvas , l = this . _getCachedSceneCanvas ( ) , m = l . getContext ( ) , n = k . hit , o = n . getContext ( ) , p = l . getWidth ( ) , q = l . getHeight ( ) ; o . clear ( ) ; try { for ( b = m . getImageData ( 0 , 0 , p , q ) , c = b . data , d = o . getImageData ( 0 , 0 , p , q ) , e = d . data , f = c . le
for ( var u = 0 , w = a . length ; w > u ; ++ u ) { var x = a [ u ] , y = this . _getTextWidth ( x ) ; if ( i && y > l ) for ( ; x . length > 0 ; ) { for ( var z = 0 , A = x . length , B = "" , C = 0 ; A > z ; ) { var D = z + A >>> 1 , E = x . slice ( 0 , D + 1 ) , F = this . _getTextWidth ( E ) ; l >= F ? ( z = D + 1 , B = E , C = F ) : A = D } if ( ! B ) break ; if ( t ) { var G = Math . max ( B . lastIndexOf ( o ) , B . lastIndexOf ( g ) ) + 1 ; G > 0 && ( z = G , B = B . slice ( 0 , z ) , C = this . _getTextWidth ( B ) ) } if ( this . _addTextLine ( B , C ) , d = Math . max ( d , C ) , n += e , ! q || j && n + e > m ) break ; if ( x = x . slice ( z ) , x . length > 0 && ( y = this . _getTextWidth ( x ) , l >= y ) ) { this . _addTextLine ( x , y ) , n += e , d = Math . max ( d , y ) ; break } } else this . _addTextLine ( x , y ) , n += e , d = Math . max ( d , y ) ; if ( j && n + e > m ) break } v . restore ( ) , this . textHeight = b , this . textWidth = d } } , Kinetic . Util . extend ( Kinetic . Text , Kinetic . Shape ) , Kinetic . Factory . addGetterSetter ( Kinetic . Text , "fontFamily" , "Arial" ) , Kinetic . Factory . addGetterSetter ( Kinetic . Text , "fontSize" , 12 ) , Kinetic . Factory . addGetterSetter ( Kinetic . Text , "fontStyle" , m ) , Kinetic . Factory . addGetterSetter ( Kinetic . Text , "fontVariant" , m ) , Kinetic . Factory . addGetterSetter ( Kinetic . Text , "padding" , 0 ) , Kinetic . Factory . addGetterSetter ( Kinetic . Text , "align" , i ) , Kinetic . Factory . addGetterSetter ( Kinetic . Text , "lineHeight" , 1 ) , Kinetic . Factory . addGetterSetter ( Kinetic . Text , "wrap" , q ) , Kinetic . Factory . addGetter ( Kinetic . Text , "text" , h ) , Kinetic . Factory . addOverloadedGetterSetter ( Kinetic . Text , "text" ) , Kinetic . Collection . mapMethods ( Kinetic . Text ) } ( ) , function ( ) { Kinetic . Line = function ( a ) { this . _ _ _init ( a ) } , Kinetic . Line . prototype = { _ _ _init : function ( a ) { Kinetic . Shape . call ( this , a ) , this . className = "Line" , this . on ( "pointsChange.kinetic tensionChange.kinetic closedChange.kinetic" , function ( ) { this . _clearCache ( "tensionPoints" ) } ) , this . sceneFunc ( this . _sceneFunc ) } , _sceneFunc : function ( a ) { var b , c , d , e = this . getPoints ( ) , f = e . length , g = this . getTension ( ) , h = this . getClosed ( ) ; if ( a . beginPath ( ) , a . moveTo ( e [ 0 ] , e [ 1 ] ) , 0 !== g && f > 4 ) { for ( b = this . getTensionPoints ( ) , c = b . length , d = h ? 0 : 4 , h || a . quadraticCurveTo ( b [ 0 ] , b [ 1 ] , b [ 2 ] , b [ 3 ] ) ; c - 2 > d ; ) a . bezierCurveTo ( b [ d ++ ] , b [ d ++ ] , b [ d ++ ] , b [ d ++ ] , b [ d ++ ] , b [ d ++ ] ) ; h || a . quadraticCurveTo ( b [ c - 2 ] , b [ c - 1 ] , e [ f - 2 ] , e [ f - 1 ] ) } else for ( d = 2 ; f > d ; d += 2 ) a . lineTo ( e [ d ] , e [ d + 1 ] ) ; h ? ( a . closePath ( ) , a . fillStrokeShape ( this ) ) : a . strokeShape ( this ) } , getTensionPoints : function ( ) { return this . _getCache ( "tensionPoints" , this . _getTensionPoints ) } , _getTensionPoints : function ( ) { return this . getClosed ( ) ? this . _getTensionPointsClosed ( ) : Kinetic . Util . _expandPoints ( this . getPoints ( ) , this . getTension ( ) ) } , _getTensionPointsClosed : function ( ) { var a = this . getPoints ( ) , b = a . length , c = this . getTension ( ) , d = Kinetic . Util , e = d . _getControlPoints ( a [ b - 2 ] , a [ b - 1 ] , a [ 0 ] , a [ 1 ] , a [ 2 ] , a [ 3 ] , c ) , f = d . _getControlPoints ( a [ b - 4 ] , a [ b - 3 ] , a [ b - 2 ] , a [ b - 1 ] , a [ 0 ] , a [ 1 ] , c ) , g = Kinetic . Util . _expandPoints ( a , c ) , h = [ e [ 2 ] , e [ 3 ] ] . concat ( g ) . concat ( [ f [ 0 ] , f [ 1 ] , a [ b - 2 ] , a [ b - 1 ] , f [ 2 ] , f [ 3 ] , e [ 0 ] , e [ 1 ] , a [ 0 ] , a [ 1 ] ] ) ; return h } } , Kinetic . Util . extend ( Kinetic . Line , Kinetic . Shape ) , Kinetic . Factory . addGetterSetter ( Kinetic . Line , "closed" , ! 1 ) , Kinetic . Factory . addGetterSetter ( Kinetic . Line , "tension" , 0 ) , Kinetic . Factory . addGetterSetter ( Kinetic . Line , "points" ) , Kinetic . Collection . mapMethods ( Kinetic . Line ) } ( ) , function ( ) { Kinetic . Sprite = function ( a ) { this . _ _ _init ( a ) } , Kinetic . Sprite . prototype = { _ _ _init : function ( a ) { Kinetic . Shape . call ( this , a ) , this . className = "Sprite" , this . anim = new Kinetic . Animation , this . on ( "animationChange.kinetic" , function ( ) { this . frameIndex ( 0 ) } ) , this . on ( "frameRateChange.kinetic" , function ( ) { this . anim . isRunning ( ) && ( clearInterval ( this . interval ) , this . _setInterval ( ) ) } ) , this . sceneFunc ( this . _sceneFunc ) , this . hitFunc ( this . _hitFunc ) } , _sceneFunc : function ( a ) { var b = this . getAnimation ( ) , c = this . frameIndex ( ) , d = 4 * c , e = this . getAnimations ( ) [ b ] , f = e [ d + 0 ] , g = e [ d + 1 ] , h = e [ d + 2 ] , i = e [ d + 3 ] , j = this . getImage ( ) ; j && a . drawImage ( j , f , g , h , i , 0 , 0 , h , i ) } , _hitFunc : function ( a ) { var b = this . getAnimation ( ) , c = this . frameIndex ( ) , d = 4 * c , e = this . getAnimations ( ) [ b ] , f = e [ d + 2 ] , g = e [ d + 3 ] ; a . beginPath ( ) , a . rect ( 0 , 0 , f , g ) , a . closePath ( ) , a . fillShape ( this ) } , _useBufferCanvas : function ( ) { return ( this . hasShadow ( ) || 1 !== this . getAbsoluteOpacity ( ) ) && this . hasStroke ( ) } , _setInterval : function ( ) { var a = this ; this . interval = setInterval ( function ( ) { a . _updateIndex ( ) } , 1e3 / this . getFrameRate ( ) ) } , start : function ( ) { var a = this . getLayer ( ) ; this . anim . setLayers ( a ) , this . _setInterval ( ) , this . anim . start ( ) } , stop : function ( ) { this . anim . stop