diff --git a/CHANGELOG.md b/CHANGELOG.md index b38d8821..0669eaed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [Not released][Not released] +## [0.10.0][2015-10-27] ### Added - RGBA filter. Thanks to [@codefo](https://github.com/codefo) diff --git a/konva.js b/konva.js index c9af5507..8ffe35d8 100644 --- a/konva.js +++ b/konva.js @@ -1,9 +1,9 @@ /* - * Konva JavaScript Framework v0.9.9 + * Konva JavaScript Framework v0.10.0 * http://konvajs.github.io/ * Licensed under the MIT or GPL Version 2 licenses. - * Date: Thu Oct 22 2015 + * Date: Tue Oct 27 2015 * * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS) * Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva) @@ -37,7 +37,7 @@ var Konva = {}; Konva = { // public - version: '0.9.9', + version: '0.10.0', // private stages: [], diff --git a/konva.min.js b/konva.min.js index cb5739fa..596a6325 100644 --- a/konva.min.js +++ b/konva.min.js @@ -1,8 +1,8 @@ /* - * Konva JavaScript Framework v0.9.9 + * Konva JavaScript Framework v0.10.0 * http://konvajs.github.io/ * Licensed under the MIT or GPL Version 2 licenses. - * Date: Thu Oct 22 2015 + * Date: Tue Oct 27 2015 * * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS) * Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva) @@ -26,7 +26,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -var Konva={};!function(t){"use strict";var e=Math.PI/180;Konva={version:"0.9.9",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:{},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(t){var n=this.names[t];if(n){for(var a=0;a"),Konva.window=Konva.document.parentWindow,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(){"use strict";return Konva}),function(){"use strict";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;et;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]=a,this.m[3]=i,this.m[4]=o,this.m[5]=r,this},invert:function(){var t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,n=-this.m[1]*t,a=-this.m[2]*t,i=this.m[0]*t,o=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),r=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=n,this.m[2]=a,this.m[3]=i,this.m[4]=o,this.m[5]=r,this},getMatrix:function(){return this.m},setAbsolutePosition:function(t,e){var n=this.m[0],a=this.m[1],i=this.m[2],o=this.m[3],r=this.m[4],s=this.m[5],h=(n*(e-s)-a*(t-r))/(n*o-a*i),c=(t-r-i*h)/n;return this.translate(c,h)}};var t="2d",e="[object Array]",n="[object Number]",a="[object String]",i=Math.PI/180,o=180/Math.PI,r="#",s="",h="0",c="Konva warning: ",l="Konva error: ",d="rgb(",u={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},v=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;Konva.Util={_isElement:function(t){return!(!t||1!=t.nodeType)},_isFunction:function(t){return!!(t&&t.constructor&&t.call&&t.apply)},_isObject:function(t){return!!t&&t.constructor===Object},_isArray:function(t){return Object.prototype.toString.call(t)===e},_isNumber:function(t){return Object.prototype.toString.call(t)===n},_isString:function(t){return Object.prototype.toString.call(t)===a},_throttle:function(t,e,n){var a,i,o,r=null,s=0,h=n||{},c=function(){s=h.leading===!1?0:(new Date).getTime(),r=null,o=t.apply(a,i),a=i=null};return function(){var n=(new Date).getTime();s||h.leading!==!1||(s=n);var l=e-(n-s);return a=this,i=arguments,0>=l?(clearTimeout(r),r=null,s=n,o=t.apply(a,i),a=i=null):r||h.trailing===!1||(r=setTimeout(c,l)),o}},_hasMethods:function(t){var e,n=[];for(e in t)t.hasOwnProperty(e)&&this._isFunction(t[e])&&n.push(e);return n.length>0},createCanvasElement:function(){var t=Konva.document.createElement("canvas");try{t.style=t.style||{}}catch(e){}return t},isBrowser:function(){return"object"!=typeof exports},_isInDocument:function(t){for(;t=t.parentNode;)if(t==Konva.document)return!0;return!1},_simplifyArray:function(t){var e,n,a=[],i=t.length,o=Konva.Util;for(e=0;i>e;e++)n=t[e],o._isNumber(n)?n=Math.round(1e3*n)/1e3:o._isString(n)||(n=n.toString()),a.push(n);return a},_getImage:function(e,n){var a,i;if(e)if(this._isElement(e))n(e);else if(this._isString(e))a=new Konva.window.Image,a.onload=function(){n(a)},a.src=e;else if(e.data){i=Konva.Util.createCanvasElement(),i.width=e.width,i.height=e.height;var o=i.getContext(t);o.putImageData(e,0,0),this._getImage(i.toDataURL(),n)}else n(null);else n(null)},_getRGBAString:function(t){var e=t.red||0,n=t.green||0,a=t.blue||0,i=t.alpha||1;return["rgba(",e,",",n,",",a,",",i,")"].join(s)},_rgbToHex:function(t,e,n){return((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1)},_hexToRgb:function(t){t=t.replace(r,s);var e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor:function(){for(var t=(16777215*Math.random()<<0).toString(16);t.length<6;)t=h+t;return r+t},get:function(t,e){return void 0===t?e:t},getRGB:function(t){var e;return t in u?(e=u[t],{r:e[0],g:e[1],b:e[2]}):t[0]===r?this._hexToRgb(t.substring(1)):t.substr(0,4)===d?(e=v.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:function(t){return t=t||"black",Konva.Util._namedColorToRBA(t)||Konva.Util._hex3ColorToRGBA(t)||Konva.Util._hex6ColorToRGBA(t)||Konva.Util._rgbColorToRGBA(t)||Konva.Util._rgbaColorToRGBA(t)},_namedColorToRBA:function(t){var e=u[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA:function(t){if(0===t.indexOf("rgb(")){t=t.match(/rgb\(([^)]+)\)/)[1];var e=t.split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA:function(t){if(0===t.indexOf("rgba(")){t=t.match(/rgba\(([^)]+)\)/)[1];var e=t.split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex6ColorToRGBA:function(t){return"#"===t[0]&&7===t.length?{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}:void 0},_hex3ColorToRGBA:function(t){return"#"===t[0]&&4===t.length?{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}:void 0},_merge:function(t,e){var n=this._clone(e);for(var a in t)this._isObject(t[a])?n[a]=this._merge(t[a],n[a]):n[a]=t[a];return n},cloneObject:function(t){var e={};for(var n in t)this._isObject(t[n])?e[n]=this.cloneObject(t[n]):this._isArray(t[n])?e[n]=this.cloneArray(t[n]):e[n]=t[n];return e},cloneArray:function(t){return t.slice(0)},_degToRad:function(t){return t*i},_radToDeg:function(t){return t*o},_capitalize:function(t){return t.charAt(0).toUpperCase()+t.slice(1)},"throw":function(t){throw new Error(l+t)},error:function(t){console.error(l+t)},warn:function(t){Konva.root.console&&console.warn&&Konva.showWarnings&&console.warn(c+t)},extend:function(t,e){function n(){this.constructor=t}n.prototype=e.prototype;var a=t.prototype;t.prototype=new n;for(var i in a)a.hasOwnProperty(i)&&(t.prototype[i]=a[i]);t.__super__=e.prototype,t["super"]=e},addMethods:function(t,e){var n;for(n in e)t.prototype[n]=e[n]},_getControlPoints:function(t,e,n,a,i,o,r){var s=Math.sqrt(Math.pow(n-t,2)+Math.pow(a-e,2)),h=Math.sqrt(Math.pow(i-n,2)+Math.pow(o-a,2)),c=r*s/(s+h),l=r*h/(s+h),d=n-c*(i-t),u=a-c*(o-e),v=n+l*(i-t),f=a+l*(o-e);return[d,u,v,f]},_expandPoints:function(t,e){var n,a,i=t.length,o=[];for(n=2;i-2>n;n+=2)a=Konva.Util._getControlPoints(t[n-2],t[n-1],t[n],t[n+1],t[n+2],t[n+3],e),o.push(a[0]),o.push(a[1]),o.push(t[n]),o.push(t[n+1]),o.push(a[2]),o.push(a[3]);return o},_removeLastLetter:function(t){return t.substring(0,t.length-1)},each:function(t,e){for(var n in t)e(n,t[n])},_getProjectionToSegment:function(t,e,n,a,i,o){var r,s,h,c=(t-n)*(t-n)+(e-a)*(e-a);if(0==c)r=t,s=e,h=(i-n)*(i-n)+(o-a)*(o-a);else{var l=((i-t)*(n-t)+(o-e)*(a-e))/c;0>l?(r=t,s=e,h=(t-i)*(t-i)+(e-o)*(e-o)):l>1?(r=n,s=a,h=(n-i)*(n-i)+(a-o)*(a-o)):(r=t+l*(n-t),s=e+l*(a-e),h=(r-i)*(r-i)+(s-o)*(s-o))}return[r,s,h]},_getProjectionToLine:function(t,e,n){var a=Konva.Util.cloneObject(t),i=Number.MAX_VALUE;return e.forEach(function(o,r){if(n||r!==e.length-1){var s=e[(r+1)%e.length],h=Konva.Util._getProjectionToSegment(o.x,o.y,s.x,s.y,t.x,t.y),c=h[0],l=h[1],d=h[2];i>d&&(a.x=c,a.y=l,i=d)}}),a},_prepareArrayForTween:function(t,e,n){var a,i=[],o=[];if(t.length>e.length){var r=e;e=t,t=r}for(a=0;ac;c++)l=v[c],d=l.method,d?(u=l.args,g+=d,g+=h?r:Konva.Util._isArray(u[0])?a+u.join(t)+i:e+u.join(t)+n):(g+=l.property,h||(g+=s+l.val)),g+=o;return g},clearTrace:function(){this.traceArr=[]},_trace:function(t){var e,n=this.traceArr;n.push(t),e=n.length,e>=Konva.traceArrMax&&n.shift()},reset:function(){var t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)},getCanvas:function(){return this.canvas},clear:function(t){var e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)},_applyLineCap:function(t){var e=t.getLineCap();e&&this.setAttr("lineCap",e)},_applyOpacity:function(t){var e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)},_applyLineJoin:function(t){var e=t.getLineJoin();e&&this.setAttr("lineJoin",e)},setAttr:function(t,e){this._context[t]=e},arc:function(){var t=arguments;this._context.arc(t[0],t[1],t[2],t[3],t[4],t[5])},beginPath:function(){this._context.beginPath()},bezierCurveTo:function(){var t=arguments;this._context.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5])},clearRect:function(){var t=arguments;this._context.clearRect(t[0],t[1],t[2],t[3])},clip:function(){this._context.clip()},closePath:function(){this._context.closePath()},createImageData:function(){var t=arguments;return 2===t.length?this._context.createImageData(t[0],t[1]):1===t.length?this._context.createImageData(t[0]):void 0},createLinearGradient:function(){var t=arguments;return this._context.createLinearGradient(t[0],t[1],t[2],t[3])},createPattern:function(){var t=arguments;return this._context.createPattern(t[0],t[1])},createRadialGradient:function(){var t=arguments;return this._context.createRadialGradient(t[0],t[1],t[2],t[3],t[4],t[5])},drawImage:function(){var t=arguments,e=this._context;3===t.length?e.drawImage(t[0],t[1],t[2]):5===t.length?e.drawImage(t[0],t[1],t[2],t[3],t[4]):9===t.length&&e.drawImage(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},isPointInPath:function(t,e){return this._context.isPointInPath(t,e)},fill:function(){this._context.fill()},fillRect:function(t,e,n,a){this._context.fillRect(t,e,n,a)},strokeRect:function(t,e,n,a){this._context.strokeRect(t,e,n,a)},fillText:function(){var t=arguments;this._context.fillText(t[0],t[1],t[2])},measureText:function(t){return this._context.measureText(t)},getImageData:function(){var t=arguments;return this._context.getImageData(t[0],t[1],t[2],t[3])},lineTo:function(){var t=arguments;this._context.lineTo(t[0],t[1])},moveTo:function(){var t=arguments;this._context.moveTo(t[0],t[1])},rect:function(){var t=arguments;this._context.rect(t[0],t[1],t[2],t[3])},putImageData:function(){var t=arguments;this._context.putImageData(t[0],t[1],t[2])},quadraticCurveTo:function(){var t=arguments;this._context.quadraticCurveTo(t[0],t[1],t[2],t[3])},restore:function(){this._context.restore()},rotate:function(){var t=arguments;this._context.rotate(t[0])},save:function(){this._context.save()},scale:function(){var t=arguments;this._context.scale(t[0],t[1])},setLineDash:function(){var t=arguments,e=this._context;this._context.setLineDash?e.setLineDash(t[0]):"mozDash"in e?e.mozDash=t[0]:"webkitLineDash"in e&&(e.webkitLineDash=t[0])},getLineDash:function(){return this._context.getLineDash()},setTransform:function(){var t=arguments;this._context.setTransform(t[0],t[1],t[2],t[3],t[4],t[5])},stroke:function(){this._context.stroke()},strokeText:function(){var t=arguments;this._context.strokeText(t[0],t[1],t[2])},transform:function(){var t=arguments;this._context.transform(t[0],t[1],t[2],t[3],t[4],t[5])},translate:function(){var t=arguments;this._context.translate(t[0],t[1])},_enableTrace:function(){var t,e,n=this,a=h.length,i=Konva.Util._simplifyArray,o=this.setAttr,r=function(t){var a,o=n[t];n[t]=function(){return e=i(Array.prototype.slice.call(arguments,0)),a=o.apply(n,arguments),"clearRect"===t&&(e[2]=e[2]/n.canvas.getPixelRatio(),e[3]=e[3]/n.canvas.getPixelRatio()),n._trace({method:t,args:e}),a}};for(t=0;a>t;t++)r(h[t]);n.setAttr=function(){o.apply(n,arguments),n._trace({property:arguments[0],val:arguments[1]})}}},c.forEach(function(t){Object.defineProperty(Konva.Context.prototype,t,{get:function(){return this._context[t]},set:function(e){this._context[t]=e}})}),Konva.SceneContext=function(t){Konva.Context.call(this,t)},Konva.SceneContext.prototype={_fillColor:function(t){var e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)},_fillPattern:function(t){var e=t.getFillPatternX(),n=t.getFillPatternY(),a=t.getFillPatternScale(),i=Konva.getAngle(t.getFillPatternRotation()),o=t.getFillPatternOffset();(e||n)&&this.translate(e||0,n||0),i&&this.rotate(i),a&&this.scale(a.x,a.y),o&&this.translate(-1*o.x,-1*o.y),this.setAttr("fillStyle",this.createPattern(t.getFillPatternImage(),t.getFillPatternRepeat()||"repeat")),this.fill()},_fillLinearGradient:function(t){var e=t.getFillLinearGradientStartPoint(),n=t.getFillLinearGradientEndPoint(),a=t.getFillLinearGradientColorStops(),i=this.createLinearGradient(e.x,e.y,n.x,n.y);if(a){for(var o=0;os;s++)h=i[s],t[h]=this.getAttr(a+l(h));return t},n.prototype[u]=function(t){var e,n=this.attrs[a];o&&(t=o.call(this,t));for(e in t)t.hasOwnProperty(e)&&this._setAttr(a+l(e),t[e]);return this._fireChangeEvent(a,n,t),r&&r.call(this),this},this.addOverloadedGetterSetter(n,a)},addOverloadedGetterSetter:function(n,a){var i=Konva.Util._capitalize(a),o=e+i,r=t+i;n.prototype[a]=function(){return arguments.length?(this[o](arguments[0]),this):this[r]()}},addDeprecatedGetterSetter:function(e,n,a,i){var o=t+Konva.Util._capitalize(n),r=n+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[o]=function(){Konva.Util.error(r);var t=this.attrs[n];return void 0===t?a:t},this.addSetter(e,n,i,function(){Konva.Util.error(r)}),this.addOverloadedGetterSetter(e,n)},backCompat:function(t,e){Konva.Util.each(e,function(e,n){var a=t.prototype[n];t.prototype[e]=function(){a.apply(this,arguments),Konva.Util.error(e+" method is deprecated and will be removed soon. Use "+n+" instead")}})},afterSetFilter:function(){this._filterUpToDate=!1}},Konva.Validators={RGBComponent:function(t){return t>255?255:0>t?0:Math.round(t)},alphaComponent:function(t){return t>1?1:1e-4>t?1e-4:t}}}(),function(t){"use strict";var e="absoluteOpacity",n="absoluteTransform",a="Change",i="children",o=".",r="",s="get",h="id",c="konva",l="listening",d="mouseenter",u="mouseleave",v="name",f="set",g="Shape",p=" ",m="stage",_="transform",y="Stage",K="visible",S=["id"],C=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(p);t.Node=function(t){this._init(t)},t.Util.addMethods(t.Node,{_init:function(a){var i=this;this._id=t.idCounter++,this.eventListeners={},this.attrs={},this._cache={},this._filterUpToDate=!1,this.setAttrs(a),this.on(C,function(){this._clearCache(_),i._clearSelfAndDescendantCache(n)}),this.on("visibleChange.konva",function(){i._clearSelfAndDescendantCache(K)}),this.on("listeningChange.konva",function(){i._clearSelfAndDescendantCache(l)}),this.on("opacityChange.konva",function(){i._clearSelfAndDescendantCache(e)})},_clearCache:function(t){t?delete this._cache[t]:this._cache={}},_getCache:function(t,e){var n=this._cache[t];return void 0===n&&(this._cache[t]=e.call(this)),this._cache[t]},_clearSelfAndDescendantCache:function(t){this._clearCache(t),this.children&&this.getChildren().each(function(e){e._clearSelfAndDescendantCache(t)})},clearCache:function(){return delete this._cache.canvas,this._filterUpToDate=!1,this},cache:function(e){var n=e||{},a=this.getClientRect(!0),i=n.width||a.width,o=n.height||a.height,r=n.x||a.x,s=n.y||a.y,h=n.offset||0,c=n.drawBorder||!1;if(!i||!o)throw new Error("Width or height of caching configuration equals 0.");i+=2*h,o+=2*h,r-=h,s-=h;var l=new t.SceneCanvas({width:i,height:o}),d=new t.SceneCanvas({width:i,height:o}),u=new t.HitCanvas({pixelRatio:1,width:i,height:o}),v=l.getContext(),f=u.getContext();return u.isCache=!0,this.clearCache(),v.save(),f.save(),v.translate(-r,-s),f.translate(-r,-s),this.drawScene(l,this,!0),this.drawHit(u,this,!0),v.restore(),f.restore(),c&&(v.save(),v.beginPath(),v.rect(0,0,i,o),v.closePath(),v.setAttr("strokeStyle","red"),v.setAttr("lineWidth",5),v.stroke(),v.restore()),this._cache.canvas={scene:l,filter:d,hit:u,x:r,y:s},this},getClientRect:function(){throw new Error('abstract "getClientRect" method call')},_transformedRect:function(t){var e,n,a,i,o=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}],r=this.getTransform();return o.forEach(function(t){var o=r.point(t);void 0===e&&(e=a=o.x,n=i=o.y),e=Math.min(e,o.x),n=Math.min(n,o.y),a=Math.max(a,o.x),i=Math.max(i,o.y)}),{x:Math.round(e),y:Math.round(n),width:Math.round(a-e),height:Math.round(i-n)}},_drawCachedSceneCanvas:function(t){t.save(),t._applyOpacity(this),t.translate(this._cache.canvas.x,this._cache.canvas.y);var e=this._getCachedSceneCanvas(),n=e.pixelRatio;t.drawImage(e._canvas,0,0,e.width/n,e.height/n),t.restore()},_drawCachedHitCanvas:function(t){var e=this._cache.canvas,n=e.hit;t.save(),t.translate(this._cache.canvas.x,this._cache.canvas.y),t.drawImage(n._canvas,0,0),t.restore()},_getCachedSceneCanvas:function(){var e,n,a,i,o=this.filters(),r=this._cache.canvas,s=r.scene,h=r.filter,c=h.getContext();if(o){if(!this._filterUpToDate){var l=s.pixelRatio;try{for(e=o.length,c.clear(),c.drawImage(s._canvas,0,0,s.getWidth()/l,s.getHeight()/l),n=c.getImageData(0,0,h.getWidth(),h.getHeight()),a=0;e>a;a++)i=o[a],i.call(this,n),c.putImageData(n,0,0)}catch(d){t.Util.warn("Unable to apply filter. "+d.message)}this._filterUpToDate=!0}return h}return s},on:function(t,e){var n,a,i,s,h,c=t.split(p),l=c.length;for(n=0;l>n;n++)a=c[n],i=a.split(o),s=i[0],h=i[1]||r,this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:h,handler:e});return this},off:function(t){var e,n,a,i,r,s,h=(t||"").split(p),c=h.length;if(!t)for(n in this.eventListeners)this._off(n);for(e=0;c>e;e++)if(a=h[e],i=a.split(o),r=i[0],s=i[1],r)this.eventListeners[r]&&this._off(r,s);else for(n in this.eventListeners)this._off(n,s);return this},dispatchEvent:function(t){var e={target:this,type:t.type,evt:t};this.fire(t.type,e)},addEventListener:function(t,e){this.on(t,function(t){e.call(this,t.evt)})},removeEventListener:function(t){this.off(t)},remove:function(){var t=this.getParent();return t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),delete this.parent),this._clearSelfAndDescendantCache(m),this._clearSelfAndDescendantCache(n),this._clearSelfAndDescendantCache(K),this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(e),this},destroy:function(){t._removeId(this.getId()),t._removeName(this.getName(),this._id),this.remove()},getAttr:function(e){var n=s+t.Util._capitalize(e);return t.Util._isFunction(this[n])?this[n]():this.attrs[e]},getAncestors:function(){for(var e=this.getParent(),n=new t.Collection;e;)n.push(e),e=e.getParent();return n},getAttrs:function(){return this.attrs||{}},setAttrs:function(e){var n,a;if(!e)return this;for(n in e)n!==i&&(a=f+t.Util._capitalize(n),t.Util._isFunction(this[a])?this[a](e[n]):this._setAttr(n,e[n]));return this},isListening:function(){return this._getCache(l,this._isListening)},_isListening:function(){var t=this.getListening(),e=this.getParent();return"inherit"===t?e?e.isListening():!0:t},isVisible:function(){return this._getCache(K,this._isVisible)},_isVisible:function(){var t=this.getVisible(),e=this.getParent();return"inherit"===t?e?e.isVisible():!0:t},shouldDrawHit:function(t){var e=this.getLayer();return t&&t.isCache||e&&e.hitGraphEnabled()&&this.isListening()&&this.isVisible()},show:function(){return this.setVisible(!0),this},hide:function(){return this.setVisible(!1),this},getZIndex:function(){return this.index||0},getAbsoluteZIndex:function(){function t(h){for(e=[],n=h.length,a=0;n>a;a++)i=h[a],s++,i.nodeType!==g&&(e=e.concat(i.getChildren().toArray())),i._id===r._id&&(a=n);e.length>0&&e[0].getDepth()<=o&&t(e)}var e,n,a,i,o=this.getDepth(),r=this,s=0;return r.nodeType!==y&&t(r.getStage().getChildren()),s},getDepth:function(){ +var Konva={};!function(t){"use strict";var e=Math.PI/180;Konva={version:"0.10.0",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:{},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(t){var n=this.names[t];if(n){for(var a=0;a"),Konva.window=Konva.document.parentWindow,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(){"use strict";return Konva}),function(){"use strict";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;et;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]=a,this.m[3]=i,this.m[4]=o,this.m[5]=r,this},invert:function(){var t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,n=-this.m[1]*t,a=-this.m[2]*t,i=this.m[0]*t,o=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),r=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=n,this.m[2]=a,this.m[3]=i,this.m[4]=o,this.m[5]=r,this},getMatrix:function(){return this.m},setAbsolutePosition:function(t,e){var n=this.m[0],a=this.m[1],i=this.m[2],o=this.m[3],r=this.m[4],s=this.m[5],h=(n*(e-s)-a*(t-r))/(n*o-a*i),c=(t-r-i*h)/n;return this.translate(c,h)}};var t="2d",e="[object Array]",n="[object Number]",a="[object String]",i=Math.PI/180,o=180/Math.PI,r="#",s="",h="0",c="Konva warning: ",l="Konva error: ",d="rgb(",u={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},v=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;Konva.Util={_isElement:function(t){return!(!t||1!=t.nodeType)},_isFunction:function(t){return!!(t&&t.constructor&&t.call&&t.apply)},_isObject:function(t){return!!t&&t.constructor===Object},_isArray:function(t){return Object.prototype.toString.call(t)===e},_isNumber:function(t){return Object.prototype.toString.call(t)===n},_isString:function(t){return Object.prototype.toString.call(t)===a},_throttle:function(t,e,n){var a,i,o,r=null,s=0,h=n||{},c=function(){s=h.leading===!1?0:(new Date).getTime(),r=null,o=t.apply(a,i),a=i=null};return function(){var n=(new Date).getTime();s||h.leading!==!1||(s=n);var l=e-(n-s);return a=this,i=arguments,0>=l?(clearTimeout(r),r=null,s=n,o=t.apply(a,i),a=i=null):r||h.trailing===!1||(r=setTimeout(c,l)),o}},_hasMethods:function(t){var e,n=[];for(e in t)t.hasOwnProperty(e)&&this._isFunction(t[e])&&n.push(e);return n.length>0},createCanvasElement:function(){var t=Konva.document.createElement("canvas");try{t.style=t.style||{}}catch(e){}return t},isBrowser:function(){return"object"!=typeof exports},_isInDocument:function(t){for(;t=t.parentNode;)if(t==Konva.document)return!0;return!1},_simplifyArray:function(t){var e,n,a=[],i=t.length,o=Konva.Util;for(e=0;i>e;e++)n=t[e],o._isNumber(n)?n=Math.round(1e3*n)/1e3:o._isString(n)||(n=n.toString()),a.push(n);return a},_getImage:function(e,n){var a,i;if(e)if(this._isElement(e))n(e);else if(this._isString(e))a=new Konva.window.Image,a.onload=function(){n(a)},a.src=e;else if(e.data){i=Konva.Util.createCanvasElement(),i.width=e.width,i.height=e.height;var o=i.getContext(t);o.putImageData(e,0,0),this._getImage(i.toDataURL(),n)}else n(null);else n(null)},_getRGBAString:function(t){var e=t.red||0,n=t.green||0,a=t.blue||0,i=t.alpha||1;return["rgba(",e,",",n,",",a,",",i,")"].join(s)},_rgbToHex:function(t,e,n){return((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1)},_hexToRgb:function(t){t=t.replace(r,s);var e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor:function(){for(var t=(16777215*Math.random()<<0).toString(16);t.length<6;)t=h+t;return r+t},get:function(t,e){return void 0===t?e:t},getRGB:function(t){var e;return t in u?(e=u[t],{r:e[0],g:e[1],b:e[2]}):t[0]===r?this._hexToRgb(t.substring(1)):t.substr(0,4)===d?(e=v.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:function(t){return t=t||"black",Konva.Util._namedColorToRBA(t)||Konva.Util._hex3ColorToRGBA(t)||Konva.Util._hex6ColorToRGBA(t)||Konva.Util._rgbColorToRGBA(t)||Konva.Util._rgbaColorToRGBA(t)},_namedColorToRBA:function(t){var e=u[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA:function(t){if(0===t.indexOf("rgb(")){t=t.match(/rgb\(([^)]+)\)/)[1];var e=t.split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA:function(t){if(0===t.indexOf("rgba(")){t=t.match(/rgba\(([^)]+)\)/)[1];var e=t.split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex6ColorToRGBA:function(t){return"#"===t[0]&&7===t.length?{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}:void 0},_hex3ColorToRGBA:function(t){return"#"===t[0]&&4===t.length?{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}:void 0},_merge:function(t,e){var n=this._clone(e);for(var a in t)this._isObject(t[a])?n[a]=this._merge(t[a],n[a]):n[a]=t[a];return n},cloneObject:function(t){var e={};for(var n in t)this._isObject(t[n])?e[n]=this.cloneObject(t[n]):this._isArray(t[n])?e[n]=this.cloneArray(t[n]):e[n]=t[n];return e},cloneArray:function(t){return t.slice(0)},_degToRad:function(t){return t*i},_radToDeg:function(t){return t*o},_capitalize:function(t){return t.charAt(0).toUpperCase()+t.slice(1)},"throw":function(t){throw new Error(l+t)},error:function(t){console.error(l+t)},warn:function(t){Konva.root.console&&console.warn&&Konva.showWarnings&&console.warn(c+t)},extend:function(t,e){function n(){this.constructor=t}n.prototype=e.prototype;var a=t.prototype;t.prototype=new n;for(var i in a)a.hasOwnProperty(i)&&(t.prototype[i]=a[i]);t.__super__=e.prototype,t["super"]=e},addMethods:function(t,e){var n;for(n in e)t.prototype[n]=e[n]},_getControlPoints:function(t,e,n,a,i,o,r){var s=Math.sqrt(Math.pow(n-t,2)+Math.pow(a-e,2)),h=Math.sqrt(Math.pow(i-n,2)+Math.pow(o-a,2)),c=r*s/(s+h),l=r*h/(s+h),d=n-c*(i-t),u=a-c*(o-e),v=n+l*(i-t),f=a+l*(o-e);return[d,u,v,f]},_expandPoints:function(t,e){var n,a,i=t.length,o=[];for(n=2;i-2>n;n+=2)a=Konva.Util._getControlPoints(t[n-2],t[n-1],t[n],t[n+1],t[n+2],t[n+3],e),o.push(a[0]),o.push(a[1]),o.push(t[n]),o.push(t[n+1]),o.push(a[2]),o.push(a[3]);return o},_removeLastLetter:function(t){return t.substring(0,t.length-1)},each:function(t,e){for(var n in t)e(n,t[n])},_getProjectionToSegment:function(t,e,n,a,i,o){var r,s,h,c=(t-n)*(t-n)+(e-a)*(e-a);if(0==c)r=t,s=e,h=(i-n)*(i-n)+(o-a)*(o-a);else{var l=((i-t)*(n-t)+(o-e)*(a-e))/c;0>l?(r=t,s=e,h=(t-i)*(t-i)+(e-o)*(e-o)):l>1?(r=n,s=a,h=(n-i)*(n-i)+(a-o)*(a-o)):(r=t+l*(n-t),s=e+l*(a-e),h=(r-i)*(r-i)+(s-o)*(s-o))}return[r,s,h]},_getProjectionToLine:function(t,e,n){var a=Konva.Util.cloneObject(t),i=Number.MAX_VALUE;return e.forEach(function(o,r){if(n||r!==e.length-1){var s=e[(r+1)%e.length],h=Konva.Util._getProjectionToSegment(o.x,o.y,s.x,s.y,t.x,t.y),c=h[0],l=h[1],d=h[2];i>d&&(a.x=c,a.y=l,i=d)}}),a},_prepareArrayForTween:function(t,e,n){var a,i=[],o=[];if(t.length>e.length){var r=e;e=t,t=r}for(a=0;ac;c++)l=v[c],d=l.method,d?(u=l.args,g+=d,g+=h?r:Konva.Util._isArray(u[0])?a+u.join(t)+i:e+u.join(t)+n):(g+=l.property,h||(g+=s+l.val)),g+=o;return g},clearTrace:function(){this.traceArr=[]},_trace:function(t){var e,n=this.traceArr;n.push(t),e=n.length,e>=Konva.traceArrMax&&n.shift()},reset:function(){var t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)},getCanvas:function(){return this.canvas},clear:function(t){var e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)},_applyLineCap:function(t){var e=t.getLineCap();e&&this.setAttr("lineCap",e)},_applyOpacity:function(t){var e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)},_applyLineJoin:function(t){var e=t.getLineJoin();e&&this.setAttr("lineJoin",e)},setAttr:function(t,e){this._context[t]=e},arc:function(){var t=arguments;this._context.arc(t[0],t[1],t[2],t[3],t[4],t[5])},beginPath:function(){this._context.beginPath()},bezierCurveTo:function(){var t=arguments;this._context.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5])},clearRect:function(){var t=arguments;this._context.clearRect(t[0],t[1],t[2],t[3])},clip:function(){this._context.clip()},closePath:function(){this._context.closePath()},createImageData:function(){var t=arguments;return 2===t.length?this._context.createImageData(t[0],t[1]):1===t.length?this._context.createImageData(t[0]):void 0},createLinearGradient:function(){var t=arguments;return this._context.createLinearGradient(t[0],t[1],t[2],t[3])},createPattern:function(){var t=arguments;return this._context.createPattern(t[0],t[1])},createRadialGradient:function(){var t=arguments;return this._context.createRadialGradient(t[0],t[1],t[2],t[3],t[4],t[5])},drawImage:function(){var t=arguments,e=this._context;3===t.length?e.drawImage(t[0],t[1],t[2]):5===t.length?e.drawImage(t[0],t[1],t[2],t[3],t[4]):9===t.length&&e.drawImage(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},isPointInPath:function(t,e){return this._context.isPointInPath(t,e)},fill:function(){this._context.fill()},fillRect:function(t,e,n,a){this._context.fillRect(t,e,n,a)},strokeRect:function(t,e,n,a){this._context.strokeRect(t,e,n,a)},fillText:function(){var t=arguments;this._context.fillText(t[0],t[1],t[2])},measureText:function(t){return this._context.measureText(t)},getImageData:function(){var t=arguments;return this._context.getImageData(t[0],t[1],t[2],t[3])},lineTo:function(){var t=arguments;this._context.lineTo(t[0],t[1])},moveTo:function(){var t=arguments;this._context.moveTo(t[0],t[1])},rect:function(){var t=arguments;this._context.rect(t[0],t[1],t[2],t[3])},putImageData:function(){var t=arguments;this._context.putImageData(t[0],t[1],t[2])},quadraticCurveTo:function(){var t=arguments;this._context.quadraticCurveTo(t[0],t[1],t[2],t[3])},restore:function(){this._context.restore()},rotate:function(){var t=arguments;this._context.rotate(t[0])},save:function(){this._context.save()},scale:function(){var t=arguments;this._context.scale(t[0],t[1])},setLineDash:function(){var t=arguments,e=this._context;this._context.setLineDash?e.setLineDash(t[0]):"mozDash"in e?e.mozDash=t[0]:"webkitLineDash"in e&&(e.webkitLineDash=t[0])},getLineDash:function(){return this._context.getLineDash()},setTransform:function(){var t=arguments;this._context.setTransform(t[0],t[1],t[2],t[3],t[4],t[5])},stroke:function(){this._context.stroke()},strokeText:function(){var t=arguments;this._context.strokeText(t[0],t[1],t[2])},transform:function(){var t=arguments;this._context.transform(t[0],t[1],t[2],t[3],t[4],t[5])},translate:function(){var t=arguments;this._context.translate(t[0],t[1])},_enableTrace:function(){var t,e,n=this,a=h.length,i=Konva.Util._simplifyArray,o=this.setAttr,r=function(t){var a,o=n[t];n[t]=function(){return e=i(Array.prototype.slice.call(arguments,0)),a=o.apply(n,arguments),"clearRect"===t&&(e[2]=e[2]/n.canvas.getPixelRatio(),e[3]=e[3]/n.canvas.getPixelRatio()),n._trace({method:t,args:e}),a}};for(t=0;a>t;t++)r(h[t]);n.setAttr=function(){o.apply(n,arguments),n._trace({property:arguments[0],val:arguments[1]})}}},c.forEach(function(t){Object.defineProperty(Konva.Context.prototype,t,{get:function(){return this._context[t]},set:function(e){this._context[t]=e}})}),Konva.SceneContext=function(t){Konva.Context.call(this,t)},Konva.SceneContext.prototype={_fillColor:function(t){var e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)},_fillPattern:function(t){var e=t.getFillPatternX(),n=t.getFillPatternY(),a=t.getFillPatternScale(),i=Konva.getAngle(t.getFillPatternRotation()),o=t.getFillPatternOffset();(e||n)&&this.translate(e||0,n||0),i&&this.rotate(i),a&&this.scale(a.x,a.y),o&&this.translate(-1*o.x,-1*o.y),this.setAttr("fillStyle",this.createPattern(t.getFillPatternImage(),t.getFillPatternRepeat()||"repeat")),this.fill()},_fillLinearGradient:function(t){var e=t.getFillLinearGradientStartPoint(),n=t.getFillLinearGradientEndPoint(),a=t.getFillLinearGradientColorStops(),i=this.createLinearGradient(e.x,e.y,n.x,n.y);if(a){for(var o=0;os;s++)h=i[s],t[h]=this.getAttr(a+l(h));return t},n.prototype[u]=function(t){var e,n=this.attrs[a];o&&(t=o.call(this,t));for(e in t)t.hasOwnProperty(e)&&this._setAttr(a+l(e),t[e]);return this._fireChangeEvent(a,n,t),r&&r.call(this),this},this.addOverloadedGetterSetter(n,a)},addOverloadedGetterSetter:function(n,a){var i=Konva.Util._capitalize(a),o=e+i,r=t+i;n.prototype[a]=function(){return arguments.length?(this[o](arguments[0]),this):this[r]()}},addDeprecatedGetterSetter:function(e,n,a,i){var o=t+Konva.Util._capitalize(n),r=n+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[o]=function(){Konva.Util.error(r);var t=this.attrs[n];return void 0===t?a:t},this.addSetter(e,n,i,function(){Konva.Util.error(r)}),this.addOverloadedGetterSetter(e,n)},backCompat:function(t,e){Konva.Util.each(e,function(e,n){var a=t.prototype[n];t.prototype[e]=function(){a.apply(this,arguments),Konva.Util.error(e+" method is deprecated and will be removed soon. Use "+n+" instead")}})},afterSetFilter:function(){this._filterUpToDate=!1}},Konva.Validators={RGBComponent:function(t){return t>255?255:0>t?0:Math.round(t)},alphaComponent:function(t){return t>1?1:1e-4>t?1e-4:t}}}(),function(t){"use strict";var e="absoluteOpacity",n="absoluteTransform",a="Change",i="children",o=".",r="",s="get",h="id",c="konva",l="listening",d="mouseenter",u="mouseleave",v="name",f="set",g="Shape",p=" ",m="stage",_="transform",y="Stage",K="visible",S=["id"],C=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(p);t.Node=function(t){this._init(t)},t.Util.addMethods(t.Node,{_init:function(a){var i=this;this._id=t.idCounter++,this.eventListeners={},this.attrs={},this._cache={},this._filterUpToDate=!1,this.setAttrs(a),this.on(C,function(){this._clearCache(_),i._clearSelfAndDescendantCache(n)}),this.on("visibleChange.konva",function(){i._clearSelfAndDescendantCache(K)}),this.on("listeningChange.konva",function(){i._clearSelfAndDescendantCache(l)}),this.on("opacityChange.konva",function(){i._clearSelfAndDescendantCache(e)})},_clearCache:function(t){t?delete this._cache[t]:this._cache={}},_getCache:function(t,e){var n=this._cache[t];return void 0===n&&(this._cache[t]=e.call(this)),this._cache[t]},_clearSelfAndDescendantCache:function(t){this._clearCache(t),this.children&&this.getChildren().each(function(e){e._clearSelfAndDescendantCache(t)})},clearCache:function(){return delete this._cache.canvas,this._filterUpToDate=!1,this},cache:function(e){var n=e||{},a=this.getClientRect(!0),i=n.width||a.width,o=n.height||a.height,r=n.x||a.x,s=n.y||a.y,h=n.offset||0,c=n.drawBorder||!1;if(!i||!o)throw new Error("Width or height of caching configuration equals 0.");i+=2*h,o+=2*h,r-=h,s-=h;var l=new t.SceneCanvas({width:i,height:o}),d=new t.SceneCanvas({width:i,height:o}),u=new t.HitCanvas({pixelRatio:1,width:i,height:o}),v=l.getContext(),f=u.getContext();return u.isCache=!0,this.clearCache(),v.save(),f.save(),v.translate(-r,-s),f.translate(-r,-s),this.drawScene(l,this,!0),this.drawHit(u,this,!0),v.restore(),f.restore(),c&&(v.save(),v.beginPath(),v.rect(0,0,i,o),v.closePath(),v.setAttr("strokeStyle","red"),v.setAttr("lineWidth",5),v.stroke(),v.restore()),this._cache.canvas={scene:l,filter:d,hit:u,x:r,y:s},this},getClientRect:function(){throw new Error('abstract "getClientRect" method call')},_transformedRect:function(t){var e,n,a,i,o=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}],r=this.getTransform();return o.forEach(function(t){var o=r.point(t);void 0===e&&(e=a=o.x,n=i=o.y),e=Math.min(e,o.x),n=Math.min(n,o.y),a=Math.max(a,o.x),i=Math.max(i,o.y)}),{x:Math.round(e),y:Math.round(n),width:Math.round(a-e),height:Math.round(i-n)}},_drawCachedSceneCanvas:function(t){t.save(),t._applyOpacity(this),t.translate(this._cache.canvas.x,this._cache.canvas.y);var e=this._getCachedSceneCanvas(),n=e.pixelRatio;t.drawImage(e._canvas,0,0,e.width/n,e.height/n),t.restore()},_drawCachedHitCanvas:function(t){var e=this._cache.canvas,n=e.hit;t.save(),t.translate(this._cache.canvas.x,this._cache.canvas.y),t.drawImage(n._canvas,0,0),t.restore()},_getCachedSceneCanvas:function(){var e,n,a,i,o=this.filters(),r=this._cache.canvas,s=r.scene,h=r.filter,c=h.getContext();if(o){if(!this._filterUpToDate){var l=s.pixelRatio;try{for(e=o.length,c.clear(),c.drawImage(s._canvas,0,0,s.getWidth()/l,s.getHeight()/l),n=c.getImageData(0,0,h.getWidth(),h.getHeight()),a=0;e>a;a++)i=o[a],i.call(this,n),c.putImageData(n,0,0)}catch(d){t.Util.warn("Unable to apply filter. "+d.message)}this._filterUpToDate=!0}return h}return s},on:function(t,e){var n,a,i,s,h,c=t.split(p),l=c.length;for(n=0;l>n;n++)a=c[n],i=a.split(o),s=i[0],h=i[1]||r,this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:h,handler:e});return this},off:function(t){var e,n,a,i,r,s,h=(t||"").split(p),c=h.length;if(!t)for(n in this.eventListeners)this._off(n);for(e=0;c>e;e++)if(a=h[e],i=a.split(o),r=i[0],s=i[1],r)this.eventListeners[r]&&this._off(r,s);else for(n in this.eventListeners)this._off(n,s);return this},dispatchEvent:function(t){var e={target:this,type:t.type,evt:t};this.fire(t.type,e)},addEventListener:function(t,e){this.on(t,function(t){e.call(this,t.evt)})},removeEventListener:function(t){this.off(t)},remove:function(){var t=this.getParent();return t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),delete this.parent),this._clearSelfAndDescendantCache(m),this._clearSelfAndDescendantCache(n),this._clearSelfAndDescendantCache(K),this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(e),this},destroy:function(){t._removeId(this.getId()),t._removeName(this.getName(),this._id),this.remove()},getAttr:function(e){var n=s+t.Util._capitalize(e);return t.Util._isFunction(this[n])?this[n]():this.attrs[e]},getAncestors:function(){for(var e=this.getParent(),n=new t.Collection;e;)n.push(e),e=e.getParent();return n},getAttrs:function(){return this.attrs||{}},setAttrs:function(e){var n,a;if(!e)return this;for(n in e)n!==i&&(a=f+t.Util._capitalize(n),t.Util._isFunction(this[a])?this[a](e[n]):this._setAttr(n,e[n]));return this},isListening:function(){return this._getCache(l,this._isListening)},_isListening:function(){var t=this.getListening(),e=this.getParent();return"inherit"===t?e?e.isListening():!0:t},isVisible:function(){return this._getCache(K,this._isVisible)},_isVisible:function(){var t=this.getVisible(),e=this.getParent();return"inherit"===t?e?e.isVisible():!0:t},shouldDrawHit:function(t){var e=this.getLayer();return t&&t.isCache||e&&e.hitGraphEnabled()&&this.isListening()&&this.isVisible()},show:function(){return this.setVisible(!0),this},hide:function(){return this.setVisible(!1),this},getZIndex:function(){return this.index||0},getAbsoluteZIndex:function(){function t(h){for(e=[],n=h.length,a=0;n>a;a++)i=h[a],s++,i.nodeType!==g&&(e=e.concat(i.getChildren().toArray())),i._id===r._id&&(a=n);e.length>0&&e[0].getDepth()<=o&&t(e)}var e,n,a,i,o=this.getDepth(),r=this,s=0;return r.nodeType!==y&&t(r.getStage().getChildren()),s},getDepth:function(){ for(var t=0,e=this.parent;e;)t++,e=e.parent;return t},setPosition:function(t){return this.setX(t.x),this.setY(t.y),this},getPosition:function(){return{x:this.getX(),y:this.getY()}},getAbsolutePosition:function(){var e=this.getAbsoluteTransform().getMatrix(),n=new t.Transform,a=this.offset();return n.m=e.slice(),n.translate(a.x,a.y),n.getTranslation()},setAbsolutePosition:function(t){var e,n=this._clearTransform();return this.attrs.x=n.x,this.attrs.y=n.y,delete n.x,delete n.y,e=this.getAbsoluteTransform(),e.invert(),e.translate(t.x,t.y),t={x:this.attrs.x+e.getTranslation().x,y:this.attrs.y+e.getTranslation().y},this.setPosition({x:t.x,y:t.y}),this._setTransform(n),this},_setTransform:function(t){var e;for(e in t)this.attrs[e]=t[e];this._clearCache(_),this._clearSelfAndDescendantCache(n)},_clearTransform:function(){var t={x:this.getX(),y:this.getY(),rotation:this.getRotation(),scaleX:this.getScaleX(),scaleY:this.getScaleY(),offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),skewX:this.getSkewX(),skewY:this.getSkewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,this._clearCache(_),this._clearSelfAndDescendantCache(n),t},move:function(t){var e=t.x,n=t.y,a=this.getX(),i=this.getY();return void 0!==e&&(a+=e),void 0!==n&&(i+=n),this.setPosition({x:a,y:i}),this},_eachAncestorReverse:function(t,e){var n,a,i=[],o=this.getParent();if(e&&e._id===this._id)return t(this),!0;for(i.unshift(this);o&&(!e||o._id!==e._id);)i.unshift(o),o=o.parent;for(n=i.length,a=0;n>a;a++)t(i[a])},rotate:function(t){return this.setRotation(this.getRotation()+t),this},moveToTop:function(){if(!this.parent)return t.Util.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index;return this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0},moveUp:function(){if(!this.parent)return t.Util.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index,n=this.parent.getChildren().length;return n-1>e?(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0):!1},moveDown:function(){if(!this.parent)return t.Util.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0):!1},moveToBottom:function(){if(!this.parent)return t.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1},setZIndex:function(e){if(!this.parent)return t.Util.warn("Node has no parent. zIndex parameter is ignored."),!1;var n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this},getAbsoluteOpacity:function(){return this._getCache(e,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 e,n,a,i,o={},r=this.getAttrs();o.attrs={};for(e in r)n=r[e],t.Util._isFunction(n)||t.Util._isElement(n)||t.Util._isObject(n)||t.Util._hasMethods(n)||(a=this[e],delete r[e],i=a?a.call(this):null,r[e]=n,i!==n&&(o.attrs[e]=n));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(m,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(n,this._getAbsoluteTransform)},_getAbsoluteTransform:function(e){var n,a,i=new t.Transform;return this._eachAncestorReverse(function(t){n=t.transformsEnabled(),a=t.getTransform(),"all"===n?i.multiply(a):"position"===n&&i.translate(t.x(),t.y())},e),i},getTransform:function(){return this._getCache(_,this._getTransform)},_getTransform:function(){var e=new t.Transform,n=this.getX(),a=this.getY(),i=t.getAngle(this.getRotation()),o=this.getScaleX(),r=this.getScaleY(),s=this.getSkewX(),h=this.getSkewY(),c=this.getOffsetX(),l=this.getOffsetY();return(0!==n||0!==a)&&e.translate(n,a),0!==i&&e.rotate(i),(0!==s||0!==h)&&e.skew(s,h),(1!==o||1!==r)&&e.scale(o,r),(0!==c||0!==l)&&e.translate(-1*c,-1*l),e},clone:function(e){var n,a,i,o,r,s=t.Util.cloneObject(this.attrs);for(var h in S){var l=S[h];delete s[l]}for(n in e)s[n]=e[n];var d=new this.constructor(s);for(n in this.eventListeners)for(a=this.eventListeners[n],i=a.length,o=0;i>o;o++)r=a[o],r.name.indexOf(c)<0&&(d.eventListeners[n]||(d.eventListeners[n]=[]),d.eventListeners[n].push(r));return d},toDataURL:function(e){e=e||{};var n=e.mimeType||null,a=e.quality||null,i=this.getStage(),o=e.x||0,r=e.y||0,s=e.pixelRatio||1,h=new t.SceneCanvas({width:e.width||this.getWidth()||(i?i.getWidth():0),height:e.height||this.getHeight()||(i?i.getHeight():0),pixelRatio:s}),c=h.getContext();return c.save(),(o||r)&&c.translate(-1*o,-1*r),this.drawScene(h),c.restore(),h.toDataURL(n,a)},toImage:function(e){if(!e||!e.callback)throw"callback required for toImage method config argument";t.Util._getImage(this.toDataURL(e),function(t){e.callback(t)})},setSize:function(t){return this.setWidth(t.width),this.setHeight(t.height),this},getSize:function(){return{width:this.getWidth(),height:this.getHeight()}},getWidth:function(){return this.attrs.width||0},getHeight:function(){return this.attrs.height||0},getClassName:function(){return this.className||this.nodeType},getType:function(){return this.nodeType},getDragDistance:function(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():t.dragDistance},_get:function(t){return this.className===t||this.nodeType===t?[this]:[]},_off:function(t,e){var n,a,i=this.eventListeners[t];for(n=0;no;o++)a.add(this._createNode(s[o]));return a},t.Factory.addOverloadedGetterSetter(t.Node,"position"),t.Factory.addGetterSetter(t.Node,"x",0),t.Factory.addGetterSetter(t.Node,"y",0),t.Factory.addGetterSetter(t.Node,"opacity",1),t.Factory.addGetter(t.Node,"name"),t.Factory.addOverloadedGetterSetter(t.Node,"name"),t.Factory.addGetter(t.Node,"id"),t.Factory.addOverloadedGetterSetter(t.Node,"id"),t.Factory.addGetterSetter(t.Node,"rotation",0),t.Factory.addComponentsGetterSetter(t.Node,"scale",["x","y"]),t.Factory.addGetterSetter(t.Node,"scaleX",1),t.Factory.addGetterSetter(t.Node,"scaleY",1),t.Factory.addComponentsGetterSetter(t.Node,"skew",["x","y"]),t.Factory.addGetterSetter(t.Node,"skewX",0),t.Factory.addGetterSetter(t.Node,"skewY",0),t.Factory.addComponentsGetterSetter(t.Node,"offset",["x","y"]),t.Factory.addGetterSetter(t.Node,"offsetX",0),t.Factory.addGetterSetter(t.Node,"offsetY",0),t.Factory.addSetter(t.Node,"dragDistance"),t.Factory.addOverloadedGetterSetter(t.Node,"dragDistance"),t.Factory.addSetter(t.Node,"width",0),t.Factory.addOverloadedGetterSetter(t.Node,"width"),t.Factory.addSetter(t.Node,"height",0),t.Factory.addOverloadedGetterSetter(t.Node,"height"),t.Factory.addGetterSetter(t.Node,"listening","inherit"),t.Factory.addGetterSetter(t.Node,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),t.Factory.addGetterSetter(t.Node,"visible","inherit"),t.Factory.addGetterSetter(t.Node,"transformsEnabled","all"),t.Factory.addOverloadedGetterSetter(t.Node,"size"),t.Factory.backCompat(t.Node,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),t.Collection.mapMethods(t.Node)}(Konva),function(){"use strict";Konva.Filters.Grayscale=function(t){var e,n,a=t.data,i=a.length;for(e=0;i>e;e+=4)n=.34*a[e]+.5*a[e+1]+.16*a[e+2],a[e]=n,a[e+1]=n,a[e+2]=n}}(),function(){"use strict";Konva.Filters.Brighten=function(t){var e,n=255*this.brightness(),a=t.data,i=a.length;for(e=0;i>e;e+=4)a[e]+=n,a[e+1]+=n,a[e+2]+=n},Konva.Factory.addGetterSetter(Konva.Node,"brightness",0,null,Konva.Factory.afterSetFilter)}(),function(){"use strict";Konva.Filters.Invert=function(t){var e,n=t.data,a=n.length;for(e=0;a>e;e+=4)n[e]=255-n[e],n[e+1]=255-n[e+1],n[e+2]=255-n[e+2]}}(),function(){"use strict";function t(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}function e(e,i){var o,r,s,h,c,l,d,u,v,f,g,p,m,_,y,K,S,C,x,w,b,F,T,P,A=e.data,k=e.width,D=e.height,M=i+i+1,G=k-1,R=D-1,L=i+1,I=L*(L+1)/2,N=new t,O=null,U=N,B=null,E=null,H=n[i],W=a[i];for(s=1;M>s;s++)U=U.next=new t,s===L&&(O=U);for(U.next=N,d=l=0,r=0;D>r;r++){for(K=S=C=x=u=v=f=g=0,p=L*(w=A[l]),m=L*(b=A[l+1]),_=L*(F=A[l+2]),y=L*(T=A[l+3]),u+=I*w,v+=I*b,f+=I*F,g+=I*T,U=N,s=0;L>s;s++)U.r=w,U.g=b,U.b=F,U.a=T,U=U.next;for(s=1;L>s;s++)h=l+((s>G?G:s)<<2),u+=(U.r=w=A[h])*(P=L-s),v+=(U.g=b=A[h+1])*P,f+=(U.b=F=A[h+2])*P,g+=(U.a=T=A[h+3])*P,K+=w,S+=b,C+=F,x+=T,U=U.next;for(B=N,E=O,o=0;k>o;o++)A[l+3]=T=g*H>>W,0!==T?(T=255/T,A[l]=(u*H>>W)*T,A[l+1]=(v*H>>W)*T,A[l+2]=(f*H>>W)*T):A[l]=A[l+1]=A[l+2]=0,u-=p,v-=m,f-=_,g-=y,p-=B.r,m-=B.g,_-=B.b,y-=B.a,h=d+((h=o+i+1)o;o++){for(S=C=x=K=v=f=g=u=0,l=o<<2,p=L*(w=A[l]),m=L*(b=A[l+1]),_=L*(F=A[l+2]),y=L*(T=A[l+3]),u+=I*w,v+=I*b,f+=I*F,g+=I*T,U=N,s=0;L>s;s++)U.r=w,U.g=b,U.b=F,U.a=T,U=U.next;for(c=k,s=1;i>=s;s++)l=c+o<<2,u+=(U.r=w=A[l])*(P=L-s),v+=(U.g=b=A[l+1])*P,f+=(U.b=F=A[l+2])*P,g+=(U.a=T=A[l+3])*P,K+=w,S+=b,C+=F,x+=T,U=U.next,R>s&&(c+=k);for(l=o,B=N,E=O,r=0;D>r;r++)h=l<<2,A[h+3]=T=g*H>>W,T>0?(T=255/T,A[h]=(u*H>>W)*T,A[h+1]=(v*H>>W)*T,A[h+2]=(f*H>>W)*T):A[h]=A[h+1]=A[h+2]=0,u-=p,v-=m,f-=_,g-=y,p-=B.r,m-=B.g,_-=B.b,y-=B.a,h=o+((h=r+L)0&&e(t,n)},Konva.Factory.addGetterSetter(Konva.Node,"blurRadius",0,null,Konva.Factory.afterSetFilter)}(),function(){"use strict";function t(t,e,n){var a=4*(n*t.width+e),i=[];return i.push(t.data[a++],t.data[a++],t.data[a++],t.data[a++]),i}function e(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}function n(t){for(var e=[0,0,0],n=0;nv?0:255}return d}}function i(t,e){for(var n=0;ns;s++)for(var h=0;e>h;h++){for(var c=s*e+h,l=0,d=0;i>d;d++)for(var u=0;i>u;u++){var v=s+d-o,f=h+u-o;if(v>=0&&n>v&&f>=0&&e>f){var g=v*e+f,p=a[d*i+u];l+=t[g]*p}}r[c]=2040===l?255:0}return r}function r(t,e,n){for(var a=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(a.length)),o=Math.floor(i/2),r=[],s=0;n>s;s++)for(var h=0;e>h;h++){for(var c=s*e+h,l=0,d=0;i>d;d++)for(var u=0;i>u;u++){var v=s+d-o,f=h+u-o;if(v>=0&&n>v&&f>=0&&e>f){var g=v*e+f,p=a[d*i+u];l+=t[g]*p}}r[c]=l>=1020?255:0}return r}function s(t,e,n){for(var a=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(a.length)),o=Math.floor(i/2),r=[],s=0;n>s;s++)for(var h=0;e>h;h++){for(var c=s*e+h,l=0,d=0;i>d;d++)for(var u=0;i>u;u++){var v=s+d-o,f=h+u-o;if(v>=0&&n>v&&f>=0&&e>f){var g=v*e+f,p=a[d*i+u];l+=t[g]*p}}r[c]=l}return r}Konva.Filters.Mask=function(t){var e=this.threshold(),n=a(t,e);return n&&(n=o(n,t.width,t.height),n=r(n,t.width,t.height),n=s(n,t.width,t.height),i(t,n)),t},Konva.Factory.addGetterSetter(Konva.Node,"threshold",0,null,Konva.Factory.afterSetFilter)}(),function(){"use strict";Konva.Filters.RGB=function(t){var e,n,a=t.data,i=a.length,o=this.red(),r=this.green(),s=this.blue();for(e=0;i>e;e+=4)n=(.34*a[e]+.5*a[e+1]+.16*a[e+2])/255,a[e]=n*o,a[e+1]=n*r,a[e+2]=n*s,a[e+3]=a[e+3]},Konva.Factory.addGetterSetter(Konva.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:0>t?0:Math.round(t)}),Konva.Factory.addGetterSetter(Konva.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:0>t?0:Math.round(t)}),Konva.Factory.addGetterSetter(Konva.Node,"blue",0,Konva.Validators.RGBComponent,Konva.Factory.afterSetFilter)}(),function(){"use strict";Konva.Filters.RGBA=function(t){var e,n,a=t.data,i=a.length,o=this.red(),r=this.green(),s=this.blue(),h=this.alpha();for(e=0;i>e;e+=4)n=1-h,a[e]=o*h+a[e]*n,a[e+1]=r*h+a[e+1]*n,a[e+2]=s*h+a[e+2]*n},Konva.Factory.addGetterSetter(Konva.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:0>t?0:Math.round(t)}),Konva.Factory.addGetterSetter(Konva.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:0>t?0:Math.round(t)}),Konva.Factory.addGetterSetter(Konva.Node,"blue",0,Konva.Validators.RGBComponent,Konva.Factory.afterSetFilter),Konva.Factory.addGetterSetter(Konva.Node,"alpha",1,function(t){return this._filterUpToDate=!1,t>1?1:0>t?0:t})}(),function(){"use strict";Konva.Filters.HSV=function(t){var e,n,a,i,o,r=t.data,s=r.length,h=Math.pow(2,this.value()),c=Math.pow(2,this.saturation()),l=Math.abs(this.hue()+360)%360,d=h*c*Math.cos(l*Math.PI/180),u=h*c*Math.sin(l*Math.PI/180),v=.299*h+.701*d+.167*u,f=.587*h-.587*d+.33*u,g=.114*h-.114*d-.497*u,p=.299*h-.299*d-.328*u,m=.587*h+.413*d+.035*u,_=.114*h-.114*d+.293*u,y=.299*h-.3*d+1.25*u,K=.587*h-.586*d-1.05*u,S=.114*h+.886*d-.2*u;for(e=0;s>e;e+=4)n=r[e+0],a=r[e+1],i=r[e+2],o=r[e+3],r[e+0]=v*n+f*a+g*i,r[e+1]=p*n+m*a+_*i,r[e+2]=y*n+K*a+S*i,r[e+3]=o},Konva.Factory.addGetterSetter(Konva.Node,"hue",0,null,Konva.Factory.afterSetFilter),Konva.Factory.addGetterSetter(Konva.Node,"saturation",0,null,Konva.Factory.afterSetFilter),Konva.Factory.addGetterSetter(Konva.Node,"value",0,null,Konva.Factory.afterSetFilter)}(),function(){"use strict";Konva.Factory.addGetterSetter(Konva.Node,"hue",0,null,Konva.Factory.afterSetFilter),Konva.Factory.addGetterSetter(Konva.Node,"saturation",0,null,Konva.Factory.afterSetFilter),Konva.Factory.addGetterSetter(Konva.Node,"luminance",0,null,Konva.Factory.afterSetFilter),Konva.Filters.HSL=function(t){var e,n,a,i,o,r=t.data,s=r.length,h=1,c=Math.pow(2,this.saturation()),l=Math.abs(this.hue()+360)%360,d=127*this.luminance(),u=h*c*Math.cos(l*Math.PI/180),v=h*c*Math.sin(l*Math.PI/180),f=.299*h+.701*u+.167*v,g=.587*h-.587*u+.33*v,p=.114*h-.114*u-.497*v,m=.299*h-.299*u-.328*v,_=.587*h+.413*u+.035*v,y=.114*h-.114*u+.293*v,K=.299*h-.3*u+1.25*v,S=.587*h-.586*u-1.05*v,C=.114*h+.886*u-.2*v;for(e=0;s>e;e+=4)n=r[e+0],a=r[e+1],i=r[e+2],o=r[e+3],r[e+0]=f*n+g*a+p*i+d,r[e+1]=m*n+_*a+y*i+d,r[e+2]=K*n+S*a+C*i+d,r[e+3]=o}}(),function(){"use strict";Konva.Filters.Emboss=function(t){var e=10*this.embossStrength(),n=255*this.embossWhiteLevel(),a=this.embossDirection(),i=this.embossBlend(),o=0,r=0,s=t.data,h=t.width,c=t.height,l=4*h,d=c;switch(a){case"top-left":o=-1,r=-1;break;case"top":o=-1,r=0;break;case"top-right":o=-1,r=1;break;case"right":o=0,r=1;break;case"bottom-right":o=1,r=1;break;case"bottom":o=1,r=0;break;case"bottom-left":o=1,r=-1;break;case"left":o=0,r=-1}do{var u=(d-1)*l,v=o;1>d+v&&(v=0),d+v>c&&(v=0);var f=(d-1+v)*h*4,g=h;do{var p=u+4*(g-1),m=r;1>g+m&&(m=0),g+m>h&&(m=0);var _=f+4*(g-1+m),y=s[p]-s[_],K=s[p+1]-s[_+1],S=s[p+2]-s[_+2],C=y,x=C>0?C:-C,w=K>0?K:-K,b=S>0?S:-S;if(w>x&&(C=K),b>x&&(C=S),C*=e,i){var F=s[p]+C,T=s[p+1]+C,P=s[p+2]+C;s[p]=F>255?255:0>F?0:F,s[p+1]=T>255?255:0>T?0:T,s[p+2]=P>255?255:0>P?0:P}else{var A=n-C;0>A?A=0:A>255&&(A=255),s[p]=s[p+1]=s[p+2]=A}}while(--g)}while(--d)},Konva.Factory.addGetterSetter(Konva.Node,"embossStrength",.5,null,Konva.Factory.afterSetFilter),Konva.Factory.addGetterSetter(Konva.Node,"embossWhiteLevel",.5,null,Konva.Factory.afterSetFilter),Konva.Factory.addGetterSetter(Konva.Node,"embossDirection","top-left",null,Konva.Factory.afterSetFilter),Konva.Factory.addGetterSetter(Konva.Node,"embossBlend",!1,null,Konva.Factory.afterSetFilter)}(),function(){"use strict";function t(t,e,n,a,i){var o,r=n-e,s=i-a;return 0===r?a+s/2:0===s?a:(o=(t-e)/r,o=s*o+a)}Konva.Filters.Enhance=function(e){var n,a,i,o,r=e.data,s=r.length,h=r[0],c=h,l=r[1],d=l,u=r[2],v=u,f=this.enhance();if(0!==f){for(o=0;s>o;o+=4)n=r[o+0],h>n?h=n:n>c&&(c=n),a=r[o+1],l>a?l=a:a>d&&(d=a),i=r[o+2],u>i?u=i:i>v&&(v=i);c===h&&(c=255,h=0),d===l&&(d=255,l=0),v===u&&(v=255,u=0);var g,p,m,_,y,K,S,C,x;for(f>0?(p=c+f*(255-c),m=h-f*(h-0),y=d+f*(255-d),K=l-f*(l-0),C=v+f*(255-v),x=u-f*(u-0)):(g=.5*(c+h),p=c+f*(c-g),m=h+f*(h-g),_=.5*(d+l),y=d+f*(d-_),K=l+f*(l-_),S=.5*(v+u),C=v+f*(v-S),x=u+f*(u-S)),o=0;s>o;o+=4)r[o+0]=t(r[o+0],h,c,m,p),r[o+1]=t(r[o+1],l,d,K,y),r[o+2]=t(r[o+2],u,v,x,C)}},Konva.Factory.addGetterSetter(Konva.Node,"enhance",0,null,Konva.Factory.afterSetFilter)}(),function(){"use strict";Konva.Filters.Posterize=function(t){var e,n=Math.round(254*this.levels())+1,a=t.data,i=a.length,o=255/n;for(e=0;i>e;e+=1)a[e]=Math.floor(a[e]/o)*o},Konva.Factory.addGetterSetter(Konva.Node,"levels",.5,null,Konva.Factory.afterSetFilter)}(),function(){"use strict";Konva.Filters.Noise=function(t){var e,n=255*this.noise(),a=t.data,i=a.length,o=n/2;for(e=0;i>e;e+=4)a[e+0]+=o-2*o*Math.random(),a[e+1]+=o-2*o*Math.random(),a[e+2]+=o-2*o*Math.random()},Konva.Factory.addGetterSetter(Konva.Node,"noise",.2,null,Konva.Factory.afterSetFilter)}(),function(){"use strict";Konva.Filters.Pixelate=function(t){var e,n,a,i,o,r,s,h,c,l,d,u,v,f,g=Math.ceil(this.pixelSize()),p=t.width,m=t.height,_=Math.ceil(p/g),y=Math.ceil(m/g);for(t=t.data,u=0;_>u;u+=1)for(v=0;y>v;v+=1){for(i=0,o=0,r=0,s=0,h=u*g,c=h+g,l=v*g,d=l+g,f=0,e=h;c>e;e+=1)if(!(e>=p))for(n=l;d>n;n+=1)n>=m||(a=4*(p*n+e),i+=t[a+0],o+=t[a+1],r+=t[a+2],s+=t[a+3],f+=1);for(i/=f,o/=f,r/=f,e=h;c>e;e+=1)if(!(e>=p))for(n=l;d>n;n+=1)n>=m||(a=4*(p*n+e),t[a+0]=i,t[a+1]=o,t[a+2]=r,t[a+3]=s)}},Konva.Factory.addGetterSetter(Konva.Node,"pixelSize",8,null,Konva.Factory.afterSetFilter)}(),function(){"use strict";Konva.Filters.Threshold=function(t){var e,n=255*this.threshold(),a=t.data,i=a.length;for(e=0;i>e;e+=1)a[e]=a[e]