diff --git a/konva.js b/konva.js index 81c3cb57..f612ee68 100644 --- a/konva.js +++ b/konva.js @@ -2,7 +2,7 @@ * Konva JavaScript Framework v1.7.6 * http://konvajs.github.io/ * Licensed under the MIT or GPL Version 2 licenses. - * Date: Thu Dec 21 2017 + * Date: Thu Dec 28 2017 * * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS) * Modified work Copyright (C) 2014 - 2017 by Anton Lavrenov (Konva) @@ -2493,7 +2493,7 @@ * cache node to improve drawing performance, apply filters, or create more accurate * hit regions. For all basic shapes size of cache canvas will be automatically detected. * If you need to cache your custom `Konva.Shape` instance you have to pass shape's bounding box - * properties. Look at [link to demo page](link to demo page) for more information. + * properties. Look at [https://konvajs.github.io/docs/performance/Shape_Caching.html](link to demo page) for more information. * @method * @memberof Konva.Node.prototype * @param {Object} [config] @@ -18519,40 +18519,46 @@ }); } - this.findOne('.top-left').position({ + var keepRatio = this.keepRatio(); + + this.findOne('.top-left').setAttrs({ x: 0, y: 0 }); - this.findOne('.top-center').position({ + this.findOne('.top-center').setAttrs({ x: width / 2, - y: 0 + y: 0, + visible: !keepRatio }); - this.findOne('.top-right').position({ + this.findOne('.top-right').setAttrs({ x: width, y: 0 }); - this.findOne('.middle-left').position({ + this.findOne('.middle-left').setAttrs({ x: 0, - y: height / 2 + y: height / 2, + visible: !keepRatio }); - this.findOne('.middle-right').position({ + this.findOne('.middle-right').setAttrs({ x: width, - y: height / 2 + y: height / 2, + visible: !keepRatio }); - this.findOne('.bottom-left').position({ + this.findOne('.bottom-left').setAttrs({ x: 0, y: height }); - this.findOne('.bottom-center').position({ + this.findOne('.bottom-center').setAttrs({ x: width / 2, - y: height + y: height, + visible: !keepRatio }); - this.findOne('.bottom-right').position({ + this.findOne('.bottom-right').setAttrs({ x: width, y: height }); - this.findOne('.rotater').position({ + this.findOne('.rotater').setAttrs({ x: width / 2, y: -50 }); @@ -18568,5 +18574,7 @@ }; Konva.Util.extend(Konva.Resizer, Konva.Group); + Konva.Factory.addGetterSetter(Konva.Resizer, 'keepRatio', false); + Konva.Collection.mapMethods(Konva.Resizer); })(Konva); diff --git a/konva.min.js b/konva.min.js index b80cd022..40623c86 100644 --- a/konva.min.js +++ b/konva.min.js @@ -2,7 +2,7 @@ * Konva JavaScript Framework v1.7.6 * http://konvajs.github.io/ * Licensed under the MIT or GPL Version 2 licenses. - * Date: Thu Dec 21 2017 + * Date: Thu Dec 28 2017 * * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS) * Modified work Copyright (C) 2014 - 2017 by Anton Lavrenov (Konva) @@ -40,4 +40,4 @@ * node.cache(); * node.filters([Konva.Filters.Sepia]); */ -Konva.Filters.Sepia=function(t){var e,n,i,a,o,r,s,h,c,l=t.data,d=t.width,u=t.height,f=4*d;do{e=(u-1)*f,n=d;do{s=.393*(a=l[i=e+4*(n-1)])+.769*(o=l[i+1])+.189*(r=l[i+2]),h=.349*a+.686*o+.168*r,c=.272*a+.534*o+.131*r,l[i]=s>255?255:s,l[i+1]=h>255?255:h,l[i+2]=c>255?255:c,l[i+3]=l[i+3]}while(--n)}while(--u)}}(),function(){"use strict";Konva.Filters.Solarize=function(t){var e=t.data,n=t.width,i=4*n,a=t.height;do{var o=(a-1)*i,r=n;do{var s=o+4*(r-1),h=e[s],c=e[s+1],l=e[s+2];h>127&&(h=255-h),c>127&&(c=255-c),l>127&&(l=255-l),e[s]=h,e[s+1]=c,e[s+2]=l}while(--r)}while(--a)}}(),function(){"use strict";Konva.Filters.Kaleidoscope=function(t){var e,n,i,a,o,r,s,h,c,l=t.width,d=t.height,u=Math.round(this.kaleidoscopePower()),f=Math.round(this.kaleidoscopeAngle()),v=Math.floor(l*(f%360)/360);if(!(u<1)){var g=Konva.Util.createCanvasElement();g.width=l,g.height=d;var p=g.getContext("2d").getImageData(0,0,l,d);!function(t,e,n){var i,a,o,r,s=t.data,h=e.data,c=t.width,l=t.height,d=n.polarCenterX||c/2,u=n.polarCenterY||l/2,f=0,v=0,g=0,p=0,m=Math.sqrt(d*d+u*u);a=c-d,o=l-u,m=(r=Math.sqrt(a*a+o*o))>m?r:m;var _,y,S,K,x=l,C=c,w=360/C*Math.PI/180;for(y=0;yl&&(y=_,S=0,K=-1),n=0;ny?h:y;var S,K,x,C=u,w=d,b=n.polarRotation||0;for(a=0;a0},removeChildren:function(){for(var t,e=Konva.Collection.toCollection(this.children),n=0;n1){for(var e=0;e0},destroy:function(){return t.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],this},_useBufferCanvas:function(t){return!t&&this.perfectDrawEnabled()&&1!==this.getAbsoluteOpacity()&&this.hasFill()&&this.hasStroke()&&this.getStage()||this.perfectDrawEnabled()&&this.hasShadow()&&1!==this.getAbsoluteOpacity()&&this.hasFill()&&this.hasStroke()&&this.getStage()},getSelfRect:function(){var t=this.getSize();return{x:this._centroid?Math.round(-t.width/2):0,y:this._centroid?Math.round(-t.height/2):0,width:t.width,height:t.height}},getClientRect:function(t){var e=(t=t||{}).skipTransform,n=t.relativeTo,i=this.getSelfRect(),a=this.hasStroke()&&this.strokeWidth()||0,o=i.width+a,r=i.height+a,s=this.hasShadow()?this.shadowOffsetX():0,h=this.hasShadow()?this.shadowOffsetY():0,c=o+Math.abs(s),l=r+Math.abs(h),d=this.hasShadow()&&this.shadowBlur()||0,u=c+2*d,f=l+2*d,v=0;Math.round(a/2)!==a/2&&(v=1);var g={width:u+v,height:f+v,x:-Math.round(a/2+d)+Math.min(s,0)+i.x,y:-Math.round(a/2+d)+Math.min(h,0)+i.y};return e?g:this._transformedRect(g,n)},drawScene:function(t,e,n,i){var a,o,r,s=this.getLayer(),h=t||s.getCanvas(),c=h.getContext(),l=this._cache.canvas,d=this.sceneFunc(),u=this.hasShadow(),f=this.hasStroke();if(!this.isVisible())return this;if(l)return c.save(),s._applyTransform(this,c,e),this._drawCachedSceneCanvas(c),c.restore(),this;if(!d)return this;if(c.save(),this._useBufferCanvas(n)&&!i){if(a=this.getStage(),o=a.bufferCanvas,(r=o.getContext()).clear(),r.save(),r._applyLineJoin(this),!n)if(s)s._applyTransform(this,r,e);else{var v=this.getAbsoluteTransform(e).getMatrix();c.transform(v[0],v[1],v[2],v[3],v[4],v[5])}d.call(this,r),r.restore();var g=o.pixelRatio;u&&!h.hitCanvas?(c.save(),c._applyShadow(this),c._applyOpacity(this),c._applyGlobalCompositeOperation(this),c.drawImage(o._canvas,0,0,o.width/g,o.height/g),c.restore()):(c._applyOpacity(this),c._applyGlobalCompositeOperation(this),c.drawImage(o._canvas,0,0,o.width/g,o.height/g))}else{if(c._applyLineJoin(this),!n)if(s)s._applyTransform(this,c,e);else{var p=this.getAbsoluteTransform(e).getMatrix();c.transform(p[0],p[1],p[2],p[3],p[4],p[5])}u&&f&&!h.hitCanvas?(c.save(),n||(c._applyOpacity(this),c._applyGlobalCompositeOperation(this)),c._applyShadow(this),d.call(this,c),c.restore(),this.hasFill()&&this.getShadowForStrokeEnabled()&&d.call(this,c)):u&&!h.hitCanvas?(c.save(),n||(c._applyOpacity(this),c._applyGlobalCompositeOperation(this)),c._applyShadow(this),d.call(this,c),c.restore()):(n||(c._applyOpacity(this),c._applyGlobalCompositeOperation(this)),d.call(this,c))}return c.restore(),this},drawHit:function(t,e,n){var i=this.getLayer(),a=t||i.hitCanvas,o=a.getContext(),r=this.hitFunc()||this.sceneFunc(),s=this._cache.canvas,h=s&&s.hit;if(!this.shouldDrawHit(a))return this;if(i&&i.clearHitCache(),h)return o.save(),i._applyTransform(this,o,e),this._drawCachedHitCanvas(o),o.restore(),this;if(!r)return this;if(o.save(),o._applyLineJoin(this),!n)if(i)i._applyTransform(this,o,e);else{var c=this.getAbsoluteTransform(e).getMatrix();o.transform(c[0],c[1],c[2],c[3],c[4],c[5])}return r.call(this,o),o.restore(),this},drawHitFromCache:function(e){var n,i,a,o,r,s=e||0,h=this._cache.canvas,c=this._getCachedSceneCanvas(),l=h.hit,d=l.getContext(),u=l.getWidth(),f=l.getHeight();d.clear(),d.drawImage(c._canvas,0,0,u,f);try{for(a=(i=(n=d.getImageData(0,0,u,f)).data).length,o=t.Util._hexToRgb(this.colorKey),r=0;rs?(i[r]=o.r,i[r+1]=o.g,i[r+2]=o.b,i[r+3]=255):i[r+3]=0;d.putImageData(n,0,0)}catch(e){t.Util.error("Unable to draw hit graph from cached scene canvas. "+e.message)}return this}}),t.Util.extend(t.Shape,t.Node),t.Factory.addGetterSetter(t.Shape,"stroke"),t.Factory.addDeprecatedGetterSetter(t.Shape,"strokeRed",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"strokeGreen",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"strokeBlue",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"strokeAlpha",1,t.Validators.alphaComponent),t.Factory.addGetterSetter(t.Shape,"strokeWidth",2),t.Factory.addGetterSetter(t.Shape,"strokeHitEnabled",!0),t.Factory.addGetterSetter(t.Shape,"perfectDrawEnabled",!0),t.Factory.addGetterSetter(t.Shape,"shadowForStrokeEnabled",!0),t.Factory.addGetterSetter(t.Shape,"lineJoin"),t.Factory.addGetterSetter(t.Shape,"lineCap"),t.Factory.addGetterSetter(t.Shape,"sceneFunc"),t.Factory.addGetterSetter(t.Shape,"hitFunc"),t.Factory.addGetterSetter(t.Shape,"dash"),t.Factory.addGetterSetter(t.Shape,"dashOffset",0),t.Factory.addGetterSetter(t.Shape,"shadowColor"),t.Factory.addDeprecatedGetterSetter(t.Shape,"shadowRed",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"shadowGreen",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"shadowBlue",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"shadowAlpha",1,t.Validators.alphaComponent),t.Factory.addGetterSetter(t.Shape,"shadowBlur"),t.Factory.addGetterSetter(t.Shape,"shadowOpacity"),t.Factory.addComponentsGetterSetter(t.Shape,"shadowOffset",["x","y"]),t.Factory.addGetterSetter(t.Shape,"shadowOffsetX",0),t.Factory.addGetterSetter(t.Shape,"shadowOffsetY",0),t.Factory.addGetterSetter(t.Shape,"fillPatternImage"),t.Factory.addGetterSetter(t.Shape,"fill"),t.Factory.addDeprecatedGetterSetter(t.Shape,"fillRed",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"fillGreen",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"fillBlue",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"fillAlpha",1,t.Validators.alphaComponent),t.Factory.addGetterSetter(t.Shape,"fillPatternX",0),t.Factory.addGetterSetter(t.Shape,"fillPatternY",0),t.Factory.addGetterSetter(t.Shape,"fillLinearGradientColorStops"),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientStartRadius",0),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientEndRadius",0),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientColorStops"),t.Factory.addGetterSetter(t.Shape,"fillPatternRepeat","repeat"),t.Factory.addGetterSetter(t.Shape,"fillEnabled",!0),t.Factory.addGetterSetter(t.Shape,"strokeEnabled",!0),t.Factory.addGetterSetter(t.Shape,"shadowEnabled",!0),t.Factory.addGetterSetter(t.Shape,"dashEnabled",!0),t.Factory.addGetterSetter(t.Shape,"strokeScaleEnabled",!0),t.Factory.addGetterSetter(t.Shape,"fillPriority","color"),t.Factory.addComponentsGetterSetter(t.Shape,"fillPatternOffset",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillPatternOffsetX",0),t.Factory.addGetterSetter(t.Shape,"fillPatternOffsetY",0),t.Factory.addComponentsGetterSetter(t.Shape,"fillPatternScale",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillPatternScaleX",1),t.Factory.addGetterSetter(t.Shape,"fillPatternScaleY",1),t.Factory.addComponentsGetterSetter(t.Shape,"fillLinearGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillLinearGradientStartPointX",0),t.Factory.addGetterSetter(t.Shape,"fillLinearGradientStartPointY",0),t.Factory.addComponentsGetterSetter(t.Shape,"fillLinearGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillLinearGradientEndPointX",0),t.Factory.addGetterSetter(t.Shape,"fillLinearGradientEndPointY",0),t.Factory.addComponentsGetterSetter(t.Shape,"fillRadialGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientStartPointX",0),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientStartPointY",0),t.Factory.addComponentsGetterSetter(t.Shape,"fillRadialGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientEndPointX",0),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientEndPointY",0),t.Factory.addGetterSetter(t.Shape,"fillPatternRotation",0),t.Factory.backCompat(t.Shape,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"}),t.Collection.mapMethods(t.Shape)}(Konva),function(){"use strict";function t(t,e){t.content.addEventListener(e,function(n){t[i+e](n)},!1)}var e="mouseout",n="mouseleave",i="_",a=["mousedown","mousemove","mouseup",e,"touchstart","touchmove","touchend","mouseover","wheel","contextmenu"],o=a.length;Konva.Stage=function(t){this.___init(t)},Konva.Util.addMethods(Konva.Stage,{___init:function(t){this.nodeType="Stage",Konva.Container.call(this,t),this._id=Konva.idCounter++,this._buildDOM(),this._bindContentEvents(),this._enableNestedTransforms=!1,Konva.stages.push(this)},_validateAdd:function(t){"Layer"!==t.getType()&&Konva.Util.throw("You may only add layers to the stage.")},setContainer:function(t){if("string"==typeof t){if("."===t.charAt(0)){var e=t.slice(1);t=Konva.document.getElementsByClassName(e)[0]}else{var n;n="#"!==t.charAt(0)?t:t.slice(1),t=Konva.document.getElementById(n)}if(!t)throw"Can not find container in document with id "+n}return this._setAttr("container",t),this},shouldDrawHit:function(){return!0},draw:function(){return Konva.Node.prototype.draw.call(this),this},setHeight:function(t){return Konva.Node.prototype.setHeight.call(this,t),this._resizeDOM(),this},setWidth:function(t){return Konva.Node.prototype.setWidth.call(this,t),this._resizeDOM(),this},clear:function(){var t,e=this.children,n=e.length;for(t=0;t-1&&Konva.stages.splice(e,1),this},getPointerPosition:function(){return this.pointerPos},getStage:function(){return this},getContent:function(){return this.content},toDataURL:function(t){var e=(t=t||{}).mimeType||null,n=t.quality||null,i=t.x||0,a=t.y||0,o=new Konva.SceneCanvas({width:t.width||this.getWidth(),height:t.height||this.getHeight(),pixelRatio:t.pixelRatio}),r=o.getContext()._context,s=this.children;(i||a)&&r.translate(-1*i,-1*a),s.each(function(t){var e=t.getCanvas().getWidth(),n=t.getCanvas().getHeight(),i=t.getCanvas().getPixelRatio();r.drawImage(t.getCanvas()._canvas,0,0,e/i,n/i)});var h=o.toDataURL(e,n);return t.callback&&t.callback(h),h},toImage:function(t){var e=t.callback;t.callback=function(t){Konva.Util._getImage(t,function(t){e(t)})},this.toDataURL(t)},getIntersection:function(t,e){var n,i,a=this.getChildren();for(n=a.length-1;n>=0;n--)if(i=a[n].getIntersection(t,e))return i;return null},_resizeDOM:function(){if(this.content){var t,e,n=this.getWidth(),i=this.getHeight(),a=this.getChildren(),o=a.length;for(this.content.style.width=n+"px",this.content.style.height=i+"px",this.bufferCanvas.setSize(n,i),this.bufferHitCanvas.setSize(n,i),t=0;t1){for(var e=0;e0){var a=t.touches[0];n=a.clientX-e.left,i=a.clientY-e.top}}else n=t.clientX-e.left,i=t.clientY-e.top;null!==n&&null!==i&&(this.pointerPos={x:n,y:i})},_getContentPosition:function(){var t=this.content.getBoundingClientRect?this.content.getBoundingClientRect():{top:0,left:0};return{top:t.top,left:t.left}},_buildDOM:function(){if(this.bufferCanvas=new Konva.SceneCanvas,this.bufferHitCanvas=new Konva.HitCanvas({pixelRatio:1}),Konva.isBrowser){var t=this.getContainer();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=Konva.document.createElement("div"),this.content.style.position="relative",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}},_onContent:function(t,e){var n,i,a=t.split(" "),o=a.length;for(n=0;n0?{antialiased:!0}:{}},drawScene:function(t,e){var n=this.getLayer(),i=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.getClearBeforeDraw()&&i.getContext().clear(),Konva.Container.prototype.drawScene.call(this,i,e),this._fire("draw",{node:this}),this},drawHit:function(t,e){var n=this.getLayer(),i=t||n&&n.hitCanvas;return n&&n.getClearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Konva.Container.prototype.drawHit.call(this,i,e),this.imageData=null,this},clear:function(t){return Konva.BaseLayer.prototype.clear.call(this,t),this.getHitCanvas().getContext().clear(t),this.imageData=null,this},setVisible:function(t){return Konva.Node.prototype.setVisible.call(this,t),t?(this.getCanvas()._canvas.style.display="block",this.hitCanvas._canvas.style.display="block"):(this.getCanvas()._canvas.style.display="none",this.hitCanvas._canvas.style.display="none"),this},enableHitGraph:function(){return this.setHitGraphEnabled(!0),this},disableHitGraph:function(){return this.setHitGraphEnabled(!1),this},setSize:function(t,e){return Konva.BaseLayer.prototype.setSize.call(this,t,e),this.hitCanvas.setSize(t,e),this}}),Konva.Util.extend(Konva.Layer,Konva.BaseLayer),Konva.Factory.addGetterSetter(Konva.Layer,"hitGraphEnabled",!0),Konva.Collection.mapMethods(Konva.Layer)}(),function(){"use strict";Konva.FastLayer=function(t){this.____init(t)},Konva.Util.addMethods(Konva.FastLayer,{____init:function(t){this.nodeType="Layer",this.canvas=new Konva.SceneCanvas,Konva.BaseLayer.call(this,t)},_validateAdd:function(t){"Shape"!==t.getType()&&Konva.Util.throw("You may only add shapes to a fast layer.")},_setCanvasSize:function(t,e){this.canvas.setSize(t,e)},hitGraphEnabled:function(){return!1},getIntersection:function(){return null},drawScene:function(t){var e=this.getLayer(),n=t||e&&e.getCanvas();return this.getClearBeforeDraw()&&n.getContext().clear(),Konva.Container.prototype.drawScene.call(this,n),this},draw:function(){return this.drawScene(),this},setVisible:function(t){return Konva.Node.prototype.setVisible.call(this,t),this.getCanvas()._canvas.style.display=t?"block":"none",this}}),Konva.Util.extend(Konva.FastLayer,Konva.BaseLayer),Konva.Collection.mapMethods(Konva.FastLayer)}(),function(){"use strict";Konva.Group=function(t){this.___init(t)},Konva.Util.addMethods(Konva.Group,{___init:function(t){this.nodeType="Group",Konva.Container.call(this,t)},_validateAdd:function(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&Konva.Util.throw("You may only add groups and shapes to groups.")}}),Konva.Util.extend(Konva.Group,Konva.Container),Konva.Collection.mapMethods(Konva.Group)}(),function(t){"use strict";function e(){return i.apply(t.global,arguments)}var n=t.global.performance&&t.global.performance.now?function(){return t.global.performance.now()}:function(){return(new Date).getTime()},i=t.global.requestAnimationFrame||t.global.webkitRequestAnimationFrame||t.global.mozRequestAnimationFrame||t.global.oRequestAnimationFrame||t.global.msRequestAnimationFrame||function(t){setTimeout(t,1e3/60)};t.Animation=function(e,i){var a=t.Animation;this.func=e,this.setLayers(i),this.id=a.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:n()}},t.Animation.prototype={setLayers:function(t){var e=[];return e=t?t.length>0?t:[t]:[],this.layers=e,this},getLayers:function(){return this.layers},addLayer:function(t){var e,n=this.layers,i=n.length;for(e=0;ethis.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())},getTime:function(){return this._time},setPosition:function(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t},getPosition:function(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)},play:function(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")},reverse:function(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")},seek:function(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")},reset:function(){this.pause(),this._time=0,this.update(),this.fire("onReset")},finish:function(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")},update:function(){this.setPosition(this.getPosition(this._time))},onEnterFrame:function(){var t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)},pause:function(){this.state=1,this.fire("onPause")},getTimer:function(){return(new Date).getTime()}},Konva.Tween=function(n){var a,o,r=this,s=n.node,h=s._id,c=n.easing||Konva.Easings.Linear,l=!!n.yoyo;a=void 0===n.duration?1:0===n.duration?.001:n.duration,this.node=s,this._id=e++;var d=s.getLayer()||(s instanceof Konva.Stage?s.getLayers():null);d||Konva.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Konva.Animation(function(){r.tween.onEnterFrame()},d),this.tween=new i(o,function(t){r._tweenFunc(t)},c,0,1,1e3*a,l),this._addListeners(),Konva.Tween.attrs[h]||(Konva.Tween.attrs[h]={}),Konva.Tween.attrs[h][this._id]||(Konva.Tween.attrs[h][this._id]={}),Konva.Tween.tweens[h]||(Konva.Tween.tweens[h]={});for(o in n)void 0===t[o]&&this._addAttr(o,n[o]);this.reset(),this.onFinish=n.onFinish,this.onReset=n.onReset},Konva.Tween.attrs={},Konva.Tween.tweens={},Konva.Tween.prototype={_addAttr:function(t,e){var i,a,o,r,s,h,c,l=this.node,d=l._id;if((o=Konva.Tween.tweens[d][t])&&delete Konva.Tween.attrs[d][o][t],i=l.getAttr(t),Konva.Util._isArray(e))for(a=[],s=Math.max(e.length,i.length),"points"===t&&e.length!==i.length&&(e.length>i.length?(c=i,i=Konva.Util._prepareArrayForTween(i,e,l.closed())):(h=e,e=Konva.Util._prepareArrayForTween(e,i,l.closed()))),r=0;rl)for(;_.length>0;){for(var S=0,K=_.length,x="",C=0;S>>1,b=_.slice(0,w+1),F=this._getTextWidth(b);F<=l?(S=w+1,x=b,C=F):K=w}if(!x)break;if(g){var T=Math.max(x.lastIndexOf(" "),x.lastIndexOf("-"))+1;T>0&&(S=T,x=x.slice(0,S),C=this._getTextWidth(x))}if(this._addTextLine(x),i=Math.max(i,C),u+=a,!v||h&&u+a>d)break;if((_=_.slice(S)).length>0&&(y=this._getTextWidth(_))<=l){this._addTextLine(_),u+=a,i=Math.max(i,y);break}}else this._addTextLine(_),u+=a,i=Math.max(i,y);if(h&&u+a>d)break}t().restore(),this.textHeight=n,this.textWidth=i}},Konva.Util.extend(Konva.Text,Konva.Shape),Konva.Factory.addGetterSetter(Konva.Text,"fontFamily","Arial"),Konva.Factory.addGetterSetter(Konva.Text,"fontSize",12),Konva.Factory.addGetterSetter(Konva.Text,"fontStyle","normal"),Konva.Factory.addGetterSetter(Konva.Text,"fontVariant","normal"),Konva.Factory.addGetterSetter(Konva.Text,"padding",0),Konva.Factory.addGetterSetter(Konva.Text,"align","left"),Konva.Factory.addGetterSetter(Konva.Text,"lineHeight",1),Konva.Factory.addGetterSetter(Konva.Text,"wrap","word"),Konva.Factory.addGetterSetter(Konva.Text,"letterSpacing",0),Konva.Factory.addGetter(Konva.Text,"text",""),Konva.Factory.addOverloadedGetterSetter(Konva.Text,"text"),Konva.Factory.addGetterSetter(Konva.Text,"textDecoration",""),Konva.Collection.mapMethods(Konva.Text)}(),function(){"use strict";Konva.Line=function(t){this.___init(t)},Konva.Line.prototype={___init:function(t){Konva.Shape.call(this,t),this.className="Line",this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")}),this.sceneFunc(this._sceneFunc)},_sceneFunc:function(t){var e,n,i,a=this.getPoints(),o=a.length,r=this.getTension(),s=this.getClosed(),h=this.getBezier();if(o){if(t.beginPath(),t.moveTo(a[0],a[1]),0!==r&&o>4){for(n=(e=this.getTensionPoints()).length,i=s?0:4,s||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);ih?s:h,v=s>h?1:s/h,g=s>h?h/s:1;t.translate(o,r),t.rotate(d),t.scale(v,g),t.arc(0,0,f,c,c+l,1-u),t.scale(1/v,1/g),t.rotate(-d),t.translate(-o,-r);break;case"z":t.closePath()}}t.fillStrokeShape(this)},getSelfRect:function(){var t=[];this.dataArray.forEach(function(e){t=t.concat(e.points)});for(var e,n,i=t[0],a=t[0],o=t[1],r=t[1],s=0;s0&&""===l[0]&&l.shift();for(var d=0;d0&&!isNaN(l[0]);){var u,f,v,g,p,m,_,y,S,K,x=null,C=[],w=r,b=s;switch(c){case"l":r+=l.shift(),s+=l.shift(),x="L",C.push(r,s);break;case"L":r=l.shift(),s=l.shift(),C.push(r,s);break;case"m":var F=l.shift(),T=l.shift();if(r+=F,s+=T,x="M",o.length>2&&"z"===o[o.length-1].command)for(var P=o.length-2;P>=0;P--)if("M"===o[P].command){r=o[P].points[0]+F,s=o[P].points[1]+T;break}C.push(r,s),c="l";break;case"M":r=l.shift(),s=l.shift(),x="M",C.push(r,s),c="L";break;case"h":r+=l.shift(),x="L",C.push(r,s);break;case"H":r=l.shift(),x="L",C.push(r,s);break;case"v":s+=l.shift(),x="L",C.push(r,s);break;case"V":s=l.shift(),x="L",C.push(r,s);break;case"C":C.push(l.shift(),l.shift(),l.shift(),l.shift()),r=l.shift(),s=l.shift(),C.push(r,s);break;case"c":C.push(r+l.shift(),s+l.shift(),r+l.shift(),s+l.shift()),r+=l.shift(),s+=l.shift(),x="C",C.push(r,s);break;case"S":f=r,v=s,"C"===(u=o[o.length-1]).command&&(f=r+(r-u.points[2]),v=s+(s-u.points[3])),C.push(f,v,l.shift(),l.shift()),r=l.shift(),s=l.shift(),x="C",C.push(r,s);break;case"s":f=r,v=s,"C"===(u=o[o.length-1]).command&&(f=r+(r-u.points[2]),v=s+(s-u.points[3])),C.push(f,v,r+l.shift(),s+l.shift()),r+=l.shift(),s+=l.shift(),x="C",C.push(r,s);break;case"Q":C.push(l.shift(),l.shift()),r=l.shift(),s=l.shift(),C.push(r,s);break;case"q":C.push(r+l.shift(),s+l.shift()),r+=l.shift(),s+=l.shift(),x="Q",C.push(r,s);break;case"T":f=r,v=s,"Q"===(u=o[o.length-1]).command&&(f=r+(r-u.points[0]),v=s+(s-u.points[1])),r=l.shift(),s=l.shift(),x="Q",C.push(f,v,r,s);break;case"t":f=r,v=s,"Q"===(u=o[o.length-1]).command&&(f=r+(r-u.points[0]),v=s+(s-u.points[1])),r+=l.shift(),s+=l.shift(),x="Q",C.push(f,v,r,s);break;case"A":g=l.shift(),p=l.shift(),m=l.shift(),_=l.shift(),y=l.shift(),S=r,K=s,r=l.shift(),s=l.shift(),x="A",C=this.convertEndpointToCenterParameterization(S,K,r,s,_,y,g,p,m);break;case"a":g=l.shift(),p=l.shift(),m=l.shift(),_=l.shift(),y=l.shift(),S=r,K=s,r+=l.shift(),s+=l.shift(),x="A",C=this.convertEndpointToCenterParameterization(S,K,r,s,_,y,g,p,m)}o.push({command:x||c,points:C,start:{x:w,y:b},pathLength:this.calcLength(w,b,x||c,C)})}"z"!==c&&"Z"!==c||o.push({command:"z",points:[],start:void 0,pathLength:0})}return o},Konva.Path.calcLength=function(t,e,n,i){var a,o,r,s,h=Konva.Path;switch(n){case"L":return h.getLineLength(t,e,i[0],i[1]);case"C":for(a=0,o=h.getPointOnCubicBezier(0,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),s=.01;s<=1;s+=.01)r=h.getPointOnCubicBezier(s,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),a+=h.getLineLength(o.x,o.y,r.x,r.y),o=r;return a;case"Q":for(a=0,o=h.getPointOnQuadraticBezier(0,t,e,i[0],i[1],i[2],i[3]),s=.01;s<=1;s+=.01)r=h.getPointOnQuadraticBezier(s,t,e,i[0],i[1],i[2],i[3]),a+=h.getLineLength(o.x,o.y,r.x,r.y),o=r;return a;case"A":a=0;var c=i[4],l=i[5],d=i[4]+l,u=Math.PI/180;if(Math.abs(c-d)d;s-=u)r=h.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),a+=h.getLineLength(o.x,o.y,r.x,r.y),o=r;else for(s=c+u;s1&&(r*=Math.sqrt(u),s*=Math.sqrt(u));var f=Math.sqrt((r*r*(s*s)-r*r*(d*d)-s*s*(l*l))/(r*r*(d*d)+s*s*(l*l)));a===o&&(f*=-1),isNaN(f)&&(f=0);var v=f*r*d/s,g=f*-s*l/r,p=(t+n)/2+Math.cos(c)*v-Math.sin(c)*g,m=(e+i)/2+Math.sin(c)*v+Math.cos(c)*g,_=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(_(t)*_(e))},S=function(t,e){return(t[0]*e[1]=1&&(w=0),0===o&&w>0&&(w-=2*Math.PI),1===o&&w<0&&(w+=2*Math.PI),[p,m,r,s,K,w,c,o]},Konva.Factory.addGetterSetter(Konva.Path,"data"),Konva.Collection.mapMethods(Konva.Path)}(),function(){"use strict";function t(t){t.fillText(this.partialText,0,0)}function e(t){t.strokeText(this.partialText,0,0)}Konva.TextPath=function(t){this.___init(t)},Konva.TextPath.prototype={___init:function(n){var i=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(){i.dataArray=Konva.Path.parsePathData(this.attrs.data),i._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva",i._setTextData),i._setTextData(),this.sceneFunc(this._sceneFunc),this.hitFunc(this._hitFunc)},_sceneFunc:function(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.getTextBaseline()),t.setAttr("textAlign","left"),t.save();var e=this.textDecoration(),n=this.fill(),i=this.fontSize(),a=this.glyphInfo;"underline"===e&&t.beginPath();for(var o=0;o=1){var n=e[0].p0;t.moveTo(n.x,n.y)}for(var i=0;i0&&(o+=t.dataArray[r].pathLength);var s=0;"center"===i&&(s=Math.max(0,o/2-a/2)),"right"===i&&(s=Math.max(0,o-a));for(var h,c,l,d=this.getText().split(""),u=this.getText().split(" ").length-1,f=-1,v=0,g=function(){v=0;for(var e=t.dataArray,n=f+1;n0)return f=n,e[n];"M"===e[n].command&&(h={x:e[n].points[0],y:e[n].points[1]})}return{}},p=function(e){var r=t._getTextSize(e).width+n;" "===e&&"justify"===i&&(r+=(o-a)/u);var s=0,d=0;for(c=void 0;Math.abs(r-s)/r>.01&&d<25;){d++;for(var f=s;void 0===l;)(l=g())&&f+l.pathLengthr?c=Konva.Path.getPointOnLine(r,h.x,h.y,l.points[0],l.points[1],h.x,h.y):l=void 0;break;case"A":var m=l.points[4],_=l.points[5],y=l.points[4]+_;0===v?v=m+1e-8:r>s?v+=Math.PI/180*_/Math.abs(_):v-=Math.PI/360*_/Math.abs(_),(_<0&&v=0&&v>y)&&(v=y,p=!0),c=Konva.Path.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],v,l.points[6]);break;case"C":0===v?v=r>l.pathLength?1e-8:r/l.pathLength:r>s?v+=(r-s)/l.pathLength:v-=(s-r)/l.pathLength,v>1&&(v=1,p=!0),c=Konva.Path.getPointOnCubicBezier(v,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3],l.points[4],l.points[5]);break;case"Q":0===v?v=r/l.pathLength:r>s?v+=(r-s)/l.pathLength:v-=(s-r)/l.pathLength,v>1&&(v=1,p=!0),c=Konva.Path.getPointOnQuadraticBezier(v,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3])}void 0!==c&&(s=Konva.Path.getLineLength(h.x,h.y,c.x,c.y)),p&&(p=!1,l=void 0)}},m=t._getTextSize("C").width+n,_=0;_255?255:s,l[i+1]=h>255?255:h,l[i+2]=c>255?255:c,l[i+3]=l[i+3]}while(--n)}while(--u)}}(),function(){"use strict";Konva.Filters.Solarize=function(t){var e=t.data,n=t.width,i=4*n,a=t.height;do{var o=(a-1)*i,r=n;do{var s=o+4*(r-1),h=e[s],c=e[s+1],l=e[s+2];h>127&&(h=255-h),c>127&&(c=255-c),l>127&&(l=255-l),e[s]=h,e[s+1]=c,e[s+2]=l}while(--r)}while(--a)}}(),function(){"use strict";Konva.Filters.Kaleidoscope=function(t){var e,n,i,a,o,r,s,h,c,l=t.width,d=t.height,u=Math.round(this.kaleidoscopePower()),f=Math.round(this.kaleidoscopeAngle()),v=Math.floor(l*(f%360)/360);if(!(u<1)){var g=Konva.Util.createCanvasElement();g.width=l,g.height=d;var p=g.getContext("2d").getImageData(0,0,l,d);!function(t,e,n){var i,a,o,r,s=t.data,h=e.data,c=t.width,l=t.height,d=n.polarCenterX||c/2,u=n.polarCenterY||l/2,f=0,v=0,g=0,p=0,m=Math.sqrt(d*d+u*u);a=c-d,o=l-u,m=(r=Math.sqrt(a*a+o*o))>m?r:m;var _,y,S,K,x=l,C=c,w=360/C*Math.PI/180;for(y=0;yl&&(y=_,S=0,K=-1),n=0;ny?h:y;var S,K,x,C=u,w=d,b=n.polarRotation||0;for(a=0;a0},removeChildren:function(){for(var t,e=Konva.Collection.toCollection(this.children),n=0;n1){for(var e=0;e0},destroy:function(){return t.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],this},_useBufferCanvas:function(t){return!t&&this.perfectDrawEnabled()&&1!==this.getAbsoluteOpacity()&&this.hasFill()&&this.hasStroke()&&this.getStage()||this.perfectDrawEnabled()&&this.hasShadow()&&1!==this.getAbsoluteOpacity()&&this.hasFill()&&this.hasStroke()&&this.getStage()},getSelfRect:function(){var t=this.getSize();return{x:this._centroid?Math.round(-t.width/2):0,y:this._centroid?Math.round(-t.height/2):0,width:t.width,height:t.height}},getClientRect:function(t){var e=(t=t||{}).skipTransform,n=t.relativeTo,i=this.getSelfRect(),a=this.hasStroke()&&this.strokeWidth()||0,o=i.width+a,r=i.height+a,s=this.hasShadow()?this.shadowOffsetX():0,h=this.hasShadow()?this.shadowOffsetY():0,c=o+Math.abs(s),l=r+Math.abs(h),d=this.hasShadow()&&this.shadowBlur()||0,u=c+2*d,f=l+2*d,v=0;Math.round(a/2)!==a/2&&(v=1);var g={width:u+v,height:f+v,x:-Math.round(a/2+d)+Math.min(s,0)+i.x,y:-Math.round(a/2+d)+Math.min(h,0)+i.y};return e?g:this._transformedRect(g,n)},drawScene:function(t,e,n,i){var a,o,r,s=this.getLayer(),h=t||s.getCanvas(),c=h.getContext(),l=this._cache.canvas,d=this.sceneFunc(),u=this.hasShadow(),f=this.hasStroke();if(!this.isVisible())return this;if(l)return c.save(),s._applyTransform(this,c,e),this._drawCachedSceneCanvas(c),c.restore(),this;if(!d)return this;if(c.save(),this._useBufferCanvas(n)&&!i){if(a=this.getStage(),o=a.bufferCanvas,(r=o.getContext()).clear(),r.save(),r._applyLineJoin(this),!n)if(s)s._applyTransform(this,r,e);else{var v=this.getAbsoluteTransform(e).getMatrix();c.transform(v[0],v[1],v[2],v[3],v[4],v[5])}d.call(this,r),r.restore();var g=o.pixelRatio;u&&!h.hitCanvas?(c.save(),c._applyShadow(this),c._applyOpacity(this),c._applyGlobalCompositeOperation(this),c.drawImage(o._canvas,0,0,o.width/g,o.height/g),c.restore()):(c._applyOpacity(this),c._applyGlobalCompositeOperation(this),c.drawImage(o._canvas,0,0,o.width/g,o.height/g))}else{if(c._applyLineJoin(this),!n)if(s)s._applyTransform(this,c,e);else{var p=this.getAbsoluteTransform(e).getMatrix();c.transform(p[0],p[1],p[2],p[3],p[4],p[5])}u&&f&&!h.hitCanvas?(c.save(),n||(c._applyOpacity(this),c._applyGlobalCompositeOperation(this)),c._applyShadow(this),d.call(this,c),c.restore(),this.hasFill()&&this.getShadowForStrokeEnabled()&&d.call(this,c)):u&&!h.hitCanvas?(c.save(),n||(c._applyOpacity(this),c._applyGlobalCompositeOperation(this)),c._applyShadow(this),d.call(this,c),c.restore()):(n||(c._applyOpacity(this),c._applyGlobalCompositeOperation(this)),d.call(this,c))}return c.restore(),this},drawHit:function(t,e,n){var i=this.getLayer(),a=t||i.hitCanvas,o=a.getContext(),r=this.hitFunc()||this.sceneFunc(),s=this._cache.canvas,h=s&&s.hit;if(!this.shouldDrawHit(a))return this;if(i&&i.clearHitCache(),h)return o.save(),i._applyTransform(this,o,e),this._drawCachedHitCanvas(o),o.restore(),this;if(!r)return this;if(o.save(),o._applyLineJoin(this),!n)if(i)i._applyTransform(this,o,e);else{var c=this.getAbsoluteTransform(e).getMatrix();o.transform(c[0],c[1],c[2],c[3],c[4],c[5])}return r.call(this,o),o.restore(),this},drawHitFromCache:function(e){var n,i,a,o,r,s=e||0,h=this._cache.canvas,c=this._getCachedSceneCanvas(),l=h.hit,d=l.getContext(),u=l.getWidth(),f=l.getHeight();d.clear(),d.drawImage(c._canvas,0,0,u,f);try{for(a=(i=(n=d.getImageData(0,0,u,f)).data).length,o=t.Util._hexToRgb(this.colorKey),r=0;rs?(i[r]=o.r,i[r+1]=o.g,i[r+2]=o.b,i[r+3]=255):i[r+3]=0;d.putImageData(n,0,0)}catch(e){t.Util.error("Unable to draw hit graph from cached scene canvas. "+e.message)}return this}}),t.Util.extend(t.Shape,t.Node),t.Factory.addGetterSetter(t.Shape,"stroke"),t.Factory.addDeprecatedGetterSetter(t.Shape,"strokeRed",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"strokeGreen",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"strokeBlue",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"strokeAlpha",1,t.Validators.alphaComponent),t.Factory.addGetterSetter(t.Shape,"strokeWidth",2),t.Factory.addGetterSetter(t.Shape,"strokeHitEnabled",!0),t.Factory.addGetterSetter(t.Shape,"perfectDrawEnabled",!0),t.Factory.addGetterSetter(t.Shape,"shadowForStrokeEnabled",!0),t.Factory.addGetterSetter(t.Shape,"lineJoin"),t.Factory.addGetterSetter(t.Shape,"lineCap"),t.Factory.addGetterSetter(t.Shape,"sceneFunc"),t.Factory.addGetterSetter(t.Shape,"hitFunc"),t.Factory.addGetterSetter(t.Shape,"dash"),t.Factory.addGetterSetter(t.Shape,"dashOffset",0),t.Factory.addGetterSetter(t.Shape,"shadowColor"),t.Factory.addDeprecatedGetterSetter(t.Shape,"shadowRed",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"shadowGreen",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"shadowBlue",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"shadowAlpha",1,t.Validators.alphaComponent),t.Factory.addGetterSetter(t.Shape,"shadowBlur"),t.Factory.addGetterSetter(t.Shape,"shadowOpacity"),t.Factory.addComponentsGetterSetter(t.Shape,"shadowOffset",["x","y"]),t.Factory.addGetterSetter(t.Shape,"shadowOffsetX",0),t.Factory.addGetterSetter(t.Shape,"shadowOffsetY",0),t.Factory.addGetterSetter(t.Shape,"fillPatternImage"),t.Factory.addGetterSetter(t.Shape,"fill"),t.Factory.addDeprecatedGetterSetter(t.Shape,"fillRed",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"fillGreen",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"fillBlue",0,t.Validators.RGBComponent),t.Factory.addDeprecatedGetterSetter(t.Shape,"fillAlpha",1,t.Validators.alphaComponent),t.Factory.addGetterSetter(t.Shape,"fillPatternX",0),t.Factory.addGetterSetter(t.Shape,"fillPatternY",0),t.Factory.addGetterSetter(t.Shape,"fillLinearGradientColorStops"),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientStartRadius",0),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientEndRadius",0),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientColorStops"),t.Factory.addGetterSetter(t.Shape,"fillPatternRepeat","repeat"),t.Factory.addGetterSetter(t.Shape,"fillEnabled",!0),t.Factory.addGetterSetter(t.Shape,"strokeEnabled",!0),t.Factory.addGetterSetter(t.Shape,"shadowEnabled",!0),t.Factory.addGetterSetter(t.Shape,"dashEnabled",!0),t.Factory.addGetterSetter(t.Shape,"strokeScaleEnabled",!0),t.Factory.addGetterSetter(t.Shape,"fillPriority","color"),t.Factory.addComponentsGetterSetter(t.Shape,"fillPatternOffset",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillPatternOffsetX",0),t.Factory.addGetterSetter(t.Shape,"fillPatternOffsetY",0),t.Factory.addComponentsGetterSetter(t.Shape,"fillPatternScale",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillPatternScaleX",1),t.Factory.addGetterSetter(t.Shape,"fillPatternScaleY",1),t.Factory.addComponentsGetterSetter(t.Shape,"fillLinearGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillLinearGradientStartPointX",0),t.Factory.addGetterSetter(t.Shape,"fillLinearGradientStartPointY",0),t.Factory.addComponentsGetterSetter(t.Shape,"fillLinearGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillLinearGradientEndPointX",0),t.Factory.addGetterSetter(t.Shape,"fillLinearGradientEndPointY",0),t.Factory.addComponentsGetterSetter(t.Shape,"fillRadialGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientStartPointX",0),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientStartPointY",0),t.Factory.addComponentsGetterSetter(t.Shape,"fillRadialGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientEndPointX",0),t.Factory.addGetterSetter(t.Shape,"fillRadialGradientEndPointY",0),t.Factory.addGetterSetter(t.Shape,"fillPatternRotation",0),t.Factory.backCompat(t.Shape,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"}),t.Collection.mapMethods(t.Shape)}(Konva),function(){"use strict";function t(t,e){t.content.addEventListener(e,function(n){t[i+e](n)},!1)}var e="mouseout",n="mouseleave",i="_",a=["mousedown","mousemove","mouseup",e,"touchstart","touchmove","touchend","mouseover","wheel","contextmenu"],o=a.length;Konva.Stage=function(t){this.___init(t)},Konva.Util.addMethods(Konva.Stage,{___init:function(t){this.nodeType="Stage",Konva.Container.call(this,t),this._id=Konva.idCounter++,this._buildDOM(),this._bindContentEvents(),this._enableNestedTransforms=!1,Konva.stages.push(this)},_validateAdd:function(t){"Layer"!==t.getType()&&Konva.Util.throw("You may only add layers to the stage.")},setContainer:function(t){if("string"==typeof t){if("."===t.charAt(0)){var e=t.slice(1);t=Konva.document.getElementsByClassName(e)[0]}else{var n;n="#"!==t.charAt(0)?t:t.slice(1),t=Konva.document.getElementById(n)}if(!t)throw"Can not find container in document with id "+n}return this._setAttr("container",t),this},shouldDrawHit:function(){return!0},draw:function(){return Konva.Node.prototype.draw.call(this),this},setHeight:function(t){return Konva.Node.prototype.setHeight.call(this,t),this._resizeDOM(),this},setWidth:function(t){return Konva.Node.prototype.setWidth.call(this,t),this._resizeDOM(),this},clear:function(){var t,e=this.children,n=e.length;for(t=0;t-1&&Konva.stages.splice(e,1),this},getPointerPosition:function(){return this.pointerPos},getStage:function(){return this},getContent:function(){return this.content},toDataURL:function(t){var e=(t=t||{}).mimeType||null,n=t.quality||null,i=t.x||0,a=t.y||0,o=new Konva.SceneCanvas({width:t.width||this.getWidth(),height:t.height||this.getHeight(),pixelRatio:t.pixelRatio}),r=o.getContext()._context,s=this.children;(i||a)&&r.translate(-1*i,-1*a),s.each(function(t){var e=t.getCanvas().getWidth(),n=t.getCanvas().getHeight(),i=t.getCanvas().getPixelRatio();r.drawImage(t.getCanvas()._canvas,0,0,e/i,n/i)});var h=o.toDataURL(e,n);return t.callback&&t.callback(h),h},toImage:function(t){var e=t.callback;t.callback=function(t){Konva.Util._getImage(t,function(t){e(t)})},this.toDataURL(t)},getIntersection:function(t,e){var n,i,a=this.getChildren();for(n=a.length-1;n>=0;n--)if(i=a[n].getIntersection(t,e))return i;return null},_resizeDOM:function(){if(this.content){var t,e,n=this.getWidth(),i=this.getHeight(),a=this.getChildren(),o=a.length;for(this.content.style.width=n+"px",this.content.style.height=i+"px",this.bufferCanvas.setSize(n,i),this.bufferHitCanvas.setSize(n,i),t=0;t1){for(var e=0;e0){var a=t.touches[0];n=a.clientX-e.left,i=a.clientY-e.top}}else n=t.clientX-e.left,i=t.clientY-e.top;null!==n&&null!==i&&(this.pointerPos={x:n,y:i})},_getContentPosition:function(){var t=this.content.getBoundingClientRect?this.content.getBoundingClientRect():{top:0,left:0};return{top:t.top,left:t.left}},_buildDOM:function(){if(this.bufferCanvas=new Konva.SceneCanvas,this.bufferHitCanvas=new Konva.HitCanvas({pixelRatio:1}),Konva.isBrowser){var t=this.getContainer();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=Konva.document.createElement("div"),this.content.style.position="relative",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}},_onContent:function(t,e){var n,i,a=t.split(" "),o=a.length;for(n=0;n0?{antialiased:!0}:{}},drawScene:function(t,e){var n=this.getLayer(),i=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.getClearBeforeDraw()&&i.getContext().clear(),Konva.Container.prototype.drawScene.call(this,i,e),this._fire("draw",{node:this}),this},drawHit:function(t,e){var n=this.getLayer(),i=t||n&&n.hitCanvas;return n&&n.getClearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Konva.Container.prototype.drawHit.call(this,i,e),this.imageData=null,this},clear:function(t){return Konva.BaseLayer.prototype.clear.call(this,t),this.getHitCanvas().getContext().clear(t),this.imageData=null,this},setVisible:function(t){return Konva.Node.prototype.setVisible.call(this,t),t?(this.getCanvas()._canvas.style.display="block",this.hitCanvas._canvas.style.display="block"):(this.getCanvas()._canvas.style.display="none",this.hitCanvas._canvas.style.display="none"),this},enableHitGraph:function(){return this.setHitGraphEnabled(!0),this},disableHitGraph:function(){return this.setHitGraphEnabled(!1),this},setSize:function(t,e){return Konva.BaseLayer.prototype.setSize.call(this,t,e),this.hitCanvas.setSize(t,e),this}}),Konva.Util.extend(Konva.Layer,Konva.BaseLayer),Konva.Factory.addGetterSetter(Konva.Layer,"hitGraphEnabled",!0),Konva.Collection.mapMethods(Konva.Layer)}(),function(){"use strict";Konva.FastLayer=function(t){this.____init(t)},Konva.Util.addMethods(Konva.FastLayer,{____init:function(t){this.nodeType="Layer",this.canvas=new Konva.SceneCanvas,Konva.BaseLayer.call(this,t)},_validateAdd:function(t){"Shape"!==t.getType()&&Konva.Util.throw("You may only add shapes to a fast layer.")},_setCanvasSize:function(t,e){this.canvas.setSize(t,e)},hitGraphEnabled:function(){return!1},getIntersection:function(){return null},drawScene:function(t){var e=this.getLayer(),n=t||e&&e.getCanvas();return this.getClearBeforeDraw()&&n.getContext().clear(),Konva.Container.prototype.drawScene.call(this,n),this},draw:function(){return this.drawScene(),this},setVisible:function(t){return Konva.Node.prototype.setVisible.call(this,t),this.getCanvas()._canvas.style.display=t?"block":"none",this}}),Konva.Util.extend(Konva.FastLayer,Konva.BaseLayer),Konva.Collection.mapMethods(Konva.FastLayer)}(),function(){"use strict";Konva.Group=function(t){this.___init(t)},Konva.Util.addMethods(Konva.Group,{___init:function(t){this.nodeType="Group",Konva.Container.call(this,t)},_validateAdd:function(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&Konva.Util.throw("You may only add groups and shapes to groups.")}}),Konva.Util.extend(Konva.Group,Konva.Container),Konva.Collection.mapMethods(Konva.Group)}(),function(t){"use strict";function e(){return i.apply(t.global,arguments)}var n=t.global.performance&&t.global.performance.now?function(){return t.global.performance.now()}:function(){return(new Date).getTime()},i=t.global.requestAnimationFrame||t.global.webkitRequestAnimationFrame||t.global.mozRequestAnimationFrame||t.global.oRequestAnimationFrame||t.global.msRequestAnimationFrame||function(t){setTimeout(t,1e3/60)};t.Animation=function(e,i){var a=t.Animation;this.func=e,this.setLayers(i),this.id=a.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:n()}},t.Animation.prototype={setLayers:function(t){var e=[];return e=t?t.length>0?t:[t]:[],this.layers=e,this},getLayers:function(){return this.layers},addLayer:function(t){var e,n=this.layers,i=n.length;for(e=0;ethis.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())},getTime:function(){return this._time},setPosition:function(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t},getPosition:function(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)},play:function(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")},reverse:function(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")},seek:function(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")},reset:function(){this.pause(),this._time=0,this.update(),this.fire("onReset")},finish:function(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")},update:function(){this.setPosition(this.getPosition(this._time))},onEnterFrame:function(){var t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)},pause:function(){this.state=1,this.fire("onPause")},getTimer:function(){return(new Date).getTime()}},Konva.Tween=function(n){var a,o,r=this,s=n.node,h=s._id,c=n.easing||Konva.Easings.Linear,l=!!n.yoyo;a=void 0===n.duration?1:0===n.duration?.001:n.duration,this.node=s,this._id=e++;var d=s.getLayer()||(s instanceof Konva.Stage?s.getLayers():null);d||Konva.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Konva.Animation(function(){r.tween.onEnterFrame()},d),this.tween=new i(o,function(t){r._tweenFunc(t)},c,0,1,1e3*a,l),this._addListeners(),Konva.Tween.attrs[h]||(Konva.Tween.attrs[h]={}),Konva.Tween.attrs[h][this._id]||(Konva.Tween.attrs[h][this._id]={}),Konva.Tween.tweens[h]||(Konva.Tween.tweens[h]={});for(o in n)void 0===t[o]&&this._addAttr(o,n[o]);this.reset(),this.onFinish=n.onFinish,this.onReset=n.onReset},Konva.Tween.attrs={},Konva.Tween.tweens={},Konva.Tween.prototype={_addAttr:function(t,e){var i,a,o,r,s,h,c,l=this.node,d=l._id;if((o=Konva.Tween.tweens[d][t])&&delete Konva.Tween.attrs[d][o][t],i=l.getAttr(t),Konva.Util._isArray(e))for(a=[],s=Math.max(e.length,i.length),"points"===t&&e.length!==i.length&&(e.length>i.length?(c=i,i=Konva.Util._prepareArrayForTween(i,e,l.closed())):(h=e,e=Konva.Util._prepareArrayForTween(e,i,l.closed()))),r=0;rl)for(;_.length>0;){for(var S=0,K=_.length,x="",C=0;S>>1,b=_.slice(0,w+1),F=this._getTextWidth(b);F<=l?(S=w+1,x=b,C=F):K=w}if(!x)break;if(g){var T=Math.max(x.lastIndexOf(" "),x.lastIndexOf("-"))+1;T>0&&(S=T,x=x.slice(0,S),C=this._getTextWidth(x))}if(this._addTextLine(x),i=Math.max(i,C),u+=a,!v||h&&u+a>d)break;if((_=_.slice(S)).length>0&&(y=this._getTextWidth(_))<=l){this._addTextLine(_),u+=a,i=Math.max(i,y);break}}else this._addTextLine(_),u+=a,i=Math.max(i,y);if(h&&u+a>d)break}t().restore(),this.textHeight=n,this.textWidth=i}},Konva.Util.extend(Konva.Text,Konva.Shape),Konva.Factory.addGetterSetter(Konva.Text,"fontFamily","Arial"),Konva.Factory.addGetterSetter(Konva.Text,"fontSize",12),Konva.Factory.addGetterSetter(Konva.Text,"fontStyle","normal"),Konva.Factory.addGetterSetter(Konva.Text,"fontVariant","normal"),Konva.Factory.addGetterSetter(Konva.Text,"padding",0),Konva.Factory.addGetterSetter(Konva.Text,"align","left"),Konva.Factory.addGetterSetter(Konva.Text,"lineHeight",1),Konva.Factory.addGetterSetter(Konva.Text,"wrap","word"),Konva.Factory.addGetterSetter(Konva.Text,"letterSpacing",0),Konva.Factory.addGetter(Konva.Text,"text",""),Konva.Factory.addOverloadedGetterSetter(Konva.Text,"text"),Konva.Factory.addGetterSetter(Konva.Text,"textDecoration",""),Konva.Collection.mapMethods(Konva.Text)}(),function(){"use strict";Konva.Line=function(t){this.___init(t)},Konva.Line.prototype={___init:function(t){Konva.Shape.call(this,t),this.className="Line",this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")}),this.sceneFunc(this._sceneFunc)},_sceneFunc:function(t){var e,n,i,a=this.getPoints(),o=a.length,r=this.getTension(),s=this.getClosed(),h=this.getBezier();if(o){if(t.beginPath(),t.moveTo(a[0],a[1]),0!==r&&o>4){for(n=(e=this.getTensionPoints()).length,i=s?0:4,s||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);ih?s:h,v=s>h?1:s/h,g=s>h?h/s:1;t.translate(o,r),t.rotate(d),t.scale(v,g),t.arc(0,0,f,c,c+l,1-u),t.scale(1/v,1/g),t.rotate(-d),t.translate(-o,-r);break;case"z":t.closePath()}}t.fillStrokeShape(this)},getSelfRect:function(){var t=[];this.dataArray.forEach(function(e){t=t.concat(e.points)});for(var e,n,i=t[0],a=t[0],o=t[1],r=t[1],s=0;s0&&""===l[0]&&l.shift();for(var d=0;d0&&!isNaN(l[0]);){var u,f,v,g,p,m,_,y,S,K,x=null,C=[],w=r,b=s;switch(c){case"l":r+=l.shift(),s+=l.shift(),x="L",C.push(r,s);break;case"L":r=l.shift(),s=l.shift(),C.push(r,s);break;case"m":var F=l.shift(),T=l.shift();if(r+=F,s+=T,x="M",o.length>2&&"z"===o[o.length-1].command)for(var P=o.length-2;P>=0;P--)if("M"===o[P].command){r=o[P].points[0]+F,s=o[P].points[1]+T;break}C.push(r,s),c="l";break;case"M":r=l.shift(),s=l.shift(),x="M",C.push(r,s),c="L";break;case"h":r+=l.shift(),x="L",C.push(r,s);break;case"H":r=l.shift(),x="L",C.push(r,s);break;case"v":s+=l.shift(),x="L",C.push(r,s);break;case"V":s=l.shift(),x="L",C.push(r,s);break;case"C":C.push(l.shift(),l.shift(),l.shift(),l.shift()),r=l.shift(),s=l.shift(),C.push(r,s);break;case"c":C.push(r+l.shift(),s+l.shift(),r+l.shift(),s+l.shift()),r+=l.shift(),s+=l.shift(),x="C",C.push(r,s);break;case"S":f=r,v=s,"C"===(u=o[o.length-1]).command&&(f=r+(r-u.points[2]),v=s+(s-u.points[3])),C.push(f,v,l.shift(),l.shift()),r=l.shift(),s=l.shift(),x="C",C.push(r,s);break;case"s":f=r,v=s,"C"===(u=o[o.length-1]).command&&(f=r+(r-u.points[2]),v=s+(s-u.points[3])),C.push(f,v,r+l.shift(),s+l.shift()),r+=l.shift(),s+=l.shift(),x="C",C.push(r,s);break;case"Q":C.push(l.shift(),l.shift()),r=l.shift(),s=l.shift(),C.push(r,s);break;case"q":C.push(r+l.shift(),s+l.shift()),r+=l.shift(),s+=l.shift(),x="Q",C.push(r,s);break;case"T":f=r,v=s,"Q"===(u=o[o.length-1]).command&&(f=r+(r-u.points[0]),v=s+(s-u.points[1])),r=l.shift(),s=l.shift(),x="Q",C.push(f,v,r,s);break;case"t":f=r,v=s,"Q"===(u=o[o.length-1]).command&&(f=r+(r-u.points[0]),v=s+(s-u.points[1])),r+=l.shift(),s+=l.shift(),x="Q",C.push(f,v,r,s);break;case"A":g=l.shift(),p=l.shift(),m=l.shift(),_=l.shift(),y=l.shift(),S=r,K=s,r=l.shift(),s=l.shift(),x="A",C=this.convertEndpointToCenterParameterization(S,K,r,s,_,y,g,p,m);break;case"a":g=l.shift(),p=l.shift(),m=l.shift(),_=l.shift(),y=l.shift(),S=r,K=s,r+=l.shift(),s+=l.shift(),x="A",C=this.convertEndpointToCenterParameterization(S,K,r,s,_,y,g,p,m)}o.push({command:x||c,points:C,start:{x:w,y:b},pathLength:this.calcLength(w,b,x||c,C)})}"z"!==c&&"Z"!==c||o.push({command:"z",points:[],start:void 0,pathLength:0})}return o},Konva.Path.calcLength=function(t,e,n,i){var a,o,r,s,h=Konva.Path;switch(n){case"L":return h.getLineLength(t,e,i[0],i[1]);case"C":for(a=0,o=h.getPointOnCubicBezier(0,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),s=.01;s<=1;s+=.01)r=h.getPointOnCubicBezier(s,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),a+=h.getLineLength(o.x,o.y,r.x,r.y),o=r;return a;case"Q":for(a=0,o=h.getPointOnQuadraticBezier(0,t,e,i[0],i[1],i[2],i[3]),s=.01;s<=1;s+=.01)r=h.getPointOnQuadraticBezier(s,t,e,i[0],i[1],i[2],i[3]),a+=h.getLineLength(o.x,o.y,r.x,r.y),o=r;return a;case"A":a=0;var c=i[4],l=i[5],d=i[4]+l,u=Math.PI/180;if(Math.abs(c-d)d;s-=u)r=h.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),a+=h.getLineLength(o.x,o.y,r.x,r.y),o=r;else for(s=c+u;s1&&(r*=Math.sqrt(u),s*=Math.sqrt(u));var f=Math.sqrt((r*r*(s*s)-r*r*(d*d)-s*s*(l*l))/(r*r*(d*d)+s*s*(l*l)));a===o&&(f*=-1),isNaN(f)&&(f=0);var v=f*r*d/s,g=f*-s*l/r,p=(t+n)/2+Math.cos(c)*v-Math.sin(c)*g,m=(e+i)/2+Math.sin(c)*v+Math.cos(c)*g,_=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(_(t)*_(e))},S=function(t,e){return(t[0]*e[1]=1&&(w=0),0===o&&w>0&&(w-=2*Math.PI),1===o&&w<0&&(w+=2*Math.PI),[p,m,r,s,K,w,c,o]},Konva.Factory.addGetterSetter(Konva.Path,"data"),Konva.Collection.mapMethods(Konva.Path)}(),function(){"use strict";function t(t){t.fillText(this.partialText,0,0)}function e(t){t.strokeText(this.partialText,0,0)}Konva.TextPath=function(t){this.___init(t)},Konva.TextPath.prototype={___init:function(n){var i=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(){i.dataArray=Konva.Path.parsePathData(this.attrs.data),i._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva",i._setTextData),i._setTextData(),this.sceneFunc(this._sceneFunc),this.hitFunc(this._hitFunc)},_sceneFunc:function(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.getTextBaseline()),t.setAttr("textAlign","left"),t.save();var e=this.textDecoration(),n=this.fill(),i=this.fontSize(),a=this.glyphInfo;"underline"===e&&t.beginPath();for(var o=0;o=1){var n=e[0].p0;t.moveTo(n.x,n.y)}for(var i=0;i0&&(o+=t.dataArray[r].pathLength);var s=0;"center"===i&&(s=Math.max(0,o/2-a/2)),"right"===i&&(s=Math.max(0,o-a));for(var h,c,l,d=this.getText().split(""),u=this.getText().split(" ").length-1,f=-1,v=0,g=function(){v=0;for(var e=t.dataArray,n=f+1;n0)return f=n,e[n];"M"===e[n].command&&(h={x:e[n].points[0],y:e[n].points[1]})}return{}},p=function(e){var r=t._getTextSize(e).width+n;" "===e&&"justify"===i&&(r+=(o-a)/u);var s=0,d=0;for(c=void 0;Math.abs(r-s)/r>.01&&d<25;){d++;for(var f=s;void 0===l;)(l=g())&&f+l.pathLengthr?c=Konva.Path.getPointOnLine(r,h.x,h.y,l.points[0],l.points[1],h.x,h.y):l=void 0;break;case"A":var m=l.points[4],_=l.points[5],y=l.points[4]+_;0===v?v=m+1e-8:r>s?v+=Math.PI/180*_/Math.abs(_):v-=Math.PI/360*_/Math.abs(_),(_<0&&v=0&&v>y)&&(v=y,p=!0),c=Konva.Path.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],v,l.points[6]);break;case"C":0===v?v=r>l.pathLength?1e-8:r/l.pathLength:r>s?v+=(r-s)/l.pathLength:v-=(s-r)/l.pathLength,v>1&&(v=1,p=!0),c=Konva.Path.getPointOnCubicBezier(v,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3],l.points[4],l.points[5]);break;case"Q":0===v?v=r/l.pathLength:r>s?v+=(r-s)/l.pathLength:v-=(s-r)/l.pathLength,v>1&&(v=1,p=!0),c=Konva.Path.getPointOnQuadraticBezier(v,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3])}void 0!==c&&(s=Konva.Path.getLineLength(h.x,h.y,c.x,c.y)),p&&(p=!1,l=void 0)}},m=t._getTextSize("C").width+n,_=0;_