diff --git a/all.js b/all.js index dde18e862e9..2d80df1db6b 100644 --- a/all.js +++ b/all.js @@ -8534,8 +8534,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, { G_vmlCanvasManager.initElement(el); } - this.setCoords(); - el.width = this.getBoundingRectWidth(); + el.width = this.getBoundingRectWidth(); el.height = this.getBoundingRectHeight(); fabric.util.wrapElement(el, 'div'); @@ -11602,7 +11601,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, { */ toObject: function() { return extend(this.callSuper('toObject'), { - objects: invoke(this.objects, 'clone') + objects: invoke(this.objects, 'toObject') }); }, diff --git a/all.min.js b/all.min.js index 6847c5472ca..bfedb822fa0 100644 --- a/all.min.js +++ b/all.min.js @@ -4,4 +4,4 @@ var fabric=fabric||{version:"0.9.12"};if(typeof exports!="undefined"){exports.fa * Copyright (c) 2009 Simo Kinnunen. * Licensed under the MIT license. */ -var Cufon=(function(){var k=function(){return k.replace.apply(null,arguments)};var u=k.DOM={ready:(function(){var z=false,B={loaded:1,complete:1};var y=[],A=function(){if(z){return}z=true;for(var C;C=y.shift();C()){}};if(fabric.document.addEventListener){fabric.document.addEventListener("DOMContentLoaded",A,false);fabric.window.addEventListener("pageshow",A,false)}if(!fabric.window.opera&&fabric.document.readyState){(function(){B[fabric.document.readyState]?A():setTimeout(arguments.callee,10)})()}if(fabric.document.readyState&&fabric.document.createStyleSheet){(function(){try{fabric.document.body.doScroll("left");A()}catch(C){setTimeout(arguments.callee,1)}})()}o(fabric.window,"load",A);return function(C){if(!arguments.length){A()}else{z?C():y.push(C)}}})()};var l=k.CSS={Size:function(z,y){this.value=parseFloat(z);this.unit=String(z).match(/[a-z%]*$/)[0]||"px";this.convert=function(A){return A/y*this.value};this.convertFrom=function(A){return A/this.value*y};this.toString=function(){return this.value+this.unit}},getStyle:function(y){return new a(y.style)},quotedList:i(function(B){var A=[],z=/\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g,y;while(y=z.exec(B)){A.push(y[3]||y[1])}return A}),ready:(function(){var A=false;var z=[],B=function(){A=true;for(var D;D=z.shift();D()){}};var y=Object.prototype.propertyIsEnumerable?f("style"):{length:0};var C=f("link");u.ready(function(){var G=0,F;for(var E=0,D=C.length;F=C[E],E=y.length+G){B()}else{setTimeout(arguments.callee,10)}});return function(D){if(A){D()}else{z.push(D)}}})(),supports:function(A,z){var y=fabric.document.createElement("span").style;if(y[A]===undefined){return false}y[A]=z;return y[A]===z},textAlign:function(B,A,y,z){if(A.get("textAlign")=="right"){if(y>0){B=" "+B}}else{if(y400}if(F==500){F=400}for(var G in D){G=parseInt(G,10);if(!C||GA){A=G}H.push(G)}if(FA){F=A}H.sort(function(J,I){return(B?(J>F&&I>F)?JI:(JI:Jz){z=e}L.push(e);e=0;continue}var B=ab.glyphs[ag[aa]]||ab.missingGlyph;if(!B){continue}e+=D=Number(B.w||ab.w)+U}L.push(e);e=Math.max(z,e);var m=[];for(var aa=L.length;aa--;){m[aa]=e-L[aa]}if(D===null){return null}V+=(H.width-D);C+=H.minX;var v,p;if(n){v=J;p=J.firstChild}else{v=fabric.document.createElement("span");v.className="cufon cufon-canvas";v.alt=E;p=fabric.document.createElement("canvas");v.appendChild(p);if(A.printable){var Y=fabric.document.createElement("span");Y.className="cufon-alt";Y.appendChild(fabric.document.createTextNode(E));v.appendChild(Y)}}var ah=v.style;var O=p.style||{};var k=o.convert(H.height-I+T);var af=Math.ceil(k);var S=af/k;p.width=Math.ceil(o.convert(e+V-C)*S);p.height=af;I+=H.minY;O.top=Math.round(o.convert(I-ab.ascent))+"px";O.left=Math.round(o.convert(C))+"px";var j=Math.ceil(o.convert(e*S));var t=j+"px";var s=o.convert(ab.height);var F=(A.lineHeight-1)*o.convert(-ab.ascent/5)*(M-1);Cufon.textOptions.width=j;Cufon.textOptions.height=(s*M)+F;Cufon.textOptions.lines=M;Cufon.textOptions.totalLineHeight=F;if(a){ah.width=t;ah.height=s+"px"}else{ah.paddingLeft=t;ah.paddingBottom=(s-1)+"px"}var ad=Cufon.textOptions.context||p.getContext("2d"),K=af/H.height;Cufon.textOptions.fontAscent=ab.ascent*K;Cufon.textOptions.boundaries=null;for(var w=Cufon.textOptions.shadowOffsets,aa=R.length;aa--;){w[aa]=[R[aa][0]*K,R[aa][1]*K]}ad.save();ad.scale(K,K);ad.translate(-C-((1/K*p.width)/2)+(Cufon.fonts[ab.family].offsetLeft||0),-I-((Cufon.textOptions.height/K)/2)+(Cufon.fonts[ab.family].offsetTop||0));ad.lineWidth=ab.face["underline-thickness"];ad.save();function q(l,i){ad.strokeStyle=i;ad.beginPath();ad.moveTo(0,l);ad.lineTo(e,l);ad.stroke()}var r=Cufon.getTextDecoration(A),u=A.fontStyle==="italic";function ae(){ad.save();ad.fillStyle=A.backgroundColor;var aj=0,an=0,y=[{left:0}];if(A.textAlign==="right"){ad.translate(m[an],0);y[0].left=m[an]*K}else{if(A.textAlign==="center"){ad.translate(m[an]/2,0);y[0].left=m[an]/2*K}}for(var al=0,ak=ag.length;al.cufon-vml-canvas{text-indent:0}@media screen{cvml\\:shape,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute}.cufon-vml-canvas{position:absolute;text-align:left}.cufon-vml{display:inline-block;position:relative;vertical-align:middle}.cufon-vml .cufon-alt{position:absolute;left:-10000in;font-size:1px}a .cufon-vml{cursor:pointer}}@media print{.cufon-vml *{display:none}.cufon-vml .cufon-alt{display:inline}}');function c(e,f){return a(e,/(?:em|ex|%)$/i.test(f)?"1em":f)}function a(h,i){if(/px$/i.test(i)){return parseFloat(i)}var g=h.style.left,f=h.runtimeStyle.left;h.runtimeStyle.left=h.currentStyle.left;h.style.left=i;var e=h.style.pixelLeft;h.style.left=g;h.runtimeStyle.left=f;return e}return function(T,z,O,w,D,U,M){var h=(z===null);if(h){z=D.alt}var B=T.viewBox;var j=O.computedFontSize||(O.computedFontSize=new Cufon.CSS.Size(c(U,O.get("fontSize"))+"px",T.baseSize));var L=O.computedLSpacing;if(L==undefined){L=O.get("letterSpacing");O.computedLSpacing=L=(L=="normal")?0:~~j.convertFrom(a(U,L))}var t,m;if(h){t=D;m=D.firstChild}else{t=fabric.document.createElement("span");t.className="cufon cufon-vml";t.alt=z;m=fabric.document.createElement("span");m.className="cufon-vml-canvas";t.appendChild(m);if(w.printable){var R=fabric.document.createElement("span");R.className="cufon-alt";R.appendChild(fabric.document.createTextNode(z));t.appendChild(R)}if(!M){t.appendChild(fabric.document.createElement("cvml:shape"))}}var Z=t.style;var G=m.style;var f=j.convert(B.height),W=Math.ceil(f);var K=W/f;var J=B.minX,I=B.minY;G.height=W;G.top=Math.round(j.convert(I-T.ascent));G.left=Math.round(j.convert(J));Z.height=j.convert(T.height)+"px";var p=Cufon.getTextDecoration(w);var y=O.get("color");var X=Cufon.CSS.textTransform(z,O).split("");var e=0,H=0,q=null;var x,r,A=w.textShadow;for(var S=0,Q=0,P=X.length;Sw?p:(o-n);s(t(currentTime,m,byValue,p));if(o>w||q()){x.onComplete&&x.onComplete();return}k(r)})()}var f=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(n,m){fabric.window.setTimeout(n,1000/60)};var k=function(){return f.apply(fabric.window,arguments)};function b(n,p,o){if(n){var m=new Image();m.onload=function(){p&&p.call(o,m);m=m.onload=null};m.src=n}else{p&&p.call(o,n)}}function i(p,s){function o(t){return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(t))]}function n(){if(++r===m){if(s){s(q)}}}var q=[],r=0,m=p.length;p.forEach(function(v,u){if(!v.type){return}var t=o(v.type);if(t.async){t.fromObject(v,function(w){q[u]=w;n()})}else{q[u]=t.fromObject(v);n()}})}function a(o,n,p){var m=o.length>1?new fabric.PathGroup(o,n):o[0];if(typeof p!=="undefined"){m.setSourcePath(p)}return m}fabric.util.removeFromArray=j;fabric.util.degreesToRadians=c;fabric.util.toFixed=e;fabric.util.getRandomInt=g;fabric.util.falseFunction=l;fabric.util.animate=d;fabric.util.requestAnimFrame=k;fabric.util.loadImage=b;fabric.util.enlivenObjects=i;fabric.util.groupSVGElements=a})();(function(){var d=Array.prototype.slice;if(!Array.prototype.indexOf){Array.prototype.indexOf=function(g){if(this===void 0||this===null){throw new TypeError()}var h=Object(this),e=h.length>>>0;if(e===0){return -1}var i=0;if(arguments.length>0){i=Number(arguments[1]);if(i!==i){i=0}else{if(i!==0&&i!==(1/0)&&i!==-(1/0)){i=(i>0||-1)*Math.floor(Math.abs(i))}}}if(i>=e){return -1}var f=i>=0?i:Math.max(e-Math.abs(i),0);for(;f>>0;f>>0;g>>0;f>>0;f>>0;g>>0,f=0,h;if(arguments.length>1){h=arguments[1]}else{do{if(f in this){h=this[f++];break}if(++f>=e){throw new TypeError()}}while(true)}for(;f=e){e=h[f][g]}}}else{while(f--){if(h[f]>=e){e=h[f]}}}return e}function c(h,g){if(!h||h.length===0){return undefined}var f=h.length-1,e=g?h[f][g]:h[f];if(g){while(f--){if(h[f][g]/g,">")}fabric.util.string={camelize:b,capitalize:c,escapeXml:a}}());(function(){var c=Array.prototype.slice,a=Function.prototype.apply,b=function(){};if(!Function.prototype.bind){Function.prototype.bind=function(d){var g=this,e=c.call(arguments,1),f;if(e.length){f=function(){return a.call(g,this instanceof b?this:d,e.concat(c.call(arguments)))}}else{f=function(){return a.call(g,this instanceof b?this:d,arguments)}}b.prototype=this.prototype;f.prototype=new b;return f}}})();(function(){var f=Array.prototype.slice,e=function(){};var c=(function(){for(var g in {toString:1}){if(g==="toString"){return false}}return true})();var b=function(g,j,h){for(var i in j){if(i in g.prototype&&typeof g.prototype[i]=="function"){g.prototype[i]=(function(k){return function(){var m=this.constructor.superclass;this.constructor.superclass=h;var l=j[k].apply(this,arguments);this.constructor.superclass=m;if(k!=="initialize"){return l}}})(i)}else{g.prototype[i]=j[i]}if(c){if(j.toString!==Object.prototype.toString){g.prototype.toString=j.toString}if(j.valueOf!==Object.prototype.valueOf){g.prototype.valueOf=j.valueOf}}}};function a(){}function d(){var k=null,j=f.call(arguments,0);if(typeof j[0]==="function"){k=j.shift()}function g(){this.initialize.apply(this,arguments)}g.superclass=k;g.subclasses=[];if(k){a.prototype=k.prototype;g.prototype=new a;k.subclasses.push(g)}for(var h=0,l=j.length;h-1?c(j,l.match(/opacity:\s*(\d?\.?\d*)/)[1]):j}for(var m in l){if(m==="opacity"){c(j,l[m])}else{var k=(m==="float"||m==="cssFloat")?(typeof n.styleFloat==="undefined"?"cssFloat":"styleFloat"):m;n[k]=l[m]}}return j}var h=fabric.document.createElement("div"),g=typeof h.style.opacity==="string",b=typeof h.style.filter==="string",a=fabric.document.defaultView,f=a&&typeof a.getComputedStyle!=="undefined",d=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,c=function(i){return i};if(g){c=function(i,j){i.style.opacity=j;return i}}else{if(b){c=function(i,j){var k=i.style;if(i.currentStyle&&!i.currentStyle.hasLayout){k.zoom=1}if(d.test(k.filter)){j=j>=0.9999?"":("alpha(opacity="+(j*100)+")");k.filter=k.filter.replace(d,j)}else{k.filter+=" alpha(opacity="+(j*100)+")"}return i}}}fabric.util.setStyle=e})();(function(){var h=Array.prototype.slice;function g(j){return typeof j==="string"?fabric.document.getElementById(j):j}function b(j){return h.call(j,0)}try{var i=b(fabric.document.childNodes) instanceof Array}catch(a){}if(!i){b=function(k){var j=new Array(k.length),l=k.length;while(l--){j[l]=k[l]}return j}}function c(k,j){var l=fabric.document.createElement(k);for(var m in j){if(m==="class"){l.className=j[m]}else{if(m==="for"){l.htmlFor=j[m]}else{l.setAttribute(m,j[m])}}}return l}function f(j,k){if((" "+j.className+" ").indexOf(" "+k+" ")===-1){j.className+=(j.className?" ":"")+k}}function e(k,l,j){if(typeof l==="string"){l=c(l,j)}if(k.parentNode){k.parentNode.replaceChild(l,k)}l.appendChild(k);return l}function d(k){var j=0,l=0;do{j+=k.offsetTop||0;l+=k.offsetLeft||0;k=k.offsetParent}while(k);return({left:l,top:j})}(function(){var k=fabric.document.documentElement.style;var l="userSelect" in k?"userSelect":"MozUserSelect" in k?"MozUserSelect":"WebkitUserSelect" in k?"WebkitUserSelect":"KhtmlUserSelect" in k?"KhtmlUserSelect":"";function m(n){if(typeof n.onselectstart!=="undefined"){n.onselectstart=fabric.util.falseFunction}if(l){n.style[l]="none"}else{if(typeof n.unselectable=="string"){n.unselectable="on"}}return n}function j(n){if(typeof n.onselectstart!=="undefined"){n.onselectstart=null}if(l){n.style[l]=""}else{if(typeof n.unselectable=="string"){n.unselectable=""}}return n}fabric.util.makeElementUnselectable=m;fabric.util.makeElementSelectable=j})();(function(){function j(k,o){var m=fabric.document.getElementsByTagName("head")[0],l=fabric.document.createElement("script"),n=true;l.type="text/javascript";l.setAttribute("runat","server");l.onload=l.onreadystatechange=function(p){if(n){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete"){return}n=false;o(p||fabric.window.event);l=l.onload=l.onreadystatechange=null}};l.src=k;m.appendChild(l)}fabric.util.getScript=j})();fabric.util.getById=g;fabric.util.toArray=b;fabric.util.makeElement=c;fabric.util.addClass=f;fabric.util.wrapElement=e;fabric.util.getElementOffset=d})();(function(){function d(e,f){return e+(/\?/.test(e)?"&":"?")+f}var c=(function(){var h=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest()}];for(var e=h.length;e--;){try{var g=h[e]();if(g){return h[e]}}catch(f){}}})();function a(){}function b(g,f){f||(f={});var j=f.method?f.method.toUpperCase():"GET",i=f.onComplete||function(){},h=c(),e;h.onreadystatechange=function(){if(h.readyState===4){i(h);h.onreadystatechange=a}};if(j==="GET"){e=null;if(typeof f.parameters=="string"){g=d(g,f.parameters)}}h.open(j,g,true);if(j==="POST"||j==="PUT"){h.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}h.send(e);return h}fabric.util.request=b})();(function(){function d(F,E,H,G){return H*(F/=G)*F+E}function l(F,E,H,G){return -H*(F/=G)*(F-2)+E}function r(F,E,H,G){if((F/=G/2)<1){return H/2*F*F+E}return -H/2*((--F)*(F-2)-1)+E}function B(F,E,H,G){return H*(F/=G)*F*F+E}function q(F,E,H,G){return H*((F=F/G-1)*F*F+1)+E}function u(F,E,H,G){if((F/=G/2)<1){return H/2*F*F*F+E}return H/2*((F-=2)*F*F+2)+E}function t(F,E,H,G){return H*(F/=G)*F*F*F+E}function g(F,E,H,G){return -H*((F=F/G-1)*F*F*F-1)+E}function k(F,E,H,G){if((F/=G/2)<1){return H/2*F*F*F*F+E}return -H/2*((F-=2)*F*F*F-2)+E}function y(F,E,H,G){return H*(F/=G)*F*F*F*F+E}function j(F,E,H,G){return H*((F=F/G-1)*F*F*F*F+1)+E}function n(F,E,H,G){if((F/=G/2)<1){return H/2*F*F*F*F*F+E}return H/2*((F-=2)*F*F*F*F+2)+E}function f(F,E,H,G){return -H*Math.cos(F/G*(Math.PI/2))+H+E}function o(F,E,H,G){return H*Math.sin(F/G*(Math.PI/2))+E}function v(F,E,H,G){return -H/2*(Math.cos(Math.PI*F/G)-1)+E}function D(F,E,H,G){return(F==0)?E:H*Math.pow(2,10*(F/G-1))+E}function c(F,E,H,G){return(F==G)?E+H:H*(-Math.pow(2,-10*F/G)+1)+E}function i(F,E,H,G){if(F==0){return E}if(F==G){return E+H}if((F/=G/2)<1){return H/2*Math.pow(2,10*(F-1))+E}return H/2*(-Math.pow(2,-10*--F)+2)+E}function h(F,E,H,G){return -H*(Math.sqrt(1-(F/=G)*F)-1)+E}function p(F,E,H,G){return H*Math.sqrt(1-(F=F/G-1)*F)+E}function x(F,E,H,G){if((F/=G/2)<1){return -H/2*(Math.sqrt(1-F*F)-1)+E}return H/2*(Math.sqrt(1-(F-=2)*F)+1)+E}function s(G,E,K,J){var H=1.70158;var I=0;var F=K;if(G==0){return E}if((G/=J)==1){return E+K}if(!I){I=J*0.3}if(F-1;w=w.split(/\s+/);var u=[];if(y){for(var v=0,t=w.length;v/i,""))}if(!x.documentElement){return}h.parseSVGDocument(x.documentElement,function(A,z){k.set(u,{objects:h.util.array.invoke(A,"toObject"),options:z});w(A,z)},t)}}function b(v){var u=v.objects,t=v.options;u=u.map(function(w){return h[f(w.type)].fromObject(w)});return({objects:u,options:t})}function n(u,x,t){u=u.trim();var v;if(typeof DOMParser!=="undefined"){var w=new DOMParser();if(w&&w.parseFromString){v=w.parseFromString(u,"text/xml")}}else{if(h.window.ActiveXObject){var v=new ActiveXObject("Microsoft.XMLDOM");v.async="false";v.loadXML(u.replace(//i,""))}}h.parseSVGDocument(v.documentElement,function(z,y){x(z,y)},t)}function m(w){var u="";for(var v=0,t=w.length;v",'",""].join("")}return u}p(h,{parseAttributes:e,parseElements:g,parseStyleAttribute:i,parsePointsAttribute:s,getCSSRules:d,loadSVGFromURL:c,loadSVGFromString:n,createSVGFontFacesMarkup:m})})(typeof exports!="undefined"?exports:this);(function(){function c(h){var g=h.getAttribute("style");if(g){var k=g.split(/\s*;\s*/);if(k[k.length-1]===""){k.pop()}for(var f=k.length;f--;){var e=k[f].split(/\s*:\s*/),d=e[0].trim(),j=e[1].trim();if(d==="stop-color"){return j}}}}fabric.Gradient=fabric.util.createClass({initialize:function(d){d||(d={});this.x1=d.x1||0;this.y1=d.y1||0;this.x2=d.x2||0;this.y2=d.y2||0;this.colorStops=d.colorStops},toObject:function(){return{x1:this.x1,x2:this.x2,y1:this.y1,y2:this.y2,colorStops:this.colorStops}},toLiveGradient:function(e){var g=e.createLinearGradient(this.x1,this.y1,this.x2||e.canvas.width,this.y2);for(var d in this.colorStops){var f=this.colorStops[d];g.addColorStop(parseFloat(d),f)}return g}});fabric.util.object.extend(fabric.Gradient,{fromElement:function(h,e){var l=h.getElementsByTagName("stop"),h,k,f={},d,j={x1:h.getAttribute("x1")||0,y1:h.getAttribute("y1")||0,x2:h.getAttribute("x2")||"100%",y2:h.getAttribute("y2")||0};for(var g=l.length;g--;){h=l[g];k=h.getAttribute("offset");k=parseFloat(k)/(/%$/.test(k)?100:1);f[k]=c(h)||h.getAttribute("stop-color")}a(e,j);return new fabric.Gradient({x1:j.x1,y1:j.y1,x2:j.x2,y2:j.y2,colorStops:f})},forObject:function(e,d){d||(d={});a(e,d);return new fabric.Gradient(d)}});function a(f,e){for(var g in e){if(typeof e[g]==="string"&&/^\d+%$/.test(e[g])){var d=parseFloat(e[g],10);if(g==="x1"||g==="x2"){e[g]=f.width*d/100}else{if(g==="y1"||g==="y2"){e[g]=f.height*d/100}}}if(g==="x1"||g==="x2"){e[g]-=f.width/2}else{if(g==="y1"||g==="y2"){e[g]-=f.height/2}}}}function b(j){var f=j.getElementsByTagName("linearGradient"),d=j.getElementsByTagName("radialGradient"),g,h={};for(var e=f.length;e--;){g=f[e];h[g.getAttribute("id")]=g}for(var e=d.length;e--;){g=d[e];h[g.getAttribute("id")]=g}return h}fabric.getGradientDefs=b})();(function(b){var c=b.fabric||(b.fabric={});if(c.Point){c.warn("fabric.Point is already defined");return}c.Point=a;function a(d,e){if(arguments.length>0){this.init(d,e)}}a.prototype={constructor:a,init:function(d,e){this.x=d;this.y=e},add:function(d){return new a(this.x+d.x,this.y+d.y)},addEquals:function(d){this.x+=d.x;this.y+=d.y;return this},scalarAdd:function(d){return new a(this.x+d,this.y+d)},scalarAddEquals:function(d){this.x+=d;this.y+=d;return this},subtract:function(d){return new a(this.x-d.x,this.y-d.y)},subtractEquals:function(d){this.x-=d.x;this.y-=d.y;return this},scalarSubtract:function(d){return new a(this.x-d,this.y-d)},scalarSubtractEquals:function(d){this.x-=d;this.y-=d;return this},multiply:function(d){return new a(this.x*d,this.y*d)},multiplyEquals:function(d){this.x*=d;this.y*=d;return this},divide:function(d){return new a(this.x/d,this.y/d)},divideEquals:function(d){this.x/=d;this.y/=d;return this},eq:function(d){return(this.x==d.x&&this.y==d.y)},lt:function(d){return(this.xd.x&&this.y>d.y)},gte:function(d){return(this.x>=d.x&&this.y>=d.y)},lerp:function(e,d){return new a(this.x+(e.x-this.x)*d,this.y+(e.y-this.y)*d)},distanceFrom:function(f){var e=this.x-f.x,d=this.y-f.y;return Math.sqrt(e*e+d*d)},min:function(d){return new a(Math.min(this.x,d.x),Math.min(this.y,d.y))},max:function(d){return new a(Math.max(this.x,d.x),Math.max(this.y,d.y))},toString:function(){return this.x+","+this.y},setXY:function(d,e){this.x=d;this.y=e},setFromPoint:function(d){this.x=d.x;this.y=d.y},swap:function(e){var d=this.x,f=this.y;this.x=e.x;this.y=e.y;e.x=d;e.y=f}}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={});if(b.Intersection){b.warn("fabric.Intersection is already defined");return}function c(d){if(arguments.length>0){this.init(d)}}b.Intersection=c;b.Intersection.prototype={init:function(d){this.status=d;this.points=[]},appendPoint:function(d){this.points.push(d)},appendPoints:function(d){this.points=this.points.concat(d)}};b.Intersection.intersectLineLine=function(h,f,l,k){var m,i=(k.x-l.x)*(h.y-l.y)-(k.y-l.y)*(h.x-l.x),j=(f.x-h.x)*(h.y-l.y)-(f.y-h.y)*(h.x-l.x),g=(k.y-l.y)*(f.x-h.x)-(k.x-l.x)*(f.y-h.y);if(g!=0){var e=i/g,d=j/g;if(0<=e&&e<=1&&0<=d&&d<=1){m=new c("Intersection");m.points.push(new b.Point(h.x+e*(f.x-h.x),h.y+e*(f.y-h.y)))}else{m=new c("No Intersection")}}else{if(i==0||j==0){m=new c("Coincident")}else{m=new c("Parallel")}}return m};b.Intersection.intersectLinePolygon=function(e,d,l){var m=new c("No Intersection"),f=l.length;for(var h=0;h0){m.status="Intersection"}return m};b.Intersection.intersectPolygonPolygon=function(j,h){var f=new c("No Intersection"),l=j.length;for(var k=0;k0){f.status="Intersection"}return f};b.Intersection.intersectPolygonRectangle=function(n,e,d){var g=e.min(d),m=e.max(d),f=new b.Point(m.x,g.y),l=new b.Point(g.x,m.y),k=c.intersectLinePolygon(g,f,n),j=c.intersectLinePolygon(f,m,n),i=c.intersectLinePolygon(m,l,n),h=c.intersectLinePolygon(l,g,n),o=new c("No Intersection");o.appendPoints(k.points);o.appendPoints(j.points);o.appendPoints(i.points);o.appendPoints(h.points);if(o.points.length>0){o.status="Intersection"}return o}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={});if(b.Color){b.warn("fabric.Color is already defined.");return}function c(d){if(!d){this.setSource([0,0,0,1])}else{this._tryParsingColor(d)}}b.Color=c;b.Color.prototype={_tryParsingColor:function(d){var e=c.sourceFromHex(d);if(!e){e=c.sourceFromRgb(d)}if(e){this.setSource(e)}},getSource:function(){return this._source},setSource:function(d){this._source=d},toRgb:function(){var d=this.getSource();return"rgb("+d[0]+","+d[1]+","+d[2]+")"},toRgba:function(){var d=this.getSource();return"rgba("+d[0]+","+d[1]+","+d[2]+","+d[3]+")"},toHex:function(){var h=this.getSource();var f=h[0].toString(16);f=(f.length==1)?("0"+f):f;var e=h[1].toString(16);e=(e.length==1)?("0"+e):e;var d=h[2].toString(16);d=(d.length==1)?("0"+d):d;return f.toUpperCase()+e.toUpperCase()+d.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(e){var d=this.getSource();d[3]=e;this.setSource(d);return this},toGrayscale:function(){var f=this.getSource(),e=parseInt((f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),10),d=f[3];this.setSource([e,e,e,d]);return this},toBlackWhite:function(d){var g=this.getSource(),f=(g[0]*0.3+g[1]*0.59+g[2]*0.11).toFixed(0),e=g[3],d=d||127;f=(Number(f)','',"',"Created with Fabric.js ",fabric.version,"",fabric.createSVGFontFacesMarkup(this.getObjects())];if(this.backgroundImage){h.push('')}for(var j=0,k=this.getObjects(),g=k.length;j");return h.join("")},isEmpty:function(){return this._objects.length===0},remove:function(g){e(this._objects,g);if(this.getActiveObject()===g){this.fire("before:selection:cleared",{target:g});this.discardActiveObject();this.fire("selection:cleared")}this.renderAll();return g},sendToBack:function(g){e(this._objects,g);this._objects.unshift(g);return this.renderAll()},bringToFront:function(g){e(this._objects,g);this._objects.push(g);return this.renderAll()},sendBackwards:function(j){var h=this._objects.indexOf(j),g=h;if(h!==0){for(var k=h-1;k>=0;--k){if(j.intersectsWithObject(this._objects[k])||j.isContainedWithinObject(this._objects[k])){g=k;break}}e(this._objects,j);this._objects.splice(g,0,j)}return this.renderAll()},bringForward:function(k){var n=this.getObjects(),h=n.indexOf(k),g=h;if(h!==n.length-1){for(var m=h+1,j=this._objects.length;m"};f(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(l){var k=l.getContext("2d"),g=k.getImageData(0,0,l.width,l.height),p=g.data,m=g.width,r=g.height,q,h,o,n;for(o=0;o0)?0:-v),r.ey-((u>0)?0:-u),t,s);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(r.ex+a-((v>0)?0:t),r.ey+a-((u>0)?0:s),t,s)},_findSelectedObjects:function(x){var y,t,D=[],s=this._groupSelector.ex,C=this._groupSelector.ey,r=s+this._groupSelector.left,A=C+this._groupSelector.top,z,w=new fabric.Point(f(s,r),f(C,A)),B=new fabric.Point(l(s,r),l(C,A));for(var u=0,v=this._objects.length;u1){var D=new fabric.Group(D);this.setActiveGroup(D);D.saveCoords();this.fire("selection:created",{target:D})}}this.renderAll()},findTarget:function(v,s){var u,w=this.getPointer(v);var t=this.getActiveGroup();if(t&&!s&&this.containsPoint(v,t)){u=t;return u}for(var r=this._objects.length;r--;){if(this._objects[r]&&this.containsPoint(v,this._objects[r])){u=this._objects[r];this.relatedTarget=u;break}}if(u&&u.selectable){return u}},getPointer:function(r){var s=q(r);return{x:s.x-this._offset.left,y:s.y-this._offset.top}},_createUpperCanvas:function(){this.upperCanvasEl=this._createCanvasElement();this.upperCanvasEl.className="upper-canvas";this.wrapperEl.appendChild(this.upperCanvasEl);this._applyCanvasStyle(this.upperCanvasEl);this.contextTop=this.upperCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.lowerCanvasEl,"div",{"class":this.containerClass});fabric.util.setStyle(this.wrapperEl,{width:this.getWidth()+"px",height:this.getHeight()+"px",position:"relative"});fabric.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(s){var t=this.getWidth()||s.width,r=this.getHeight()||s.height;fabric.util.setStyle(s,{position:"absolute",width:t+"px",height:r+"px",left:0,top:0});s.width=t;s.height=r;fabric.util.makeElementUnselectable(s)},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},setActiveObject:function(r,s){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=r;r.setActive(true);this.renderAll();this.fire("object:selected",{target:r,e:s});r.fire("selected",{e:s});return this},getActiveObject:function(){return this._activeObject},discardActiveObject:function(){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=null;return this},setActiveGroup:function(r){this._activeGroup=r;r&&r.setActive(true);return this},getActiveGroup:function(){return this._activeGroup},discardActiveGroup:function(){var r=this.getActiveGroup();if(r){r.destroy()}return this.setActiveGroup(null)},deactivateAll:function(){var s=this.getObjects(),t=0,r=s.length;for(;t1)?q.apply(this,o.call(arguments,1)):q.call(this)},initialize:function(i){if(i){this.setOptions(i);this._initGradient(i)}},_initGradient:function(i){if(i.fill&&typeof i.fill=="object"&&!(i.fill instanceof d.Gradient)){this.set("fill",new d.Gradient(i.fill))}},setOptions:function(q){var r=this.stateProperties.length,s;while(r--){s=this.stateProperties[r];if(s in q){this.set(s,q[s])}}},transform:function(i){i.globalAlpha=this.opacity;i.translate(this.left,this.top);i.rotate(this._theta);i.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toObject:function(){var q=d.Object.NUM_FRACTION_DIGITS;var i={type:this.type,left:c(this.left,q),top:c(this.top,q),width:c(this.width,q),height:c(this.height,q),fill:(this.fill&&this.fill.toObject)?this.fill.toObject():this.fill,overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,strokeDashArray:this.strokeDashArray,scaleX:c(this.scaleX,q),scaleY:c(this.scaleY,q),angle:c(this.getAngle(),q),flipX:this.flipX,flipY:this.flipY,opacity:c(this.opacity,q),selectable:this.selectable,hasControls:this.hasControls,hasBorders:this.hasBorders,hasRotatingPoint:this.hasRotatingPoint};if(!this.includeDefaultValues){i=this._removeDefaultValues(i)}return i},toDatalessObject:function(){return this.toObject()},getSvgStyles:function(){return["stroke: ",(this.stroke?this.stroke:"none"),"; ","stroke-width: ",(this.strokeWidth?this.strokeWidth:"0"),"; ","stroke-dasharray: ",(this.strokeDashArray?this.strokeDashArray.join(" "):"; "),"fill: ",(this.fill?this.fill:"none"),"; ","opacity: ",(this.opacity?this.opacity:"1"),";"].join("")},getSvgTransform:function(){var i=this.getAngle();return["translate(",c(this.left,2)," ",c(this.top,2),")",i!==0?(" rotate("+c(i,2)+")"):"",(this.scaleX===1&&this.scaleY===1)?"":(" scale("+c(this.scaleX,2)+" "+c(this.scaleY,2)+")")].join("")},_removeDefaultValues:function(q){var i=d.Object.prototype.options;if(i){this.stateProperties.forEach(function(r){if(q[r]===i[r]){delete q[r]}})}return q},isActive:function(){return !!this.active},setActive:function(i){this.active=!!i;return this},toString:function(){return"#"},set:function(i,q){if(typeof i==="object"){for(var r in i){this._set(r,i[r])}}else{if(typeof q==="function"){this._set(i,q(this.get(i)))}else{this._set(i,q)}}return this},_set:function(i,q){var r=(i==="scaleX"||i==="scaleY")&&q1?this.strokeWidth:0,B=this.padding;this.currentWidth=(this.width+z)*this.scaleX+B*2;this.currentHeight=(this.height+z)*this.scaleY+B*2;this._hypotenuse=Math.sqrt(Math.pow(this.currentWidth/2,2)+Math.pow(this.currentHeight/2,2));this._angle=Math.atan(this.currentHeight/this.currentWidth);var w=Math.cos(this._angle+this._theta)*this._hypotenuse,v=Math.sin(this._angle+this._theta)*this._hypotenuse,r=this._theta,A=Math.sin(r),y=Math.cos(r);var E={x:this.left-w,y:this.top-v};var x={x:E.x+(this.currentWidth*y),y:E.y+(this.currentWidth*A)};var D={x:x.x-(this.currentHeight*A),y:x.y+(this.currentHeight*y)};var s={x:E.x-(this.currentHeight*A),y:E.y+(this.currentHeight*y)};var u={x:E.x-(this.currentHeight/2*A),y:E.y+(this.currentHeight/2*y)};var i={x:E.x+(this.currentWidth/2*y),y:E.y+(this.currentWidth/2*A)};var q={x:x.x-(this.currentHeight/2*A),y:x.y+(this.currentHeight/2*y)};var C={x:s.x+(this.currentWidth/2*y),y:s.y+(this.currentWidth/2*A)};var t={x:E.x+(this.currentWidth/2*y),y:E.y+(this.currentWidth/2*A)};this.oCoords={tl:E,tr:x,br:D,bl:s,ml:u,mt:i,mr:q,mb:C,mtr:t};this._setCornerCoords();return this},getBoundingRectWidth:function(){this.oCoords||this.setCoords();var q=[this.oCoords.tl.x,this.oCoords.tr.x,this.oCoords.br.x,this.oCoords.bl.x];var i=d.util.array.min(q);var r=d.util.array.max(q);return Math.abs(i-r)},getBoundingRectHeight:function(){this.oCoords||this.setCoords();var i=[this.oCoords.tl.y,this.oCoords.tr.y,this.oCoords.br.y,this.oCoords.bl.y];var r=d.util.array.min(i);var q=d.util.array.max(i);return Math.abs(r-q)},drawBorders:function(A){if(!this.hasBorders){return}var t=d.Object.MIN_SCALE_LIMIT,v=this.padding,i=v*2,u=this.strokeWidth>1?this.strokeWidth:0;A.save();A.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;A.strokeStyle=this.borderColor;var z=1/(this.scaleXi){var C=x-i}if(E){z+=(D*E)-(C*E||0)}else{v+=(D*y)-(C*y||0)}B[1&s?"moveTo":"lineTo"](z,v);if(s>=u){s=0}}}q(1,0);q(0,1);q(-1,0);q(0,-1);B.stroke();B.closePath();B.restore()},drawCorners:function(A){if(!this.hasControls){return}var w=this.cornersize,r=w/2,i=this.strokeWidth/2,q=-(this.width/2),u=-(this.height/2),G,B,y=w/this.scaleX,v=w/this.scaleY,D=this.padding/this.scaleX,C=this.padding/this.scaleY,E=r/this.scaleY,F=r/this.scaleX,t=(r-w)/this.scaleX,s=(r-w)/this.scaleY,x=this.height,z=this.width;A.save();A.lineWidth=1/Math.max(this.scaleX,this.scaleY);A.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;A.strokeStyle=A.fillStyle=this.cornerColor;G=q-F-i-D;B=u-E-i-C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q+z-F+i+D;B=u-E-i-C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q-F-i-D;B=u+x+s+i+C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q+z+t+i+D;B=u+x+s+i+C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);if(!this.lockUniScaling){G=q+z/2-F;B=u-E-i-C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q+z/2-F;B=u+x+s+i+C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q+z+t+i+D;B=u+x/2-E;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q-F-i-D;B=u+x/2-E;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v)}if(this.hasRotatingPoint){G=q+z/2-F;B=this.flipY?(u+x+(this.rotatingPointOffset/this.scaleY)-v/2+i+C):(u-(this.rotatingPointOffset/this.scaleY)-v/2-i-C);A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v)}A.restore();return this},clone:function(i){if(this.constructor.fromObject){return this.constructor.fromObject(this.toObject(),i)}return new d.Object(this.toObject())},cloneAsImage:function(s){if(d.Image){var q=new Image();q.onload=function(){if(s){s(new d.Image(q),r)}q=q.onload=null};var r={angle:this.get("angle"),flipX:this.get("flipX"),flipY:this.get("flipY")};this.set("angle",0).set("flipX",false).set("flipY",false);this.toDataURL(function(i){q.src=i})}return this},toDataURL:function(s){var q=d.document.createElement("canvas");if(!q.getContext&&typeof G_vmlCanvasManager!="undefined"){G_vmlCanvasManager.initElement(q)}this.setCoords();q.width=this.getBoundingRectWidth();q.height=this.getBoundingRectHeight();d.util.wrapElement(q,"div");var i=new d.Canvas(q);i.backgroundColor="transparent";i.renderAll();if(this.constructor.async){this.clone(r)}else{r(this.clone())}function r(u){u.left=q.width/2;u.top=q.height/2;u.setActive(false);i.add(u);var t=i.toDataURL("png");i.dispose();i=u=null;s&&s(t)}},hasStateChanged:function(){return this.stateProperties.some(function(i){return this[i]!==this.originalState[i]},this)},saveState:function(){this.stateProperties.forEach(function(i){this.originalState[i]=this.get(i)},this);return this},setupState:function(){this.originalState={};this.saveState()},intersectsWithRect:function(r,t){var w=this.oCoords,i=new d.Point(w.tl.x,w.tl.y),s=new d.Point(w.tr.x,w.tr.y),v=new d.Point(w.bl.x,w.bl.y),q=new d.Point(w.br.x,w.br.y);var u=d.Intersection.intersectPolygonRectangle([i,s,q,v],r,t);return(u.status==="Intersection")},intersectsWithObject:function(i){function q(u){return{tl:new d.Point(u.tl.x,u.tl.y),tr:new d.Point(u.tr.x,u.tr.y),bl:new d.Point(u.bl.x,u.bl.y),br:new d.Point(u.br.x,u.br.y)}}var r=q(this.oCoords),t=q(i.oCoords);var s=d.Intersection.intersectPolygonPolygon([r.tl,r.tr,r.br,r.bl],[t.tl,t.tr,t.br,t.bl]);return(s.status==="Intersection")},isContainedWithinObject:function(i){return this.isContainedWithinRect(i.oCoords.tl,i.oCoords.br)},isContainedWithinRect:function(r,t){var v=this.oCoords,i=new d.Point(v.tl.x,v.tl.y),s=new d.Point(v.tr.x,v.tr.y),u=new d.Point(v.bl.x,v.bl.y),q=new d.Point(v.br.x,v.br.y);return i.x>r.x&&s.xr.y&&u.y=v)&&(s.d.y>=v)){continue}if((s.o.x==s.d.x)&&(s.o.x>=w)){x=s.o.x;u=v}else{z=0;y=(s.d.y-s.o.y)/(s.d.x-s.o.x);r=v-z*w;q=s.o.y-y*s.o.x;x=-(r-q)/(z-y);u=r+z*x}if(x>=w){t+=1}if(t==2){break}}return t},_getImageLines:function(r,q){return{topline:{o:r.tl,d:r.tr},rightline:{o:r.tr,d:r.br},bottomline:{o:r.br,d:r.bl},leftline:{o:r.bl,d:r.tl}}},_setCornerCoords:function(){var u=this.oCoords,q=b(45-this.getAngle()),s=Math.sqrt(2*Math.pow(this.cornersize,2))/2,i=s*Math.cos(q),r=s*Math.sin(q),v=Math.sin(this._theta),t=Math.cos(this._theta);u.tl.corner={tl:{x:u.tl.x-r,y:u.tl.y-i},tr:{x:u.tl.x+i,y:u.tl.y-r},bl:{x:u.tl.x-i,y:u.tl.y+r},br:{x:u.tl.x+r,y:u.tl.y+i}};u.tr.corner={tl:{x:u.tr.x-r,y:u.tr.y-i},tr:{x:u.tr.x+i,y:u.tr.y-r},br:{x:u.tr.x+r,y:u.tr.y+i},bl:{x:u.tr.x-i,y:u.tr.y+r}};u.bl.corner={tl:{x:u.bl.x-r,y:u.bl.y-i},bl:{x:u.bl.x-i,y:u.bl.y+r},br:{x:u.bl.x+r,y:u.bl.y+i},tr:{x:u.bl.x+i,y:u.bl.y-r}};u.br.corner={tr:{x:u.br.x+i,y:u.br.y-r},bl:{x:u.br.x-i,y:u.br.y+r},br:{x:u.br.x+r,y:u.br.y+i},tl:{x:u.br.x-r,y:u.br.y-i}};u.ml.corner={tl:{x:u.ml.x-r,y:u.ml.y-i},tr:{x:u.ml.x+i,y:u.ml.y-r},bl:{x:u.ml.x-i,y:u.ml.y+r},br:{x:u.ml.x+r,y:u.ml.y+i}};u.mt.corner={tl:{x:u.mt.x-r,y:u.mt.y-i},tr:{x:u.mt.x+i,y:u.mt.y-r},bl:{x:u.mt.x-i,y:u.mt.y+r},br:{x:u.mt.x+r,y:u.mt.y+i}};u.mr.corner={tl:{x:u.mr.x-r,y:u.mr.y-i},tr:{x:u.mr.x+i,y:u.mr.y-r},bl:{x:u.mr.x-i,y:u.mr.y+r},br:{x:u.mr.x+r,y:u.mr.y+i}};u.mb.corner={tl:{x:u.mb.x-r,y:u.mb.y-i},tr:{x:u.mb.x+i,y:u.mb.y-r},bl:{x:u.mb.x-i,y:u.mb.y+r},br:{x:u.mb.x+r,y:u.mb.y+i}};u.mtr.corner={tl:{x:u.mtr.x-r+(v*this.rotatingPointOffset),y:u.mtr.y-i-(t*this.rotatingPointOffset)},tr:{x:u.mtr.x+i+(v*this.rotatingPointOffset),y:u.mtr.y-r-(t*this.rotatingPointOffset)},bl:{x:u.mtr.x-i+(v*this.rotatingPointOffset),y:u.mtr.y+r-(t*this.rotatingPointOffset)},br:{x:u.mtr.x+r+(v*this.rotatingPointOffset),y:u.mtr.y+i-(t*this.rotatingPointOffset)}}},toGrayscale:function(){var i=this.get("fill");if(i){this.set("overlayFill",new d.Color(i).toGrayscale().toRgb())}return this},complexity:function(){return 0},toJSON:function(){return this.toObject()},setGradientFill:function(i){this.set("fill",d.Gradient.forObject(this,i))},animate:function(){if(arguments[0]&&typeof arguments[0]=="object"){for(var i in arguments[0]){this._animate(i,arguments[0][i],arguments[1])}}else{this._animate.apply(this,arguments)}return this},_animate:function(q,s,i){var r=this;i||(i={});if(!("from" in i)){i.from=this.get(q)}if(/[+-]/.test((s+"").charAt(0))){s=this.get(q)+parseFloat(s)}d.util.animate({startValue:i.from,endValue:s,byValue:i.by,easing:i.easing,duration:i.duration,onChange:function(t){r.set(q,t);i.onChange&&i.onChange()},onComplete:function(){r.setCoords();i.onComplete&&i.onComplete()}})},centerH:function(){this.canvas.centerObjectH(this);return this},centerV:function(){this.canvas.centerObjectV(this);return this},center:function(){return this.centerH().centerV()},remove:function(){return this.canvas.remove(this)},sendToBack:function(){this.canvas.sendToBack(this);return this},bringToFront:function(){this.canvas.bringToFront(this);return this},sendBackwards:function(){this.canvas.sendBackwards(this);return this},bringForward:function(){this.canvas.bringForward(this);return this}});d.Object.prototype.rotate=d.Object.prototype.setAngle;var j=d.Object.prototype;for(var g=j.stateProperties.length;g--;){var h=j.stateProperties[g],e=h.charAt(0).toUpperCase()+h.slice(1),f="set"+e,n="get"+e;if(!j[n]){j[n]=(function(i){return new Function('return this.get("'+i+'")')})(h)}if(!j[f]){j[f]=(function(i){return new Function("value",'return this.set("'+i+'", value)')})(h)}}l(d.Object.prototype,d.Observable);l(d.Object,{NUM_FRACTION_DIGITS:2,MIN_SCALE_LIMIT:0.1})})(typeof exports!="undefined"?exports:this);(function(b){var c=b.fabric||(b.fabric={}),e=c.util.object.extend,d=c.Object.prototype.set,a={x1:1,x2:1,y1:1,y2:1};if(c.Line){c.warn("fabric.Line is already defined");return}c.Line=c.util.createClass(c.Object,{type:"line",initialize:function(g,f){if(!g){g=[0,0,0,0]}this.callSuper("initialize",f);this.set("x1",g[0]);this.set("y1",g[1]);this.set("x2",g[2]);this.set("y2",g[3]);this._setWidthHeight(f)},_setWidthHeight:function(f){f||(f={});this.set("width",(this.x2-this.x1)||1);this.set("height",(this.y2-this.y1)||1);this.set("left","left" in f?f.left:(this.x1+this.width/2));this.set("top","top" in f?f.top:(this.y1+this.height/2))},_set:function(f,g){this[f]=g;if(f in a){this._setWidthHeight()}return this},_render:function(f){f.beginPath();if(this.group){f.translate(-this.group.width/2+this.left,-this.group.height/2+this.top)}f.moveTo(this.width===1?0:(-this.width/2),this.height===1?0:(-this.height/2));f.lineTo(this.width===1?0:(this.width/2),this.height===1?0:(this.height/2));f.lineWidth=this.strokeWidth;var g=f.strokeStyle;f.strokeStyle=f.fillStyle;f.stroke();f.strokeStyle=g},complexity:function(){return 1},toObject:function(){return e(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})},toSVG:function(){return[""].join("")}});c.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");c.Line.fromElement=function(g,f){var i=c.parseAttributes(g,c.Line.ATTRIBUTE_NAMES);var h=[i.x1||0,i.y1||0,i.x2||0,i.y2||0];return new c.Line(h,e(i,f))};c.Line.fromObject=function(f){var g=[f.x1,f.y1,f.x2,f.y2];return new c.Line(g,f)}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={}),d=Math.PI*2,e=b.util.object.extend;if(b.Circle){b.warn("fabric.Circle is already defined.");return}b.Circle=b.util.createClass(b.Object,{type:"circle",initialize:function(f){f=f||{};this.set("radius",f.radius||0);this.callSuper("initialize",f);var g=this.get("radius")*2;this.set("width",g).set("height",g)},toObject:function(){return e(this.callSuper("toObject"),{radius:this.get("radius")})},toSVG:function(){return('')},_render:function(f,g){f.beginPath();f.globalAlpha*=this.opacity;f.arc(g?this.left:0,g?this.top:0,this.radius,0,d,false);f.closePath();if(this.fill){f.fill()}if(this.stroke){f.stroke()}},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(f){this.radius=f;this.set("width",f*2).set("height",f*2)},complexity:function(){return 1}});b.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity opacity stroke stroke-width transform".split(" ");b.Circle.fromElement=function(g,f){f||(f={});var h=b.parseAttributes(g,b.Circle.ATTRIBUTE_NAMES);if(!c(h)){throw Error("value of `r` attribute is required and can not be negative")}if("left" in h){h.left-=(f.width/2)||0}if("top" in h){h.top-=(f.height/2)||0}return new b.Circle(e(h,f))};function c(f){return(("radius" in f)&&(f.radius>0))}b.Circle.fromObject=function(f){return new b.Circle(f)}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={});if(b.Triangle){b.warn("fabric.Triangle is already defined");return}b.Triangle=b.util.createClass(b.Object,{type:"triangle",initialize:function(c){c=c||{};this.callSuper("initialize",c);this.set("width",c.width||100).set("height",c.height||100)},_render:function(c){var d=this.width/2,e=this.height/2;c.beginPath();c.moveTo(-d,e);c.lineTo(0,-e);c.lineTo(d,e);c.closePath();if(this.fill){c.fill()}if(this.stroke){c.stroke()}},complexity:function(){return 1},toSVG:function(){var c=this.width/2,d=this.height/2;var e=[-c+" "+d,"0 "+-d,c+" "+d].join(",");return''}});b.Triangle.fromObject=function(c){return new b.Triangle(c)}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={}),c=Math.PI*2,d=b.util.object.extend;if(b.Ellipse){b.warn("fabric.Ellipse is already defined.");return}b.Ellipse=b.util.createClass(b.Object,{type:"ellipse",initialize:function(e){e=e||{};this.callSuper("initialize",e);this.set("rx",e.rx||0);this.set("ry",e.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return d(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},toSVG:function(){return[""].join("")},render:function(e,f){if(this.rx===0||this.ry===0){return}return this.callSuper("render",e,f)},_render:function(e,f){e.beginPath();e.save();e.globalAlpha*=this.opacity;if(this.transformMatrix&&this.group){e.translate(this.cx,this.cy)}e.transform(1,0,0,this.ry/this.rx,0,0);e.arc(f?this.left:0,f?this.top:0,this.rx,0,c,false);if(this.stroke){e.stroke()}if(this.fill){e.fill()}e.restore()},complexity:function(){return 1}});b.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity opacity stroke stroke-width transform".split(" ");b.Ellipse.fromElement=function(g,f){f||(f={});var i=b.parseAttributes(g,b.Ellipse.ATTRIBUTE_NAMES);var e=i.left;var j=i.top;if("left" in i){i.left-=(f.width/2)||0}if("top" in i){i.top-=(f.height/2)||0}var h=new b.Ellipse(d(i,f));h.cx=e||0;h.cy=j||0;return h};b.Ellipse.fromObject=function(e){return new b.Ellipse(e)}})(typeof exports!="undefined"?exports:this);(function(b){var c=b.fabric||(b.fabric={});if(c.Rect){console.warn("fabric.Rect is already defined");return}c.Rect=c.util.createClass(c.Object,{type:"rect",rx:0,ry:0,initialize:function(d){this._initStateProperties();this.callSuper("initialize",d);this._initRxRy()},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat(["rx","ry"])},_initRxRy:function(){if(this.rx&&!this.ry){this.ry=this.rx}else{if(this.ry&&!this.rx){this.rx=this.ry}}},_render:function(f){var j=this.rx||0,i=this.ry||0,d=-this.width/2,k=-this.height/2,e=this.width,g=this.height;f.beginPath();f.globalAlpha*=this.opacity;if(this.transformMatrix&&this.group){f.translate(this.width/2+this.x,this.height/2+this.y)}if(!this.transformMatrix&&this.group){f.translate(-this.group.width/2+this.width/2+this.x,-this.group.height/2+this.height/2+this.y)}f.moveTo(d+j,k);f.lineTo(d+e-j,k);f.quadraticCurveTo(d+e,k,d+e,k+i,d+e,k+i);f.lineTo(d+e,k+g-i);f.quadraticCurveTo(d+e,k+g,d+e-j,k+g,d+e-j,k+g);f.lineTo(d+j,k+g);f.quadraticCurveTo(d,k+g,d,k+g-i,d,k+g-i);f.lineTo(d,k+i);f.quadraticCurveTo(d,k,d+j,k,d+j,k);f.closePath();if(this.fill){f.fill()}if(this.strokeDashArray){this._renderDashedStroke(f)}else{if(this.stroke){f.stroke()}}},_normalizeLeftTopProperties:function(d){if(d.left){this.set("left",d.left+this.getWidth()/2)}this.set("x",d.left||0);if(d.top){this.set("top",d.top+this.getHeight()/2)}this.set("y",d.top||0);return this},complexity:function(){return 1},toObject:function(){return c.util.object.extend(this.callSuper("toObject"),{rx:this.get("rx")||0,ry:this.get("ry")||0})},toSVG:function(){return''}});c.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity opacity stroke stroke-width transform".split(" ");function a(d){d.left=d.left||0;d.top=d.top||0;return d}c.Rect.fromElement=function(e,d){if(!e){return null}var g=c.parseAttributes(e,c.Rect.ATTRIBUTE_NAMES);g=a(g);var f=new c.Rect(c.util.object.extend((d?c.util.object.clone(d):{}),g));f._normalizeLeftTopProperties(g);return f};c.Rect.fromObject=function(d){return new c.Rect(d)}})(typeof exports!="undefined"?exports:this);(function(b){var c=b.fabric||(b.fabric={}),a=c.util.toFixed;if(c.Polyline){c.warn("fabric.Polyline is already defined");return}c.Polyline=c.util.createClass(c.Object,{type:"polyline",initialize:function(e,d){d=d||{};this.set("points",e);this.callSuper("initialize",d);this._calcDimensions()},_calcDimensions:function(){return c.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return c.Polygon.prototype.toObject.call(this)},toSVG:function(){var f=[];for(var e=0,d=this.points.length;e"].join("")},_render:function(f){var e;f.beginPath();f.moveTo(this.points[0].x,this.points[0].y);for(var g=0,d=this.points.length;g"].join("")},_render:function(l){var k;l.beginPath();l.moveTo(this.points[0].x,this.points[0].y);for(var m=0,j=this.points.length;m1){E=Math.sqrt(E);O*=E;N*=E}var R=aa/O;var Q=W/O;var D=(-W)/N;var C=(aa)/N;var H=R*M+Q*L;var q=D*M+C*L;var F=R*T+Q*S;var ab=D*T+C*S;var Z=(F-H)*(F-H)+(ab-q)*(ab-q);var U=1/Z-0.25;if(U<0){U=0}var w=Math.sqrt(U);if(P==J){w=-w}var V=0.5*(H+F)-w*(ab-q);var K=0.5*(q+ab)+w*(F-H);var v=Math.atan2(q-K,H-V);var u=Math.atan2(ab-K,F-V);var Y=u-v;if(Y<0&&P==1){Y+=2*Math.PI}else{if(Y>0&&P==0){Y-=2*Math.PI}}var B=Math.ceil(Math.abs(Y/(Math.PI*0.5+0.001)));var I=[];for(var X=0;X"},toObject:function(){var q=g(this.callSuper("toObject"),{path:this.path});if(this.sourcePath){q.sourcePath=this.sourcePath}if(this.transformMatrix){q.transformMatrix=this.transformMatrix}return q},toDatalessObject:function(){var q=this.toObject();if(this.sourcePath){q.path=this.sourcePath}delete q.sourcePath;return q},toSVG:function(){var t=[];for(var r=0,q=this.path.length;r',"',""].join("")},complexity:function(){return this.path.length},_parsePath:function(){var C=[],z,v,y;for(var u=0,t,q,w=this.path.length;uB){for(var r=1,x=q.length;r"];for(var l=0,j=m.length;l");return k.join("")},toString:function(){return"#"},isSameColor:function(){var j=this.getObjects()[0].get("fill");return this.getObjects().every(function(k){return k.get("fill")===j})},complexity:function(){return this.paths.reduce(function(j,k){return j+((k&&k.complexity)?k.complexity():0)},0)},toGrayscale:function(){var j=this.paths.length;while(j--){this.paths[j].toGrayscale()}return this},getObjects:function(){return this.paths}});function c(m){for(var l=0,j=m.length;l"},getObjects:function(){return this.objects},addWithUpdate:function(h){this._restoreObjectsState();this.objects.push(h);this._calcBounds();this._updateObjectsCoords();return this},removeWithUpdate:function(h){this._restoreObjectsState();f(this.objects,h);h.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},add:function(h){this.objects.push(h);return this},remove:function(h){f(this.objects,h);return this},size:function(){return this.getObjects().length},_set:function(j,k){if(j==="fill"||j==="opacity"){var h=this.objects.length;this[j]=k;while(h--){this.objects[h].set(j,k)}}else{this[j]=k}},contains:function(h){return this.objects.indexOf(h)>-1},toObject:function(){return g(this.callSuper("toObject"),{objects:b(this.objects,"clone")})},render:function(j,o){j.save();this.transform(j);var n=Math.max(this.scaleX,this.scaleY);for(var l=0,h=this.objects.length,k;k=this.objects[l];l++){var m=k.borderScaleFactor;k.borderScaleFactor=n;k.render(j);k.borderScaleFactor=m}if(!o&&this.active){this.drawBorders(j);this.hideCorners||this.drawCorners(j)}j.restore();this.setCoords()},item:function(h){return this.getObjects()[h]},complexity:function(){return this.getObjects().reduce(function(i,h){i+=(typeof h.complexity=="function")?h.complexity():0;return i},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,this);return this},_restoreObjectState:function(j){var l=this.get("left"),m=this.get("top"),h=this.getAngle()*(Math.PI/180),k=j.get("originalLeft"),n=j.get("originalTop"),i=Math.cos(h)*j.get("top")+Math.sin(h)*j.get("left"),o=-Math.sin(h)*j.get("top")+Math.cos(h)*j.get("left");j.setAngle(j.getAngle()+this.getAngle());j.set("left",l+o*this.get("scaleX"));j.set("top",m+i*this.get("scaleY"));j.set("scaleX",j.get("scaleX")*this.get("scaleX"));j.set("scaleY",j.get("scaleY")*this.get("scaleY"));j.setCoords();j.hideCorners=false;j.setActive(false);j.setCoords();return this},destroy:function(){return this._restoreObjectsState()},saveCoords:function(){this._originalLeft=this.get("left");this._originalTop=this.get("top");return this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){this.forEachObject(function(h){h.setCoords()});return this},activateAllObjects:function(){this.forEachObject(function(h){h.setActive()});return this},forEachObject:e.StaticCanvas.prototype.forEachObject,_setOpacityIfSame:function(){var j=this.getObjects(),i=j[0]?j[0].get("opacity"):1;var h=j.every(function(k){return k.get("opacity")===i});if(h){this.opacity=i}},_calcBounds:function(){var s=[],q=[],p,n,k,h,m,l,u,r=0,t=this.objects.length;for(;ri.x&&j-hi.y},toGrayscale:function(){var h=this.objects.length;while(h--){this.objects[h].toGrayscale()}},toSVG:function(){var k=[];for(var j=0,h=this.objects.length;j'+k.join("")+"")}});e.Group.fromObject=function(h,i){e.util.enlivenObjects(h.objects,function(j){delete h.objects;i&&i(new e.Group(j,h))})};e.Group.async=true})(typeof exports!="undefined"?exports:this);(function(a){var b=fabric.util.object.extend;if(!a.fabric){a.fabric={}}if(a.fabric.Image){fabric.warn("fabric.Image is already defined.");return}if(!fabric.Object){fabric.warn("fabric.Object is required for fabric.Image initialization");return}fabric.Image=fabric.util.createClass(fabric.Object,{active:false,bordervisibility:false,cornervisibility:false,type:"image",initialize:function(d,c){c||(c={});this.callSuper("initialize",c);this._initElement(d);this._originalImage=this.getElement();this._initConfig(c);this.filters=[];if(c.filters){this.filters=c.filters;this.applyFilters()}},getElement:function(){return this._element},setElement:function(c){this._element=c;this._initConfig();return this},getOriginalSize:function(){var c=this.getElement();return{width:c.width,height:c.height}},setBorderVisibility:function(c){this._resetWidthHeight();this._adjustWidthHeightToBorders(showBorder);this.setCoords()},setCornersVisibility:function(c){this.cornervisibility=!!c},render:function(d,e){d.save();var c=this.transformMatrix;this._resetWidthHeight();if(this.group){d.translate(-this.group.width/2+this.width/2,-this.group.height/2+this.height/2)}if(c){d.transform(c[0],c[1],c[2],c[3],c[4],c[5])}if(!e){this.transform(d)}this._render(d);if(this.active&&!e){this.drawBorders(d);this.hideCorners||this.drawCorners(d)}d.restore()},toObject:function(){return b(this.callSuper("toObject"),{src:this._originalImage.src||this._originalImage._src,filters:this.filters.concat()})},toSVG:function(){return''},getSrc:function(){return this.getElement().src||this.getElement()._src},toString:function(){return'#'},clone:function(c){this.constructor.fromObject(this.toObject(),c)},applyFilters:function(i){if(this.filters.length===0){this.setElement(this._originalImage);i&&i();return}var c=typeof Buffer!=="undefined"&&typeof window==="undefined",g=this._originalImage,e=fabric.document.createElement("canvas"),f=c?new (require("canvas").Image):fabric.document.createElement("img"),h=this;if(!e.getContext&&typeof G_vmlCanvasManager!="undefined"){G_vmlCanvasManager.initElement(e)}e.width=g.width;e.height=g.height;e.getContext("2d").drawImage(g,0,0,g.width,g.height);this.filters.forEach(function(j){j&&j.applyTo(e)});f.onload=function(){h._element=f;i&&i();f.onload=e=g=null};f.width=g.width;f.height=g.height;if(c){var d=e.toDataURL("image/png").replace(/data:image\/png;base64,/,"");f.src=new Buffer(d,"base64");h._element=f;i&&i()}else{f.src=e.toDataURL("image/png")}return this},_render:function(c){c.drawImage(this.getElement(),-this.width/2,-this.height/2,this.width,this.height)},_adjustWidthHeightToBorders:function(c){if(c){this.currentBorder=this.borderwidth;this.width+=(2*this.currentBorder);this.height+=(2*this.currentBorder)}else{this.currentBorder=0}},_resetWidthHeight:function(){var c=this.getElement();this.set("width",c.width);this.set("height",c.height)},_initElement:function(c){this.setElement(fabric.util.getById(c));fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(c){c||(c={});this.setOptions(c);this._setBorder();this._setWidthHeight(c)},_initFilters:function(c){if(c.filters&&c.filters.length){this.filters=c.filters.map(function(d){return d&&fabric.Image.filters[d.type].fromObject(d)})}},_setBorder:function(){if(this.bordervisibility){this.currentBorder=this.borderwidth}else{this.currentBorder=0}},_setWidthHeight:function(c){var d=2*this.currentBorder;this.width="width" in c?c.width:((this.getElement().width||0)+d);this.height="height" in c?c.height:((this.getElement().height||0)+d)},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.prototype.getSvgSrc=fabric.Image.prototype.getSrc;fabric.Image.fromObject=function(d,f){var c=fabric.document.createElement("img"),e=d.src;if(d.width){c.width=d.width}if(d.height){c.height=d.height}c.onload=function(){fabric.Image.prototype._initFilters.call(d,d);var g=new fabric.Image(c,d);f&&f(g);c=c.onload=null};c.src=e};fabric.Image.fromURL=function(d,f,e){var c=fabric.document.createElement("img");c.onload=function(){if(f){f(new fabric.Image(c,e))}c=c.onload=null};c.src=d};fabric.Image.ATTRIBUTE_NAMES="x y width height fill fill-opacity opacity stroke stroke-width transform xlink:href".split(" ");fabric.Image.fromElement=function(d,f,c){c||(c={});var e=fabric.parseAttributes(d,fabric.Image.ATTRIBUTE_NAMES);fabric.Image.fromURL(e["xlink:href"],f,b(e,c))};fabric.Image.async=true})(typeof exports!="undefined"?exports:this);fabric.util.object.extend(fabric.Object.prototype,{_getAngleValueForStraighten:function(){var a=this.get("angle");if(a>-225&&a<=-135){return -180}else{if(a>-135&&a<=-45){return -90}else{if(a>-45&&a<=45){return 0}else{if(a>45&&a<=135){return 90}else{if(a>135&&a<=225){return 180}else{if(a>225&&a<=315){return 270}else{if(a>315){return 360}}}}}}}return 0},straighten:function(){var a=this._getAngleValueForStraighten();this.setAngle(a);return this},fxStraighten:function(b){b=b||{};var c=function(){},d=b.onComplete||c,a=b.onChange||c,e=this;fabric.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(f){e.setAngle(f);a()},onComplete:function(){e.setCoords();d()},onStart:function(){e.setActive(false)}});return this}});fabric.util.object.extend(fabric.StaticCanvas.prototype,{straightenObject:function(a){a.straighten();this.renderAll();return this},fxStraightenObject:function(a){a.fxStraighten({onChange:this.renderAll.bind(this)});return this}});fabric.Image.filters={};fabric.Image.filters.Grayscale=fabric.util.createClass({type:"Grayscale",applyTo:function(d){var c=d.getContext("2d"),a=c.getImageData(0,0,d.width,d.height),h=a.data,e=a.width,l=a.height,k,b,g,f;for(g=0;gh&&m>h&&o>h&&p(a-m)0){l[m]=o;l[m+1]=e;l[m+2]=k}}f.putImageData(c,0,0)},toJSON:function(){return{type:this.type,color:this.color}}});fabric.Image.filters.Tint.fromObject=function(a){return new fabric.Image.filters.Tint(a)};(function(b){var c=b.fabric||(b.fabric={}),e=c.util.object.extend,d=c.util.object.clone,a=c.util.toFixed;if(c.Text){c.warn("fabric.Text is already defined");return}if(!c.Object){c.warn("fabric.Text requires fabric.Object");return}c.Text=c.util.createClass(c.Object,{fontSize:40,fontWeight:100,fontFamily:"Times New Roman",textDecoration:"",textShadow:"",textAlign:"left",fontStyle:"",lineHeight:1.3,strokeStyle:"",strokeWidth:1,backgroundColor:"",path:null,type:"text",useNative:true,initialize:function(g,f){this._initStateProperties();this.text=g;this.setOptions(f||{});this._theta=this.angle*Math.PI/180;this._initDimensions();this.setCoords()},_initDimensions:function(){var f=c.document.createElement("canvas");if(!f.getContext&&typeof G_vmlCanvasManager!="undefined"){G_vmlCanvasManager.initElement(f)}this._render(f.getContext("2d"))},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat();this.stateProperties.push("fontFamily","fontWeight","fontSize","path","text","textDecoration","textShadow","textAlign","fontStyle","lineHeight","strokeStyle","strokeWidth","backgroundColor","useNative");c.util.removeFromArray(this.stateProperties,"width")},toString:function(){return"#'},_render:function(f){if(typeof Cufon==="undefined"||this.useNative===true){this._renderViaNative(f)}else{this._renderViaCufon(f)}},_renderViaCufon:function(f){var h=Cufon.textOptions||(Cufon.textOptions={});h.left=this.left;h.top=this.top;h.context=f;h.color=this.fill;var g=this._initDummyElementForCufon();this.transform(f);Cufon.replaceElement(g,{engine:"canvas",separate:"none",fontFamily:this.fontFamily,fontWeight:this.fontWeight,textDecoration:this.textDecoration,textShadow:this.textShadow,textAlign:this.textAlign,fontStyle:this.fontStyle,lineHeight:this.lineHeight,strokeStyle:this.strokeStyle,strokeWidth:this.strokeWidth,backgroundColor:this.backgroundColor});this.width=h.width;this.height=h.height;this._totalLineHeight=h.totalLineHeight;this._fontAscent=h.fontAscent;this._boundaries=h.boundaries;this._shadowOffsets=h.shadowOffsets;this._shadows=h.shadows||[];g=null;this.setCoords()},_renderViaNative:function(f){this.transform(f);this._setTextStyles(f);var g=this.text.split(/\r?\n/);this.width=this._getTextWidth(f,g);this.height=this._getTextHeight(f,g);this._renderTextBackground(f,g);if(this.textAlign!=="left"){f.save();f.translate(this.textAlign==="center"?(this.width/2):this.width,0)}this._setTextShadow(f);this._renderTextFill(f,g);this.textShadow&&f.restore();this._renderTextStroke(f,g);if(this.textAlign!=="left"){f.restore()}this._renderTextDecoration(f,g);this._setBoundaries(f,g);this._totalLineHeight=0;this.setCoords()},_setBoundaries:function(h,k){this._boundaries=[];for(var j=0,g=k.length;jk){k=l}}return k},_setTextShadow:function(f){if(this.textShadow){var j=/\s+(-?\d+)(?:px)?\s+(-?\d+)(?:px)?\s+(\d+)(?:px)?\s*/;var g=this.textShadow;var i=j.exec(this.textShadow);var h=g.replace(j,"");f.save();f.shadowColor=h;f.shadowOffsetX=parseInt(i[1],10);f.shadowOffsetY=parseInt(i[2],10);f.shadowBlur=parseInt(i[3],10);this._shadows=[{blur:f.shadowBlur,color:f.shadowColor,offX:f.shadowOffsetX,offY:f.shadowOffsetY}];this._shadowOffsets=[[parseInt(f.shadowOffsetX,10),parseInt(f.shadowOffsetY,10)]]}},_renderTextFill:function(g,j){this._boundaries=[];for(var h=0,f=j.length;h-1){f.call(this,this.fontSize)}if(this.textDecoration.indexOf("line-through")>-1){f.call(this,this.fontSize/2)}if(this.textDecoration.indexOf("overline")>-1){f.call(this,0)}},_getFontDeclaration:function(){return[this.fontStyle,this.fontWeight,this.fontSize+"px",(c.isLikelyNode?('"'+this.fontFamily+'"'):this.fontFamily)].join(" ")},_initDummyElementForCufon:function(){var g=c.document.createElement("pre"),f=c.document.createElement("div");f.appendChild(g);if(typeof G_vmlCanvasManager=="undefined"){g.innerHTML=this.text}else{g.innerText=this.text.replace(/\r?\n/gi,"\r")}g.style.fontSize=this.fontSize+"px";g.style.letterSpacing="normal";return g},render:function(f,g){f.save();this._render(f);if(!g&&this.active){this.drawBorders(f);this.hideCorners||this.drawCorners(f)}f.restore()},toObject:function(){return e(this.callSuper("toObject"),{text:this.text,fontSize:this.fontSize,fontWeight:this.fontWeight,fontFamily:this.fontFamily,fontStyle:this.fontStyle,lineHeight:this.lineHeight,textDecoration:this.textDecoration,textShadow:this.textShadow,textAlign:this.textAlign,path:this.path,strokeStyle:this.strokeStyle,strokeWidth:this.strokeWidth,backgroundColor:this.backgroundColor,useNative:this.useNative})},toSVG:function(){var i=this.text.split(/\r?\n/),j=this.useNative?this.fontSize*this.lineHeight:(-this._fontAscent-((this._fontAscent/5)*this.lineHeight)),g=-(this.width/2),f=this.useNative?this.fontSize-1:(this.height/2)-(i.length*this.fontSize)-this._totalLineHeight,h=this._getSVGTextAndBg(j,g,i),k=this._getSVGShadows(j,i);f+=(this._fontAscent?((this._fontAscent/5)*this.lineHeight):0);return['',h.textBgRects.join(""),"',k.join(""),h.textSpans.join(""),"",""].join("")},_getSVGShadows:function(h,n){var o=[],k,l,p,g,f=1;if(!this._shadows||!this._boundaries){return o}for(k=0,p=this._shadows.length;k",c.util.string.escapeXml(n[l]),"");f=1}else{f++}}}return o},_getSVGTextAndBg:function(j,h,n){var g=[],k=[],l,m,o,f=1;for(l=0,o=n.length;l",c.util.string.escapeXml(n[l]),"");f=1}else{f++}if(!this.backgroundColor||!this._boundaries){continue}k.push("')}return{textSpans:g,textBgRects:k}},_getFillAttributes:function(f){var g=f?new c.Color(f):"";if(!g||!g.getSource()||g.getAlpha()===1){return'fill="'+f+'"'}return'opacity="'+g.getAlpha()+'" fill="'+g.setAlpha(1).toRgb()+'"'},setColor:function(f){this.set("fill",f);return this},setFontsize:function(f){this.set("fontSize",f);this._initDimensions();this.setCoords();return this},getText:function(){return this.text},setText:function(f){this.set("text",f);this._initDimensions();this.setCoords();return this},_set:function(f,g){if(f==="fontFamily"&&this.path){this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+g+"$3")}this.callSuper("_set",f,g)}});c.Text.ATTRIBUTE_NAMES=("x y fill fill-opacity opacity stroke stroke-width transform font-family font-style font-weight font-size text-decoration").split(" ");c.Text.fromObject=function(f){return new c.Text(f.text,d(f))};c.Text.fromElement=function(g,f){if(!g){return null}var h=c.parseAttributes(g,c.Text.ATTRIBUTE_NAMES);var f=c.util.object.extend((f?c.util.object.clone(f):{}),h);var i=new c.Text(g.textContent,f);return i}})(typeof exports!="undefined"?exports:this);(function(){if(typeof document!="undefined"&&typeof window!="undefined"){return}var DOMParser=new require("xmldom").DOMParser,URL=require("url"),HTTP=require("http"),Canvas=require("canvas"),Image=require("canvas").Image;function request(url,encoding,callback){var oURL=URL.parse(url),client=HTTP.createClient(oURL.port,oURL.hostname),request=client.request("GET",oURL.pathname,{host:oURL.hostname});client.addListener("error",function(err){if(err.errno===process.ECONNREFUSED){fabric.log("ECONNREFUSED: connection refused to "+client.host+":"+client.port)}else{fabric.log(err.message)}});request.end();request.on("response",function(response){var body="";if(encoding){response.setEncoding(encoding)}response.on("end",function(){callback(body)});response.on("data",function(chunk){if(response.statusCode==200){body+=chunk}})})}fabric.util.loadImage=function(url,callback){request(url,"binary",function(body){var img=new Image();img.src=new Buffer(body,"binary");img._src=url;callback(img)})};fabric.loadSVGFromURL=function(url,callback){url=url.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();request(url,"",function(body){fabric.loadSVGFromString(body,callback)})};fabric.loadSVGFromString=function(string,callback){var doc=new DOMParser().parseFromString(string);fabric.parseSVGDocument(doc.documentElement,function(results,options){callback(results,options)})};fabric.util.getScript=function(url,callback){request(url,"",function(body){eval(body);callback&&callback()})};fabric.Image.fromObject=function(object,callback){fabric.util.loadImage(object.src,function(img){var oImg=new fabric.Image(img);oImg._initConfig(object);oImg._initFilters(object);callback(oImg)})};fabric.createCanvasForNode=function(width,height){var canvasEl=fabric.document.createElement("canvas"),nodeCanvas=new Canvas(width||600,height||600);canvasEl.style={};canvasEl.width=nodeCanvas.width;canvasEl.height=nodeCanvas.height;var canvas=fabric.Canvas||fabric.StaticCanvas;var fabricCanvas=new canvas(canvasEl);fabricCanvas.contextContainer=nodeCanvas.getContext("2d");fabricCanvas.nodeCanvas=nodeCanvas;return fabricCanvas};fabric.StaticCanvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()};if(fabric.Canvas){fabric.Canvas.prototype.createPNGStream}var origSetWidth=fabric.StaticCanvas.prototype.setWidth;fabric.StaticCanvas.prototype.setWidth=function(width){origSetWidth.call(this);this.nodeCanvas.width=width;return this};if(fabric.Canvas){fabric.Canvas.prototype.setWidth=fabric.StaticCanvas.prototype.setWidth}var origSetHeight=fabric.StaticCanvas.prototype.setHeight;fabric.StaticCanvas.prototype.setHeight=function(height){origSetHeight.call(this);this.nodeCanvas.height=height;return this};if(fabric.Canvas){fabric.Canvas.prototype.setHeight=fabric.StaticCanvas.prototype.setHeight}})(); \ No newline at end of file +var Cufon=(function(){var k=function(){return k.replace.apply(null,arguments)};var u=k.DOM={ready:(function(){var z=false,B={loaded:1,complete:1};var y=[],A=function(){if(z){return}z=true;for(var C;C=y.shift();C()){}};if(fabric.document.addEventListener){fabric.document.addEventListener("DOMContentLoaded",A,false);fabric.window.addEventListener("pageshow",A,false)}if(!fabric.window.opera&&fabric.document.readyState){(function(){B[fabric.document.readyState]?A():setTimeout(arguments.callee,10)})()}if(fabric.document.readyState&&fabric.document.createStyleSheet){(function(){try{fabric.document.body.doScroll("left");A()}catch(C){setTimeout(arguments.callee,1)}})()}o(fabric.window,"load",A);return function(C){if(!arguments.length){A()}else{z?C():y.push(C)}}})()};var l=k.CSS={Size:function(z,y){this.value=parseFloat(z);this.unit=String(z).match(/[a-z%]*$/)[0]||"px";this.convert=function(A){return A/y*this.value};this.convertFrom=function(A){return A/this.value*y};this.toString=function(){return this.value+this.unit}},getStyle:function(y){return new a(y.style)},quotedList:i(function(B){var A=[],z=/\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g,y;while(y=z.exec(B)){A.push(y[3]||y[1])}return A}),ready:(function(){var A=false;var z=[],B=function(){A=true;for(var D;D=z.shift();D()){}};var y=Object.prototype.propertyIsEnumerable?f("style"):{length:0};var C=f("link");u.ready(function(){var G=0,F;for(var E=0,D=C.length;F=C[E],E=y.length+G){B()}else{setTimeout(arguments.callee,10)}});return function(D){if(A){D()}else{z.push(D)}}})(),supports:function(A,z){var y=fabric.document.createElement("span").style;if(y[A]===undefined){return false}y[A]=z;return y[A]===z},textAlign:function(B,A,y,z){if(A.get("textAlign")=="right"){if(y>0){B=" "+B}}else{if(y400}if(F==500){F=400}for(var G in D){G=parseInt(G,10);if(!C||GA){A=G}H.push(G)}if(FA){F=A}H.sort(function(J,I){return(B?(J>F&&I>F)?JI:(JI:Jz){z=e}L.push(e);e=0;continue}var B=ab.glyphs[ag[aa]]||ab.missingGlyph;if(!B){continue}e+=D=Number(B.w||ab.w)+U}L.push(e);e=Math.max(z,e);var m=[];for(var aa=L.length;aa--;){m[aa]=e-L[aa]}if(D===null){return null}V+=(H.width-D);C+=H.minX;var v,p;if(n){v=J;p=J.firstChild}else{v=fabric.document.createElement("span");v.className="cufon cufon-canvas";v.alt=E;p=fabric.document.createElement("canvas");v.appendChild(p);if(A.printable){var Y=fabric.document.createElement("span");Y.className="cufon-alt";Y.appendChild(fabric.document.createTextNode(E));v.appendChild(Y)}}var ah=v.style;var O=p.style||{};var k=o.convert(H.height-I+T);var af=Math.ceil(k);var S=af/k;p.width=Math.ceil(o.convert(e+V-C)*S);p.height=af;I+=H.minY;O.top=Math.round(o.convert(I-ab.ascent))+"px";O.left=Math.round(o.convert(C))+"px";var j=Math.ceil(o.convert(e*S));var t=j+"px";var s=o.convert(ab.height);var F=(A.lineHeight-1)*o.convert(-ab.ascent/5)*(M-1);Cufon.textOptions.width=j;Cufon.textOptions.height=(s*M)+F;Cufon.textOptions.lines=M;Cufon.textOptions.totalLineHeight=F;if(a){ah.width=t;ah.height=s+"px"}else{ah.paddingLeft=t;ah.paddingBottom=(s-1)+"px"}var ad=Cufon.textOptions.context||p.getContext("2d"),K=af/H.height;Cufon.textOptions.fontAscent=ab.ascent*K;Cufon.textOptions.boundaries=null;for(var w=Cufon.textOptions.shadowOffsets,aa=R.length;aa--;){w[aa]=[R[aa][0]*K,R[aa][1]*K]}ad.save();ad.scale(K,K);ad.translate(-C-((1/K*p.width)/2)+(Cufon.fonts[ab.family].offsetLeft||0),-I-((Cufon.textOptions.height/K)/2)+(Cufon.fonts[ab.family].offsetTop||0));ad.lineWidth=ab.face["underline-thickness"];ad.save();function q(l,i){ad.strokeStyle=i;ad.beginPath();ad.moveTo(0,l);ad.lineTo(e,l);ad.stroke()}var r=Cufon.getTextDecoration(A),u=A.fontStyle==="italic";function ae(){ad.save();ad.fillStyle=A.backgroundColor;var aj=0,an=0,y=[{left:0}];if(A.textAlign==="right"){ad.translate(m[an],0);y[0].left=m[an]*K}else{if(A.textAlign==="center"){ad.translate(m[an]/2,0);y[0].left=m[an]/2*K}}for(var al=0,ak=ag.length;al.cufon-vml-canvas{text-indent:0}@media screen{cvml\\:shape,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute}.cufon-vml-canvas{position:absolute;text-align:left}.cufon-vml{display:inline-block;position:relative;vertical-align:middle}.cufon-vml .cufon-alt{position:absolute;left:-10000in;font-size:1px}a .cufon-vml{cursor:pointer}}@media print{.cufon-vml *{display:none}.cufon-vml .cufon-alt{display:inline}}');function c(e,f){return a(e,/(?:em|ex|%)$/i.test(f)?"1em":f)}function a(h,i){if(/px$/i.test(i)){return parseFloat(i)}var g=h.style.left,f=h.runtimeStyle.left;h.runtimeStyle.left=h.currentStyle.left;h.style.left=i;var e=h.style.pixelLeft;h.style.left=g;h.runtimeStyle.left=f;return e}return function(T,z,O,w,D,U,M){var h=(z===null);if(h){z=D.alt}var B=T.viewBox;var j=O.computedFontSize||(O.computedFontSize=new Cufon.CSS.Size(c(U,O.get("fontSize"))+"px",T.baseSize));var L=O.computedLSpacing;if(L==undefined){L=O.get("letterSpacing");O.computedLSpacing=L=(L=="normal")?0:~~j.convertFrom(a(U,L))}var t,m;if(h){t=D;m=D.firstChild}else{t=fabric.document.createElement("span");t.className="cufon cufon-vml";t.alt=z;m=fabric.document.createElement("span");m.className="cufon-vml-canvas";t.appendChild(m);if(w.printable){var R=fabric.document.createElement("span");R.className="cufon-alt";R.appendChild(fabric.document.createTextNode(z));t.appendChild(R)}if(!M){t.appendChild(fabric.document.createElement("cvml:shape"))}}var Z=t.style;var G=m.style;var f=j.convert(B.height),W=Math.ceil(f);var K=W/f;var J=B.minX,I=B.minY;G.height=W;G.top=Math.round(j.convert(I-T.ascent));G.left=Math.round(j.convert(J));Z.height=j.convert(T.height)+"px";var p=Cufon.getTextDecoration(w);var y=O.get("color");var X=Cufon.CSS.textTransform(z,O).split("");var e=0,H=0,q=null;var x,r,A=w.textShadow;for(var S=0,Q=0,P=X.length;Sw?p:(o-n);s(t(currentTime,m,byValue,p));if(o>w||q()){x.onComplete&&x.onComplete();return}k(r)})()}var f=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(n,m){fabric.window.setTimeout(n,1000/60)};var k=function(){return f.apply(fabric.window,arguments)};function b(n,p,o){if(n){var m=new Image();m.onload=function(){p&&p.call(o,m);m=m.onload=null};m.src=n}else{p&&p.call(o,n)}}function i(p,s){function o(t){return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(t))]}function n(){if(++r===m){if(s){s(q)}}}var q=[],r=0,m=p.length;p.forEach(function(v,u){if(!v.type){return}var t=o(v.type);if(t.async){t.fromObject(v,function(w){q[u]=w;n()})}else{q[u]=t.fromObject(v);n()}})}function a(o,n,p){var m=o.length>1?new fabric.PathGroup(o,n):o[0];if(typeof p!=="undefined"){m.setSourcePath(p)}return m}fabric.util.removeFromArray=j;fabric.util.degreesToRadians=c;fabric.util.toFixed=e;fabric.util.getRandomInt=g;fabric.util.falseFunction=l;fabric.util.animate=d;fabric.util.requestAnimFrame=k;fabric.util.loadImage=b;fabric.util.enlivenObjects=i;fabric.util.groupSVGElements=a})();(function(){var d=Array.prototype.slice;if(!Array.prototype.indexOf){Array.prototype.indexOf=function(g){if(this===void 0||this===null){throw new TypeError()}var h=Object(this),e=h.length>>>0;if(e===0){return -1}var i=0;if(arguments.length>0){i=Number(arguments[1]);if(i!==i){i=0}else{if(i!==0&&i!==(1/0)&&i!==-(1/0)){i=(i>0||-1)*Math.floor(Math.abs(i))}}}if(i>=e){return -1}var f=i>=0?i:Math.max(e-Math.abs(i),0);for(;f>>0;f>>0;g>>0;f>>0;f>>0;g>>0,f=0,h;if(arguments.length>1){h=arguments[1]}else{do{if(f in this){h=this[f++];break}if(++f>=e){throw new TypeError()}}while(true)}for(;f=e){e=h[f][g]}}}else{while(f--){if(h[f]>=e){e=h[f]}}}return e}function c(h,g){if(!h||h.length===0){return undefined}var f=h.length-1,e=g?h[f][g]:h[f];if(g){while(f--){if(h[f][g]/g,">")}fabric.util.string={camelize:b,capitalize:c,escapeXml:a}}());(function(){var c=Array.prototype.slice,a=Function.prototype.apply,b=function(){};if(!Function.prototype.bind){Function.prototype.bind=function(d){var g=this,e=c.call(arguments,1),f;if(e.length){f=function(){return a.call(g,this instanceof b?this:d,e.concat(c.call(arguments)))}}else{f=function(){return a.call(g,this instanceof b?this:d,arguments)}}b.prototype=this.prototype;f.prototype=new b;return f}}})();(function(){var f=Array.prototype.slice,e=function(){};var c=(function(){for(var g in {toString:1}){if(g==="toString"){return false}}return true})();var b=function(g,j,h){for(var i in j){if(i in g.prototype&&typeof g.prototype[i]=="function"){g.prototype[i]=(function(k){return function(){var m=this.constructor.superclass;this.constructor.superclass=h;var l=j[k].apply(this,arguments);this.constructor.superclass=m;if(k!=="initialize"){return l}}})(i)}else{g.prototype[i]=j[i]}if(c){if(j.toString!==Object.prototype.toString){g.prototype.toString=j.toString}if(j.valueOf!==Object.prototype.valueOf){g.prototype.valueOf=j.valueOf}}}};function a(){}function d(){var k=null,j=f.call(arguments,0);if(typeof j[0]==="function"){k=j.shift()}function g(){this.initialize.apply(this,arguments)}g.superclass=k;g.subclasses=[];if(k){a.prototype=k.prototype;g.prototype=new a;k.subclasses.push(g)}for(var h=0,l=j.length;h-1?c(j,l.match(/opacity:\s*(\d?\.?\d*)/)[1]):j}for(var m in l){if(m==="opacity"){c(j,l[m])}else{var k=(m==="float"||m==="cssFloat")?(typeof n.styleFloat==="undefined"?"cssFloat":"styleFloat"):m;n[k]=l[m]}}return j}var h=fabric.document.createElement("div"),g=typeof h.style.opacity==="string",b=typeof h.style.filter==="string",a=fabric.document.defaultView,f=a&&typeof a.getComputedStyle!=="undefined",d=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,c=function(i){return i};if(g){c=function(i,j){i.style.opacity=j;return i}}else{if(b){c=function(i,j){var k=i.style;if(i.currentStyle&&!i.currentStyle.hasLayout){k.zoom=1}if(d.test(k.filter)){j=j>=0.9999?"":("alpha(opacity="+(j*100)+")");k.filter=k.filter.replace(d,j)}else{k.filter+=" alpha(opacity="+(j*100)+")"}return i}}}fabric.util.setStyle=e})();(function(){var h=Array.prototype.slice;function g(j){return typeof j==="string"?fabric.document.getElementById(j):j}function b(j){return h.call(j,0)}try{var i=b(fabric.document.childNodes) instanceof Array}catch(a){}if(!i){b=function(k){var j=new Array(k.length),l=k.length;while(l--){j[l]=k[l]}return j}}function c(k,j){var l=fabric.document.createElement(k);for(var m in j){if(m==="class"){l.className=j[m]}else{if(m==="for"){l.htmlFor=j[m]}else{l.setAttribute(m,j[m])}}}return l}function f(j,k){if((" "+j.className+" ").indexOf(" "+k+" ")===-1){j.className+=(j.className?" ":"")+k}}function e(k,l,j){if(typeof l==="string"){l=c(l,j)}if(k.parentNode){k.parentNode.replaceChild(l,k)}l.appendChild(k);return l}function d(k){var j=0,l=0;do{j+=k.offsetTop||0;l+=k.offsetLeft||0;k=k.offsetParent}while(k);return({left:l,top:j})}(function(){var k=fabric.document.documentElement.style;var l="userSelect" in k?"userSelect":"MozUserSelect" in k?"MozUserSelect":"WebkitUserSelect" in k?"WebkitUserSelect":"KhtmlUserSelect" in k?"KhtmlUserSelect":"";function m(n){if(typeof n.onselectstart!=="undefined"){n.onselectstart=fabric.util.falseFunction}if(l){n.style[l]="none"}else{if(typeof n.unselectable=="string"){n.unselectable="on"}}return n}function j(n){if(typeof n.onselectstart!=="undefined"){n.onselectstart=null}if(l){n.style[l]=""}else{if(typeof n.unselectable=="string"){n.unselectable=""}}return n}fabric.util.makeElementUnselectable=m;fabric.util.makeElementSelectable=j})();(function(){function j(k,o){var m=fabric.document.getElementsByTagName("head")[0],l=fabric.document.createElement("script"),n=true;l.type="text/javascript";l.setAttribute("runat","server");l.onload=l.onreadystatechange=function(p){if(n){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete"){return}n=false;o(p||fabric.window.event);l=l.onload=l.onreadystatechange=null}};l.src=k;m.appendChild(l)}fabric.util.getScript=j})();fabric.util.getById=g;fabric.util.toArray=b;fabric.util.makeElement=c;fabric.util.addClass=f;fabric.util.wrapElement=e;fabric.util.getElementOffset=d})();(function(){function d(e,f){return e+(/\?/.test(e)?"&":"?")+f}var c=(function(){var h=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest()}];for(var e=h.length;e--;){try{var g=h[e]();if(g){return h[e]}}catch(f){}}})();function a(){}function b(g,f){f||(f={});var j=f.method?f.method.toUpperCase():"GET",i=f.onComplete||function(){},h=c(),e;h.onreadystatechange=function(){if(h.readyState===4){i(h);h.onreadystatechange=a}};if(j==="GET"){e=null;if(typeof f.parameters=="string"){g=d(g,f.parameters)}}h.open(j,g,true);if(j==="POST"||j==="PUT"){h.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}h.send(e);return h}fabric.util.request=b})();(function(){function d(F,E,H,G){return H*(F/=G)*F+E}function l(F,E,H,G){return -H*(F/=G)*(F-2)+E}function r(F,E,H,G){if((F/=G/2)<1){return H/2*F*F+E}return -H/2*((--F)*(F-2)-1)+E}function B(F,E,H,G){return H*(F/=G)*F*F+E}function q(F,E,H,G){return H*((F=F/G-1)*F*F+1)+E}function u(F,E,H,G){if((F/=G/2)<1){return H/2*F*F*F+E}return H/2*((F-=2)*F*F+2)+E}function t(F,E,H,G){return H*(F/=G)*F*F*F+E}function g(F,E,H,G){return -H*((F=F/G-1)*F*F*F-1)+E}function k(F,E,H,G){if((F/=G/2)<1){return H/2*F*F*F*F+E}return -H/2*((F-=2)*F*F*F-2)+E}function y(F,E,H,G){return H*(F/=G)*F*F*F*F+E}function j(F,E,H,G){return H*((F=F/G-1)*F*F*F*F+1)+E}function n(F,E,H,G){if((F/=G/2)<1){return H/2*F*F*F*F*F+E}return H/2*((F-=2)*F*F*F*F+2)+E}function f(F,E,H,G){return -H*Math.cos(F/G*(Math.PI/2))+H+E}function o(F,E,H,G){return H*Math.sin(F/G*(Math.PI/2))+E}function v(F,E,H,G){return -H/2*(Math.cos(Math.PI*F/G)-1)+E}function D(F,E,H,G){return(F==0)?E:H*Math.pow(2,10*(F/G-1))+E}function c(F,E,H,G){return(F==G)?E+H:H*(-Math.pow(2,-10*F/G)+1)+E}function i(F,E,H,G){if(F==0){return E}if(F==G){return E+H}if((F/=G/2)<1){return H/2*Math.pow(2,10*(F-1))+E}return H/2*(-Math.pow(2,-10*--F)+2)+E}function h(F,E,H,G){return -H*(Math.sqrt(1-(F/=G)*F)-1)+E}function p(F,E,H,G){return H*Math.sqrt(1-(F=F/G-1)*F)+E}function x(F,E,H,G){if((F/=G/2)<1){return -H/2*(Math.sqrt(1-F*F)-1)+E}return H/2*(Math.sqrt(1-(F-=2)*F)+1)+E}function s(G,E,K,J){var H=1.70158;var I=0;var F=K;if(G==0){return E}if((G/=J)==1){return E+K}if(!I){I=J*0.3}if(F-1;w=w.split(/\s+/);var u=[];if(y){for(var v=0,t=w.length;v/i,""))}if(!x.documentElement){return}h.parseSVGDocument(x.documentElement,function(A,z){k.set(u,{objects:h.util.array.invoke(A,"toObject"),options:z});w(A,z)},t)}}function b(v){var u=v.objects,t=v.options;u=u.map(function(w){return h[f(w.type)].fromObject(w)});return({objects:u,options:t})}function n(u,x,t){u=u.trim();var v;if(typeof DOMParser!=="undefined"){var w=new DOMParser();if(w&&w.parseFromString){v=w.parseFromString(u,"text/xml")}}else{if(h.window.ActiveXObject){var v=new ActiveXObject("Microsoft.XMLDOM");v.async="false";v.loadXML(u.replace(//i,""))}}h.parseSVGDocument(v.documentElement,function(z,y){x(z,y)},t)}function m(w){var u="";for(var v=0,t=w.length;v",'",""].join("")}return u}p(h,{parseAttributes:e,parseElements:g,parseStyleAttribute:i,parsePointsAttribute:s,getCSSRules:d,loadSVGFromURL:c,loadSVGFromString:n,createSVGFontFacesMarkup:m})})(typeof exports!="undefined"?exports:this);(function(){function c(h){var g=h.getAttribute("style");if(g){var k=g.split(/\s*;\s*/);if(k[k.length-1]===""){k.pop()}for(var f=k.length;f--;){var e=k[f].split(/\s*:\s*/),d=e[0].trim(),j=e[1].trim();if(d==="stop-color"){return j}}}}fabric.Gradient=fabric.util.createClass({initialize:function(d){d||(d={});this.x1=d.x1||0;this.y1=d.y1||0;this.x2=d.x2||0;this.y2=d.y2||0;this.colorStops=d.colorStops},toObject:function(){return{x1:this.x1,x2:this.x2,y1:this.y1,y2:this.y2,colorStops:this.colorStops}},toLiveGradient:function(e){var g=e.createLinearGradient(this.x1,this.y1,this.x2||e.canvas.width,this.y2);for(var d in this.colorStops){var f=this.colorStops[d];g.addColorStop(parseFloat(d),f)}return g}});fabric.util.object.extend(fabric.Gradient,{fromElement:function(h,e){var l=h.getElementsByTagName("stop"),h,k,f={},d,j={x1:h.getAttribute("x1")||0,y1:h.getAttribute("y1")||0,x2:h.getAttribute("x2")||"100%",y2:h.getAttribute("y2")||0};for(var g=l.length;g--;){h=l[g];k=h.getAttribute("offset");k=parseFloat(k)/(/%$/.test(k)?100:1);f[k]=c(h)||h.getAttribute("stop-color")}a(e,j);return new fabric.Gradient({x1:j.x1,y1:j.y1,x2:j.x2,y2:j.y2,colorStops:f})},forObject:function(e,d){d||(d={});a(e,d);return new fabric.Gradient(d)}});function a(f,e){for(var g in e){if(typeof e[g]==="string"&&/^\d+%$/.test(e[g])){var d=parseFloat(e[g],10);if(g==="x1"||g==="x2"){e[g]=f.width*d/100}else{if(g==="y1"||g==="y2"){e[g]=f.height*d/100}}}if(g==="x1"||g==="x2"){e[g]-=f.width/2}else{if(g==="y1"||g==="y2"){e[g]-=f.height/2}}}}function b(j){var f=j.getElementsByTagName("linearGradient"),d=j.getElementsByTagName("radialGradient"),g,h={};for(var e=f.length;e--;){g=f[e];h[g.getAttribute("id")]=g}for(var e=d.length;e--;){g=d[e];h[g.getAttribute("id")]=g}return h}fabric.getGradientDefs=b})();(function(b){var c=b.fabric||(b.fabric={});if(c.Point){c.warn("fabric.Point is already defined");return}c.Point=a;function a(d,e){if(arguments.length>0){this.init(d,e)}}a.prototype={constructor:a,init:function(d,e){this.x=d;this.y=e},add:function(d){return new a(this.x+d.x,this.y+d.y)},addEquals:function(d){this.x+=d.x;this.y+=d.y;return this},scalarAdd:function(d){return new a(this.x+d,this.y+d)},scalarAddEquals:function(d){this.x+=d;this.y+=d;return this},subtract:function(d){return new a(this.x-d.x,this.y-d.y)},subtractEquals:function(d){this.x-=d.x;this.y-=d.y;return this},scalarSubtract:function(d){return new a(this.x-d,this.y-d)},scalarSubtractEquals:function(d){this.x-=d;this.y-=d;return this},multiply:function(d){return new a(this.x*d,this.y*d)},multiplyEquals:function(d){this.x*=d;this.y*=d;return this},divide:function(d){return new a(this.x/d,this.y/d)},divideEquals:function(d){this.x/=d;this.y/=d;return this},eq:function(d){return(this.x==d.x&&this.y==d.y)},lt:function(d){return(this.xd.x&&this.y>d.y)},gte:function(d){return(this.x>=d.x&&this.y>=d.y)},lerp:function(e,d){return new a(this.x+(e.x-this.x)*d,this.y+(e.y-this.y)*d)},distanceFrom:function(f){var e=this.x-f.x,d=this.y-f.y;return Math.sqrt(e*e+d*d)},min:function(d){return new a(Math.min(this.x,d.x),Math.min(this.y,d.y))},max:function(d){return new a(Math.max(this.x,d.x),Math.max(this.y,d.y))},toString:function(){return this.x+","+this.y},setXY:function(d,e){this.x=d;this.y=e},setFromPoint:function(d){this.x=d.x;this.y=d.y},swap:function(e){var d=this.x,f=this.y;this.x=e.x;this.y=e.y;e.x=d;e.y=f}}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={});if(b.Intersection){b.warn("fabric.Intersection is already defined");return}function c(d){if(arguments.length>0){this.init(d)}}b.Intersection=c;b.Intersection.prototype={init:function(d){this.status=d;this.points=[]},appendPoint:function(d){this.points.push(d)},appendPoints:function(d){this.points=this.points.concat(d)}};b.Intersection.intersectLineLine=function(h,f,l,k){var m,i=(k.x-l.x)*(h.y-l.y)-(k.y-l.y)*(h.x-l.x),j=(f.x-h.x)*(h.y-l.y)-(f.y-h.y)*(h.x-l.x),g=(k.y-l.y)*(f.x-h.x)-(k.x-l.x)*(f.y-h.y);if(g!=0){var e=i/g,d=j/g;if(0<=e&&e<=1&&0<=d&&d<=1){m=new c("Intersection");m.points.push(new b.Point(h.x+e*(f.x-h.x),h.y+e*(f.y-h.y)))}else{m=new c("No Intersection")}}else{if(i==0||j==0){m=new c("Coincident")}else{m=new c("Parallel")}}return m};b.Intersection.intersectLinePolygon=function(e,d,l){var m=new c("No Intersection"),f=l.length;for(var h=0;h0){m.status="Intersection"}return m};b.Intersection.intersectPolygonPolygon=function(j,h){var f=new c("No Intersection"),l=j.length;for(var k=0;k0){f.status="Intersection"}return f};b.Intersection.intersectPolygonRectangle=function(n,e,d){var g=e.min(d),m=e.max(d),f=new b.Point(m.x,g.y),l=new b.Point(g.x,m.y),k=c.intersectLinePolygon(g,f,n),j=c.intersectLinePolygon(f,m,n),i=c.intersectLinePolygon(m,l,n),h=c.intersectLinePolygon(l,g,n),o=new c("No Intersection");o.appendPoints(k.points);o.appendPoints(j.points);o.appendPoints(i.points);o.appendPoints(h.points);if(o.points.length>0){o.status="Intersection"}return o}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={});if(b.Color){b.warn("fabric.Color is already defined.");return}function c(d){if(!d){this.setSource([0,0,0,1])}else{this._tryParsingColor(d)}}b.Color=c;b.Color.prototype={_tryParsingColor:function(d){var e=c.sourceFromHex(d);if(!e){e=c.sourceFromRgb(d)}if(e){this.setSource(e)}},getSource:function(){return this._source},setSource:function(d){this._source=d},toRgb:function(){var d=this.getSource();return"rgb("+d[0]+","+d[1]+","+d[2]+")"},toRgba:function(){var d=this.getSource();return"rgba("+d[0]+","+d[1]+","+d[2]+","+d[3]+")"},toHex:function(){var h=this.getSource();var f=h[0].toString(16);f=(f.length==1)?("0"+f):f;var e=h[1].toString(16);e=(e.length==1)?("0"+e):e;var d=h[2].toString(16);d=(d.length==1)?("0"+d):d;return f.toUpperCase()+e.toUpperCase()+d.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(e){var d=this.getSource();d[3]=e;this.setSource(d);return this},toGrayscale:function(){var f=this.getSource(),e=parseInt((f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),10),d=f[3];this.setSource([e,e,e,d]);return this},toBlackWhite:function(d){var g=this.getSource(),f=(g[0]*0.3+g[1]*0.59+g[2]*0.11).toFixed(0),e=g[3],d=d||127;f=(Number(f)','',"',"Created with Fabric.js ",fabric.version,"",fabric.createSVGFontFacesMarkup(this.getObjects())];if(this.backgroundImage){h.push('')}for(var j=0,k=this.getObjects(),g=k.length;j");return h.join("")},isEmpty:function(){return this._objects.length===0},remove:function(g){e(this._objects,g);if(this.getActiveObject()===g){this.fire("before:selection:cleared",{target:g});this.discardActiveObject();this.fire("selection:cleared")}this.renderAll();return g},sendToBack:function(g){e(this._objects,g);this._objects.unshift(g);return this.renderAll()},bringToFront:function(g){e(this._objects,g);this._objects.push(g);return this.renderAll()},sendBackwards:function(j){var h=this._objects.indexOf(j),g=h;if(h!==0){for(var k=h-1;k>=0;--k){if(j.intersectsWithObject(this._objects[k])||j.isContainedWithinObject(this._objects[k])){g=k;break}}e(this._objects,j);this._objects.splice(g,0,j)}return this.renderAll()},bringForward:function(k){var n=this.getObjects(),h=n.indexOf(k),g=h;if(h!==n.length-1){for(var m=h+1,j=this._objects.length;m"};f(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(l){var k=l.getContext("2d"),g=k.getImageData(0,0,l.width,l.height),p=g.data,m=g.width,r=g.height,q,h,o,n;for(o=0;o0)?0:-v),r.ey-((u>0)?0:-u),t,s);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(r.ex+a-((v>0)?0:t),r.ey+a-((u>0)?0:s),t,s)},_findSelectedObjects:function(x){var y,t,D=[],s=this._groupSelector.ex,C=this._groupSelector.ey,r=s+this._groupSelector.left,A=C+this._groupSelector.top,z,w=new fabric.Point(f(s,r),f(C,A)),B=new fabric.Point(l(s,r),l(C,A));for(var u=0,v=this._objects.length;u1){var D=new fabric.Group(D);this.setActiveGroup(D);D.saveCoords();this.fire("selection:created",{target:D})}}this.renderAll()},findTarget:function(v,s){var u,w=this.getPointer(v);var t=this.getActiveGroup();if(t&&!s&&this.containsPoint(v,t)){u=t;return u}for(var r=this._objects.length;r--;){if(this._objects[r]&&this.containsPoint(v,this._objects[r])){u=this._objects[r];this.relatedTarget=u;break}}if(u&&u.selectable){return u}},getPointer:function(r){var s=q(r);return{x:s.x-this._offset.left,y:s.y-this._offset.top}},_createUpperCanvas:function(){this.upperCanvasEl=this._createCanvasElement();this.upperCanvasEl.className="upper-canvas";this.wrapperEl.appendChild(this.upperCanvasEl);this._applyCanvasStyle(this.upperCanvasEl);this.contextTop=this.upperCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.lowerCanvasEl,"div",{"class":this.containerClass});fabric.util.setStyle(this.wrapperEl,{width:this.getWidth()+"px",height:this.getHeight()+"px",position:"relative"});fabric.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(s){var t=this.getWidth()||s.width,r=this.getHeight()||s.height;fabric.util.setStyle(s,{position:"absolute",width:t+"px",height:r+"px",left:0,top:0});s.width=t;s.height=r;fabric.util.makeElementUnselectable(s)},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},setActiveObject:function(r,s){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=r;r.setActive(true);this.renderAll();this.fire("object:selected",{target:r,e:s});r.fire("selected",{e:s});return this},getActiveObject:function(){return this._activeObject},discardActiveObject:function(){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=null;return this},setActiveGroup:function(r){this._activeGroup=r;r&&r.setActive(true);return this},getActiveGroup:function(){return this._activeGroup},discardActiveGroup:function(){var r=this.getActiveGroup();if(r){r.destroy()}return this.setActiveGroup(null)},deactivateAll:function(){var s=this.getObjects(),t=0,r=s.length;for(;t1)?q.apply(this,o.call(arguments,1)):q.call(this)},initialize:function(i){if(i){this.setOptions(i);this._initGradient(i)}},_initGradient:function(i){if(i.fill&&typeof i.fill=="object"&&!(i.fill instanceof d.Gradient)){this.set("fill",new d.Gradient(i.fill))}},setOptions:function(q){var r=this.stateProperties.length,s;while(r--){s=this.stateProperties[r];if(s in q){this.set(s,q[s])}}},transform:function(i){i.globalAlpha=this.opacity;i.translate(this.left,this.top);i.rotate(this._theta);i.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toObject:function(){var q=d.Object.NUM_FRACTION_DIGITS;var i={type:this.type,left:c(this.left,q),top:c(this.top,q),width:c(this.width,q),height:c(this.height,q),fill:(this.fill&&this.fill.toObject)?this.fill.toObject():this.fill,overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,strokeDashArray:this.strokeDashArray,scaleX:c(this.scaleX,q),scaleY:c(this.scaleY,q),angle:c(this.getAngle(),q),flipX:this.flipX,flipY:this.flipY,opacity:c(this.opacity,q),selectable:this.selectable,hasControls:this.hasControls,hasBorders:this.hasBorders,hasRotatingPoint:this.hasRotatingPoint};if(!this.includeDefaultValues){i=this._removeDefaultValues(i)}return i},toDatalessObject:function(){return this.toObject()},getSvgStyles:function(){return["stroke: ",(this.stroke?this.stroke:"none"),"; ","stroke-width: ",(this.strokeWidth?this.strokeWidth:"0"),"; ","stroke-dasharray: ",(this.strokeDashArray?this.strokeDashArray.join(" "):"; "),"fill: ",(this.fill?this.fill:"none"),"; ","opacity: ",(this.opacity?this.opacity:"1"),";"].join("")},getSvgTransform:function(){var i=this.getAngle();return["translate(",c(this.left,2)," ",c(this.top,2),")",i!==0?(" rotate("+c(i,2)+")"):"",(this.scaleX===1&&this.scaleY===1)?"":(" scale("+c(this.scaleX,2)+" "+c(this.scaleY,2)+")")].join("")},_removeDefaultValues:function(q){var i=d.Object.prototype.options;if(i){this.stateProperties.forEach(function(r){if(q[r]===i[r]){delete q[r]}})}return q},isActive:function(){return !!this.active},setActive:function(i){this.active=!!i;return this},toString:function(){return"#"},set:function(i,q){if(typeof i==="object"){for(var r in i){this._set(r,i[r])}}else{if(typeof q==="function"){this._set(i,q(this.get(i)))}else{this._set(i,q)}}return this},_set:function(i,q){var r=(i==="scaleX"||i==="scaleY")&&q1?this.strokeWidth:0,B=this.padding;this.currentWidth=(this.width+z)*this.scaleX+B*2;this.currentHeight=(this.height+z)*this.scaleY+B*2;this._hypotenuse=Math.sqrt(Math.pow(this.currentWidth/2,2)+Math.pow(this.currentHeight/2,2));this._angle=Math.atan(this.currentHeight/this.currentWidth);var w=Math.cos(this._angle+this._theta)*this._hypotenuse,v=Math.sin(this._angle+this._theta)*this._hypotenuse,r=this._theta,A=Math.sin(r),y=Math.cos(r);var E={x:this.left-w,y:this.top-v};var x={x:E.x+(this.currentWidth*y),y:E.y+(this.currentWidth*A)};var D={x:x.x-(this.currentHeight*A),y:x.y+(this.currentHeight*y)};var s={x:E.x-(this.currentHeight*A),y:E.y+(this.currentHeight*y)};var u={x:E.x-(this.currentHeight/2*A),y:E.y+(this.currentHeight/2*y)};var i={x:E.x+(this.currentWidth/2*y),y:E.y+(this.currentWidth/2*A)};var q={x:x.x-(this.currentHeight/2*A),y:x.y+(this.currentHeight/2*y)};var C={x:s.x+(this.currentWidth/2*y),y:s.y+(this.currentWidth/2*A)};var t={x:E.x+(this.currentWidth/2*y),y:E.y+(this.currentWidth/2*A)};this.oCoords={tl:E,tr:x,br:D,bl:s,ml:u,mt:i,mr:q,mb:C,mtr:t};this._setCornerCoords();return this},getBoundingRectWidth:function(){this.oCoords||this.setCoords();var q=[this.oCoords.tl.x,this.oCoords.tr.x,this.oCoords.br.x,this.oCoords.bl.x];var i=d.util.array.min(q);var r=d.util.array.max(q);return Math.abs(i-r)},getBoundingRectHeight:function(){this.oCoords||this.setCoords();var i=[this.oCoords.tl.y,this.oCoords.tr.y,this.oCoords.br.y,this.oCoords.bl.y];var r=d.util.array.min(i);var q=d.util.array.max(i);return Math.abs(r-q)},drawBorders:function(A){if(!this.hasBorders){return}var t=d.Object.MIN_SCALE_LIMIT,v=this.padding,i=v*2,u=this.strokeWidth>1?this.strokeWidth:0;A.save();A.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;A.strokeStyle=this.borderColor;var z=1/(this.scaleXi){var C=x-i}if(E){z+=(D*E)-(C*E||0)}else{v+=(D*y)-(C*y||0)}B[1&s?"moveTo":"lineTo"](z,v);if(s>=u){s=0}}}q(1,0);q(0,1);q(-1,0);q(0,-1);B.stroke();B.closePath();B.restore()},drawCorners:function(A){if(!this.hasControls){return}var w=this.cornersize,r=w/2,i=this.strokeWidth/2,q=-(this.width/2),u=-(this.height/2),G,B,y=w/this.scaleX,v=w/this.scaleY,D=this.padding/this.scaleX,C=this.padding/this.scaleY,E=r/this.scaleY,F=r/this.scaleX,t=(r-w)/this.scaleX,s=(r-w)/this.scaleY,x=this.height,z=this.width;A.save();A.lineWidth=1/Math.max(this.scaleX,this.scaleY);A.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;A.strokeStyle=A.fillStyle=this.cornerColor;G=q-F-i-D;B=u-E-i-C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q+z-F+i+D;B=u-E-i-C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q-F-i-D;B=u+x+s+i+C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q+z+t+i+D;B=u+x+s+i+C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);if(!this.lockUniScaling){G=q+z/2-F;B=u-E-i-C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q+z/2-F;B=u+x+s+i+C;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q+z+t+i+D;B=u+x/2-E;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v);G=q-F-i-D;B=u+x/2-E;A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v)}if(this.hasRotatingPoint){G=q+z/2-F;B=this.flipY?(u+x+(this.rotatingPointOffset/this.scaleY)-v/2+i+C):(u-(this.rotatingPointOffset/this.scaleY)-v/2-i-C);A.clearRect(G,B,y,v);A.strokeRect(G,B,y,v)}A.restore();return this},clone:function(i){if(this.constructor.fromObject){return this.constructor.fromObject(this.toObject(),i)}return new d.Object(this.toObject())},cloneAsImage:function(s){if(d.Image){var q=new Image();q.onload=function(){if(s){s(new d.Image(q),r)}q=q.onload=null};var r={angle:this.get("angle"),flipX:this.get("flipX"),flipY:this.get("flipY")};this.set("angle",0).set("flipX",false).set("flipY",false);this.toDataURL(function(i){q.src=i})}return this},toDataURL:function(s){var q=d.document.createElement("canvas");if(!q.getContext&&typeof G_vmlCanvasManager!="undefined"){G_vmlCanvasManager.initElement(q)}q.width=this.getBoundingRectWidth();q.height=this.getBoundingRectHeight();d.util.wrapElement(q,"div");var i=new d.Canvas(q);i.backgroundColor="transparent";i.renderAll();if(this.constructor.async){this.clone(r)}else{r(this.clone())}function r(u){u.left=q.width/2;u.top=q.height/2;u.setActive(false);i.add(u);var t=i.toDataURL("png");i.dispose();i=u=null;s&&s(t)}},hasStateChanged:function(){return this.stateProperties.some(function(i){return this[i]!==this.originalState[i]},this)},saveState:function(){this.stateProperties.forEach(function(i){this.originalState[i]=this.get(i)},this);return this},setupState:function(){this.originalState={};this.saveState()},intersectsWithRect:function(r,t){var w=this.oCoords,i=new d.Point(w.tl.x,w.tl.y),s=new d.Point(w.tr.x,w.tr.y),v=new d.Point(w.bl.x,w.bl.y),q=new d.Point(w.br.x,w.br.y);var u=d.Intersection.intersectPolygonRectangle([i,s,q,v],r,t);return(u.status==="Intersection")},intersectsWithObject:function(i){function q(u){return{tl:new d.Point(u.tl.x,u.tl.y),tr:new d.Point(u.tr.x,u.tr.y),bl:new d.Point(u.bl.x,u.bl.y),br:new d.Point(u.br.x,u.br.y)}}var r=q(this.oCoords),t=q(i.oCoords);var s=d.Intersection.intersectPolygonPolygon([r.tl,r.tr,r.br,r.bl],[t.tl,t.tr,t.br,t.bl]);return(s.status==="Intersection")},isContainedWithinObject:function(i){return this.isContainedWithinRect(i.oCoords.tl,i.oCoords.br)},isContainedWithinRect:function(r,t){var v=this.oCoords,i=new d.Point(v.tl.x,v.tl.y),s=new d.Point(v.tr.x,v.tr.y),u=new d.Point(v.bl.x,v.bl.y),q=new d.Point(v.br.x,v.br.y);return i.x>r.x&&s.xr.y&&u.y=v)&&(s.d.y>=v)){continue}if((s.o.x==s.d.x)&&(s.o.x>=w)){x=s.o.x;u=v}else{z=0;y=(s.d.y-s.o.y)/(s.d.x-s.o.x);r=v-z*w;q=s.o.y-y*s.o.x;x=-(r-q)/(z-y);u=r+z*x}if(x>=w){t+=1}if(t==2){break}}return t},_getImageLines:function(r,q){return{topline:{o:r.tl,d:r.tr},rightline:{o:r.tr,d:r.br},bottomline:{o:r.br,d:r.bl},leftline:{o:r.bl,d:r.tl}}},_setCornerCoords:function(){var u=this.oCoords,q=b(45-this.getAngle()),s=Math.sqrt(2*Math.pow(this.cornersize,2))/2,i=s*Math.cos(q),r=s*Math.sin(q),v=Math.sin(this._theta),t=Math.cos(this._theta);u.tl.corner={tl:{x:u.tl.x-r,y:u.tl.y-i},tr:{x:u.tl.x+i,y:u.tl.y-r},bl:{x:u.tl.x-i,y:u.tl.y+r},br:{x:u.tl.x+r,y:u.tl.y+i}};u.tr.corner={tl:{x:u.tr.x-r,y:u.tr.y-i},tr:{x:u.tr.x+i,y:u.tr.y-r},br:{x:u.tr.x+r,y:u.tr.y+i},bl:{x:u.tr.x-i,y:u.tr.y+r}};u.bl.corner={tl:{x:u.bl.x-r,y:u.bl.y-i},bl:{x:u.bl.x-i,y:u.bl.y+r},br:{x:u.bl.x+r,y:u.bl.y+i},tr:{x:u.bl.x+i,y:u.bl.y-r}};u.br.corner={tr:{x:u.br.x+i,y:u.br.y-r},bl:{x:u.br.x-i,y:u.br.y+r},br:{x:u.br.x+r,y:u.br.y+i},tl:{x:u.br.x-r,y:u.br.y-i}};u.ml.corner={tl:{x:u.ml.x-r,y:u.ml.y-i},tr:{x:u.ml.x+i,y:u.ml.y-r},bl:{x:u.ml.x-i,y:u.ml.y+r},br:{x:u.ml.x+r,y:u.ml.y+i}};u.mt.corner={tl:{x:u.mt.x-r,y:u.mt.y-i},tr:{x:u.mt.x+i,y:u.mt.y-r},bl:{x:u.mt.x-i,y:u.mt.y+r},br:{x:u.mt.x+r,y:u.mt.y+i}};u.mr.corner={tl:{x:u.mr.x-r,y:u.mr.y-i},tr:{x:u.mr.x+i,y:u.mr.y-r},bl:{x:u.mr.x-i,y:u.mr.y+r},br:{x:u.mr.x+r,y:u.mr.y+i}};u.mb.corner={tl:{x:u.mb.x-r,y:u.mb.y-i},tr:{x:u.mb.x+i,y:u.mb.y-r},bl:{x:u.mb.x-i,y:u.mb.y+r},br:{x:u.mb.x+r,y:u.mb.y+i}};u.mtr.corner={tl:{x:u.mtr.x-r+(v*this.rotatingPointOffset),y:u.mtr.y-i-(t*this.rotatingPointOffset)},tr:{x:u.mtr.x+i+(v*this.rotatingPointOffset),y:u.mtr.y-r-(t*this.rotatingPointOffset)},bl:{x:u.mtr.x-i+(v*this.rotatingPointOffset),y:u.mtr.y+r-(t*this.rotatingPointOffset)},br:{x:u.mtr.x+r+(v*this.rotatingPointOffset),y:u.mtr.y+i-(t*this.rotatingPointOffset)}}},toGrayscale:function(){var i=this.get("fill");if(i){this.set("overlayFill",new d.Color(i).toGrayscale().toRgb())}return this},complexity:function(){return 0},toJSON:function(){return this.toObject()},setGradientFill:function(i){this.set("fill",d.Gradient.forObject(this,i))},animate:function(){if(arguments[0]&&typeof arguments[0]=="object"){for(var i in arguments[0]){this._animate(i,arguments[0][i],arguments[1])}}else{this._animate.apply(this,arguments)}return this},_animate:function(q,s,i){var r=this;i||(i={});if(!("from" in i)){i.from=this.get(q)}if(/[+-]/.test((s+"").charAt(0))){s=this.get(q)+parseFloat(s)}d.util.animate({startValue:i.from,endValue:s,byValue:i.by,easing:i.easing,duration:i.duration,onChange:function(t){r.set(q,t);i.onChange&&i.onChange()},onComplete:function(){r.setCoords();i.onComplete&&i.onComplete()}})},centerH:function(){this.canvas.centerObjectH(this);return this},centerV:function(){this.canvas.centerObjectV(this);return this},center:function(){return this.centerH().centerV()},remove:function(){return this.canvas.remove(this)},sendToBack:function(){this.canvas.sendToBack(this);return this},bringToFront:function(){this.canvas.bringToFront(this);return this},sendBackwards:function(){this.canvas.sendBackwards(this);return this},bringForward:function(){this.canvas.bringForward(this);return this}});d.Object.prototype.rotate=d.Object.prototype.setAngle;var j=d.Object.prototype;for(var g=j.stateProperties.length;g--;){var h=j.stateProperties[g],e=h.charAt(0).toUpperCase()+h.slice(1),f="set"+e,n="get"+e;if(!j[n]){j[n]=(function(i){return new Function('return this.get("'+i+'")')})(h)}if(!j[f]){j[f]=(function(i){return new Function("value",'return this.set("'+i+'", value)')})(h)}}l(d.Object.prototype,d.Observable);l(d.Object,{NUM_FRACTION_DIGITS:2,MIN_SCALE_LIMIT:0.1})})(typeof exports!="undefined"?exports:this);(function(b){var c=b.fabric||(b.fabric={}),e=c.util.object.extend,d=c.Object.prototype.set,a={x1:1,x2:1,y1:1,y2:1};if(c.Line){c.warn("fabric.Line is already defined");return}c.Line=c.util.createClass(c.Object,{type:"line",initialize:function(g,f){if(!g){g=[0,0,0,0]}this.callSuper("initialize",f);this.set("x1",g[0]);this.set("y1",g[1]);this.set("x2",g[2]);this.set("y2",g[3]);this._setWidthHeight(f)},_setWidthHeight:function(f){f||(f={});this.set("width",(this.x2-this.x1)||1);this.set("height",(this.y2-this.y1)||1);this.set("left","left" in f?f.left:(this.x1+this.width/2));this.set("top","top" in f?f.top:(this.y1+this.height/2))},_set:function(f,g){this[f]=g;if(f in a){this._setWidthHeight()}return this},_render:function(f){f.beginPath();if(this.group){f.translate(-this.group.width/2+this.left,-this.group.height/2+this.top)}f.moveTo(this.width===1?0:(-this.width/2),this.height===1?0:(-this.height/2));f.lineTo(this.width===1?0:(this.width/2),this.height===1?0:(this.height/2));f.lineWidth=this.strokeWidth;var g=f.strokeStyle;f.strokeStyle=f.fillStyle;f.stroke();f.strokeStyle=g},complexity:function(){return 1},toObject:function(){return e(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})},toSVG:function(){return[""].join("")}});c.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");c.Line.fromElement=function(g,f){var i=c.parseAttributes(g,c.Line.ATTRIBUTE_NAMES);var h=[i.x1||0,i.y1||0,i.x2||0,i.y2||0];return new c.Line(h,e(i,f))};c.Line.fromObject=function(f){var g=[f.x1,f.y1,f.x2,f.y2];return new c.Line(g,f)}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={}),d=Math.PI*2,e=b.util.object.extend;if(b.Circle){b.warn("fabric.Circle is already defined.");return}b.Circle=b.util.createClass(b.Object,{type:"circle",initialize:function(f){f=f||{};this.set("radius",f.radius||0);this.callSuper("initialize",f);var g=this.get("radius")*2;this.set("width",g).set("height",g)},toObject:function(){return e(this.callSuper("toObject"),{radius:this.get("radius")})},toSVG:function(){return('')},_render:function(f,g){f.beginPath();f.globalAlpha*=this.opacity;f.arc(g?this.left:0,g?this.top:0,this.radius,0,d,false);f.closePath();if(this.fill){f.fill()}if(this.stroke){f.stroke()}},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(f){this.radius=f;this.set("width",f*2).set("height",f*2)},complexity:function(){return 1}});b.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity opacity stroke stroke-width transform".split(" ");b.Circle.fromElement=function(g,f){f||(f={});var h=b.parseAttributes(g,b.Circle.ATTRIBUTE_NAMES);if(!c(h)){throw Error("value of `r` attribute is required and can not be negative")}if("left" in h){h.left-=(f.width/2)||0}if("top" in h){h.top-=(f.height/2)||0}return new b.Circle(e(h,f))};function c(f){return(("radius" in f)&&(f.radius>0))}b.Circle.fromObject=function(f){return new b.Circle(f)}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={});if(b.Triangle){b.warn("fabric.Triangle is already defined");return}b.Triangle=b.util.createClass(b.Object,{type:"triangle",initialize:function(c){c=c||{};this.callSuper("initialize",c);this.set("width",c.width||100).set("height",c.height||100)},_render:function(c){var d=this.width/2,e=this.height/2;c.beginPath();c.moveTo(-d,e);c.lineTo(0,-e);c.lineTo(d,e);c.closePath();if(this.fill){c.fill()}if(this.stroke){c.stroke()}},complexity:function(){return 1},toSVG:function(){var c=this.width/2,d=this.height/2;var e=[-c+" "+d,"0 "+-d,c+" "+d].join(",");return''}});b.Triangle.fromObject=function(c){return new b.Triangle(c)}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={}),c=Math.PI*2,d=b.util.object.extend;if(b.Ellipse){b.warn("fabric.Ellipse is already defined.");return}b.Ellipse=b.util.createClass(b.Object,{type:"ellipse",initialize:function(e){e=e||{};this.callSuper("initialize",e);this.set("rx",e.rx||0);this.set("ry",e.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return d(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},toSVG:function(){return[""].join("")},render:function(e,f){if(this.rx===0||this.ry===0){return}return this.callSuper("render",e,f)},_render:function(e,f){e.beginPath();e.save();e.globalAlpha*=this.opacity;if(this.transformMatrix&&this.group){e.translate(this.cx,this.cy)}e.transform(1,0,0,this.ry/this.rx,0,0);e.arc(f?this.left:0,f?this.top:0,this.rx,0,c,false);if(this.stroke){e.stroke()}if(this.fill){e.fill()}e.restore()},complexity:function(){return 1}});b.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity opacity stroke stroke-width transform".split(" ");b.Ellipse.fromElement=function(g,f){f||(f={});var i=b.parseAttributes(g,b.Ellipse.ATTRIBUTE_NAMES);var e=i.left;var j=i.top;if("left" in i){i.left-=(f.width/2)||0}if("top" in i){i.top-=(f.height/2)||0}var h=new b.Ellipse(d(i,f));h.cx=e||0;h.cy=j||0;return h};b.Ellipse.fromObject=function(e){return new b.Ellipse(e)}})(typeof exports!="undefined"?exports:this);(function(b){var c=b.fabric||(b.fabric={});if(c.Rect){console.warn("fabric.Rect is already defined");return}c.Rect=c.util.createClass(c.Object,{type:"rect",rx:0,ry:0,initialize:function(d){this._initStateProperties();this.callSuper("initialize",d);this._initRxRy()},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat(["rx","ry"])},_initRxRy:function(){if(this.rx&&!this.ry){this.ry=this.rx}else{if(this.ry&&!this.rx){this.rx=this.ry}}},_render:function(f){var j=this.rx||0,i=this.ry||0,d=-this.width/2,k=-this.height/2,e=this.width,g=this.height;f.beginPath();f.globalAlpha*=this.opacity;if(this.transformMatrix&&this.group){f.translate(this.width/2+this.x,this.height/2+this.y)}if(!this.transformMatrix&&this.group){f.translate(-this.group.width/2+this.width/2+this.x,-this.group.height/2+this.height/2+this.y)}f.moveTo(d+j,k);f.lineTo(d+e-j,k);f.quadraticCurveTo(d+e,k,d+e,k+i,d+e,k+i);f.lineTo(d+e,k+g-i);f.quadraticCurveTo(d+e,k+g,d+e-j,k+g,d+e-j,k+g);f.lineTo(d+j,k+g);f.quadraticCurveTo(d,k+g,d,k+g-i,d,k+g-i);f.lineTo(d,k+i);f.quadraticCurveTo(d,k,d+j,k,d+j,k);f.closePath();if(this.fill){f.fill()}if(this.strokeDashArray){this._renderDashedStroke(f)}else{if(this.stroke){f.stroke()}}},_normalizeLeftTopProperties:function(d){if(d.left){this.set("left",d.left+this.getWidth()/2)}this.set("x",d.left||0);if(d.top){this.set("top",d.top+this.getHeight()/2)}this.set("y",d.top||0);return this},complexity:function(){return 1},toObject:function(){return c.util.object.extend(this.callSuper("toObject"),{rx:this.get("rx")||0,ry:this.get("ry")||0})},toSVG:function(){return''}});c.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity opacity stroke stroke-width transform".split(" ");function a(d){d.left=d.left||0;d.top=d.top||0;return d}c.Rect.fromElement=function(e,d){if(!e){return null}var g=c.parseAttributes(e,c.Rect.ATTRIBUTE_NAMES);g=a(g);var f=new c.Rect(c.util.object.extend((d?c.util.object.clone(d):{}),g));f._normalizeLeftTopProperties(g);return f};c.Rect.fromObject=function(d){return new c.Rect(d)}})(typeof exports!="undefined"?exports:this);(function(b){var c=b.fabric||(b.fabric={}),a=c.util.toFixed;if(c.Polyline){c.warn("fabric.Polyline is already defined");return}c.Polyline=c.util.createClass(c.Object,{type:"polyline",initialize:function(e,d){d=d||{};this.set("points",e);this.callSuper("initialize",d);this._calcDimensions()},_calcDimensions:function(){return c.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return c.Polygon.prototype.toObject.call(this)},toSVG:function(){var f=[];for(var e=0,d=this.points.length;e"].join("")},_render:function(f){var e;f.beginPath();f.moveTo(this.points[0].x,this.points[0].y);for(var g=0,d=this.points.length;g"].join("")},_render:function(l){var k;l.beginPath();l.moveTo(this.points[0].x,this.points[0].y);for(var m=0,j=this.points.length;m1){E=Math.sqrt(E);O*=E;N*=E}var R=aa/O;var Q=W/O;var D=(-W)/N;var C=(aa)/N;var H=R*M+Q*L;var q=D*M+C*L;var F=R*T+Q*S;var ab=D*T+C*S;var Z=(F-H)*(F-H)+(ab-q)*(ab-q);var U=1/Z-0.25;if(U<0){U=0}var w=Math.sqrt(U);if(P==J){w=-w}var V=0.5*(H+F)-w*(ab-q);var K=0.5*(q+ab)+w*(F-H);var v=Math.atan2(q-K,H-V);var u=Math.atan2(ab-K,F-V);var Y=u-v;if(Y<0&&P==1){Y+=2*Math.PI}else{if(Y>0&&P==0){Y-=2*Math.PI}}var B=Math.ceil(Math.abs(Y/(Math.PI*0.5+0.001)));var I=[];for(var X=0;X"},toObject:function(){var q=g(this.callSuper("toObject"),{path:this.path});if(this.sourcePath){q.sourcePath=this.sourcePath}if(this.transformMatrix){q.transformMatrix=this.transformMatrix}return q},toDatalessObject:function(){var q=this.toObject();if(this.sourcePath){q.path=this.sourcePath}delete q.sourcePath;return q},toSVG:function(){var t=[];for(var r=0,q=this.path.length;r',"',""].join("")},complexity:function(){return this.path.length},_parsePath:function(){var C=[],z,v,y;for(var u=0,t,q,w=this.path.length;uB){for(var r=1,x=q.length;r"];for(var l=0,j=m.length;l");return k.join("")},toString:function(){return"#"},isSameColor:function(){var j=this.getObjects()[0].get("fill");return this.getObjects().every(function(k){return k.get("fill")===j})},complexity:function(){return this.paths.reduce(function(j,k){return j+((k&&k.complexity)?k.complexity():0)},0)},toGrayscale:function(){var j=this.paths.length;while(j--){this.paths[j].toGrayscale()}return this},getObjects:function(){return this.paths}});function c(m){for(var l=0,j=m.length;l"},getObjects:function(){return this.objects},addWithUpdate:function(h){this._restoreObjectsState();this.objects.push(h);this._calcBounds();this._updateObjectsCoords();return this},removeWithUpdate:function(h){this._restoreObjectsState();f(this.objects,h);h.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},add:function(h){this.objects.push(h);return this},remove:function(h){f(this.objects,h);return this},size:function(){return this.getObjects().length},_set:function(j,k){if(j==="fill"||j==="opacity"){var h=this.objects.length;this[j]=k;while(h--){this.objects[h].set(j,k)}}else{this[j]=k}},contains:function(h){return this.objects.indexOf(h)>-1},toObject:function(){return g(this.callSuper("toObject"),{objects:b(this.objects,"toObject")})},render:function(j,o){j.save();this.transform(j);var n=Math.max(this.scaleX,this.scaleY);for(var l=0,h=this.objects.length,k;k=this.objects[l];l++){var m=k.borderScaleFactor;k.borderScaleFactor=n;k.render(j);k.borderScaleFactor=m}if(!o&&this.active){this.drawBorders(j);this.hideCorners||this.drawCorners(j)}j.restore();this.setCoords()},item:function(h){return this.getObjects()[h]},complexity:function(){return this.getObjects().reduce(function(i,h){i+=(typeof h.complexity=="function")?h.complexity():0;return i},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,this);return this},_restoreObjectState:function(j){var l=this.get("left"),m=this.get("top"),h=this.getAngle()*(Math.PI/180),k=j.get("originalLeft"),n=j.get("originalTop"),i=Math.cos(h)*j.get("top")+Math.sin(h)*j.get("left"),o=-Math.sin(h)*j.get("top")+Math.cos(h)*j.get("left");j.setAngle(j.getAngle()+this.getAngle());j.set("left",l+o*this.get("scaleX"));j.set("top",m+i*this.get("scaleY"));j.set("scaleX",j.get("scaleX")*this.get("scaleX"));j.set("scaleY",j.get("scaleY")*this.get("scaleY"));j.setCoords();j.hideCorners=false;j.setActive(false);j.setCoords();return this},destroy:function(){return this._restoreObjectsState()},saveCoords:function(){this._originalLeft=this.get("left");this._originalTop=this.get("top");return this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){this.forEachObject(function(h){h.setCoords()});return this},activateAllObjects:function(){this.forEachObject(function(h){h.setActive()});return this},forEachObject:e.StaticCanvas.prototype.forEachObject,_setOpacityIfSame:function(){var j=this.getObjects(),i=j[0]?j[0].get("opacity"):1;var h=j.every(function(k){return k.get("opacity")===i});if(h){this.opacity=i}},_calcBounds:function(){var s=[],q=[],p,n,k,h,m,l,u,r=0,t=this.objects.length;for(;ri.x&&j-hi.y},toGrayscale:function(){var h=this.objects.length;while(h--){this.objects[h].toGrayscale()}},toSVG:function(){var k=[];for(var j=0,h=this.objects.length;j'+k.join("")+"")}});e.Group.fromObject=function(h,i){e.util.enlivenObjects(h.objects,function(j){delete h.objects;i&&i(new e.Group(j,h))})};e.Group.async=true})(typeof exports!="undefined"?exports:this);(function(a){var b=fabric.util.object.extend;if(!a.fabric){a.fabric={}}if(a.fabric.Image){fabric.warn("fabric.Image is already defined.");return}if(!fabric.Object){fabric.warn("fabric.Object is required for fabric.Image initialization");return}fabric.Image=fabric.util.createClass(fabric.Object,{active:false,bordervisibility:false,cornervisibility:false,type:"image",initialize:function(d,c){c||(c={});this.callSuper("initialize",c);this._initElement(d);this._originalImage=this.getElement();this._initConfig(c);this.filters=[];if(c.filters){this.filters=c.filters;this.applyFilters()}},getElement:function(){return this._element},setElement:function(c){this._element=c;this._initConfig();return this},getOriginalSize:function(){var c=this.getElement();return{width:c.width,height:c.height}},setBorderVisibility:function(c){this._resetWidthHeight();this._adjustWidthHeightToBorders(showBorder);this.setCoords()},setCornersVisibility:function(c){this.cornervisibility=!!c},render:function(d,e){d.save();var c=this.transformMatrix;this._resetWidthHeight();if(this.group){d.translate(-this.group.width/2+this.width/2,-this.group.height/2+this.height/2)}if(c){d.transform(c[0],c[1],c[2],c[3],c[4],c[5])}if(!e){this.transform(d)}this._render(d);if(this.active&&!e){this.drawBorders(d);this.hideCorners||this.drawCorners(d)}d.restore()},toObject:function(){return b(this.callSuper("toObject"),{src:this._originalImage.src||this._originalImage._src,filters:this.filters.concat()})},toSVG:function(){return''},getSrc:function(){return this.getElement().src||this.getElement()._src},toString:function(){return'#'},clone:function(c){this.constructor.fromObject(this.toObject(),c)},applyFilters:function(i){if(this.filters.length===0){this.setElement(this._originalImage);i&&i();return}var c=typeof Buffer!=="undefined"&&typeof window==="undefined",g=this._originalImage,e=fabric.document.createElement("canvas"),f=c?new (require("canvas").Image):fabric.document.createElement("img"),h=this;if(!e.getContext&&typeof G_vmlCanvasManager!="undefined"){G_vmlCanvasManager.initElement(e)}e.width=g.width;e.height=g.height;e.getContext("2d").drawImage(g,0,0,g.width,g.height);this.filters.forEach(function(j){j&&j.applyTo(e)});f.onload=function(){h._element=f;i&&i();f.onload=e=g=null};f.width=g.width;f.height=g.height;if(c){var d=e.toDataURL("image/png").replace(/data:image\/png;base64,/,"");f.src=new Buffer(d,"base64");h._element=f;i&&i()}else{f.src=e.toDataURL("image/png")}return this},_render:function(c){c.drawImage(this.getElement(),-this.width/2,-this.height/2,this.width,this.height)},_adjustWidthHeightToBorders:function(c){if(c){this.currentBorder=this.borderwidth;this.width+=(2*this.currentBorder);this.height+=(2*this.currentBorder)}else{this.currentBorder=0}},_resetWidthHeight:function(){var c=this.getElement();this.set("width",c.width);this.set("height",c.height)},_initElement:function(c){this.setElement(fabric.util.getById(c));fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(c){c||(c={});this.setOptions(c);this._setBorder();this._setWidthHeight(c)},_initFilters:function(c){if(c.filters&&c.filters.length){this.filters=c.filters.map(function(d){return d&&fabric.Image.filters[d.type].fromObject(d)})}},_setBorder:function(){if(this.bordervisibility){this.currentBorder=this.borderwidth}else{this.currentBorder=0}},_setWidthHeight:function(c){var d=2*this.currentBorder;this.width="width" in c?c.width:((this.getElement().width||0)+d);this.height="height" in c?c.height:((this.getElement().height||0)+d)},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.prototype.getSvgSrc=fabric.Image.prototype.getSrc;fabric.Image.fromObject=function(d,f){var c=fabric.document.createElement("img"),e=d.src;if(d.width){c.width=d.width}if(d.height){c.height=d.height}c.onload=function(){fabric.Image.prototype._initFilters.call(d,d);var g=new fabric.Image(c,d);f&&f(g);c=c.onload=null};c.src=e};fabric.Image.fromURL=function(d,f,e){var c=fabric.document.createElement("img");c.onload=function(){if(f){f(new fabric.Image(c,e))}c=c.onload=null};c.src=d};fabric.Image.ATTRIBUTE_NAMES="x y width height fill fill-opacity opacity stroke stroke-width transform xlink:href".split(" ");fabric.Image.fromElement=function(d,f,c){c||(c={});var e=fabric.parseAttributes(d,fabric.Image.ATTRIBUTE_NAMES);fabric.Image.fromURL(e["xlink:href"],f,b(e,c))};fabric.Image.async=true})(typeof exports!="undefined"?exports:this);fabric.util.object.extend(fabric.Object.prototype,{_getAngleValueForStraighten:function(){var a=this.get("angle");if(a>-225&&a<=-135){return -180}else{if(a>-135&&a<=-45){return -90}else{if(a>-45&&a<=45){return 0}else{if(a>45&&a<=135){return 90}else{if(a>135&&a<=225){return 180}else{if(a>225&&a<=315){return 270}else{if(a>315){return 360}}}}}}}return 0},straighten:function(){var a=this._getAngleValueForStraighten();this.setAngle(a);return this},fxStraighten:function(b){b=b||{};var c=function(){},d=b.onComplete||c,a=b.onChange||c,e=this;fabric.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(f){e.setAngle(f);a()},onComplete:function(){e.setCoords();d()},onStart:function(){e.setActive(false)}});return this}});fabric.util.object.extend(fabric.StaticCanvas.prototype,{straightenObject:function(a){a.straighten();this.renderAll();return this},fxStraightenObject:function(a){a.fxStraighten({onChange:this.renderAll.bind(this)});return this}});fabric.Image.filters={};fabric.Image.filters.Grayscale=fabric.util.createClass({type:"Grayscale",applyTo:function(d){var c=d.getContext("2d"),a=c.getImageData(0,0,d.width,d.height),h=a.data,e=a.width,l=a.height,k,b,g,f;for(g=0;gh&&m>h&&o>h&&p(a-m)0){l[m]=o;l[m+1]=e;l[m+2]=k}}f.putImageData(c,0,0)},toJSON:function(){return{type:this.type,color:this.color}}});fabric.Image.filters.Tint.fromObject=function(a){return new fabric.Image.filters.Tint(a)};(function(b){var c=b.fabric||(b.fabric={}),e=c.util.object.extend,d=c.util.object.clone,a=c.util.toFixed;if(c.Text){c.warn("fabric.Text is already defined");return}if(!c.Object){c.warn("fabric.Text requires fabric.Object");return}c.Text=c.util.createClass(c.Object,{fontSize:40,fontWeight:100,fontFamily:"Times New Roman",textDecoration:"",textShadow:"",textAlign:"left",fontStyle:"",lineHeight:1.3,strokeStyle:"",strokeWidth:1,backgroundColor:"",path:null,type:"text",useNative:true,initialize:function(g,f){this._initStateProperties();this.text=g;this.setOptions(f||{});this._theta=this.angle*Math.PI/180;this._initDimensions();this.setCoords()},_initDimensions:function(){var f=c.document.createElement("canvas");if(!f.getContext&&typeof G_vmlCanvasManager!="undefined"){G_vmlCanvasManager.initElement(f)}this._render(f.getContext("2d"))},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat();this.stateProperties.push("fontFamily","fontWeight","fontSize","path","text","textDecoration","textShadow","textAlign","fontStyle","lineHeight","strokeStyle","strokeWidth","backgroundColor","useNative");c.util.removeFromArray(this.stateProperties,"width")},toString:function(){return"#'},_render:function(f){if(typeof Cufon==="undefined"||this.useNative===true){this._renderViaNative(f)}else{this._renderViaCufon(f)}},_renderViaCufon:function(f){var h=Cufon.textOptions||(Cufon.textOptions={});h.left=this.left;h.top=this.top;h.context=f;h.color=this.fill;var g=this._initDummyElementForCufon();this.transform(f);Cufon.replaceElement(g,{engine:"canvas",separate:"none",fontFamily:this.fontFamily,fontWeight:this.fontWeight,textDecoration:this.textDecoration,textShadow:this.textShadow,textAlign:this.textAlign,fontStyle:this.fontStyle,lineHeight:this.lineHeight,strokeStyle:this.strokeStyle,strokeWidth:this.strokeWidth,backgroundColor:this.backgroundColor});this.width=h.width;this.height=h.height;this._totalLineHeight=h.totalLineHeight;this._fontAscent=h.fontAscent;this._boundaries=h.boundaries;this._shadowOffsets=h.shadowOffsets;this._shadows=h.shadows||[];g=null;this.setCoords()},_renderViaNative:function(f){this.transform(f);this._setTextStyles(f);var g=this.text.split(/\r?\n/);this.width=this._getTextWidth(f,g);this.height=this._getTextHeight(f,g);this._renderTextBackground(f,g);if(this.textAlign!=="left"){f.save();f.translate(this.textAlign==="center"?(this.width/2):this.width,0)}this._setTextShadow(f);this._renderTextFill(f,g);this.textShadow&&f.restore();this._renderTextStroke(f,g);if(this.textAlign!=="left"){f.restore()}this._renderTextDecoration(f,g);this._setBoundaries(f,g);this._totalLineHeight=0;this.setCoords()},_setBoundaries:function(h,k){this._boundaries=[];for(var j=0,g=k.length;jk){k=l}}return k},_setTextShadow:function(f){if(this.textShadow){var j=/\s+(-?\d+)(?:px)?\s+(-?\d+)(?:px)?\s+(\d+)(?:px)?\s*/;var g=this.textShadow;var i=j.exec(this.textShadow);var h=g.replace(j,"");f.save();f.shadowColor=h;f.shadowOffsetX=parseInt(i[1],10);f.shadowOffsetY=parseInt(i[2],10);f.shadowBlur=parseInt(i[3],10);this._shadows=[{blur:f.shadowBlur,color:f.shadowColor,offX:f.shadowOffsetX,offY:f.shadowOffsetY}];this._shadowOffsets=[[parseInt(f.shadowOffsetX,10),parseInt(f.shadowOffsetY,10)]]}},_renderTextFill:function(g,j){this._boundaries=[];for(var h=0,f=j.length;h-1){f.call(this,this.fontSize)}if(this.textDecoration.indexOf("line-through")>-1){f.call(this,this.fontSize/2)}if(this.textDecoration.indexOf("overline")>-1){f.call(this,0)}},_getFontDeclaration:function(){return[this.fontStyle,this.fontWeight,this.fontSize+"px",(c.isLikelyNode?('"'+this.fontFamily+'"'):this.fontFamily)].join(" ")},_initDummyElementForCufon:function(){var g=c.document.createElement("pre"),f=c.document.createElement("div");f.appendChild(g);if(typeof G_vmlCanvasManager=="undefined"){g.innerHTML=this.text}else{g.innerText=this.text.replace(/\r?\n/gi,"\r")}g.style.fontSize=this.fontSize+"px";g.style.letterSpacing="normal";return g},render:function(f,g){f.save();this._render(f);if(!g&&this.active){this.drawBorders(f);this.hideCorners||this.drawCorners(f)}f.restore()},toObject:function(){return e(this.callSuper("toObject"),{text:this.text,fontSize:this.fontSize,fontWeight:this.fontWeight,fontFamily:this.fontFamily,fontStyle:this.fontStyle,lineHeight:this.lineHeight,textDecoration:this.textDecoration,textShadow:this.textShadow,textAlign:this.textAlign,path:this.path,strokeStyle:this.strokeStyle,strokeWidth:this.strokeWidth,backgroundColor:this.backgroundColor,useNative:this.useNative})},toSVG:function(){var i=this.text.split(/\r?\n/),j=this.useNative?this.fontSize*this.lineHeight:(-this._fontAscent-((this._fontAscent/5)*this.lineHeight)),g=-(this.width/2),f=this.useNative?this.fontSize-1:(this.height/2)-(i.length*this.fontSize)-this._totalLineHeight,h=this._getSVGTextAndBg(j,g,i),k=this._getSVGShadows(j,i);f+=(this._fontAscent?((this._fontAscent/5)*this.lineHeight):0);return['',h.textBgRects.join(""),"',k.join(""),h.textSpans.join(""),"",""].join("")},_getSVGShadows:function(h,n){var o=[],k,l,p,g,f=1;if(!this._shadows||!this._boundaries){return o}for(k=0,p=this._shadows.length;k",c.util.string.escapeXml(n[l]),"");f=1}else{f++}}}return o},_getSVGTextAndBg:function(j,h,n){var g=[],k=[],l,m,o,f=1;for(l=0,o=n.length;l",c.util.string.escapeXml(n[l]),"");f=1}else{f++}if(!this.backgroundColor||!this._boundaries){continue}k.push("')}return{textSpans:g,textBgRects:k}},_getFillAttributes:function(f){var g=f?new c.Color(f):"";if(!g||!g.getSource()||g.getAlpha()===1){return'fill="'+f+'"'}return'opacity="'+g.getAlpha()+'" fill="'+g.setAlpha(1).toRgb()+'"'},setColor:function(f){this.set("fill",f);return this},setFontsize:function(f){this.set("fontSize",f);this._initDimensions();this.setCoords();return this},getText:function(){return this.text},setText:function(f){this.set("text",f);this._initDimensions();this.setCoords();return this},_set:function(f,g){if(f==="fontFamily"&&this.path){this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+g+"$3")}this.callSuper("_set",f,g)}});c.Text.ATTRIBUTE_NAMES=("x y fill fill-opacity opacity stroke stroke-width transform font-family font-style font-weight font-size text-decoration").split(" ");c.Text.fromObject=function(f){return new c.Text(f.text,d(f))};c.Text.fromElement=function(g,f){if(!g){return null}var h=c.parseAttributes(g,c.Text.ATTRIBUTE_NAMES);var f=c.util.object.extend((f?c.util.object.clone(f):{}),h);var i=new c.Text(g.textContent,f);return i}})(typeof exports!="undefined"?exports:this);(function(){if(typeof document!="undefined"&&typeof window!="undefined"){return}var DOMParser=new require("xmldom").DOMParser,URL=require("url"),HTTP=require("http"),Canvas=require("canvas"),Image=require("canvas").Image;function request(url,encoding,callback){var oURL=URL.parse(url),client=HTTP.createClient(oURL.port,oURL.hostname),request=client.request("GET",oURL.pathname,{host:oURL.hostname});client.addListener("error",function(err){if(err.errno===process.ECONNREFUSED){fabric.log("ECONNREFUSED: connection refused to "+client.host+":"+client.port)}else{fabric.log(err.message)}});request.end();request.on("response",function(response){var body="";if(encoding){response.setEncoding(encoding)}response.on("end",function(){callback(body)});response.on("data",function(chunk){if(response.statusCode==200){body+=chunk}})})}fabric.util.loadImage=function(url,callback){request(url,"binary",function(body){var img=new Image();img.src=new Buffer(body,"binary");img._src=url;callback(img)})};fabric.loadSVGFromURL=function(url,callback){url=url.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();request(url,"",function(body){fabric.loadSVGFromString(body,callback)})};fabric.loadSVGFromString=function(string,callback){var doc=new DOMParser().parseFromString(string);fabric.parseSVGDocument(doc.documentElement,function(results,options){callback(results,options)})};fabric.util.getScript=function(url,callback){request(url,"",function(body){eval(body);callback&&callback()})};fabric.Image.fromObject=function(object,callback){fabric.util.loadImage(object.src,function(img){var oImg=new fabric.Image(img);oImg._initConfig(object);oImg._initFilters(object);callback(oImg)})};fabric.createCanvasForNode=function(width,height){var canvasEl=fabric.document.createElement("canvas"),nodeCanvas=new Canvas(width||600,height||600);canvasEl.style={};canvasEl.width=nodeCanvas.width;canvasEl.height=nodeCanvas.height;var canvas=fabric.Canvas||fabric.StaticCanvas;var fabricCanvas=new canvas(canvasEl);fabricCanvas.contextContainer=nodeCanvas.getContext("2d");fabricCanvas.nodeCanvas=nodeCanvas;return fabricCanvas};fabric.StaticCanvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()};if(fabric.Canvas){fabric.Canvas.prototype.createPNGStream}var origSetWidth=fabric.StaticCanvas.prototype.setWidth;fabric.StaticCanvas.prototype.setWidth=function(width){origSetWidth.call(this);this.nodeCanvas.width=width;return this};if(fabric.Canvas){fabric.Canvas.prototype.setWidth=fabric.StaticCanvas.prototype.setWidth}var origSetHeight=fabric.StaticCanvas.prototype.setHeight;fabric.StaticCanvas.prototype.setHeight=function(height){origSetHeight.call(this);this.nodeCanvas.height=height;return this};if(fabric.Canvas){fabric.Canvas.prototype.setHeight=fabric.StaticCanvas.prototype.setHeight}})(); \ No newline at end of file diff --git a/all.min.js.gz b/all.min.js.gz index a95ade466f2..198ec3f4710 100644 Binary files a/all.min.js.gz and b/all.min.js.gz differ