Files
konva/konva.min.js

46 lines
128 KiB
JavaScript
Raw Normal View History

2015-04-07 15:03:08 +07:00
/*
* Konva JavaScript Framework v0.9.5
* http://konvajs.github.io/
* Licensed under the MIT or GPL Version 2 licenses.
* Date: Tue Apr 07 2015
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva)
*
* @license
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
var Konva={};!function(t){var e=Math.PI/180;Konva={version:"0.9.5",stages:[],idCounter:0,ids:{},names:{},shapes:{},listenClickTap:!1,inDblClickWindow:!1,enableTrace:!1,traceArrMax:100,dblClickWindow:400,pixelRatio:void 0,dragDistance:0,angleDeg:!0,showWarnings:!0,Filters:{},Node:function(t){this._init(t)},Shape:function(t){this.__init(t)},Container:function(t){this.__init(t)},Stage:function(t){this.___init(t)},BaseLayer:function(t){this.___init(t)},Layer:function(t){this.____init(t)},FastLayer:function(t){this.____init(t)},Group:function(t){this.___init(t)},isDragging:function(){var t=Konva.DD;return t?t.isDragging:!1},isDragReady:function(){var t=Konva.DD;return t?!!t.node:!1},_addId:function(t,e){void 0!==e&&(this.ids[e]=t)},_removeId:function(t){void 0!==t&&delete this.ids[t]},_addName:function(t,e){e&&(this.names[e]||(this.names[e]=[]),this.names[e].push(t))},_removeName:function(t,e){if(void 0!==t){var n=this.names[t];if(void 0!==n){for(var a=0;a<n.length;a++){var i=n[a];i._id===e&&n.splice(a,1)}0===n.length&&delete this.names[t]}}},getAngle:function(t){return this.angleDeg?t*e:t},_parseUA:function(t){var e=t.toLowerCase(),n=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[],a=!!t.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i),i=!!t.match(/IEMobile/i);return{browser:n[1]||"",version:n[2]||"0",mobile:a,ieMobile:i}},UA:void 0},Konva.UA=Konva._parseUA(t.navigator&&t.navigator.userAgent||"")}(this),function(t,e){if("object"==typeof exports){var n=e();if(global.window===global)Konva.document=global.document,Konva.window=global;else{var a=require("canvas"),i=require("jsdom").jsdom;Konva.document=i("<!DOCTYPE html><html><head></head><body></body></html>"),Konva.window=Konva.document.createWindow(),Konva.window.Image=a.Image,Konva._nodeCanvas=a}return Konva.root=t,void(module.exports=n)}"function"==typeof define&&define.amd&&define(e),Konva.document=document,Konva.window=window,Konva.root=t}(this,function(){return Konva}),function(){Konva.Collection=function(){var t=[].slice.call(arguments),e=t.length,n=0;for(this.length=e;e>n;n++)this[n]=t[n];return this},Konva.Collection.prototype=[],Konva.Collection.prototype.each=function(t){for(var e=0;e<this.length;e++)t(this[e],e)},Konva.Collection.prototype.toArray=function(){var t,e=[],n=this.length;for(t=0;n>t;t++)e.push(this[t]);return e},Konva.Collection.toCollection=function(t){var e,n=new Konva.Collection,a=t.length;for(e=0;a>e;e++)n.push(t[e]);return n},Konva.Collection._mapMethod=function(t){Konva.Collection.prototype[t]=function(){var e,n=this.length,a=[].slice.call(arguments);for(e=0;n>e;e++)this[e][t].apply(this[e],a);return this}},Konva.Collection.mapMethods=function(t){var e=t.prototype;for(var n in e)Konva.Collection._mapMethod(n)},Konva.Transform=function(t){this.m=t&&t.slice()||[1,0,0,1,0,0]},Konva.Transform.prototype={copy:function(){return new Konva.Transform(this.m)},point:function(t){var e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}},translate:function(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this},scale:function(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this},rotate:function(t){var e=Math.cos(t),n=Math.sin(t),a=this.m[0]*e+this.m[2]*n,i=this.m[1]*e+this.m[3]*n,o=this.m[0]*-n+this.m[2]*e,r=this.m[1]*-n+this.m[3]*e;return this.m[0]=a,this.m[1]=i,this.m[2]=o,this.m[3]=r,this},getTranslation:function(){return{x:this.m[4],y:this.m[5]}},skew:function(t,e){var n=this.m[0]+this.m[2]*e,a=this.m[1]+this.m[3]*e,i=this.m[2]+this.m[0]*t,o=this.m[3]+this.m[1]*t;return this.m[0]=n,this.m[1]=a,this.m[2]=i,this.m[3]=o,this},multiply:function(t){var e=this.m[0]*t.m[0]+this.m[2]*t.m[1],n=this.m[1]*t.m[0]+this.m[3]*t.m[1],a=this.m[0]*t.m[2]+this.m[2]*t.m[3],i=this.m[1]*t.m[2]+this.m[3]*t.m[3],o=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],r=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=n,this.m[2]=
var t=this.index;return this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0},moveUp:function(){if(!this.parent)return void Konva.Util.warn("Node has no parent. moveUp function is ignored.");var t=this.index,e=this.parent.getChildren().length;return e-1>t?(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0):!1},moveDown:function(){if(!this.parent)return void Konva.Util.warn("Node has no parent. moveDown function is ignored.");var t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0):!1},moveToBottom:function(){if(!this.parent)return void Konva.Util.warn("Node has no parent. moveToBottom function is ignored.");var t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1},setZIndex:function(t){if(!this.parent)return void Konva.Util.warn("Node has no parent. zIndex parameter is ignored.");var e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this},getAbsoluteOpacity:function(){return this._getCache(t,this._getAbsoluteOpacity)},_getAbsoluteOpacity:function(){var t=this.getOpacity();return this.getParent()&&(t*=this.getParent().getAbsoluteOpacity()),t},moveTo:function(t){return this.getParent()!==t&&(this.remove(),t.add(this)),this},toObject:function(){var t,e,n,a,i=Konva.Util,o={},r=this.getAttrs();o.attrs={};for(t in r)e=r[t],i._isFunction(e)||i._isElement(e)||i._isObject(e)&&i._hasMethods(e)||(n=this[t],delete r[t],a=n?n.call(this):null,r[t]=e,a!==e&&(o.attrs[t]=e));return o.className=this.getClassName(),o},toJSON:function(){return JSON.stringify(this.toObject())},getParent:function(){return this.parent},getLayer:function(){var t=this.getParent();return t?t.getLayer():null},getStage:function(){return this._getCache(p,this._getStage)},_getStage:function(){var t=this.getParent();return t?t.getStage():void 0},fire:function(t,e,n){return n?this._fireAndBubble(t,e||{}):this._fire(t,e||{}),this},getAbsoluteTransform:function(t){return t?this._getAbsoluteTransform(t):this._getCache(e,this._getAbsoluteTransform)},_getAbsoluteTransform:function(t){var e,n,a=new Konva.Transform;return this._eachAncestorReverse(function(t){e=t.transformsEnabled(),n=t.getTransform(),"all"===e?a.multiply(n):"position"===e&&a.translate(t.x(),t.y())},t),a},getTransform:function(){return this._getCache(K,this._getTransform)},_getTransform:function(){var t=new Konva.Transform,e=this.getX(),n=this.getY(),a=Konva.getAngle(this.getRotation()),i=this.getScaleX(),o=this.getScaleY(),r=this.getSkewX(),s=this.getSkewY(),h=this.getOffsetX(),c=this.getOffsetY();return(0!==e||0!==n)&&t.translate(e,n),0!==a&&t.rotate(a),(0!==r||0!==s)&&t.skew(r,s),(1!==i||1!==o)&&t.scale(i,o),(0!==h||0!==c)&&t.translate(-1*h,-1*c),t},clone:function(t){var e,n,a,i,o,r=this.getClassName(),s=Konva.Util.cloneObject(this.attrs);for(var c in y){var l=y[c];delete s[l]}for(e in t)s[e]=t[e];var d=new Konva[r](s);for(e in this.eventListeners)for(n=this.eventListeners[e],a=n.length,i=0;a>i;i++)o=n[i],o.name.indexOf(h)<0&&(d.eventListeners[e]||(d.eventListeners[e]=[]),d.eventListeners[e].push(o));return d},toDataURL:function(t){t=t||{};var e=t.mimeType||null,n=t.quality||null,a=this.getStage(),i=t.x||0,o=t.y||0,r=new Konva.SceneCanvas({width:t.width||this.getWidth()||(a?a.getWidth():0),height:t.height||this.getHeight()||(a?a.getHeight():0),pixelRatio:1}),s=r.getContext();return s.save(),(i||o)&&s.translate(-1*i,-1*o),this.drawScene(r),s.restore(),r.toDataURL(e,n)},toImage:function(t){Konva.Util._getImage(this.toDataURL(t),function(e){t.callback(e)})},setSize:function(t){return this.setWidth(t.width),this.setHeight(t.height),this},getSize:function(){return{width:this.getWidth(),height:this.getHeight()}},getTransformedSize:function(){},getWidth:function(){return this.attrs.width||0},getHeight:function(){return this.attrs.height||0},getClassName:function(){return
* Sepia Filter
* Based on: Pixastic Lib - Sepia filter - v0.1.0
* Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
* @function
* @name Sepia
* @memberof Konva.Filters
* @param {Object} imageData
* @author Jacob Seidelin <jseidelin@nihilogic.dk>
* @license MPL v1.1 [http://www.pixastic.com/lib/license.txt]
* @example
* node.cache();
* node.filters([Konva.Filters.Sepia]);
*/
Konva.Filters.Sepia=function(t){var e,n,a,i,o,r,s,h,c,l=t.data,d=t.width,v=t.height,u=4*d;do{e=(v-1)*u,n=d;do a=e+4*(n-1),i=l[a],o=l[a+1],r=l[a+2],s=.393*i+.769*o+.189*r,h=.349*i+.686*o+.168*r,c=.272*i+.534*o+.131*r,l[a]=s>255?255:s,l[a+1]=h>255?255:h,l[a+2]=c>255?255:c,l[a+3]=l[a+3];while(--n)}while(--v)}}(),function(){Konva.Filters.Solarize=function(t){var e=t.data,n=t.width,a=t.height,i=4*n,o=a;do{var r=(o-1)*i,s=n;do{var h=r+4*(s-1),c=e[h],l=e[h+1],d=e[h+2];c>127&&(c=255-c),l>127&&(l=255-l),d>127&&(d=255-d),e[h]=c,e[h+1]=l,e[h+2]=d}while(--s)}while(--o)}}(),function(){var t=function(t,e,n){var a,i,o,r,s=t.data,h=e.data,c=t.width,l=t.height,d=n.polarCenterX||c/2,v=n.polarCenterY||l/2,u=0,f=0,g=0,p=0,K=Math.sqrt(d*d+v*v);i=c-d,o=l-v,r=Math.sqrt(i*i+o*o),K=r>K?r:K;var m,_,y,S,C=l,x=c,w=360/x*Math.PI/180;for(_=0;x>_;_+=1)for(y=Math.sin(_*w),S=Math.cos(_*w),m=0;C>m;m+=1)i=Math.floor(d+K*m/C*S),o=Math.floor(v+K*m/C*y),a=4*(o*c+i),u=s[a+0],f=s[a+1],g=s[a+2],p=s[a+3],a=4*(_+m*c),h[a+0]=u,h[a+1]=f,h[a+2]=g,h[a+3]=p},e=function(t,e,n){var a,i,o,r,s,h,c=t.data,l=e.data,d=t.width,v=t.height,u=n.polarCenterX||d/2,f=n.polarCenterY||v/2,g=0,p=0,K=0,m=0,_=Math.sqrt(u*u+f*f);i=d-u,o=v-f,h=Math.sqrt(i*i+o*o),_=h>_?h:_;var y,S,C,x,w=v,b=d,F=n.polarRotation||0;for(i=0;d>i;i+=1)for(o=0;v>o;o+=1)r=i-u,s=o-f,y=Math.sqrt(r*r+s*s)*w/_,S=(180*Math.atan2(s,r)/Math.PI+360+F)%360,S=S*b/360,C=Math.floor(S),x=Math.floor(y),a=4*(x*d+C),g=c[a+0],p=c[a+1],K=c[a+2],m=c[a+3],a=4*(o*d+i),l[a+0]=g,l[a+1]=p,l[a+2]=K,l[a+3]=m},n=Konva.Util.createCanvasElement();Konva.Filters.Kaleidoscope=function(a){var i,o,r,s,h,c,l,d,v,u,f=a.width,g=a.height,p=Math.round(this.kaleidoscopePower()),K=Math.round(this.kaleidoscopeAngle()),m=Math.floor(f*(K%360)/360);if(!(1>p)){n.width=f,n.height=g;var _=n.getContext("2d").getImageData(0,0,f,g);t(a,_,{polarCenterX:f/2,polarCenterY:g/2});for(var y=f/Math.pow(2,p);8>=y;)y=2*y,p-=1;y=Math.ceil(y);var S=y,C=0,x=S,w=1;for(m+y>f&&(C=S,x=0,w=-1),o=0;g>o;o+=1)for(i=C;i!==x;i+=w)r=Math.round(i+m)%f,v=4*(f*o+r),h=_.data[v+0],c=_.data[v+1],l=_.data[v+2],d=_.data[v+3],u=4*(f*o+i),_.data[u+0]=h,_.data[u+1]=c,_.data[u+2]=l,_.data[u+3]=d;for(o=0;g>o;o+=1)for(S=Math.floor(y),s=0;p>s;s+=1){for(i=0;S+1>i;i+=1)v=4*(f*o+i),h=_.data[v+0],c=_.data[v+1],l=_.data[v+2],d=_.data[v+3],u=4*(f*o+2*S-i-1),_.data[u+0]=h,_.data[u+1]=c,_.data[u+2]=l,_.data[u+3]=d;S*=2}e(_,a,{polarRotation:0})}},Konva.Factory.addGetterSetter(Konva.Node,"kaleidoscopePower",2,null,Konva.Factory.afterSetFilter),Konva.Factory.addGetterSetter(Konva.Node,"kaleidoscopeAngle",0,null,Konva.Factory.afterSetFilter)}(),function(){function t(t){setTimeout(t,1e3/60)}function e(){return i.apply(Konva.root,arguments)}var n=500,a=function(){return Konva.root.performance&&Konva.root.performance.now?function(){return Konva.root.performance.now()}:function(){return(new Date).getTime()}}(),i=function(){return Konva.root.requestAnimationFrame||Konva.root.webkitRequestAnimationFrame||Konva.root.mozRequestAnimationFrame||Konva.root.oRequestAnimationFrame||Konva.root.msRequestAnimationFrame||t}();Konva.Animation=function(t,e){var n=Konva.Animation;this.func=t,this.setLayers(e),this.id=n.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:a()}},Konva.Animation.prototype={setLayers:function(t){var e=[];e=t?t.length>0?t:[t]:[],this.layers=e},getLayers:function(){return this.layers},addLayer:function(t){var e,n,a=this.layers;if(a){for(e=a.length,n=0;e>n;n++)if(a[n]._id===t._id)return!1}else this.layers=[];return this.layers.push(t),!0},isRunning:function(){var t,e=Konva.Animation,n=e.animations,a=n.length;for(t=0;a>t;t++)if(n[t].id===this.id)return!0;return!1},start:function(){var t=Konva.Animation;this.stop(),this.frame.timeDiff=0,this.frame.lastTime=a(),t._addAnimation(this)},stop:function(){Konva.Animation._removeAnimation(this)},_updateFrameObject:function(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}},Konva.Animation.animations=[],Konva.Animation.animIdCounter=0,Konva.Animation.animRunning=!1,
for(var e=0;e<arguments.length;e++)this.add(arguments[e])},getParent:function(){return null},getLayer:function(){return null},getLayers:function(){return this.getChildren()},_bindContentEvents:function(){for(var e=0;U>e;e++)t(this,B[e])},_mouseover:function(t){Konva.UA.mobile||(this._setPointerPosition(t),this._fire(C,{evt:t}))},_mouseout:function(t){if(!Konva.UA.mobile){this._setPointerPosition(t);var e=this.targetShape;e&&!Konva.isDragging()&&(e._fireAndBubble(i,{evt:t}),e._fireAndBubble(o,{evt:t}),this.targetShape=null),this.pointerPos=void 0,this._fire(S,{evt:t})}},_mousemove:function(t){if(Konva.UA.ieMobile)return this._touchmove(t);if(("undefined"==typeof t.webkitMovementX&&"undefined"==typeof t.webkitMovementY||0!==t.webkitMovementY||0!==t.webkitMovementX)&&!Konva.UA.mobile){this._setPointerPosition(t);var e,n=Konva.DD;Konva.isDragging()||(e=this.getIntersection(this.getPointerPosition()),e&&e.isListening()?Konva.isDragging()||this.targetShape&&this.targetShape._id===e._id?e._fireAndBubble(h,{evt:t}):(this.targetShape&&(this.targetShape._fireAndBubble(i,{evt:t},e),this.targetShape._fireAndBubble(o,{evt:t},e)),e._fireAndBubble(r,{evt:t},this.targetShape),e._fireAndBubble(s,{evt:t},this.targetShape),this.targetShape=e):this.targetShape&&!Konva.isDragging()&&(this.targetShape._fireAndBubble(i,{evt:t}),this.targetShape._fireAndBubble(o,{evt:t}),this.targetShape=null),this._fire(x,{evt:t})),n&&n._drag(t),t.preventDefault&&t.preventDefault()}},_mousedown:function(t){if(Konva.UA.ieMobile)return this._touchstart(t);if(!Konva.UA.mobile){this._setPointerPosition(t);var e=this.getIntersection(this.getPointerPosition());Konva.listenClickTap=!0,e&&e.isListening()&&(this.clickStartShape=e,e._fireAndBubble(c,{evt:t})),this._fire(w,{evt:t})}t.preventDefault&&t.preventDefault()},_mouseup:function(t){if(Konva.UA.ieMobile)return this._touchend(t);if(!Konva.UA.mobile){this._setPointerPosition(t);var e=this.getIntersection(this.getPointerPosition()),n=this.clickStartShape,a=!1,i=Konva.DD;Konva.inDblClickWindow?(a=!0,Konva.inDblClickWindow=!1):i&&i.justDragged?i&&(i.justDragged=!1):Konva.inDblClickWindow=!0,setTimeout(function(){Konva.inDblClickWindow=!1},Konva.dblClickWindow),e&&e.isListening()&&(e._fireAndBubble(l,{evt:t}),Konva.listenClickTap&&n&&n._id===e._id&&(e._fireAndBubble(d,{evt:t}),a&&e._fireAndBubble(v,{evt:t}))),this._fire(b,{evt:t}),Konva.listenClickTap&&(this._fire(F,{evt:t}),a&&this._fire(T,{evt:t})),Konva.listenClickTap=!1}t.preventDefault&&t.preventDefault()},_touchstart:function(t){this._setPointerPosition(t);var e=this.getIntersection(this.getPointerPosition());Konva.listenClickTap=!0,e&&e.isListening()&&(this.tapStartShape=e,e._fireAndBubble(u,{evt:t}),e.isListening()&&t.preventDefault&&t.preventDefault()),this._fire(P,{evt:t})},_touchend:function(t){this._setPointerPosition(t);var e=this.getIntersection(this.getPointerPosition()),n=!1;Konva.inDblClickWindow?(n=!0,Konva.inDblClickWindow=!1):Konva.inDblClickWindow=!0,setTimeout(function(){Konva.inDblClickWindow=!1},Konva.dblClickWindow),e&&e.isListening()&&(e._fireAndBubble(f,{evt:t}),Konva.listenClickTap&&e._id===this.tapStartShape._id&&(e._fireAndBubble(g,{evt:t}),n&&e._fireAndBubble(p,{evt:t})),e.isListening()&&t.preventDefault&&t.preventDefault()),Konva.listenClickTap&&(this._fire(A,{evt:t}),n&&this._fire(k,{evt:t})),Konva.listenClickTap=!1},_touchmove:function(t){this._setPointerPosition(t);var e,n=Konva.DD;Konva.isDragging()||(e=this.getIntersection(this.getPointerPosition()),e&&e.isListening()&&(e._fireAndBubble(K,{evt:t}),e.isListening()&&t.preventDefault&&t.preventDefault()),this._fire(M,{evt:t})),n&&(n._drag(t),Konva.isDragging()&&t.preventDefault())},_DOMMouseScroll:function(t){this._mousewheel(t)},_mousewheel:function(t){this._setPointerPosition(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()&&e._fireAndBubble(_,{evt:t})},_wheel:function(t){this._mousewheel(t)},_setPointerPosition:function(t){var e,n=this._getContentPosition(),a=t.offsetX,i=t.clientX,o=null,r=null;t=t?t:window.event,void 0!==t.touches?t.touches.length>0&&(e=t
break;case"T":u=r,f=s,v=o[o.length-1],"Q"===v.command&&(u=r+(r-v.points[0]),f=s+(s-v.points[1])),r=l.shift(),s=l.shift(),C="Q",x.push(u,f,r,s);break;case"t":u=r,f=s,v=o[o.length-1],"Q"===v.command&&(u=r+(r-v.points[0]),f=s+(s-v.points[1])),r+=l.shift(),s+=l.shift(),C="Q",x.push(u,f,r,s);break;case"A":g=l.shift(),p=l.shift(),K=l.shift(),m=l.shift(),_=l.shift(),y=r,S=s,r=l.shift(),s=l.shift(),C="A",x=this.convertEndpointToCenterParameterization(y,S,r,s,m,_,g,p,K);break;case"a":g=l.shift(),p=l.shift(),K=l.shift(),m=l.shift(),_=l.shift(),y=r,S=s,r+=l.shift(),s+=l.shift(),C="A",x=this.convertEndpointToCenterParameterization(y,S,r,s,m,_,g,p,K)}o.push({command:C||c,points:x,start:{x:w,y:b},pathLength:this.calcLength(w,b,C||c,x)})}("z"===c||"Z"===c)&&o.push({command:"z",points:[],start:void 0,pathLength:0})}return o},Konva.Path.calcLength=function(t,e,n,a){var i,o,r,s,h=Konva.Path;switch(n){case"L":return h.getLineLength(t,e,a[0],a[1]);case"C":for(i=0,o=h.getPointOnCubicBezier(0,t,e,a[0],a[1],a[2],a[3],a[4],a[5]),s=.01;1>=s;s+=.01)r=h.getPointOnCubicBezier(s,t,e,a[0],a[1],a[2],a[3],a[4],a[5]),i+=h.getLineLength(o.x,o.y,r.x,r.y),o=r;return i;case"Q":for(i=0,o=h.getPointOnQuadraticBezier(0,t,e,a[0],a[1],a[2],a[3]),s=.01;1>=s;s+=.01)r=h.getPointOnQuadraticBezier(s,t,e,a[0],a[1],a[2],a[3]),i+=h.getLineLength(o.x,o.y,r.x,r.y),o=r;return i;case"A":i=0;var c=a[4],l=a[5],d=a[4]+l,v=Math.PI/180;if(Math.abs(c-d)<v&&(v=Math.abs(c-d)),o=h.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],c,0),0>l)for(s=c-v;s>d;s-=v)r=h.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],s,0),i+=h.getLineLength(o.x,o.y,r.x,r.y),o=r;else for(s=c+v;d>s;s+=v)r=h.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],s,0),i+=h.getLineLength(o.x,o.y,r.x,r.y),o=r;return r=h.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],d,0),i+=h.getLineLength(o.x,o.y,r.x,r.y)}return 0},Konva.Path.convertEndpointToCenterParameterization=function(t,e,n,a,i,o,r,s,h){var c=h*(Math.PI/180),l=Math.cos(c)*(t-n)/2+Math.sin(c)*(e-a)/2,d=-1*Math.sin(c)*(t-n)/2+Math.cos(c)*(e-a)/2,v=l*l/(r*r)+d*d/(s*s);v>1&&(r*=Math.sqrt(v),s*=Math.sqrt(v));var u=Math.sqrt((r*r*s*s-r*r*d*d-s*s*l*l)/(r*r*d*d+s*s*l*l));i===o&&(u*=-1),isNaN(u)&&(u=0);var f=u*r*d/s,g=u*-s*l/r,p=(t+n)/2+Math.cos(c)*f-Math.sin(c)*g,K=(e+a)/2+Math.sin(c)*f+Math.cos(c)*g,m=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},_=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(m(t)*m(e))},y=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(_(t,e))},S=y([1,0],[(l-f)/r,(d-g)/s]),C=[(l-f)/r,(d-g)/s],x=[(-1*l-f)/r,(-1*d-g)/s],w=y(C,x);return _(C,x)<=-1&&(w=Math.PI),_(C,x)>=1&&(w=0),0===o&&w>0&&(w-=2*Math.PI),1===o&&0>w&&(w+=2*Math.PI),[p,K,r,s,S,w,c,o]},Konva.Factory.addGetterSetter(Konva.Path,"data"),Konva.Collection.mapMethods(Konva.Path)}(),function(){function t(t){t.fillText(this.partialText,0,0)}function e(t){t.strokeText(this.partialText,0,0)}var n="",a="normal";Konva.TextPath=function(t){this.___init(t)},Konva.TextPath.prototype={___init:function(n){var a=this;this.dummyCanvas=Konva.Util.createCanvasElement(),this.dataArray=[],Konva.Shape.call(this,n),this._fillFunc=t,this._strokeFunc=e,this._fillFuncHit=t,this._strokeFuncHit=e,this.className="TextPath",this.dataArray=Konva.Path.parsePathData(this.attrs.data),this.on("dataChange.konva",function(){a.dataArray=Konva.Path.parsePathData(this.attrs.data)}),this.on("textChange.konva textStroke.konva textStrokeWidth.konva",a._setTextData),a._setTextData(),this.sceneFunc(this._sceneFunc)},_sceneFunc:function(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline","middle"),t.setAttr("textAlign","left"),t.save();for(var e=this.glyphInfo,n=0;n<e.length;n++){t.save();var a=e[n].p0;t.translate(a.x,a.y),t.rotate(e[n].rotation),this.partialText=e[n].text,t.fillStrokeShape(this),t.restore()}t.restore()},getTextWidth:function(){return this.textWidth},getTextHeight:function(){return this.textHeight},setText:function(t){Konva.Text.prototype.setText.call(this,t)},_getTextSize:function(t){var e=this.dummyCanvas,n=e.getContext("2d");n.save(),n.font=this._getContextFont();var a=n.measureText(t);return n.restore(),{wi