/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */ var fabric=fabric||{version:"0.4.13"};(function(){var a=document.defaultView;if(a&&a.getComputedStyle){var b=a.getComputedStyle(document.documentElement,"");if(b===null){a.getComputedStyle=function c(d,e){return d.style}}}})(); /*! * 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(document.addEventListener){document.addEventListener("DOMContentLoaded",A,false);window.addEventListener("pageshow",A,false)}if(!window.opera&&document.readyState){(function(){B[document.readyState]?A():setTimeout(arguments.callee,10)})()}if(document.readyState&&document.createStyleSheet){(function(){try{document.body.doScroll("left");A()}catch(C){setTimeout(arguments.callee,1)}})()}o(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=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:JU){U=P}if(O>S){S=O}if(Pw){w=h}K.push(h);h=0;continue}var A=aa.glyphs[af[Z]]||aa.missingGlyph;if(!A){continue}h+=C=Number(A.w||aa.w)+T}K.push(h);h=Math.max(w,h);var m=[];for(var Z=K.length;Z--;){m[Z]=h-K[Z]}if(C===null){return null}U+=(G.width-C);B+=G.minX;var v,p;if(n){v=I;p=I.firstChild}else{v=document.createElement("span");v.className="cufon cufon-canvas";v.alt=D;p=document.createElement("canvas");v.appendChild(p);if(z.printable){var X=document.createElement("span");X.className="cufon-alt";X.appendChild(document.createTextNode(D));v.appendChild(X)}}var ag=v.style;var N=p.style;var k=o.convert(G.height-H+S);var ae=Math.ceil(k);var R=ae/k;p.width=Math.ceil(o.convert(h+U-B)*R);p.height=ae;H+=G.minY;N.top=Math.round(o.convert(H-aa.ascent))+"px";N.left=Math.round(o.convert(B))+"px";var j=Math.ceil(o.convert(h*R));var t=j+"px";var s=o.convert(aa.height);var E=(z.lineHeight-1)*o.convert(-aa.ascent/5)*(L-1);Cufon.textOptions.width=j;Cufon.textOptions.height=(s*L)+E;Cufon.textOptions.lines=L;if(a){ag.width=t;ag.height=s+"px"}else{ag.paddingLeft=t;ag.paddingBottom=(s-1)+"px"}var ac=Cufon.textOptions.context||p.getContext("2d"),J=ae/G.height;ac.save();ac.scale(J,J);ac.translate(-B-((1/J*p.width)/2)+(Cufon.fonts[aa.family].offsetLeft||0),-H-(Cufon.textOptions.height/J)/2);ac.lineWidth=aa.face["underline-thickness"];ac.save();function q(i,g){ac.strokeStyle=g;ac.beginPath();ac.moveTo(0,i);ac.lineTo(h,i);ac.stroke()}var r=z.enableTextDecoration?Cufon.CSS.textDecoration(ab,V):{},u=z.fontStyle==="italic";function ad(){ac.save();ac.fillStyle=z.backgroundColor;var aj=0,ak=0;if(z.textAlign==="right"){ac.translate(m[ak],0)}else{if(z.textAlign==="center"){ac.translate(m[ak]/2,0)}}for(var ah=0,x=af.length;ah.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=document.createElement("span");t.className="cufon cufon-vml";t.alt=z;m=document.createElement("span");m.className="cufon-vml-canvas";t.appendChild(m);if(w.printable){var R=document.createElement("span");R.className="cufon-alt";R.appendChild(document.createTextNode(z));t.appendChild(R)}if(!M){t.appendChild(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=w.enableTextDecoration?Cufon.CSS.textDecoration(U,O):{};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;SO;R.onStart&&R.onStart();var H=setInterval(function(){J=+new Date();P=J>Q?1:(J-G)/K;M(I?(F-(F-O)*N(P)):(F+(O-F)*N(P)));if(J>Q||L()){clearInterval(H);R.onComplete&&R.onComplete()}},10);return H}var C={has:function(F,G){G(false)},get:function(F,G){},set:function(G,F){}};function B(F,H){F=F.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();C.has(F,function(I){if(I){C.get(F,function(K){var J=E(K);H(J.objects,J.options)})}else{new h.util.request(F,{method:"get",onComplete:G})}});function G(J){var I=J.responseXML;if(!I){return}var K=I.documentElement;if(!K){return}console.log(K);h.parseSVGDocument(K,function(M,L){C.set(F,{objects:h.util.array.invoke(M,"toObject"),options:L});H(M,L)})}}function E(H){var G=H.objects,F=H.options;G=G.map(function(I){return h[e(I.type)].fromObject(I)});return({objects:G,options:F})}function z(F,I){var G;if(typeof DOMParser!=="undefined"){var H=new DOMParser();if(H&&H.parseFromString){G=H.parseFromString(F,"text/xml")}}else{if(window.ActiveXObject){var G=new ActiveXObject("Microsoft.XMLDOM");if(G&&G.loadXML){G.async="false";G.loadXML(F)}}}h.parseSVGDocument(G.documentElement,function(K,J){I(K,J)})}h.util.removeFromArray=A;h.util.degreesToRadians=u;h.util.toFixed=w;h.util.getRandomInt=x;h.util.falseFunction=D;h.util.animate=v;h.loadSVGFromURL=B;h.loadSVGFromString=z})();if(!Array.prototype.indexOf){Array.prototype.indexOf=function(v,w){var u=this.length>>>0;w=Number(w)||0;w=Math[w<0?"ceil":"floor"](w);if(w<0){w+=u}for(;w>>0;v>>0;w>>0;v>>0;v>>0;w>>0,v=0,x;if(arguments.length>1){x=arguments[1]}else{do{if(v in this){x=this[v++];break}if(++v>=u){throw new TypeError()}}while(true)}for(;v=u){u=x[v][w]}}}else{while(v--){if(x[v]>=u){u=x[v]}}}return u}function l(x,w){var v=x.length-1,u=w?x[v][w]:x[v];if(w){while(v--){if(x[v][w]-1?w(D,F.match(/opacity:\s*(\d?\.?\d*)/)[1]):D}for(var G in F){if(G==="opacity"){w(D,F[G])}else{var E=(G==="float"||G==="cssFloat")?(typeof H.styleFloat==="undefined"?"cssFloat":"styleFloat"):G;H[E]=F[G]}}return D}var B=document.createElement("div"),A=typeof B.style.opacity==="string",v=typeof B.style.filter==="string",u=document.defaultView,z=u&&typeof u.getComputedStyle!=="undefined",x=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,w=function(C){return C};if(A){w=function(C,D){C.style.opacity=D;return C}}else{if(v){w=function(C,D){var E=C.style;if(C.currentStyle&&!C.currentStyle.hasLayout){E.zoom=1}if(x.test(E.filter)){D=D>=0.9999?"":("alpha(opacity="+(D*100)+")");E.filter=E.filter.replace(x,D)}else{E.filter+=" alpha(opacity="+(D*100)+")"}return C}}}h.util.setStyle=y})();var c=Array.prototype.slice;function p(u){return typeof u==="string"?document.getElementById(u):u}function n(u){return c.call(u,0)}try{var g=n(document.childNodes) instanceof Array}catch(d){}if(!g){n=function(v){var u=new Array(v.length),w=v.length;while(w--){u[w]=v[w]}return u}}function b(v,u){var w=document.createElement(v);for(var x in u){if(x==="class"){w.className=u[x]}else{if(x==="for"){w.htmlFor=u[x]}else{w.setAttribute(x,u[x])}}}return w}function f(u,v){if((" "+u.className+" ").indexOf(" "+v+" ")===-1){u.className+=(u.className?" ":"")+v}}function a(v,w,u){if(typeof w==="string"){w=b(w,u)}if(v.parentNode){v.parentNode.replaceChild(w,v)}w.appendChild(v);return w}function k(v){var u=0,w=0;do{u+=v.offsetTop||0;w+=v.offsetLeft||0;v=v.offsetParent}while(v);return({left:w,top:u})}(function(){var u=document.documentElement.style;var v="userSelect" in u?"userSelect":"MozUserSelect" in u?"MozUserSelect":"WebkitUserSelect" in u?"WebkitUserSelect":"KhtmlUserSelect" in u?"KhtmlUserSelect":"";function w(x){if(typeof x.onselectstart!=="undefined"){x.onselectstart=h.util.falseFunction}if(v){x.style[v]="none"}else{if(typeof x.unselectable=="string"){x.unselectable="on"}}return x}h.util.makeElementUnselectable=w})();(function(){function u(x,B){var z=document.getElementsByTagName("head")[0],y=document.createElement("script"),A=true;y.type="text/javascript";y.setAttribute("runat","server");y.onload=y.onreadystatechange=function(C){if(A){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete"){return}A=false;B(C||window.event);y=y.onload=y.onreadystatechange=null}};y.src=x;z.appendChild(y)}function w(x,y){v.load(x);y()}h.util.getScript=u;var v=m.Jaxer;if(v&&v.load){h.util.getScript=w}})();h.util.getById=p;h.util.toArray=n;h.util.makeElement=b;h.util.addClass=f;h.util.wrapElement=a;h.util.getElementOffset=k;(function(){function x(y,z){return y+(/\?/.test(y)?"&":"?")+z}var w=(function(){var B=[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 y=B.length;y--;){try{var A=B[y]();if(A){return B[y]}}catch(z){}}})();function u(){}function v(A,z){z||(z={});var D=z.method?z.method.toUpperCase():"GET",C=z.onComplete||function(){},B=w(),y;B.onreadystatechange=function(){if(B.readyState===4){C(B);B.onreadystatechange=u}};if(D==="GET"){y=null;if(typeof z.parameters=="string"){A=x(A,z.parameters)}}B.open(D,A,true);if(D==="POST"||D==="PUT"){B.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}B.send(y);return B}h.util.request=v})()})(this);(function(b){var c=b.fabric||(b.fabric={}),h=c.util.object.extend,f=c.util.string.capitalize,i=c.util.object.clone;var d={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};function m(q,p){if(!q){return}var s,o,n={};if(q.parentNode&&/^g$/i.test(q.parentNode.nodeName)){n=c.parseAttributes(q.parentNode,p)}var r=p.reduce(function(u,t){s=q.getAttribute(t);o=parseFloat(s);if(s){if((t==="fill"||t==="stroke")&&s==="none"){s=""}if(t==="fill-rule"){s=(s==="evenodd")?"destination-over":s}if(t==="transform"){s=c.parseTransformAttribute(s)}if(t in d){t=d[t]}u[t]=isNaN(o)?s:o}return u},{});r=h(r,h(a(q),c.parseStyleAttribute(q)));return h(n,r)}c.parseTransformAttribute=(function(){function n(G,H){var I=H[0];G[0]=Math.cos(I);G[1]=Math.sin(I);G[2]=-Math.sin(I);G[3]=Math.cos(I)}function s(I,J){var H=J[0],G=(J.length===2)?J[1]:J[0];I[0]=H;I[3]=G}function D(G,H){G[2]=H[0]}function p(G,H){G[1]=H[0]}function A(G,H){G[4]=H[0];if(H.length===2){G[5]=H[1]}}var u=[1,0,0,1,0,0],o="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",E="(?:\\s+,?\\s*|,\\s*)",v="(?:(skewX)\\s*\\(\\s*("+o+")\\s*\\))",t="(?:(skewY)\\s*\\(\\s*("+o+")\\s*\\))",C="(?:(rotate)\\s*\\(\\s*("+o+")(?:"+E+"("+o+")"+E+"("+o+"))?\\s*\\))",F="(?:(scale)\\s*\\(\\s*("+o+")(?:"+E+"("+o+"))?\\s*\\))",y="(?:(translate)\\s*\\(\\s*("+o+")(?:"+E+"("+o+"))?\\s*\\))",B="(?:(matrix)\\s*\\(\\s*("+o+")"+E+"("+o+")"+E+"("+o+")"+E+"("+o+")"+E+"("+o+")"+E+"("+o+")\\s*\\))",z="(?:"+B+"|"+y+"|"+F+"|"+C+"|"+v+"|"+t+")",w="(?:"+z+"(?:"+E+z+")*)",q="^\\s*(?:"+w+"?)\\s*$",x=new RegExp(q),r=new RegExp(z);return function(H){var G=u.concat();if(!H||(H&&!x.test(H))){return G}H.replace(r,function(L){var I=new RegExp(z).exec(L).filter(function(M){return(M!==""&&M!=null)}),J=I[1],K=I.slice(2).map(parseFloat);switch(J){case"translate":A(G,K);break;case"rotate":n(G,K);break;case"scale":s(G,K);break;case"skewX":D(G,K);break;case"skewY":p(G,K);break;case"matrix":G=K;break}});return G}})();function j(q){if(!q){return null}q=q.trim();var s=q.indexOf(",")>-1;q=q.split(/\s+/);var o=[];if(s){for(var p=0,n=q.length;p0){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}}})(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}})(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)0)?0:-A),w.ey-((z>0)?0:-z),y,x);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(w.ex+c-((A>0)?0:y),w.ey+c-((z>0)?0:x),y,x)},_findSelectedObjects:function(C){var D,y,I=[],x=this._groupSelector.ex,H=this._groupSelector.ey,w=x+this._groupSelector.left,F=H+this._groupSelector.top,E,B=new fabric.Point(o(x,w),o(H,F)),G=new fabric.Point(r(x,w),r(H,F));for(var z=0,A=this._objects.length;z1){var I=new fabric.Group(I);this.setActiveGroup(I);I.saveCoords();this.fire("selection:created",{target:I})}}this.renderAll()},add:function(){this._objects.push.apply(this._objects,arguments);for(var w=arguments.length;w--;){this.stateful&&arguments[w].setupState();arguments[w].setCoords()}this.renderOnAddition&&this.renderAll();return this},insertAt:function(x,w){this._objects.splice(w,0,x);this.stateful&&x.setupState();x.setCoords();this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop},clearContext:function(w){w.clearRect(0,0,this.width,this.height);return this},clear:function(){this._objects.length=0;this.clearContext(this.contextTop);this.clearContext(this.contextContainer);this.renderAll();return this},renderAll:function(x){var C=this[x?"contextTop":"contextContainer"];this.clearContext(this.contextTop);if(!x){this.clearContext(C)}var B=this._objects.length,A=this.getActiveGroup(),z=new Date();if(this.clipTo){C.save();C.beginPath();this.clipTo(C);C.clip()}C.fillStyle=this.backgroundColor;C.fillRect(0,0,this.width,this.height);if(B){for(var y=0;y=0;--z){if(y.intersectsWithObject(this._objects[z])||y.isContainedWithinObject(this._objects[z])){w=z;break}}j(this._objects,y);this._objects.splice(w,0,y)}return this.renderAll()},bringForward:function(z){var B=this.getObjects(),x=B.indexOf(z),w=x;if(x!==B.length-1){for(var A=x+1,y=this._objects.length;A"};s(fabric.Canvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(z){var y=z.getContext("2d"),w=y.getImageData(0,0,z.width,z.height),D=w.data,A=w.width,F=w.height,E,x,C,B;for(C=0;C1){var o=new fabric.PathGroup(q,n)}else{var o=q[0]}o.setSourcePath(m);if(!(o instanceof fabric.PathGroup)){fabric.util.object.extend(o,n);if(typeof n.angle!=="undefined"){o.setAngle(n.angle)}}g(o,l)})}}}},this)}catch(c){fabric.log(c.message)}},loadFromJSON:function(a,d){if(!a){return}var b=JSON.parse(a);if(!b||(b&&!b.objects)){return}this.clear();var c=this;this._enlivenObjects(b.objects,function(){c.backgroundColor=b.background;if(d){d()}});return this},_enlivenObjects:function(b,e){var c=0,a=b.filter(function(f){return f.type==="image"}).length;var d=this;b.forEach(function(h,g){if(!h.type){return}switch(h.type){case"image":case"font":fabric[fabric.util.string.capitalize(h.type)].fromObject(h,function(i){d.insertAt(i,g);if(++c===a){if(e){e()}}});break;default:var f=fabric[fabric.util.string.camelize(fabric.util.string.capitalize(h.type))];if(f&&f.fromObject){d.insertAt(f.fromObject(h),g)}break}});if(a===0&&e){e()}},_toDataURL:function(a,b){this.clone(function(c){b(c.toDataURL(a))})},_toDataURLWithMultiplier:function(a,c,b){this.clone(function(d){b(d.toDataURLWithMultiplier(a,c))})},clone:function(c){var a=document.createElement("canvas");a.width=this.getWidth();a.height=this.getHeight();var b=this.__clone||(this.__clone=new fabric.Canvas(a));b.clipTo=this.clipTo;return b.loadFromJSON(JSON.stringify(this.toJSON()),function(){if(c){c(b)}})}});(function(a){var d=a.fabric||(a.fabric={}),l=d.util.object.extend,m=d.util.object.clone,c=d.util.toFixed,k=d.util.string.capitalize,p=d.util.getPointer,b=d.util.degreesToRadians,o=Array.prototype.slice;if(d.Object){return}d.Object=d.util.createClass({type:"object",includeDefaultValues:true,NUM_FRACTION_DIGITS:2,FX_DURATION:500,MIN_SCALE_LIMIT:0.1,stateProperties:("top left width height scaleX scaleY flipX flipY theta angle opacity cornersize fill overlayFill stroke strokeWidth fillRule borderScaleFactor transformMatrix selectable").split(" "),top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:false,flipY:false,theta:0,opacity:1,angle:0,cornersize:12,padding:0,borderColor:"rgba(102,153,255,0.75)",cornerColor:"rgba(102,153,255,0.5)",fill:"rgb(0,0,0)",fillRule:"source-over",overlayFill:null,stroke:null,strokeWidth:1,borderOpacityWhenMoving:0.4,borderScaleFactor:1,transformMatrix:null,selectable:true,hasControls:true,hasBorders:true,callSuper:function(i){var q=this.constructor.superclass.prototype[i];return(arguments.length>1)?q.apply(this,o.call(arguments,1)):q.call(this)},initialize:function(i){i&&this.setOptions(i)},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 i={type:this.type,left:c(this.left,this.NUM_FRACTION_DIGITS),top:c(this.top,this.NUM_FRACTION_DIGITS),width:c(this.width,this.NUM_FRACTION_DIGITS),height:c(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,scaleX:c(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:c(this.scaleY,this.NUM_FRACTION_DIGITS),angle:c(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:c(this.opacity,this.NUM_FRACTION_DIGITS),selectable:this.selectable};if(!this.includeDefaultValues){i=this._removeDefaultValues(i)}return i},toDatalessObject:function(){return this.toObject()},_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(q,i){var s=(q==="scaleX"||q==="scaleY")&&ir.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 t=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);t.tl.corner={tl:{x:t.tl.x-r,y:t.tl.y-i},tr:{x:t.tl.x+i,y:t.tl.y-r},bl:{x:t.tl.x-i,y:t.tl.y+r},br:{x:t.tl.x+r,y:t.tl.y+i}};t.tr.corner={tl:{x:t.tr.x-r,y:t.tr.y-i},tr:{x:t.tr.x+i,y:t.tr.y-r},br:{x:t.tr.x+r,y:t.tr.y+i},bl:{x:t.tr.x-i,y:t.tr.y+r}};t.bl.corner={tl:{x:t.bl.x-r,y:t.bl.y-i},bl:{x:t.bl.x-i,y:t.bl.y+r},br:{x:t.bl.x+r,y:t.bl.y+i},tr:{x:t.bl.x+i,y:t.bl.y-r}};t.br.corner={tr:{x:t.br.x+i,y:t.br.y-r},bl:{x:t.br.x-i,y:t.br.y+r},br:{x:t.br.x+r,y:t.br.y+i},tl:{x:t.br.x-r,y:t.br.y-i}};t.ml.corner={tl:{x:t.ml.x-r,y:t.ml.y-i},tr:{x:t.ml.x+i,y:t.ml.y-r},bl:{x:t.ml.x-i,y:t.ml.y+r},br:{x:t.ml.x+r,y:t.ml.y+i}};t.mt.corner={tl:{x:t.mt.x-r,y:t.mt.y-i},tr:{x:t.mt.x+i,y:t.mt.y-r},bl:{x:t.mt.x-i,y:t.mt.y+r},br:{x:t.mt.x+r,y:t.mt.y+i}};t.mr.corner={tl:{x:t.mr.x-r,y:t.mr.y-i},tr:{x:t.mr.x+i,y:t.mr.y-r},bl:{x:t.mr.x-i,y:t.mr.y+r},br:{x:t.mr.x+r,y:t.mr.y+i}};t.mb.corner={tl:{x:t.mb.x-r,y:t.mb.y-i},tr:{x:t.mb.x+i,y:t.mb.y-r},bl:{x:t.mb.x-i,y:t.mb.y+r},br:{x:t.mb.x+r,y:t.mb.y+i}}},toGrayscale:function(){var i=this.get("fill");if(i){this.set("overlayFill",new d.Color(i).toGrayscale().toRgb())}return this},complexity:function(){return 0},getCenter:function(){return{x:this.get("left")+this.width/2,y:this.get("top")+this.height/2}},straighten:function(){var i=this._getAngleValueForStraighten();this.setAngle(i);return this},fxStraighten:function(q){q=q||{};var r=function(){},s=q.onComplete||r,i=q.onChange||r,t=this;d.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(u){t.setAngle(u);i()},onComplete:function(){t.setCoords();s()},onStart:function(){t.setActive(false)}});return this},fxRemove:function(q){q||(q={});var r=function(){},s=q.onComplete||r,i=q.onChange||r,t=this;d.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(u){t.set("opacity",u);i()},onComplete:s,onStart:function(){t.setActive(false)}});return this},_getAngleValueForStraighten:function(){var i=this.get("angle");if(i>-225&&i<=-135){return -180}else{if(i>-135&&i<=-45){return -90}else{if(i>-45&&i<=45){return 0}else{if(i>45&&i<=135){return 90}else{if(i>135&&i<=225){return 180}else{if(i>225&&i<=315){return 270}else{if(i>315){return 360}}}}}}}return 0},toJSON:function(){return this.toObject()},setGradientFill:function(i,q){this.set("fill",d.Gradient.forObject(this,i,q))},animate:function(q,s,i){var r=this;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,duration:i.duration,onChange:function(t){r.set(q,t);i.onChange&&i.onChange()},onComplete:function(){r.setCoords();i.onComplete&&i.onComplete()}})}});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)}}})(this);(function(a){var b=a.fabric||(a.fabric={}),c=b.util.object.extend;if(b.Line){b.warn("fabric.Line is already defined");return}b.Line=b.util.createClass(b.Object,{type:"line",initialize:function(e,d){if(!e){e=[0,0,0,0]}this.callSuper("initialize",d);this.set("x1",e[0]);this.set("y1",e[1]);this.set("x2",e[2]);this.set("y2",e[3]);this.set("width",(this.x2-this.x1)||1);this.set("height",(this.y2-this.y1)||1);this.set("left",this.x1+this.width/2);this.set("top",this.y1+this.height/2)},_render:function(d){d.beginPath();d.moveTo(-this.width/2,-this.height/2);d.lineTo(this.width/2,this.height/2);d.lineWidth=this.strokeWidth;var e=d.strokeStyle;d.strokeStyle=d.fillStyle;d.stroke();d.strokeStyle=e},complexity:function(){return 1},toObject:function(){return c(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});b.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");b.Line.fromElement=function(e,d){var g=b.parseAttributes(e,b.Line.ATTRIBUTE_NAMES);var f=[g.x1||0,g.y1||0,g.x2||0,g.y2||0];return new b.Line(f,c(g,d))};b.Line.fromObject=function(d){var e=[d.x1,d.y1,d.x2,d.y2];return new b.Line(e,d)}})(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.get("scaleX");this.set("width",g).set("height",g)},toObject:function(){return e(this.callSuper("toObject"),{radius:this.get("radius")})},_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")},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)}})(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}});b.Triangle.fromObject=function(c){return new b.Triangle(c)}})(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")})},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;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(f,e){e||(e={});var g=b.parseAttributes(f,b.Ellipse.ATTRIBUTE_NAMES);if("left" in g){g.left-=(e.width/2)||0}if("top" in g){g.top-=(e.height/2)||0}return new b.Ellipse(d(g,e))};b.Ellipse.fromObject=function(e){return new b.Ellipse(e)}})(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",options:{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.group){f.translate(this.x,this.y)}f.moveTo(d+j,k);f.lineTo(d+e-j,k);f.bezierCurveTo(d+e,k,d+e,k+i,d+e,k+i);f.lineTo(d+e,k+g-i);f.bezierCurveTo(d+e,k+g,d+e-j,k+g,d+e-j,k+g);f.lineTo(d+j,k+g);f.bezierCurveTo(d,k+g,d,k+g-i,d,k+g-i);f.lineTo(d,k+i);f.bezierCurveTo(d,k,d+j,k,d+j,k);f.closePath();if(this.fill){f.fill()}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}});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)}})(this);(function(a){var b=a.fabric||(a.fabric={});if(b.Polyline){b.warn("fabric.Polyline is already defined");return}b.Polyline=b.util.createClass(b.Object,{type:"polyline",initialize:function(d,c){c=c||{};this.set("points",d);this.callSuper("initialize",c);this._calcDimensions()},_calcDimensions:function(){return b.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return b.Polygon.prototype.toObject.call(this)},_render:function(e){var d;e.beginPath();for(var f=0,c=this.points.length;f1){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},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"},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},add:function(h){this._restoreObjectsState();this.objects.push(h);h.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(h){this._restoreObjectsState();f(this.objects,h);h.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(h,k){if(typeof k=="function"){this.set(h,k(this[h]))}else{if(h==="fill"||h==="opacity"){var j=this.objects.length;this[h]=k;while(j--){this.objects[j].set(h,k)}}else{this[h]=k}}return this},contains:function(h){return this.objects.indexOf(h)>-1},toObject:function(){return g(this.callSuper("toObject"),{objects:b(this.objects,"clone")})},render:function(j){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}this.hideBorders||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(){return this.setActive(true)},setActive:function(h){this.forEachObject(function(i){i.setActive(h)});return this},forEachObject:e.Canvas.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()}}});e.Group.fromObject=function(h){return new e.Group(h.objects,h)}})(this);(function(a){var b=a.fabric||(a.fabric={}),d=b.util.object.extend,c=b.util.object.clone;if(b.Text){b.warn("fabric.Text is already defined");return}if(!b.Object){b.warn("fabric.Text requires fabric.Object");return}b.Text=b.util.createClass(b.Object,{fontSize:20,fontWeight:100,fontFamily:"Times_New_Roman",textDecoration:"",textShadow:null,textAlign:"left",fontStyle:"",lineHeight:1.6,strokeStyle:"",strokeWidth:1,backgroundColor:"",path:null,type:"text",initialize:function(f,e){this._initStateProperties();this.text=f;this.setOptions(e);this.theta=this.angle*Math.PI/180;this.width=this.getWidth();this.setCoords()},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat();this.stateProperties.push("fontFamily","fontWeight","path","text","textDecoration","textShadow","textAlign","fontStyle","lineHeight","strokeStyle","strokeWidth","backgroundColor");b.util.removeFromArray(this.stateProperties,"width")},toString:function(){return"#'},_render:function(e){var g=Cufon.textOptions||(Cufon.textOptions={});g.left=this.left;g.top=this.top;g.context=e;g.color=this.fill;var f=this._initDummyElement();this.transform(e);Cufon.replaceElement(f,{separate:"none",fontFamily:this.fontFamily,enableTextDecoration:true,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=g.width;this.height=g.height;this.setCoords()},_initDummyElement:function(){var f=document.createElement("div"),e=document.createElement("div");e.appendChild(f);f.innerHTML=this.text;f.style.fontSize="40px";f.style.fontWeight="400";f.style.letterSpacing="normal";f.style.color="#000000";f.style.fontWeight="600";f.style.fontFamily="Verdana";return f},render:function(e,f){e.save();this._render(e);if(!f&&this.active){this.drawBorders(e);this.hideCorners||this.drawCorners(e)}e.restore()},toObject:function(){return d(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})},setColor:function(e){this.set("fill",e);return this},setFontsize:function(e){this.set("fontSize",e);this.setCoords();return this},getText:function(){return this.text},setText:function(e){this.set("text",e);this.setCoords();return this},set:function(e,f){this[e]=f;if(e==="fontFamily"&&this.path){this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+f+"$3")}return this}});b.Text.fromObject=function(e){return new b.Text(e.text,c(e))};b.Text.fromElement=function(e){}})(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,{maxwidth:null,maxheight:null,active:false,bordervisibility:false,cornervisibility:false,type:"image",__isGrayscaled:false,initialize:function(d,c){this.callSuper("initialize",c);this._initElement(d);this._initConfig(c||{})},getElement:function(){return this._element},setElement:function(c){this._element=c;return this},getNormalizedSize:function(d,c,e){if(e&&c&&(d.width>d.height&&(d.width/d.height)<(c/e))){normalizedWidth=~~((d.width*e)/d.height);normalizedHeight=e}else{if(e&&((d.height==d.width)||(d.height>d.width)||(d.height>e))){normalizedWidth=~~((d.width*e)/d.height);normalizedHeight=e}else{if(c&&(c'},clone:function(c){this.constructor.fromObject(this.toObject(),c)},toGrayscale:function(g){if(this.__isGrayscaled){return}var e=this.getElement(),c=document.createElement("canvas"),d=document.createElement("img"),f=this;c.width=e.width;c.height=e.height;c.getContext("2d").drawImage(e,0,0);fabric.Canvas.toGrayscale(c);d.onload=function(){f.setElement(d);g&&g();d.onload=c=e=imageData=null};d.width=e.width;d.height=e.height;d.src=c.toDataURL("image/png");this.__isGrayscaled=true;return this},_render:function(d){var c=this.getOriginalSize();d.drawImage(this.getElement(),-c.width/2,-c.height/2,c.width,c.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){this.setOptions(c);this._setBorder();this._setWidthHeight(c)},_setBorder:function(){if(this.bordervisibility){this.currentBorder=this.borderwidth}else{this.currentBorder=0}},_setWidthHeight:function(c){var d=2*this.currentBorder;this.width=(this.getElement().width||0)+d;this.height=(this.getElement().height||0)+d},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(d,f){var c=document.createElement("img"),e=d.src;if(d.width){c.width=d.width}if(d.height){c.height=d.height}c.onload=function(){if(f){f(new fabric.Image(c,d))}c=c.onload=null};c.src=e};fabric.Image.fromURL=function(d,f,e){var c=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.fromElement.async=true})(this);