mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-30 01:54:44 +00:00
7 lines
No EOL
98 KiB
JavaScript
7 lines
No EOL
98 KiB
JavaScript
/* Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
|
|
var fabric=fabric||{version:"0.2.2"};fabric.log=function(){};fabric.warn=function(){};if(typeof console!=="undefined"){if(typeof console.log!=="undefined"&&console.log.apply){fabric.log=function(){return console.log.apply(console,arguments)}}if(typeof console.warn!=="undefined"&&console.warn.apply){fabric.warn=function(){return console.warn.apply(console,arguments)}}}if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());(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 m=function(){return m.replace.apply(null,arguments)};var w=m.DOM={ready:(function(){var B=false,D={loaded:1,complete:1};var A=[],C=function(){if(B){return}B=true;for(var E;E=A.shift();E()){}};if(document.addEventListener){document.addEventListener("DOMContentLoaded",C,false);window.addEventListener("pageshow",C,false)}if(!window.opera&&document.readyState){(function(){D[document.readyState]?C():setTimeout(arguments.callee,10)})()}if(document.readyState&&document.createStyleSheet){(function(){try{document.body.doScroll("left");C()}catch(E){setTimeout(arguments.callee,1)}})()}q(window,"load",C);return function(E){if(!arguments.length){C()}else{B?E():A.push(E)}}})()};var n=m.CSS={Size:function(B,A){this.value=parseFloat(B);this.unit=String(B).match(/[a-z%]*$/)[0]||"px";this.convert=function(C){return C/A*this.value};this.convertFrom=function(C){return C/this.value*A};this.toString=function(){return this.value+this.unit}},getStyle:function(A){return new a(A.style)},quotedList:k(function(D){var C=[],B=/\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g,A;while(A=B.exec(D)){C.push(A[3]||A[1])}return C}),ready:(function(){var C=false;var B=[],D=function(){C=true;for(var F;F=B.shift();F()){}};var A=Object.prototype.propertyIsEnumerable?f("style"):{length:0};var E=f("link");w.ready(function(){var I=0,H;for(var G=0,F=E.length;H=E[G],G<F;++G){if(!H.disabled&&H.rel.toLowerCase()=="stylesheet"){++I}}if(document.styleSheets.length>=A.length+I){D()}else{setTimeout(arguments.callee,10)}});return function(F){if(C){F()}else{B.push(F)}}})(),supports:function(C,B){var A=document.createElement("span").style;if(A[C]===undefined){return false}A[C]=B;return A[C]===B},textAlign:function(D,C,A,B){if(C.get("textAlign")=="right"){if(A>0){D=" "+D}}else{if(A<B-1){D+=" "}}return D},textDecoration:function(F,E){if(!E){E=this.getStyle(F)}var B={underline:null,overline:null,"line-through":null};for(var A=F;A.parentNode&&A.parentNode.nodeType==1;){var D=true;for(var C in B){if(B[C]){continue}if(E.get("textDecoration").indexOf(C)!=-1){B[C]=E.get("color")}D=false}if(D){break}E=this.getStyle(A=A.parentNode)}return B},textShadow:k(function(E){if(E=="none"){return null}var D=[],F={},A,B=0;var C=/(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)|(-?[\d.]+[a-z%]*)|,/ig;while(A=C.exec(E)){if(A[0]==","){D.push(F);F={},B=0}else{if(A[1]){F.color=A[1]}else{F[["offX","offY","blur"][B++]]=A[2]}}}D.push(F);return D}),color:k(function(B){var A={};A.color=B.replace(/^rgba\((.*?),\s*([\d.]+)\)/,function(D,C,E){A.opacity=parseFloat(E);return"rgb("+C+")"});return A}),textTransform:function(B,A){return B[{uppercase:"toUpperCase",lowercase:"toLowerCase"}[A.get("textTransform")]||"toString"]()}};function s(B){var A=this.face=B.face;this.glyphs=B.glyphs;this.w=B.w;this.baseSize=parseInt(A["units-per-em"],10);this.family=A["font-family"].toLowerCase();this.weight=A["font-weight"];this.style=A["font-style"]||"normal";this.viewBox=(function(){var D=A.bbox.split(/\s+/);var C={minX:parseInt(D[0],10),minY:parseInt(D[1],10),maxX:parseInt(D[2],10),maxY:parseInt(D[3],10)};C.width=C.maxX-C.minX,C.height=C.maxY-C.minY;C.toString=function(){return[this.minX,this.minY,this.width,this.height].join(" ")};return C})();this.ascent=-parseInt(A.ascent,10);this.descent=-parseInt(A.descent,10);this.height=-this.ascent+this.descent}function e(){var B={},A={oblique:"italic",italic:"oblique"};this.add=function(C){(B[C.style]||(B[C.style]={}))[C.weight]=C};this.get=function(G,H){var F=B[G]||B[A[G]]||B.normal||B.italic||B.oblique;if(!F){return null}H={normal:400,bold:700}[H]||parseInt(H,10);if(F[H]){return F[H]}var D={1:1,99:0}[H%100],J=[],E,C;if(D===undefined){D=H>400}if(H==500){H=400}for(var I in F){I=parseInt(I,10);if(!E||I<E){E=I}if(!C||I>C){C=I}J.push(I)}if(H<E){H=E}if(H>C){H=C}J.sort(function(L,K){return(D?(L>H&&K>H)?L<K:L>K:(L<H&&K<H)?L>K:L<K)?-1:1});return F[J[0]]}}function r(){function C(E,F){if(E.contains){return E.contains(F)}return E.compareDocumentPosition(F)&16}function A(F){var E=F.relatedTarget;if(!E||C(this,E)){return}B(this)}function D(E){B(this)}function B(E){setTimeout(function(){m.replace(E,d.get(E).options,true)},10)}this.attach=function(E){if(E.onmouseenter===undefined){q(E,"mouseover",A);q(E,"mouseout",A)}else{q(E,"mouseenter",D);q(E,"mouseleave",D)}}}function z(){var C={},A=0;function B(D){return D.cufid||(D.cufid=++A)}this.get=function(D){var E=B(D);return C[E]||(C[E]={})}}function a(A){var C={},B={};this.get=function(D){return C[D]!=undefined?C[D]:A[D]};this.getSize=function(E,D){return B[E]||(B[E]=new n.Size(this.get(E),D))};this.extend=function(D){for(var E in D){C[E]=D[E]}return this}}function q(B,A,C){if(B.addEventListener){B.addEventListener(A,C,false)}else{if(B.attachEvent){B.attachEvent("on"+A,function(){return C.call(B,window.event)})}}}function t(B,A){var C=d.get(B);if(C.options){return B}if(A.hover&&A.hoverables[B.nodeName.toLowerCase()]){b.attach(B)}C.options=A;return B}function k(A){var B={};return function(C){if(!B.hasOwnProperty(C)){B[C]=A.apply(null,arguments)}return B[C]}}function c(F,E){if(!E){E=n.getStyle(F)}var B=n.quotedList(E.get("fontFamily").toLowerCase()),D;for(var C=0,A=B.length;C<A;++C){D=B[C];if(h[D]){return h[D].get(E.get("fontStyle"),E.get("fontWeight"))}}return null}function f(A){return document.getElementsByTagName(A)}function g(){var A={},D;for(var C=0,B=arguments.length;C<B;++C){for(D in arguments[C]){A[D]=arguments[C][D]}}return A}function o(D,L,B,M,E,C){var K=M.separate;if(K=="none"){return y[M.engine].apply(null,arguments)}var J=document.createDocumentFragment(),G;var H=L.split(p[K]),A=(K=="words");if(A&&u){if(/^\s/.test(L)){H.unshift("")}if(/\s$/.test(L)){H.push("")}}for(var I=0,F=H.length;I<F;++I){G=y[M.engine](D,A?n.textAlign(H[I],B,I,F):H[I],B,M,E,C,I<F-1);if(G){J.appendChild(G)}}return J}function l(B,I){var C,A,F,H;for(var D=t(B,I).firstChild;D;D=F){F=D.nextSibling;H=false;if(D.nodeType==1){if(!D.firstChild){continue}if(!/cufon/.test(D.className)){arguments.callee(D,I);continue}else{H=true}}if(!A){A=n.getStyle(B).extend(I)}if(!C){C=c(B,A)}if(!C){continue}if(H){y[I.engine](C,null,A,I,D,B);continue}var G=D.data;if(G===""){continue}var E=o(C,G,A,I,D,B);if(E){D.parentNode.replaceChild(E,D)}else{D.parentNode.removeChild(D)}}}var u=" ".split(/\s+/).length==0;var d=new z();var b=new r();var x=[];var y={},h={},v={enableTextDecoration:false,engine:null,hover:false,hoverables:{a:true},printable:true,selector:(window.Sizzle||(window.jQuery&&function(A){return jQuery(A)})||(window.dojo&&dojo.query)||(window.$$&&function(A){return $$(A)})||(window.$&&function(A){return $(A)})||(document.querySelectorAll&&function(A){return document.querySelectorAll(A)})||f),separate:"words",textShadow:"none"};var p={words:/\s+/,characters:""};m.now=function(){w.ready();return m};m.refresh=function(){var C=x.splice(0,x.length);for(var B=0,A=C.length;B<A;++B){m.replace.apply(null,C[B])}return m};m.registerEngine=function(B,A){if(!A){return m}y[B]=A;return m.set("engine",B)};m.registerFont=function(C){var A=new s(C),B=A.family;if(!h[B]){h[B]=new e()}h[B].add(A);return m.set("fontFamily",'"'+B+'"')};m.replace=function(C,B,A){B=g(v,B);if(!B.engine){return m}if(typeof B.textShadow=="string"&&B.textShadow){B.textShadow=n.textShadow(B.textShadow)}if(!A){x.push(arguments)}if(C.nodeType||typeof C=="string"){C=[C]}n.ready(function(){for(var E=0,D=C.length;E<D;++E){var F=C[E];if(typeof F=="string"){m.replace(B.selector(F),B,true)}else{l(F,B)}}});return m};m.replaceElement=function(B,A){A=g(v,A);if(typeof A.textShadow=="string"&&A.textShadow){A.textShadow=n.textShadow(A.textShadow)}return l(B,A)};m.engines=y;m.fonts=h;m.getOptions=function(){return g(v)};m.set=function(A,B){v[A]=B;return m};return m})();Cufon.registerEngine("canvas",(function(){var b=document.createElement("canvas");if(!b||!b.getContext||!b.getContext.apply){return}b=null;var a=Cufon.CSS.supports("display","inline-block");var e=!a&&(document.compatMode=="BackCompat"||/frameset|transitional/i.test(document.doctype.publicId));var f=document.createElement("style");f.type="text/css";f.appendChild(document.createTextNode(".cufon-canvas{text-indent:0}@media screen,projection{.cufon-canvas{display:inline;display:inline-block;position:relative;vertical-align:middle"+(e?"":";font-size:1px;line-height:1px")+"}.cufon-canvas .cufon-alt{display:-moz-inline-box;display:inline-block;width:0;height:0;overflow:hidden}"+(a?".cufon-canvas canvas{position:relative}":".cufon-canvas canvas{position:absolute}")+"}@media print{.cufon-canvas{padding:0 !important}.cufon-canvas canvas{display:none}.cufon-canvas .cufon-alt{display:inline}}"));document.getElementsByTagName("head")[0].appendChild(f);function d(q,h){var o=0,n=0;var g=[],p=/([mrvxe])([^a-z]*)/g,l;generate:for(var k=0;l=p.exec(q);++k){var m=l[2].split(",");switch(l[1]){case"v":g[k]={m:"bezierCurveTo",a:[o+~~m[0],n+~~m[1],o+~~m[2],n+~~m[3],o+=~~m[4],n+=~~m[5]]};break;case"r":g[k]={m:"lineTo",a:[o+=~~m[0],n+=~~m[1]]};break;case"m":g[k]={m:"moveTo",a:[o=~~m[0],n=~~m[1]]};break;case"x":g[k]={m:"closePath"};break;case"e":break generate}h[g[k].m].apply(h,g[k].a)}return g}function c(n,m){for(var k=0,h=n.length;k<h;++k){var g=n[k];m[g.m].apply(m,g.a)}}return function(Z,D,U,z,I,aa){var n=(D===null);var G=Z.viewBox;var o=U.getSize("fontSize",Z.baseSize);var S=U.get("letterSpacing");S=(S=="normal")?0:o.convertFrom(parseInt(S,10));var H=0,T=0,R=0,B=0;var F=z.textShadow,P=[];if(F){for(var Y=0,V=F.length;Y<V;++Y){var L=F[Y];var O=o.convertFrom(parseFloat(L.offX));var N=o.convertFrom(parseFloat(L.offY));P[Y]=[O,N];if(N<H){H=N}if(O>T){T=O}if(N>R){R=N}if(O<B){B=O}}}var ad=Cufon.CSS.textTransform(n?I.alt:D,U).split("");var h=0,C=null;var w=0,K=1;for(var Y=0,V=ad.length;Y<V;++Y){if(ad[Y]==="\n"){K++;if(h>w){w=h}h=0;continue}var A=Z.glyphs[ad[Y]]||Z.missingGlyph;if(!A){continue}h+=C=Number(A.w||Z.w)+S}h=Math.max(w,h);if(C===null){return null}T+=(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 W=document.createElement("span");W.className="cufon-alt";W.appendChild(document.createTextNode(D));v.appendChild(W)}}var ae=v.style;var M=p.style;var m=o.convert(G.height-H+R);var ac=Math.ceil(m);var Q=ac/m;p.width=Math.ceil(o.convert(h+T-B)*Q);p.height=ac;H+=G.minY;M.top=Math.round(o.convert(H-Z.ascent))+"px";M.left=Math.round(o.convert(B))+"px";var k=Math.ceil(o.convert(h*Q));var t=k+"px";var s=o.convert(Z.height);var E=(z.lineHeight-1)*o.convert(-Z.ascent/5)*(K-1);Cufon.textOptions.width=k;Cufon.textOptions.height=(s*K)+E;Cufon.textOptions.lines=K;if(a){ae.width=t;ae.height=s+"px"}else{ae.paddingLeft=t;ae.paddingBottom=(s-1)+"px"}var ab=Cufon.textOptions.context||p.getContext("2d"),J=ac/G.height;ab.save();ab.scale(J,J);ab.translate(-B-((1/J*p.width)/2)+(Cufon.fonts[Z.family].offsetLeft||0),-H-(Cufon.textOptions.height/J)/2);ab.lineWidth=Z.face["underline-thickness"];ab.save();function q(l,g){ab.strokeStyle=g;ab.beginPath();ab.moveTo(0,l);ab.lineTo(h,l);ab.stroke()}var r=z.enableTextDecoration?Cufon.CSS.textDecoration(aa,U):{},u=z.fontStyle==="italic";ab.fillStyle=Cufon.textOptions.color||U.get("color");function X(){var ag=0;for(var y=0,x=ad.length;y<x;++y){if(ad[y]==="\n"){ab.translate(-ag,-Z.ascent-((Z.ascent/5)*z.lineHeight));ag=0;continue}var af=Z.glyphs[ad[y]]||Z.missingGlyph;if(!af){continue}var g=Number(af.w||Z.w)+S;if(r){ab.save();ab.strokeStyle=ab.fillStyle;ab.beginPath();if(r.underline){ab.moveTo(0,-Z.face["underline-position"]);ab.lineTo(g,-Z.face["underline-position"])}if(r.overline){ab.moveTo(0,Z.ascent);ab.lineTo(g,Z.ascent)}if(r["line-through"]){ab.moveTo(0,-Z.descent);ab.lineTo(g,-Z.descent)}ab.stroke();ab.restore()}if(u){ab.save();ab.transform(1,0,-0.25,1,0,0)}ab.beginPath();if(af.d){if(af.code){c(af.code,ab)}else{af.code=d("m"+af.d,ab)}}ab.fill();if(z.strokeStyle){ab.closePath();ab.save();ab.lineWidth=z.strokeWidth;ab.strokeStyle=z.strokeStyle;ab.stroke();ab.restore()}if(u){ab.restore()}ab.translate(g,0);ag+=g}}if(F){for(var Y=0,V=F.length;Y<V;++Y){var L=F[Y];ab.save();ab.fillStyle=L.color;ab.translate.apply(ab,P[Y]);X();ab.restore()}}ab.save();X();ab.restore();ab.restore();ab.restore();return v}})());Cufon.registerEngine("vml",(function(){if(!document.namespaces){return}var d=document.createElement("canvas");if(d&&d.getContext&&d.getContext.apply){return}if(document.namespaces.cvml==null){document.namespaces.add("cvml","urn:schemas-microsoft-com:vml")}var b=document.createElement("cvml:shape");b.style.behavior="url(#default#VML)";if(!b.coordsize){return}b=null;document.write('<style type="text/css">.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}}</style>');function c(e,f){return a(e,/(?:em|ex|%)$/i.test(f)?"1em":f)}function a(h,k){if(/px$/i.test(k)){return parseFloat(k)}var g=h.style.left,f=h.runtimeStyle.left;h.runtimeStyle.left=h.currentStyle.left;h.style.left=k;var e=h.style.pixelLeft;h.style.left=g;h.runtimeStyle.left=f;return e}return function(U,A,P,x,E,V,N){var h=(A===null);if(h){A=E.alt}var C=U.viewBox;var m=P.computedFontSize||(P.computedFontSize=new Cufon.CSS.Size(c(V,P.get("fontSize"))+"px",U.baseSize));var M=P.computedLSpacing;if(M==undefined){M=P.get("letterSpacing");P.computedLSpacing=M=(M=="normal")?0:~~m.convertFrom(a(V,M))}var u,n;if(h){u=E;n=E.firstChild}else{u=document.createElement("span");u.className="cufon cufon-vml";u.alt=A;n=document.createElement("span");n.className="cufon-vml-canvas";u.appendChild(n);if(x.printable){var S=document.createElement("span");S.className="cufon-alt";S.appendChild(document.createTextNode(A));u.appendChild(S)}if(!N){u.appendChild(document.createElement("cvml:shape"))}}var aa=u.style;var H=n.style;var f=m.convert(C.height),X=Math.ceil(f);var L=X/f;var K=C.minX,J=C.minY;H.height=X;H.top=Math.round(m.convert(J-U.ascent));H.left=Math.round(m.convert(K));aa.height=m.convert(U.height)+"px";var q=x.enableTextDecoration?Cufon.CSS.textDecoration(V,P):{};var z=P.get("color");var Y=Cufon.CSS.textTransform(A,P).split("");var e=0,I=0,r=null;var y,s,B=x.textShadow;for(var T=0,R=0,Q=Y.length;T<Q;++T){y=U.glyphs[Y[T]]||U.missingGlyph;if(y){e+=r=~~(y.w||U.w)+M}}if(r===null){return null}var t=-K+e+(C.width-r);var Z=m.convert(t*L),O=Math.round(Z);var G=t+","+C.height,g;var D="r"+G+"nsnf";for(T=0;T<Q;++T){y=U.glyphs[Y[T]]||U.missingGlyph;if(!y){continue}if(h){s=n.childNodes[R];if(s.firstChild){s.removeChild(s.firstChild)}}else{s=document.createElement("cvml:shape");n.appendChild(s)}s.stroked="f";s.coordsize=G;s.coordorigin=g=(K-I)+","+J;s.path=(y.d?"m"+y.d+"xe":"")+"m"+g+D;s.fillcolor=z;var W=s.style;W.width=O;W.height=X;if(B){var p=B[0],o=B[1];var w=Cufon.CSS.color(p.color),v;var F=document.createElement("cvml:shadow");F.on="t";F.color=w.color;F.offset=p.offX+","+p.offY;if(o){v=Cufon.CSS.color(o.color);F.type="double";F.color2=v.color;F.offset2=o.offX+","+o.offY}F.opacity=w.opacity||(v&&v.opacity)||1;s.appendChild(F)}I+=~~(y.w||U.w)+M;++R}aa.width=Math.max(Math.ceil(m.convert(e*L)),0);return u}})());(function(p){var k=p.fabric||(p.fabric={}),m=Array.prototype.slice,l=Function.prototype.apply;k.util={};(function(){function C(F,E){var D=F.indexOf(E);if(D!==-1){F.splice(D,1)}return F}function A(E,D){return Math.floor(Math.random()*(D-E+1))+E}var y=Math.PI/180;function z(D){return D*y}function x(E,D){return parseFloat(Number(E).toFixed(D))}function B(){return false}k.util.removeFromArray=C;k.util.degreesToRadians=z;k.util.toFixed=x;k.util.getRandomInt=A;k.util.falseFunction=B})();if(!Array.prototype.indexOf){Array.prototype.indexOf=function(y,z){var x=this.length>>>0;z=Number(z)||0;z=Math[z<0?"ceil":"floor"](z);if(z<0){z+=x}for(;z<x;z++){if(z in this&&this[z]===y){return z}}return -1}}if(!Array.prototype.forEach){Array.prototype.forEach=function(A,z){for(var y=0,x=this.length>>>0;y<x;y++){if(y in this){A.call(z,this[y],y,this)}}}}if(!Array.prototype.map){Array.prototype.map=function(B,A){var y=[];for(var z=0,x=this.length>>>0;z<x;z++){if(z in this){y[z]=B.call(A,this[z],z,this)}}return y}}if(!Array.prototype.every){Array.prototype.every=function(A,z){for(var y=0,x=this.length>>>0;y<x;y++){if(y in this&&!A.call(z,this[y],y,this)){return false}}return true}}if(!Array.prototype.some){Array.prototype.some=function(A,z){for(var y=0,x=this.length>>>0;y<x;y++){if(y in this&&A.call(z,this[y],y,this)){return true}}return false}}if(!Array.prototype.filter){Array.prototype.filter=function(B,A){var y=[],C;for(var z=0,x=this.length>>>0;z<x;z++){if(z in this){C=this[z];if(B.call(A,C,z,this)){y.push(C)}}}return y}}if(!Array.prototype.reduce){Array.prototype.reduce=function(z){var x=this.length>>>0,y=0,A;if(arguments.length>1){A=arguments[1]}else{do{if(y in this){A=this[y++];break}if(++y>=x){throw new TypeError()}}while(true)}for(;y<x;y++){if(y in this){A=z.call(null,A,this[y],y,this)}}return A}}function w(C,B){var z=m.call(arguments,2),y=[];for(var A=0,x=C.length;A<x;A++){y[A]=z.length?C[A][B].apply(C[A],z):C[A][B].call(C[A])}return y}function r(A,z){var y=A.length-1,x=z?A[y][z]:A[y];if(z){while(y--){if(A[y][z]>=x){x=A[y][z]}}}else{while(y--){if(A[y]>=x){x=A[y]}}}return x}function o(A,z){var y=A.length-1,x=z?A[y][z]:A[y];if(z){while(y--){if(A[y][z]<x){x=A[y][z]}}}else{while(y--){if(A[y]<x){x=A[y]}}}return x}k.util.array={invoke:w,min:o,max:r};function t(x,z){for(var y in z){x[y]=z[y]}return x}function u(x){return t({},x)}k.util.object={extend:t,clone:u};if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")}}function v(x){return x.replace(/-+(.)?/g,function(y,z){return z?z.toUpperCase():""})}function f(x){return x.charAt(0).toUpperCase()+x.slice(1).toLowerCase()}k.util.string={camelize:v,capitalize:f};if(!Function.prototype.bind){Function.prototype.bind=function(x){var z=this,y=m.call(arguments,1);return y.length?function(){return l.call(z,x,y.concat(m.call(arguments)))}:function(){return l.call(z,x,arguments)}}}(function(){var z=(function(){for(var B in {toString:1}){if(B==="toString"){return false}}return true})();var y;if(z){y=function(B,D){if(D.toString!==Object.prototype.toString){B.prototype.toString=D.toString}if(D.valueOf!==Object.prototype.valueOf){B.prototype.valueOf=D.valueOf}for(var C in D){B.prototype[C]=D[C]}}}else{y=function(B,D){for(var C in D){B.prototype[C]=D[C]}}}function x(){}function A(){var E=null,D=m.call(arguments,0);if(typeof D[0]==="function"){E=D.shift()}function B(){this.initialize.apply(this,arguments)}B.superclass=E;B.subclasses=[];if(E){x.prototype=E.prototype;B.prototype=new x;E.subclasses.push(B)}for(var C=0,F=D.length;C<F;C++){y(B,D[C])}if(!B.prototype.initialize){B.prototype.initialize=emptyFunction}B.prototype.constructor=B;return B}k.util.createClass=A})();(function(P){function L(T){var W=Array.prototype.slice.call(arguments,1),V,U,S=W.length;for(U=0;U<S;U++){V=typeof T[W[U]];if(!(/^(?:function|object|unknown)$/).test(V)){return false}}return true}var I=(function(){if(typeof document.documentElement.uniqueID!=="undefined"){return function(T){return T.uniqueID}}var S=0;return function(T){return T.__uniqueID||(T.__uniqueID="uniqueID__"+S++)}})();var F,Q;(function(){var S={};F=function(T){return S[T]};Q=function(U,T){S[U]=T}})();function D(S,T){return{handler:T,wrappedHandler:K(S,T)}}function K(S,T){return function(U){T.call(F(S),U||window.event)}}function E(T,S){return function(X){if(N[T]&&N[T][S]){var V=N[T][S];for(var W=0,U=V.length;W<U;W++){V[W].call(this,X||window.event)}}}}var O=(L(document.documentElement,"addEventListener","removeEventListener")&&L(window,"addEventListener","removeEventListener")),G=(L(document.documentElement,"attachEvent","detachEvent")&&L(window,"attachEvent","detachEvent")),M={},N={},J,B;if(O){J=function(T,S,U){T.addEventListener(S,U,false)};B=function(T,S,U){T.removeEventListener(S,U,false)}}else{if(G){J=function(U,S,V){var T=I(U);Q(T,U);if(!M[T]){M[T]={}}if(!M[T][S]){M[T][S]=[]}var W=D(T,V);M[T][S].push(W);U.attachEvent("on"+S,W.wrappedHandler)};B=function(W,T,X){var V=I(W),Y;if(M[V]&&M[V][T]){for(var U=0,S=M[V][T].length;U<S;U++){Y=M[V][T][U];if(Y&&Y.handler===X){W.detachEvent("on"+T,Y.wrappedHandler);M[V][T][U]=null}}}}}else{J=function(U,S,V){var T=I(U);if(!N[T]){N[T]={}}if(!N[T][S]){N[T][S]=[];var W=U["on"+S];if(W){N[T][S].push(W)}U["on"+S]=E(T,S)}N[T][S].push(V)};B=function(X,U,Y){var W=I(X);if(N[W]&&N[W][U]){var T=N[W][U];for(var V=0,S=T.length;V<S;V++){if(T[V]===Y){T.splice(V,1)}}}}}}k.util.addListener=J;k.util.removeListener=B;var z={};function C(S,T){if(!z[S]){z[S]=[]}z[S].push(T)}function A(S,T){if(z[S]){k.util.removeFromArray(z[S],T)}}function R(V,U){var T=z[V];if(!T){return}for(var W=0,S=T.length;W<S;W++){T[W]({memo:U})}}function H(S){return{x:y(S),y:x(S)}}function y(U){var T=document.documentElement,S=document.body||{scrollLeft:0};return U.pageX||((typeof U.clientX!="unknown"?U.clientX:0)+(T.scrollLeft||S.scrollLeft)-(T.clientLeft||0))}function x(U){var T=document.documentElement,S=document.body||{scrollTop:0};return U.pageY||((typeof U.clientY!="unknown"?U.clientY:0)+(T.scrollTop||S.scrollTop)-(T.clientTop||0))}k.util.getPointer=H;k.util.observeEvent=C;k.util.stopObservingEvent=A;k.util.fireEvent=R})(this);(function(){function B(G,I){var K=G.style,F;if(typeof I==="string"){G.style.cssText+=";"+I;return I.indexOf("opacity")>-1?z(G,I.match(/opacity:\s*(\d?\.?\d*)/)[1]):G}for(var J in I){if(J==="opacity"){z(G,I[J])}else{var H=(J==="float"||J==="cssFloat")?(typeof K.styleFloat==="undefined"?"cssFloat":"styleFloat"):J;K[H]=I[J]}}return G}var E=document.createElement("div"),D=typeof E.style.opacity==="string",y=typeof E.style.filter==="string",x=document.defaultView,C=x&&typeof x.getComputedStyle!=="undefined",A=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,z=function(F){return F};if(D){z=function(F,G){F.style.opacity=G;return F}}else{if(y){z=function(F,G){var H=F.style;if(F.currentStyle&&!F.currentStyle.hasLayout){H.zoom=1}if(A.test(H.filter)){G=G>=0.9999?"":("alpha(opacity="+(G*100)+")");H.filter=H.filter.replace(A,G)}else{H.filter+=" alpha(opacity="+(G*100)+")"}return F}}}k.util.setStyle=B})();var d=Array.prototype.slice;function s(x){return typeof x==="string"?document.getElementById(x):x}function q(x){return d.call(x,0)}try{var h=q(document.childNodes) instanceof Array}catch(e){}if(!h){q=function(y){var x=new Array(y.length),z=y.length;while(z--){x[z]=y[z]}return x}}function b(y,x){var z=document.createElement(y);for(var A in x){if(A==="class"){z.className=x[A]}else{if(A==="for"){z.htmlFor=x[A]}else{z.setAttribute(A,x[A])}}}return z}function g(x,y){if((" "+x.className+" ").indexOf(" "+y+" ")===-1){x.className+=(x.className?" ":"")+y}}function a(y,z,x){if(typeof z==="string"){z=b(z,x)}if(y.parentNode){y.parentNode.replaceChild(z,y)}z.appendChild(y);return z}function n(y){var x=0,z=0;do{x+=y.offsetTop||0;z+=y.offsetLeft||0;y=y.offsetParent}while(y);return({left:z,top:x})}(function(){var x=document.documentElement.style;var y="userSelect" in x?"userSelect":"MozUserSelect" in x?"MozUserSelect":"WebkitUserSelect" in x?"WebkitUserSelect":"KhtmlUserSelect" in x?"KhtmlUserSelect":"";function z(A){if(typeof A.onselectstart!=="undefined"){A.onselectstart=k.util.falseFunction}if(y){A.style[y]="none"}else{if(typeof A.unselectable=="string"){A.unselectable="on"}}return A}k.util.makeElementUnselectable=z})();(function(){function x(A,E){var C=document.getElementsByTagName("head")[0],B=document.createElement("script"),D=true;B.type="text/javascript";B.setAttribute("runat","server");B.onload=B.onreadystatechange=function(F){if(D){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete"){return}D=false;E(F||window.event);B=B.onload=B.onreadystatechange=null}};B.src=A;C.appendChild(B)}function z(A,B){y.load(A);B()}k.util.getScript=x;var y=p.Jaxer;if(y&&y.load){k.util.getScript=z}})();function c(J){J||(J={});var y=+new Date(),C=J.duration||500,I=y+C,B,H,E=J.onChange||function(){},D=J.abort||function(){return false},F=J.easing||function(K){return(-Math.cos(K*Math.PI)/2)+0.5},x="startValue" in J?J.startValue:0,G="endValue" in J?J.endValue:100,A=x>G;J.onStart&&J.onStart();var z=setInterval(function(){B=+new Date();H=B>I?1:(B-y)/C;E(A?(x-(x-G)*F(H)):(x+(G-x)*F(H)));if(B>I||D()){clearInterval(z);J.onComplete&&J.onComplete()}},10);return z}k.util.getById=s;k.util.toArray=q;k.util.makeElement=b;k.util.addClass=g;k.util.wrapElement=a;k.util.getElementOffset=n;k.util.animate=c;(function(){function A(B,C){return B+(/\?/.test(B)?"&":"?")+C}var z=(function(){var E=[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 B=E.length;B--;){try{var D=E[B]();if(D){return E[B]}}catch(C){}}})();function x(){}function y(D,C){C||(C={});var G=C.method?C.method.toUpperCase():"GET",F=C.onComplete||function(){},E=z(),B;E.onreadystatechange=function(){if(E.readyState===4){F(E);E.onreadystatechange=x}};if(G==="GET"){B=null;if(typeof C.parameters=="string"){D=A(D,C.parameters)}}E.open(G,D,true);if(G==="POST"||G==="PUT"){E.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}E.send(B);return E}k.util.request=y})()})(this);(function(b){var c=b.fabric||(b.fabric={}),h=c.util.object.extend,f=c.util.string.capitalize,k=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 o(s,r){if(!s){return}var u,q,p={};if(s.parentNode&&/^g$/i.test(s.parentNode.nodeName)){p=c.parseAttributes(s.parentNode,r)}var t=r.reduce(function(w,v){u=s.getAttribute(v);q=parseFloat(u);if(u){if((v==="fill"||v==="stroke")&&u==="none"){u=""}if(v==="fill-rule"){u=(u==="evenodd")?"destination-over":u}if(v==="transform"){u=c.parseTransformAttribute(u)}if(v in d){v=d[v]}w[v]=isNaN(q)?u:q}return w},{});t=h(t,h(a(s),c.parseStyleAttribute(s)));return h(p,t)}c.parseTransformAttribute=(function(){function p(I,J){var K=J[0];I[0]=Math.cos(K);I[1]=Math.sin(K);I[2]=-Math.sin(K);I[3]=Math.cos(K)}function u(K,L){var J=L[0],I=(L.length===2)?L[1]:L[0];K[0]=J;K[3]=I}function F(I,J){I[2]=J[0]}function r(I,J){I[1]=J[0]}function C(I,J){I[4]=J[0];if(J.length===2){I[5]=J[1]}}var w=[1,0,0,1,0,0],q="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",G="(?:\\s+,?\\s*|,\\s*)",x="(?:(skewX)\\s*\\(\\s*("+q+")\\s*\\))",v="(?:(skewY)\\s*\\(\\s*("+q+")\\s*\\))",E="(?:(rotate)\\s*\\(\\s*("+q+")(?:"+G+"("+q+")"+G+"("+q+"))?\\s*\\))",H="(?:(scale)\\s*\\(\\s*("+q+")(?:"+G+"("+q+"))?\\s*\\))",A="(?:(translate)\\s*\\(\\s*("+q+")(?:"+G+"("+q+"))?\\s*\\))",D="(?:(matrix)\\s*\\(\\s*("+q+")"+G+"("+q+")"+G+"("+q+")"+G+"("+q+")"+G+"("+q+")"+G+"("+q+")\\s*\\))",B="(?:"+D+"|"+A+"|"+H+"|"+E+"|"+x+"|"+v+")",y="(?:"+B+"(?:"+G+B+")*)",s="^\\s*(?:"+y+"?)\\s*$",z=new RegExp(s),t=new RegExp(B);return function(J){var I=w.concat();if(!J||(J&&!z.test(J))){return I}J.replace(t,function(N){var K=new RegExp(B).exec(N).filter(function(O){return(O!==""&&O!=null)}),L=K[1],M=K.slice(2).map(parseFloat);switch(L){case"translate":C(I,M);break;case"rotate":p(I,M);break;case"scale":u(I,M);break;case"skewX":F(I,M);break;case"skewY":r(I,M);break;case"matrix":I=M;break}});return I}})();function l(s){if(!s){return null}s=s.trim();var u=s.indexOf(",")>-1;s=s.split(/\s+/);var q=[];if(u){for(var r=0,p=s.length;r<p;r++){var t=s[r].split(",");q.push({x:parseFloat(t[0]),y:parseFloat(t[1])})}}else{for(var r=0,p=s.length;r<p;r+=2){q.push({x:parseFloat(s[r]),y:parseFloat(s[r+1])})}}if(q.length%2!==0){}return q}function g(q){var p={},r=q.getAttribute("style");if(r){if(typeof r=="string"){r=r.replace(/;$/,"").split(";");p=r.reduce(function(u,x){var t=x.split(":"),v=t[0].trim(),w=t[1].trim();u[v]=w;return u},{})}else{for(var s in r){if(typeof r[s]!=="undefined"){p[s]=r[s]}}}}return p}function n(u){var q=c.Element.activeInstance,p=q?q.getContext():null;if(!p){return}for(var r=u.length;r--;){var s=u[r].get("fill");if(/^url\(/.test(s)){var t=s.slice(5,s.length-1);if(c.gradientDefs[t]){u[r].set("fill",c.Gradient.fromElement(c.gradientDefs[t],p,u[r]))}}}}function e(q,y,z){var p=Array(q.length),t=q.length;function r(){if(--t===0){p=p.filter(function(A){return A!=null});n(p);y(p)}}for(var v=0,s,u=q.length;v<u;v++){s=q[v];var x=c[f(s.tagName)];if(x&&x.fromElement){try{if(x.fromElement.async){x.fromElement(s,(function(A){return function(B){p.splice(A,0,B);r()}})(v),z)}else{p.splice(v,0,x.fromElement(s,z));r()}}catch(w){c.log(w.message||w)}}else{r()}}}function m(u){var s=u.getElementsByTagName("style"),q={},v;for(var r=0,p=s.length;r<p;r++){var t=s[0].textContent;t=t.replace(/\/\*[\s\S]*?\*\//g,"");v=t.match(/[^{]*\{[\s\S]*?\}/g);v=v.map(function(w){return w.trim()});v.forEach(function(B){var z=B.match(/([\s\S]*?)\s*\{([^}]*)\}/),B=z[1],w=z[2].trim(),D=w.replace(/;$/,"").split(/\s*;\s*/);if(!q[B]){q[B]={}}for(var y=0,A=D.length;y<A;y++){var x=D[y].split(/\s*:\s*/),E=x[0],C=x[1];q[B][E]=C}})}return q}function a(q){var w=q.nodeName,r=q.getAttribute("class"),v=q.getAttribute("id"),s={};for(var u in c.cssRules){var p=(r&&new RegExp("^\\."+r).test(u))||(v&&new RegExp("^#"+v).test(u))||(new RegExp("^"+w).test(u));if(p){for(var t in c.cssRules[u]){s[t]=c.cssRules[u][t]}}}return s}c.parseSVGDocument=(function(){var p=/^(path|circle|polygon|polyline|ellipse|rect|line|image)$/;var q="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)";var r=new RegExp("^\\s*("+q+"+)\\s*,?\\s*("+q+"+)\\s*,?\\s*("+q+"+)\\s*,?\\s*("+q+"+)\\s*$");function s(t,u){while(t&&(t=t.parentNode)){if(u.test(t.nodeName)){return true}}return false}return function(C,E){if(!C){return}var w=new Date(),B=c.util.toArray(C.getElementsByTagName("*"));var t=B.filter(function(G){return p.test(G.tagName)&&!s(G,/^(?:pattern|defs)$/)});if(!t||(t&&!t.length)){return}var u=C.getAttribute("viewBox"),z=C.getAttribute("width"),x=C.getAttribute("height"),v=null,D=null,A,y;if(u&&(u=u.match(r))){A=parseInt(u[1],10);y=parseInt(u[2],10);v=parseInt(u[3],10);D=parseInt(u[4],10)}v=z?parseFloat(z):v;D=x?parseFloat(x):D;var F={width:v,height:D};c.gradientDefs=c.getGradientDefs(C);c.cssRules=m(C);c.parseElements(t,function(G){c.documentParsingTime=new Date()-w;if(E){E(G,F)}},k(F))}})();h(c,{parseAttributes:o,parseElements:e,parseStyleAttribute:g,parsePointsAttribute:l,getCSSRules:m})})(this);(function(){function c(h){var g=h.getAttribute("style");if(g){var l=g.split(/\s*;\s*/);for(var f=l.length;f--;){var e=l[f].split(/\s*:\s*/),d=e[0].trim(),k=e[1].trim();if(d==="stop-color"){return k}}}}fabric.Gradient={create:function(n,o){o||(o={});var f=o.x1||0,m=o.y1||0,e=o.x2||n.canvas.width,k=o.y2||0,g=o.colorStops;var l=n.createLinearGradient(f,m,e,k);for(var h in g){var d=g[h];l.addColorStop(parseFloat(h),d)}return l},fromElement:function(d,n,m){var l=d.getElementsByTagName("stop"),d,f,e={},g;for(var h=l.length;h--;){d=l[h];f=parseInt(d.getAttribute("offset"),10)/100;e[f]=c(d)||d.getAttribute("stop-color")}var k={x1:d.getAttribute("x1")||0,y1:d.getAttribute("y1")||0,x2:d.getAttribute("x2")||"100%",y2:d.getAttribute("y2")||0};a(m,k);return fabric.Gradient.create(n,{x1:k.x1,y1:k.y1,x2:k.x2,y2:k.y2,colorStops:e})},forObject:function(g,d,e){e||(e={});a(g,e);var f=fabric.Gradient.create(d,{x1:e.x1-(g.width/2),y1:e.y1-(g.height/2),x2:e.x2-(g.width/2),y2:e.y2-(g.height/2),colorStops:e.colorStops});return f}};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(k){var f=k.getElementsByTagName("linearGradient"),d=k.getElementsByTagName("radialGradient"),g,h={};for(var e=f.length;e--;){g=f[e];h[g.id]=g}for(var e=d.length;e--;){g=d[e];h[g.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.x<d.x&&this.y<d.y)},lte:function(d){return(this.x<=d.x&&this.y<=d.y)},gt:function(d){return(this.x>d.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,n,m){var o,k=(m.x-n.x)*(h.y-n.y)-(m.y-n.y)*(h.x-n.x),l=(f.x-h.x)*(h.y-n.y)-(f.y-h.y)*(h.x-n.x),g=(m.y-n.y)*(f.x-h.x)-(m.x-n.x)*(f.y-h.y);if(g!=0){var e=k/g,d=l/g;if(0<=e&&e<=1&&0<=d&&d<=1){o=new c("Intersection");o.points.push(new b.Point(h.x+e*(f.x-h.x),h.y+e*(f.y-h.y)))}else{o=new c("No Intersection")}}else{if(k==0||l==0){o=new c("Coincident")}else{o=new c("Parallel")}}return o};b.Intersection.intersectLinePolygon=function(e,d,m){var n=new c("No Intersection"),f=m.length;for(var h=0;h<f;h++){var l=m[h],k=m[(h+1)%f],g=c.intersectLineLine(e,d,l,k);n.appendPoints(g.points)}if(n.points.length>0){n.status="Intersection"}return n};b.Intersection.intersectPolygonPolygon=function(k,h){var f=new c("No Intersection"),m=k.length;for(var l=0;l<m;l++){var g=k[l],e=k[(l+1)%m],d=c.intersectLinePolygon(g,e,h);f.appendPoints(d.points)}if(f.points.length>0){f.status="Intersection"}return f};b.Intersection.intersectPolygonRectangle=function(p,e,d){var g=e.min(d),o=e.max(d),f=new b.Point(o.x,g.y),n=new b.Point(g.x,o.y),m=c.intersectLinePolygon(g,f,p),l=c.intersectLinePolygon(f,o,p),k=c.intersectLinePolygon(o,n,p),h=c.intersectLinePolygon(n,g,p),q=new c("No Intersection");q.appendPoints(m.points);q.appendPoints(l.points);q.appendPoints(k.points);q.appendPoints(h.points);if(q.points.length>0){q.status="Intersection"}return q}})(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)<Number(d))?0:255;this.setSource([f,f,f,e]);return this},overlayWith:function(l){if(!(l instanceof c)){l=new c(l)}var d=[],k=this.getAlpha(),g=0.5,h=this.getSource(),e=l.getSource();for(var f=0;f<3;f++){d.push(Math.round((h[f]*(1-g))+(e[f]*g)))}d[4]=k;this.setSource(d);return this}};b.Color.reRGBa=/^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;b.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;b.Color.fromRgb=function(d){return c.fromSource(c.sourceFromRgb(d))};b.Color.sourceFromRgb=function(d){var e=d.match(c.reRGBa);if(e){return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),e[4]?parseFloat(e[4]):1]}};b.Color.fromRgba=c.fromRgb;b.Color.fromHex=function(d){return c.fromSource(c.sourceFromHex(d))};b.Color.sourceFromHex=function(f){if(f.match(c.reHex)){var l=f.slice(f.indexOf("#")+1),e=(l.length===3),k=e?(l.charAt(0)+l.charAt(0)):l.substring(0,2),h=e?(l.charAt(1)+l.charAt(1)):l.substring(2,4),d=e?(l.charAt(2)+l.charAt(2)):l.substring(4,6);return[parseInt(k,16),parseInt(h,16),parseInt(d,16),1]}};b.Color.fromSource=function(d){var e=new c();e.setSource(d);return e}})(this);(function(t){if(fabric.Element){fabric.warn("fabric.Element is already defined.");return}var g=t.window,p=g.document,v=fabric.util.object.extend,k=fabric.util.string.capitalize,w=fabric.util.string.camelize,A=fabric.util.fireEvent,f=fabric.util.getPointer,s=fabric.util.getElementOffset,m=fabric.util.removeFromArray,l=fabric.util.addListener,e=fabric.util.removeListener,o=fabric.util.array.min,q=fabric.util.array.max,y=Math.sqrt,c=Math.pow,b=Math.atan2,n=Math.abs,r=Math.min,u=Math.max,h=new Error("Could not initialize `canvas` element"),a=500,d=0.5,x="decel",z={tr:"ne-resize",br:"se-resize",bl:"sw-resize",tl:"nw-resize",ml:"w-resize",mt:"n-resize",mr:"e-resize",mb:"s-resize"};fabric.Element=function(C,B){B||(B={});this._groupSelector=null;this._objects=[];this._context=null;this._currentTransform=null;this._activeGroup=null;this._freeDrawingXPoints=[];this._freeDrawingYPoints=[];this._createUpperCanvas(C);this._initOptions(B);this._initWrapperElement();this._createLowerCanvas();this._initEvents();if(B.overlayImage){this.setOverlayImage(B.overlayImage)}this.calcOffset();fabric.Element.activeInstance=this};v(fabric.Element.prototype,{backgroundColor:"rgba(0, 0, 0, 0)",selectionColor:"rgba(100, 100, 255, 0.3)",selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,freeDrawingColor:"rgb(0, 0, 0)",freeDrawingLineWidth:1,includeDefaultValues:true,shouldCacheImages:false,stateful:true,renderOnAddition:true,CANVAS_WIDTH:600,CANVAS_HEIGHT:600,CONTAINER_CLASS:"canvas-container",onBeforeScaleRotate:function(B){},onFpsUpdate:null,calcOffset:function(){this._offset=s(this.upperCanvasEl);return this},setOverlayImage:function(C,E){if(C){var D=this,B=new Image();B.onload=function(){D.overlayImage=B;if(E){E()}B=B.onload=null};B.src=C}return this},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.upperCanvasEl,"div",{"class":this.CONTAINER_CLASS});fabric.util.setStyle(this.wrapperEl,{width:this.getWidth()+"px",height:this.getHeight()+"px",position:"relative"});fabric.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(C){var D=this.getWidth()||C.width,B=this.getHeight()||C.height;fabric.util.setStyle(C,{position:"absolute",width:D+"px",height:B+"px",left:0,top:0});C.width=D;C.height=B;fabric.util.makeElementUnselectable(C)},_createCanvasElement:function(){var B=p.createElement("canvas");if(!B){throw h}this._initCanvasElement(B);return B},_initCanvasElement:function(B){if(typeof B.getContext==="undefined"&&typeof G_vmlCanvasManager!=="undefined"&&G_vmlCanvasManager.initElement){G_vmlCanvasManager.initElement(B)}if(typeof B.getContext==="undefined"){throw h}},_initOptions:function(B){for(var C in B){this[C]=B[C]}this.width=parseInt(this.upperCanvasEl.width,10)||0;this.height=parseInt(this.upperCanvasEl.height,10)||0;this.upperCanvasEl.style.width=this.width+"px";this.upperCanvasEl.style.height=this.height+"px"},_initEvents:function(){var B=this;this._onMouseDown=function(C){B.__onMouseDown(C)};this._onMouseUp=function(C){B.__onMouseUp(C)};this._onMouseMove=function(C){B.__onMouseMove(C)};this._onResize=function(C){B.calcOffset()};l(this.upperCanvasEl,"mousedown",this._onMouseDown);l(p,"mousemove",this._onMouseMove);l(p,"mouseup",this._onMouseUp);l(g,"resize",this._onResize)},_createUpperCanvas:function(B){this.upperCanvasEl=fabric.util.getById(B)||this._createCanvasElement();this._initCanvasElement(this.upperCanvasEl);fabric.util.addClass(this.upperCanvasEl,"upper-canvas");this._applyCanvasStyle(this.upperCanvasEl);this.contextTop=this.upperCanvasEl.getContext("2d")},_createLowerCanvas:function(){this.lowerCanvasEl=this._createCanvasElement();this.lowerCanvasEl.className="lower-canvas";this.wrapperEl.insertBefore(this.lowerCanvasEl,this.upperCanvasEl);this._applyCanvasStyle(this.lowerCanvasEl);this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(B){return this._setDimension("width",B)},setHeight:function(B){return this._setDimension("height",B)},setDimensions:function(B){for(var C in B){this._setDimension(C,B[C])}return this},_setDimension:function(C,B){this.lowerCanvasEl[C]=B;this.lowerCanvasEl.style[C]=B+"px";this.upperCanvasEl[C]=B;this.upperCanvasEl.style[C]=B+"px";this.wrapperEl.style[C]=B+"px";this[C]=B;this.calcOffset();this.renderAll();return this},__onMouseUp:function(F){if(this.isDrawingMode&&this._isCurrentlyDrawing){this._finalizeDrawingPath();return}if(this._currentTransform){var B=this._currentTransform,E=B.target;if(E._scaling){A("object:scaled",{target:E});E._scaling=false}var C=this._objects.length;while(C--){this._objects[C].setCoords()}if(this.stateful&&E.hasStateChanged()){E.isMoving=false;A("object:modified",{target:E})}}this._currentTransform=null;if(this._groupSelector){this._findSelectedObjects(F)}var D=this.getActiveGroup();if(D){if(this.stateful&&D.hasStateChanged()&&D.containsPoint(this.getPointer(F))){A("group:modified",{target:D})}D.setObjectsCoords();D.set("isMoving",false);this._setCursor("default")}this._groupSelector=null;this.renderAll();this._setCursorFromEvent(F,E);this._setCursor("");var G=this;setTimeout(function(){G._setCursorFromEvent(F,E)},50);A("mouse:up")},_shouldClearSelection:function(D){var C=this.findTarget(D),B=this.getActiveGroup();return(!C||(C&&B&&!B.contains(C)&&B!==C&&!D.shiftKey))},__onMouseDown:function(F){if(this.isDrawingMode){this._prepareForDrawing(F);this._captureDrawingPath(F);return}if(this._currentTransform){return}var E=this.findTarget(F),G=this.getPointer(F),C=this.getActiveGroup(),D;if(this._shouldClearSelection(F)){this._groupSelector={ex:G.x,ey:G.y,top:0,left:0};this.deactivateAllWithDispatch()}else{this.stateful&&E.saveState();if(D=E._findTargetCorner(F,this._offset)){this.onBeforeScaleRotate(E)}this._setupCurrentTransform(F,E);var B=F.shiftKey&&(C||this.getActiveObject());if(B){this._handleGroupLogic(F,E)}else{if(E!==this.getActiveGroup()){this.deactivateAll()}this.setActiveObject(E)}}this.renderAll()},getElement:function(){return this.upperCanvasEl},deactivateAllWithDispatch:function(){var B=this.getActiveGroup();if(B){A("before:group:destroyed",{target:B})}this.deactivateAll();if(B){A("after:group:destroyed")}A("selection:cleared");return this},_setupCurrentTransform:function(E,D){var C="drag",B,F=f(E);if(B=D._findTargetCorner(E,this._offset)){C=(B==="ml"||B==="mr")?"scaleX":(B==="mt"||B==="mb")?"scaleY":"rotate"}this._currentTransform={target:D,action:C,scaleX:D.scaleX,scaleY:D.scaleY,offsetX:F.x-D.left,offsetY:F.y-D.top,ex:F.x,ey:F.y,left:D.left,top:D.top,theta:D.theta,width:D.width*D.scaleX};this._currentTransform.original={left:D.left,top:D.top}},_handleGroupLogic:function(E,D){if(D.isType("group")){D=this.findTarget(E,true);if(!D||D.isType("group")){return}}var B=this.getActiveGroup();if(B){if(B.contains(D)){B.remove(D);D.setActive(false);if(B.size()===1){this.removeActiveGroup()}}else{B.add(D)}A("group:selected",{target:B});B.setActive(true)}else{if(this._activeObject){if(D!==this._activeObject){var C=new fabric.Group([this._activeObject,D]);this.setActiveGroup(C);B=this.getActiveGroup()}}D.setActive(true)}if(B){B.saveCoords()}},_prepareForDrawing:function(B){this._isCurrentlyDrawing=true;this.removeActiveObject().renderAll();var C=this.getPointer(B);this._freeDrawingXPoints.length=this._freeDrawingYPoints.length=0;this._freeDrawingXPoints.push(C.x);this._freeDrawingYPoints.push(C.y);this.contextTop.beginPath();this.contextTop.moveTo(C.x,C.y);this.contextTop.strokeStyle=this.freeDrawingColor;this.contextTop.lineWidth=this.freeDrawingLineWidth;this.contextTop.lineCap=this.contextTop.lineJoin="round"},_captureDrawingPath:function(B){var C=this.getPointer(B);this._freeDrawingXPoints.push(C.x);this._freeDrawingYPoints.push(C.y);this.contextTop.lineTo(C.x,C.y);this.contextTop.stroke()},_finalizeDrawingPath:function(){this.contextTop.closePath();this._isCurrentlyDrawing=false;var G=o(this._freeDrawingXPoints),F=o(this._freeDrawingYPoints),D=q(this._freeDrawingXPoints),B=q(this._freeDrawingYPoints),L=this.contextTop,M=[],H,J,C=this._freeDrawingXPoints,K=this._freeDrawingYPoints;M.push("M ",C[0]-G," ",K[0]-F," ");for(var I=1;H=C[I],J=K[I];I++){M.push("L ",H-G," ",J-F," ")}M=M.join("");if(M==="M 0 0 L 0 0 "){return}var E=new fabric.Path(M);E.fill=null;E.stroke=this.freeDrawingColor;E.strokeWidth=this.freeDrawingLineWidth;this.add(E);E.set("left",G+(D-G)/2).set("top",F+(B-F)/2).setCoords();this.renderAll();A("path:created",{path:E})},__onMouseMove:function(G){if(this.isDrawingMode){if(this._isCurrentlyDrawing){this._captureDrawingPath(G)}return}var C=this._groupSelector;if(C!==null){var H=f(G);C.left=H.x-this._offset.left-C.ex;C.top=H.y-this._offset.top-C.ey;this.renderTop()}else{if(!this._currentTransform){var E=this.upperCanvasEl.style;var F=this.findTarget(G);if(!F){for(var D=this._objects.length;D--;){if(!this._objects[D].active){this._objects[D].setActive(false)}}E.cursor="default"}else{this._setCursorFromEvent(G,F);if(F.isActive()){F.setCornersVisibility&&F.setCornersVisibility(true)}}}else{var H=f(G),B=H.x,I=H.y;this._currentTransform.target.isMoving=true;if(this._currentTransform.action==="rotate"){if(!G.shiftKey){this._rotateObject(B,I)}this._scaleObject(B,I)}else{if(this._currentTransform.action==="scaleX"){this._scaleObject(B,I,"x")}else{if(this._currentTransform.action==="scaleY"){this._scaleObject(B,I,"y")}else{this._translateObject(B,I);A("object:moved",{target:this._currentTransform.target})}}}this.renderAll()}}},_translateObject:function(B,D){var C=this._currentTransform.target;C.lockMovementX||C.set("left",B-this._currentTransform.offsetX);C.lockMovementY||C.set("top",D-this._currentTransform.offsetY)},_scaleObject:function(B,I,G){var C=this._currentTransform,H=this._offset,F=C.target;if(F.lockScalingX&&F.lockScalingY){return}var E=y(c(C.ey-C.top-H.top,2)+c(C.ex-C.left-H.left,2)),D=y(c(I-C.top-H.top,2)+c(B-C.left-H.left,2));F._scaling=true;if(!G){F.lockScalingX||F.set("scaleX",C.scaleX*D/E);F.lockScalingY||F.set("scaleY",C.scaleY*D/E)}else{if(G==="x"&&!F.lockUniScaling){F.lockScalingX||F.set("scaleX",C.scaleX*D/E)}else{if(G==="y"&&!F.lockUniScaling){F.lockScalingY||F.set("scaleY",C.scaleY*D/E)}}}},_rotateObject:function(B,G){var C=this._currentTransform,E=this._offset;if(C.target.lockRotation){return}var D=b(C.ey-C.top-E.top,C.ex-C.left-E.left),F=b(G-C.top-E.top,B-C.left-E.left);C.target.set("theta",(F-D)+C.theta)},_setCursor:function(B){this.upperCanvasEl.style.cursor=B},_setCursorFromEvent:function(F,E){var C=this.upperCanvasEl.style;if(!E){C.cursor="default";return false}else{var B=this.getActiveGroup();var D=!!E._findTargetCorner&&(!B||!B.contains(E))&&E._findTargetCorner(F,this._offset);if(!D){C.cursor="move"}else{if(D in z){C.cursor=z[D]}else{C.cursor="default";return false}}}return true},_draw:function(B,C){C&&C.render(B)},_drawSelection:function(){var B=this._groupSelector,F=B.left,E=B.top,D=n(F),C=n(E);this.contextTop.fillStyle=this.selectionColor;this.contextTop.fillRect(B.ex-((F>0)?0:-F),B.ey-((E>0)?0:-E),D,C);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(B.ex+d-((F>0)?0:D),B.ey+d-((E>0)?0:C),D,C)},_findSelectedObjects:function(H){var I,D,N=[],C=this._groupSelector.ex,M=this._groupSelector.ey,B=C+this._groupSelector.left,K=M+this._groupSelector.top,J,G=new fabric.Point(r(C,B),r(M,K)),L=new fabric.Point(u(C,B),u(M,K));for(var E=0,F=this._objects.length;E<F;++E){J=this._objects[E];if(J.intersectsWithRect(G,L)||J.isContainedWithinRect(G,L)){J.setActive(true);N.push(J)}}if(N.length===1){this.setActiveObject(N[0]);A("object:selected",{target:N[0]})}else{if(N.length>1){var N=new fabric.Group(N);this.setActiveGroup(N);N.saveCoords();A("group:selected",{target:N})}}this.renderAll()},add:function(){this._objects.push.apply(this._objects,arguments);for(var B=arguments.length;B--;){this.stateful&&arguments[B].setupState();arguments[B].setCoords()}this.renderOnAddition&&this.renderAll();return this},insertAt:function(C,B){this._objects.splice(B,0,C);this.stateful&&C.setupState();C.setCoords();this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop},clearContext:function(B){B.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(C){var H=this[C?"contextTop":"contextContainer"];this.clearContext(this.contextTop);if(!C){this.clearContext(H)}H.fillStyle=this.backgroundColor;H.fillRect(0,0,this.width,this.height);var G=this._objects.length,F=this.getActiveGroup(),E=new Date();if(this.clipTo){H.beginPath();this.clipTo(H);H.clip()}if(G){for(var D=0;D<G;++D){if(!F||(F&&!F.contains(this._objects[D]))){this._draw(H,this._objects[D])}}}if(F){this._draw(this.contextTop,F)}if(this.overlayImage){this.contextTop.drawImage(this.overlayImage,0,0)}if(this.onFpsUpdate){var B=new Date()-E;this.onFpsUpdate(~~(1000/B))}A("after:render");return this},renderTop:function(){this.clearContext(this.contextTop);if(this.overlayImage){this.contextTop.drawImage(this.overlayImage,0,0)}if(this._groupSelector){this._drawSelection()}var B=this.getActiveGroup();if(B){B.render(this.contextTop)}A("after:render");return this},containsPoint:function(G,F){var H=this.getPointer(G),E=this._normalizePointer(F,H),B=E.x,I=E.y;var C=F._getImageLines(F.oCoords),D=F._findCrossPoints(B,I,C);if((D&&D%2===1)||F._findTargetCorner(G,this._offset)){return true}return false},_normalizePointer:function(C,F){var E=this.getActiveGroup(),B=F.x,G=F.y;var D=(E&&C.type!=="group"&&E.contains(C));if(D){B-=E.left;G-=E.top}return{x:B,y:G}},findTarget:function(F,C){var E,G=this.getPointer(F);var D=this.getActiveGroup();if(D&&!C&&this.containsPoint(F,D)){E=D;return E}for(var B=this._objects.length;B--;){if(this.containsPoint(F,this._objects[B])){E=this._objects[B];this.relatedTarget=E;break}}return E},toDataURL:function(C){var B;if(!C){C="png"}if(C==="jpeg"||C==="png"){this.renderAll(true);B=this.upperCanvasEl.toDataURL("image/"+C);this.renderAll()}return B},toDataURLWithMultiplier:function(E,I){var H=this.getWidth(),G=this.getHeight(),C=H*I,D=G*I,B=this.getActiveObject();this.setWidth(C).setHeight(D);this.contextTop.scale(I,I);if(B){this.deactivateAll().renderAll()}var F=this.toDataURL(E);this.contextTop.scale(1/I,1/I);this.setWidth(H).setHeight(G);if(B){this.setActiveObject(B)}this.renderAll();return F},getPointer:function(B){var C=f(B);return{x:C.x-this._offset.left,y:C.y-this._offset.top}},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(B){B.set("left",this.getCenter().left);this.renderAll();return this},fxCenterObjectH:function(C,D){D=D||{};var E=function(){},F=D.onComplete||E,B=D.onChange||E,G=this;fabric.util.animate({startValue:C.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(H){C.set("left",H);G.renderAll();B()},onComplete:function(){C.setCoords();F()}});return this},centerObjectV:function(B){B.set("top",this.getCenter().top);this.renderAll();return this},fxCenterObjectV:function(C,D){D=D||{};var E=function(){},F=D.onComplete||E,B=D.onChange||E,G=this;fabric.util.animate({startValue:C.get("top"),endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(H){C.set("top",H);G.renderAll();B()},onComplete:function(){C.setCoords();F()}});return this},straightenObject:function(B){B.straighten();this.renderAll();return this},fxStraightenObject:function(B){B.fxStraighten({onChange:this.renderAll.bind(this)});return this},toDatalessJSON:function(){return this.toDatalessObject()},toObject:function(){return this._toObjectMethod("toObject")},toDatalessObject:function(){return this._toObjectMethod("toDatalessObject")},_toObjectMethod:function(B){return{objects:this._objects.map(function(C){if(!this.includeDefaultValues){var D=C.includeDefaultValues;C.includeDefaultValues=false}var E=C[B]();if(!this.includeDefaultValues){C.includeDefaultValues=D}return E},this),background:this.backgroundColor}},isEmpty:function(){return this._objects.length===0},loadFromJSON:function(B,E){if(!B){return}var C=JSON.parse(B);if(!C||(C&&!C.objects)){return}this.clear();var D=this;this._enlivenObjects(C.objects,function(){D.backgroundColor=C.background;if(E){E()}});return this},_enlivenObjects:function(C,F){var D=0,B=C.filter(function(G){return G.type==="image"}).length;var E=this;C.forEach(function(I,H){if(!I.type){return}switch(I.type){case"image":case"font":fabric[k(I.type)].fromObject(I,function(J){E.insertAt(J,H);if(++D===B){if(F){F()}}});break;default:var G=fabric[w(k(I.type))];if(G&&G.fromObject){E.insertAt(G.fromObject(I),H)}break}});if(B===0&&F){F()}},loadFromDatalessJSON:function(B,D){if(!B){return}var C=(typeof B==="string")?JSON.parse(B):B;if(!C||(C&&!C.objects)){return}this.clear();this.backgroundColor=C.background;this._enlivenDatalessObjects(C.objects,D)},_enlivenDatalessObjects:function(C,H){function G(J,I){F.insertAt(J,I);J.setCoords();if(++E===B){H&&H()}}var F=this,E=0,B=C.length;if(B===0&&H){H()}try{C.forEach(function(O,M){var J=O.paths?"paths":"path";var N=O[J];delete O[J];if(typeof N!=="string"){switch(O.type){case"image":case"text":fabric[k(O.type)].fromObject(O,function(P){G(P,M)});break;default:var I=fabric[w(k(O.type))];if(I&&I.fromObject){if(N){O[J]=N}G(I.fromObject(O),M)}break}}else{if(O.type==="image"){F.loadImageFromURL(N,function(P){P.setSourcePath(N);v(P,O);P.setAngle(O.angle);G(P,M)})}else{if(O.type==="text"){O.path=N;var L=fabric.Text.fromObject(O);var K=function(){if(Object.prototype.toString.call(g.opera)==="[object Opera]"){setTimeout(function(){G(L,M)},500)}else{G(L,M)}};fabric.util.getScript(N,K)}else{F.loadSVGFromURL(N,function(R,Q){if(R.length>1){var P=new fabric.PathGroup(R,O)}else{var P=R[0]}P.setSourcePath(N);if(!(P instanceof fabric.PathGroup)){v(P,O);if(typeof O.angle!=="undefined"){P.setAngle(O.angle)}}G(P,M)})}}}},this)}catch(D){fabric.log(D.message)}},loadImageFromURL:(function(){var B={};return function(C,G){var F=this;function D(){var H=p.getElementById(B[C]);if(H.width&&H.height){G(new fabric.Image(H))}else{setTimeout(D,50)}}if(B[C]){D()}else{var E=new Image();E.onload=function(){E.onload=null;if(E.width&&E.height){G(new fabric.Image(E))}};E.className="canvas-img-clone";E.src=C;if(this.shouldCacheImages){B[C]=Element.identify(E)}p.body.appendChild(E)}}})(),loadSVGFromURL:function(B,E){var D=this;B=B.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(B,function(F){if(F){D.cache.get(B,function(H){var G=D._enlivenCachedObject(H);E(G.objects,G.options)})}else{new fabric.util.request(B,{method:"get",onComplete:C})}});function C(G){var F=G.responseXML;if(!F){return}var H=F.documentElement;if(!H){return}fabric.parseSVGDocument(H,function(J,I){D.cache.set(B,{objects:fabric.util.array.invoke(J,"toObject"),options:I});E(J,I)})}},_enlivenCachedObject:function(D){var C=D.objects,B=D.options;C=C.map(function(E){return fabric[k(E.type)].fromObject(E)});return({objects:C,options:B})},remove:function(B){m(this._objects,B);if(this.getActiveObject()===B){this.removeActiveObject()}this.renderAll();return B},fxRemove:function(B,D){var C=this;B.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){C.remove(B);if(typeof D==="function"){D()}}});return this},sendToBack:function(B){m(this._objects,B);this._objects.unshift(B);return this.renderAll()},bringToFront:function(B){m(this._objects,B);this._objects.push(B);return this.renderAll()},sendBackwards:function(D){var C=this._objects.indexOf(D),B=C;if(C!==0){for(var E=C-1;E>=0;--E){if(D.intersectsWithObject(this._objects[E])){B=E;break}}m(this._objects,D);this._objects.splice(B,0,D)}return this.renderAll()},bringForward:function(E){var G=this.getObjects(),C=G.indexOf(E),B=C;if(C!==G.length-1){for(var F=C+1,D=this._objects.length;F<D;++F){if(E.intersectsWithObject(G[F])){B=F;break}}m(G,E);G.splice(B,0,E)}this.renderAll()},setActiveObject:function(B){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=B;B.setActive(true);this.renderAll();A("object:selected",{target:B});return this},getActiveObject:function(){return this._activeObject},removeActiveObject:function(){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=null;return this},setActiveGroup:function(B){this._activeGroup=B;return this},getActiveGroup:function(){return this._activeGroup},removeActiveGroup:function(){var B=this.getActiveGroup();if(B){B.destroy()}return this.setActiveGroup(null)},item:function(B){return this.getObjects()[B]},deactivateAll:function(){var C=this.getObjects(),D=0,B=C.length;for(;D<B;D++){C[D].setActive(false)}this.removeActiveGroup();this.removeActiveObject();return this},complexity:function(){return this.getObjects().reduce(function(B,C){B+=C.complexity?C.complexity():0;return B},0)},dispose:function(){this.clear();e(this.upperCanvasEl,"mousedown",this._onMouseDown);e(p,"mouseup",this._onMouseUp);e(p,"mousemove",this._onMouseMove);e(g,"resize",this._onResize);return this},clone:function(D){var B=p.createElement("canvas");B.width=this.getWidth();B.height=this.getHeight();var C=this.__clone||(this.__clone=new fabric.Element(B));return C.loadFromJSON(JSON.stringify(this.toJSON()),function(){if(D){D(C)}})},_toDataURL:function(B,C){this.clone(function(D){C(D.toDataURL(B))})},_toDataURLWithMultiplier:function(B,D,C){this.clone(function(E){C(E.toDataURLWithMultiplier(B,D))})},_resizeImageToFit:function(D){var C=D.width||D.offsetWidth,B=this.getWidth()/C;if(C){D.width=C*B}},cache:{has:function(B,C){C(false)},get:function(B,C){},set:function(C,B){}}});fabric.Element.prototype.toString=function(){return"#<fabric.Element ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"};v(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(E){var D=E.getContext("2d"),I=D.getImageData(0,0,E.width,E.height),G=I.data,B=I.width,H=I.height,C,F;for(i=0;i<B;i++){for(j=0;j<H;j++){C=(i*4)*H+(j*4);F=(G[C]+G[C+1]+G[C+2])/3;G[C]=F;G[C+1]=F;G[C+2]=F}}D.putImageData(I,0,0)},supports:function(C){var D=p.createElement("canvas");if(typeof G_vmlCanvasManager!=="undefined"){G_vmlCanvasManager.initElement(D)}if(!D||!D.getContext){return null}var B=D.getContext("2d");if(!B){return null}switch(C){case"getImageData":return typeof B.getImageData!=="undefined";case"toDataURL":return typeof D.toDataURL!=="undefined";default:return null}}});fabric.Element.prototype.toJSON=fabric.Element.prototype.toObject})(this);(function(a){var d=a.fabric||(a.fabric={}),f=d.util.object.extend,g=d.util.object.clone,c=d.util.toFixed,e=d.util.string.capitalize,k=d.util.getPointer,b=d.util.degreesToRadians,h=Array.prototype.slice;if(d.Object){return}d.Object=d.util.createClass({type:"object",includeDefaultValues:true,NUM_FRACTION_DIGITS:2,FX_DURATION:500,FX_TRANSITION:"decel",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").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,callSuper:function(l){var m=this.constructor.superclass.prototype[l];return(arguments.length>1)?m.apply(this,h.call(arguments,1)):m.call(this)},initialize:function(l){l&&this.setOptions(l)},setOptions:function(l){var m=this.stateProperties.length,n;while(m--){n=this.stateProperties[m];if(n in l){(n==="angle")?this.setAngle(l[n]):(this[n]=l[n])}}},transform:function(l){l.globalAlpha=this.opacity;l.translate(this.left,this.top);l.rotate(this.theta);l.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toObject:function(){var l={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)};if(!this.includeDefaultValues){l=this._removeDefaultValues(l)}return l},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(m){var l=d.Object.prototype.options;if(l){this.stateProperties.forEach(function(n){if(m[n]===l[n]){delete m[n]}})}return m},isActive:function(){return !!this.active},setActive:function(l){this.active=!!l;return this},toString:function(){return"#<fabric."+e(this.type)+">"},set:function(m,l){var n=(m==="scaleX"||m==="scaleY")&&l<this.MIN_SCALE_LIMIT;if(n){l=this.MIN_SCALE_LIMIT}if(m==="angle"){this.setAngle(l)}else{this[m]=l}return this},toggle:function(m){var l=this.get(m);if(typeof l==="boolean"){this.set(m,!l)}return this},setSourcePath:function(l){this.sourcePath=l;return this},get:function(l){return(l==="angle")?this.getAngle():this[l]},render:function(n,o){if(this.width===0||this.height===0){return}n.save();var l=this.transformMatrix;if(l){n.setTransform(l[0],l[1],l[2],l[3],l[4],l[5])}if(!o){this.transform(n)}if(this.stroke){n.lineWidth=this.strokeWidth;n.strokeStyle=this.stroke}if(this.overlayFill){n.fillStyle=this.overlayFill}else{if(this.fill){n.fillStyle=this.fill}}this._render(n,o);if(this.active&&!o){this.drawBorders(n);this.hideCorners||this.drawCorners(n)}n.restore()},getWidth:function(){return this.width*this.scaleX},getHeight:function(){return this.height*this.scaleY},scale:function(l){this.scaleX=l;this.scaleY=l;return this},scaleToWidth:function(l){return this.scale(l/this.width)},scaleToHeight:function(l){return this.scale(l/this.height)},setOpacity:function(l){this.set("opacity",l);return this},getAngle:function(){return this.theta*180/Math.PI},setAngle:function(l){this.theta=l/180*Math.PI;this.angle=l;return this},setCoords:function(){this.currentWidth=this.width*this.scaleX;this.currentHeight=this.height*this.scaleY;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 r=Math.cos(this._angle+this.theta)*this._hypotenuse,q=Math.sin(this._angle+this.theta)*this._hypotenuse,n=this.theta,u=Math.sin(n),s=Math.cos(n);var x={x:this.left-r,y:this.top-q};var t={x:x.x+(this.currentWidth*s),y:x.y+(this.currentWidth*u)};var w={x:t.x-(this.currentHeight*u),y:t.y+(this.currentHeight*s)};var o={x:x.x-(this.currentHeight*u),y:x.y+(this.currentHeight*s)};var p={x:x.x-(this.currentHeight/2*u),y:x.y+(this.currentHeight/2*s)};var l={x:x.x+(this.currentWidth/2*s),y:x.y+(this.currentWidth/2*u)};var m={x:t.x-(this.currentHeight/2*u),y:t.y+(this.currentHeight/2*s)};var v={x:o.x+(this.currentWidth/2*s),y:o.y+(this.currentWidth/2*u)};this.oCoords={tl:x,tr:t,br:w,bl:o,ml:p,mt:l,mr:m,mb:v};this._setCornerCoords();return this},drawBorders:function(m){var r=this.padding,o=r*2;m.save();m.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;m.strokeStyle=this.borderColor;var p=1/(this.scaleX<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleX),n=1/(this.scaleY<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleY);m.lineWidth=1/this.borderScaleFactor;m.scale(p,n);var l=this.getWidth(),q=this.getHeight();m.strokeRect(~~(-(l/2)-r)+0.5,~~(-(q/2)-r)+0.5,~~(l+o),~~(q+o));m.restore();return this},drawCorners:function(x){var z=this.cornersize,u=z/2,t=this.padding,n=-(this.width/2),s=-(this.height/2),y,w,m=z/this.scaleX,l=z/this.scaleY,o=(t+u)/this.scaleY,p=(t+u)/this.scaleX,r=(t+u-z)/this.scaleX,q=(t+u-z)/this.scaleY,v=this.height;x.save();x.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;x.fillStyle=this.cornerColor;y=n-p;w=s-o;x.fillRect(y,w,m,l);y=n+this.width-p;w=s-o;x.fillRect(y,w,m,l);y=n-p;w=s+v+q;x.fillRect(y,w,m,l);y=n+this.width+r;w=s+v+q;x.fillRect(y,w,m,l);y=n+this.width/2-p;w=s-o;x.fillRect(y,w,m,l);y=n+this.width/2-p;w=s+v+q;x.fillRect(y,w,m,l);y=n+this.width+r;w=s+v/2-o;x.fillRect(y,w,m,l);y=n-p;w=s+v/2-o;x.fillRect(y,w,m,l);x.restore();return this},clone:function(l){if(this.constructor.fromObject){return this.constructor.fromObject(this.toObject(),l)}return new d.Object(this.toObject())},cloneAsImage:function(n){if(d.Image){var l=new Image();l.onload=function(){if(n){n(new d.Image(l),m)}l=l.onload=null};var m={angle:this.get("angle"),flipX:this.get("flipX"),flipY:this.get("flipY")};this.set("angle",0).set("flipX",false).set("flipY",false);l.src=this.toDataURL()}return this},toDataURL:function(){var m=document.createElement("canvas");m.width=this.getWidth();m.height=this.getHeight();d.util.wrapElement(m,"div");var l=new d.Element(m);l.backgroundColor="transparent";l.renderAll();var o=this.clone();o.left=m.width/2;o.top=m.height/2;o.setActive(false);l.add(o);var n=l.toDataURL("png");l.dispose();l=o=null;return n},hasStateChanged:function(){return this.stateProperties.some(function(l){return this[l]!==this.originalState[l]},this)},saveState:function(){this.stateProperties.forEach(function(l){this.originalState[l]=this.get(l)},this);return this},setupState:function(){this.originalState={};this.saveState()},intersectsWithRect:function(n,p){var s=this.oCoords,l=new d.Point(s.tl.x,s.tl.y),o=new d.Point(s.tr.x,s.tr.y),r=new d.Point(s.bl.x,s.bl.y),m=new d.Point(s.br.x,s.br.y);var q=d.Intersection.intersectPolygonRectangle([l,o,m,r],n,p);return(q.status==="Intersection")},intersectsWithObject:function(l){function m(q){return{tl:new d.Point(q.tl.x,q.tl.y),tr:new d.Point(q.tr.x,q.tr.y),bl:new d.Point(q.bl.x,q.bl.y),br:new d.Point(q.br.x,q.br.y)}}var n=m(this.oCoords),p=m(l.oCoords);var o=d.Intersection.intersectPolygonPolygon([n.tl,n.tr,n.br,n.bl],[p.tl,p.tr,p.br,p.bl]);return(o.status==="Intersection")},isContainedWithinRect:function(n,p){var r=this.oCoords,l=new d.Point(r.tl.x,r.tl.y),o=new d.Point(r.tr.x,r.tr.y),q=new d.Point(r.bl.x,r.bl.y),m=new d.Point(r.br.x,r.br.y);return l.x>n.x&&o.x<p.x&&l.y>n.y&&q.y<p.y},isType:function(l){return this.type===l},_findTargetCorner:function(q,s){var r=k(q),p=r.x-s.left,m=r.y-s.top,o,l;for(var n in this.oCoords){l=this._getImageLines(this.oCoords[n].corner,n);o=this._findCrossPoints(p,m,l);if(o%2==1&&o!=0){this.__corner=n;return n}}return false},_findCrossPoints:function(s,r,l){var v,u,n,m,t,q,p=0,o;for(var w in l){o=l[w];if((o.o.y<r)&&(o.d.y<r)){continue}if((o.o.y>=r)&&(o.d.y>=r)){continue}if((o.o.x==o.d.x)&&(o.o.x>=s)){t=o.o.x;q=r}else{v=0;u=(o.d.y-o.o.y)/(o.d.x-o.o.x);n=r-v*s;m=o.o.y-u*o.o.x;t=-(n-m)/(v-u);q=n+v*t}if(t>=s){p+=1}if(p==2){break}}return p},_getImageLines:function(m,l){return{topline:{o:m.tl,d:m.tr},rightline:{o:m.tr,d:m.br},bottomline:{o:m.br,d:m.bl},leftline:{o:m.bl,d:m.tl}}},_setCornerCoords:function(){var p=this.oCoords,m=b(45-this.getAngle()),o=Math.sqrt(2*Math.pow(this.cornersize,2))/2,l=o*Math.cos(m),n=o*Math.sin(m);p.tl.corner={tl:{x:p.tl.x-n,y:p.tl.y-l},tr:{x:p.tl.x+l,y:p.tl.y-n},bl:{x:p.tl.x-l,y:p.tl.y+n},br:{x:p.tl.x+n,y:p.tl.y+l}};p.tr.corner={tl:{x:p.tr.x-n,y:p.tr.y-l},tr:{x:p.tr.x+l,y:p.tr.y-n},br:{x:p.tr.x+n,y:p.tr.y+l},bl:{x:p.tr.x-l,y:p.tr.y+n}};p.bl.corner={tl:{x:p.bl.x-n,y:p.bl.y-l},bl:{x:p.bl.x-l,y:p.bl.y+n},br:{x:p.bl.x+n,y:p.bl.y+l},tr:{x:p.bl.x+l,y:p.bl.y-n}};p.br.corner={tr:{x:p.br.x+l,y:p.br.y-n},bl:{x:p.br.x-l,y:p.br.y+n},br:{x:p.br.x+n,y:p.br.y+l},tl:{x:p.br.x-n,y:p.br.y-l}};p.ml.corner={tl:{x:p.ml.x-n,y:p.ml.y-l},tr:{x:p.ml.x+l,y:p.ml.y-n},bl:{x:p.ml.x-l,y:p.ml.y+n},br:{x:p.ml.x+n,y:p.ml.y+l}};p.mt.corner={tl:{x:p.mt.x-n,y:p.mt.y-l},tr:{x:p.mt.x+l,y:p.mt.y-n},bl:{x:p.mt.x-l,y:p.mt.y+n},br:{x:p.mt.x+n,y:p.mt.y+l}};p.mr.corner={tl:{x:p.mr.x-n,y:p.mr.y-l},tr:{x:p.mr.x+l,y:p.mr.y-n},bl:{x:p.mr.x-l,y:p.mr.y+n},br:{x:p.mr.x+n,y:p.mr.y+l}};p.mb.corner={tl:{x:p.mb.x-n,y:p.mb.y-l},tr:{x:p.mb.x+l,y:p.mb.y-n},bl:{x:p.mb.x-l,y:p.mb.y+n},br:{x:p.mb.x+n,y:p.mb.y+l}}},toGrayscale:function(){var l=this.get("fill");if(l){this.set("overlayFill",new d.Color(l).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 l=this._getAngleValueForStraighten();this.setAngle(l);return this},fxStraighten:function(m){m=m||{};var n=function(){},o=m.onComplete||n,l=m.onChange||n,p=this;d.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(q){p.setAngle(q);l()},onComplete:function(){p.setCoords();o()},onStart:function(){p.setActive(false)}});return this},fxRemove:function(m){m||(m={});var n=function(){},o=m.onComplete||n,l=m.onChange||n,p=this;d.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(q){p.set("opacity",q);l()},onComplete:o,onStart:function(){p.setActive(false)}});return this},_getAngleValueForStraighten:function(){var l=this.get("angle");if(l>-225&&l<=-135){return -180}else{if(l>-135&&l<=-45){return -90}else{if(l>-45&&l<=45){return 0}else{if(l>45&&l<=135){return 90}else{if(l>135&&l<=225){return 180}else{if(l>225&&l<=315){return 270}else{if(l>315){return 360}}}}}}}return 0},toJSON:function(){return this.toObject()},setGradientFill:function(l,m){this.set("fill",d.Gradient.forObject(this,l,m))}});d.Object.prototype.rotate=d.Object.prototype.setAngle})(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);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.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 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.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);e.restore();if(this.stroke){e.stroke()}if(this.fill){e.fill()}},complexity:function(){return 1}});b.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-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 l=this.rx||0,k=this.ry||0,d=-this.width/2,m=-this.height/2,e=this.width,g=this.height;f.beginPath();f.moveTo(d+l,m);f.lineTo(d+e-l,m);f.bezierCurveTo(d+e,m,d+e,m+k,d+e,m+k);f.lineTo(d+e,m+g-k);f.bezierCurveTo(d+e,m+g,d+e-l,m+g,d+e-l,m+g);f.lineTo(d+l,m+g);f.bezierCurveTo(d,m+g,d,m+g-k,d,m+g-k);f.lineTo(d,m+k);f.bezierCurveTo(d,m,d+l,m,d+l,m);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)}if(d.top){this.set("top",d.top+this.getHeight()/2)}return this},complexity:function(){return 1}});c.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-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;f<c;f++){d=this.points[f];e.lineTo(d.x,d.y)}if(this.fill){e.fill()}if(this.stroke){e.stroke()}},complexity:function(){return this.get("points").length}});b.Polyline.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");b.Polyline.fromElement=function(f,d){if(!f){return null}d||(d={});var g=b.parsePointsAttribute(f.getAttribute("points")),h=b.parseAttributes(f,b.Polyline.ATTRIBUTE_NAMES);for(var e=0,c=g.length;e<c;e++){g[e].x-=(d.width/2)||0;g[e].y-=(d.height/2)||0}return new b.Polyline(g,b.util.object.extend(h,d))};b.Polyline.fromObject=function(c){var d=c.points;return new b.Polyline(d,c)}})(this);(function(e){var f=e.fabric||(e.fabric={}),g=f.util.object.extend,d=f.util.array.min,a=f.util.array.max;if(f.Polygon){f.warn("fabric.Polygon is already defined");return}function c(h){return h.x}function b(h){return h.y}f.Polygon=f.util.createClass(f.Object,{type:"polygon",initialize:function(k,h){h=h||{};this.points=k;this.callSuper("initialize",h);this._calcDimensions()},_calcDimensions:function(){var k=this.points,h=d(k,"x"),n=d(k,"y"),m=a(k,"x"),l=a(k,"y");this.width=m-h;this.height=l-n;this.minX=h;this.minY=n},toObject:function(){return g(this.callSuper("toObject"),{points:this.points.concat()})},_render:function(l){var k;l.beginPath();for(var m=0,h=this.points.length;m<h;m++){k=this.points[m];l.lineTo(k.x,k.y)}if(this.fill){l.fill()}if(this.stroke){l.closePath();l.stroke()}},complexity:function(){return this.points.length}});f.Polygon.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");f.Polygon.fromElement=function(m,k){if(!m){return null}k||(k={});var n=f.parsePointsAttribute(m.getAttribute("points")),o=f.parseAttributes(m,f.Polygon.ATTRIBUTE_NAMES);for(var l=0,h=n.length;l<h;l++){n[l].x-=(k.width/2)||0;n[l].y-=(k.height/2)||0}return new f.Polygon(n,g(o,k))};f.Polygon.fromObject=function(h){return new f.Polygon(h.points,h)}})(this);(function(e){var f=e.fabric||(e.fabric={}),d=f.util.array.min,a=f.util.array.max,h=f.util.object.extend,g=Object.prototype.toString;if(f.Path){f.warn("fabric.Path is already defined");return}if(!f.Object){f.warn("fabric.Path requires fabric.Object");return}function c(k){if(k[0]==="H"){return k[1]}return k[k.length-2]}function b(k){if(k[0]==="V"){return k[1]}return k[k.length-1]}f.Path=f.util.createClass(f.Object,{type:"path",initialize:function(m,l){l=l||{};this.setOptions(l);if(!m){throw Error("`path` argument is required")}var k=g.call(m)==="[object Array]";this.path=k?m:m.match&&m.match(/[a-zA-Z][^a-zA-Z]*/g);if(!this.path){return}if(!k){this._initializeFromArray(l)}if(l.sourcePath){this.setSourcePath(l.sourcePath)}},_initializeFromArray:function(l){var k="width" in l,m="height" in l;this.path=this._parsePath();if(!k||!m){h(this,this._parseDimensions());if(k){this.width=l.width}if(m){this.height=l.height}}},_render:function(w){var r,u=0,s=0,k=0,z=0,p,o,m=-(this.width/2),v=-(this.height/2);for(var n=0,q=this.path.length;n<q;++n){r=this.path[n];switch(r[0]){case"l":u+=r[1];s+=r[2];w.lineTo(u+m,s+v);break;case"L":u=r[1];s=r[2];w.lineTo(u+m,s+v);break;case"h":u+=r[1];w.lineTo(u+m,s+v);break;case"H":u=r[1];w.lineTo(u+m,s+v);break;case"v":s+=r[1];w.lineTo(u+m,s+v);break;case"V":s=r[1];w.lineTo(u+m,s+v);break;case"m":u+=r[1];s+=r[2];w.moveTo(u+m,s+v);break;case"M":u=r[1];s=r[2];w.moveTo(u+m,s+v);break;case"c":p=u+r[5];o=s+r[6];k=u+r[3];z=s+r[4];w.bezierCurveTo(u+r[1]+m,s+r[2]+v,k+m,z+v,p+m,o+v);u=p;s=o;break;case"C":u=r[5];s=r[6];k=r[3];z=r[4];w.bezierCurveTo(r[1]+m,r[2]+v,k+m,z+v,u+m,s+v);break;case"s":p=u+r[3];o=s+r[4];k=2*u-k;z=2*s-z;w.bezierCurveTo(k+m,z+v,u+r[1]+m,s+r[2]+v,p+m,o+v);u=p;s=o;break;case"S":p=r[3];o=r[4];k=2*u-k;z=2*s-z;w.bezierCurveTo(k+m,z+v,r[1]+m,r[2]+v,p+m,o+v);u=p;s=o;break;case"q":u+=r[3];s+=r[4];w.quadraticCurveTo(r[1]+m,r[2]+v,u+m,s+v);break;case"Q":u=r[3];s=r[4];k=r[1];z=r[2];w.quadraticCurveTo(k+m,z+v,u+m,s+v);break;case"T":p=u;o=s;u=r[1];s=r[2];k=-k+2*p;z=-z+2*o;w.quadraticCurveTo(k+m,z+v,u+m,s+v);break;case"a":break;case"A":break;case"z":case"Z":w.closePath();break}}},render:function(l,n){l.save();var k=this.transformMatrix;if(k){l.transform(k[0],k[1],k[2],k[3],k[4],k[5])}if(!n){this.transform(l)}if(this.overlayFill){l.fillStyle=this.overlayFill}else{if(this.fill){l.fillStyle=this.fill}}if(this.stroke){l.strokeStyle=this.stroke}l.beginPath();this._render(l);if(this.fill){l.fill()}if(this.stroke){l.strokeStyle=this.stroke;l.lineWidth=this.strokeWidth;l.lineCap=l.lineJoin="round";l.stroke()}if(!n&&this.active){this.drawBorders(l);this.hideCorners||this.drawCorners(l)}l.restore()},toString:function(){return"#<fabric.Path ("+this.complexity()+"): "+JSON.stringify({top:this.top,left:this.left})+">"},toObject:function(){var k=h(this.callSuper("toObject"),{path:this.path});if(this.sourcePath){k.sourcePath=this.sourcePath}if(this.transformMatrix){k.transformMatrix=this.transformMatrix}return k},toDatalessObject:function(){var k=this.toObject();if(this.sourcePath){k.path=this.sourcePath}delete k.sourcePath;return k},complexity:function(){return this.path.length},_parsePath:function(){var l=[],p,q;for(var o=0,m,n,k=this.path.length;o<k;o++){p=this.path[o];q=p.slice(1).trim().replace(/(\d)-/g,"$1###-").split(/\s|,|###/);m=q.length,n=[p.charAt(0)];while(m--){n[m+1]=parseFloat(q[m])}l.push(n)}return l},_parseDimensions:function(){var s=[],q=[],t,r,u=false,w,v;this.path.forEach(function(x,o){if(x[0]!=="H"){t=(o===0)?c(x):c(this.path[o-1])}if(x[0]!=="V"){r=(o===0)?b(x):b(this.path[o-1])}if(x[0]===x[0].toLowerCase()){u=true}w=u?t+c(x):x[0]==="V"?t:c(x);v=u?r+b(x):x[0]==="H"?r:b(x);var y=parseInt(w,10);if(!isNaN(y)){s.push(y)}y=parseInt(v,10);if(!isNaN(y)){q.push(y)}},this);var m=d(s),l=d(q),p=0,n=0;var k={top:l-n,left:m-p,bottom:a(q)-n,right:a(s)-p};k.width=k.right-k.left;k.height=k.bottom-k.top;return k}});f.Path.fromObject=function(k){return new f.Path(k.path,k)};f.Path.ATTRIBUTE_NAMES="d fill fill-opacity fill-rule stroke stroke-width transform".split(" ");f.Path.fromElement=function(l,k){var m=f.parseAttributes(l,f.Path.ATTRIBUTE_NAMES);return new f.Path(m.d,h(m,k))}})(this);(function(a){var d=a.fabric||(a.fabric={}),h=d.util.object.extend,f=d.util.array.invoke,k=d.Object.prototype.set,e=d.Object.prototype.toObject,b=d.util.string.camelize,g=d.util.string.capitalize;if(d.PathGroup){d.warn("fabric.PathGroup is already defined");return}d.PathGroup=d.util.createClass(d.Path,{type:"path-group",forceFillOverwrite:false,initialize:function(m,l){l=l||{};this.paths=m;this.setOptions(l);this.setCoords();if(l.sourcePath){this.setSourcePath(l.sourcePath)}},render:function(p){if(this.stub){p.save();this.transform(p);this.stub.render(p,false);if(this.active){this.drawBorders(p);this.drawCorners(p)}p.restore()}else{p.save();var n=this.transformMatrix;if(n){p.transform(n[0],n[1],n[2],n[3],n[4],n[5])}this.transform(p);for(var q=0,o=this.paths.length;q<o;++q){this.paths[q].render(p,true)}if(this.active){this.drawBorders(p);this.hideCorners||this.drawCorners(p)}p.restore()}},set:function(n,m){if((n==="fill"||n==="overlayFill")&&this.isSameColor()){this[n]=m;var l=this.paths.length;while(l--){this.paths[l].set(n,m)}}else{k.call(this,n,m)}return this},toObject:function(){return h(e.call(this),{paths:f(this.getObjects(),"clone"),sourcePath:this.sourcePath})},toDatalessObject:function(){var l=this.toObject();if(this.sourcePath){l.paths=this.sourcePath}return l},toString:function(){return"#<fabric.PathGroup ("+this.complexity()+"): { top: "+this.top+", left: "+this.left+" }>"},isSameColor:function(){var l=this.getObjects()[0].get("fill");return this.getObjects().every(function(m){return m.get("fill")===l})},complexity:function(){return this.paths.reduce(function(l,m){return l+((m&&m.complexity)?m.complexity():0)},0)},toGrayscale:function(){var l=this.paths.length;while(l--){this.paths[l].toGrayscale()}return this},getObjects:function(){return this.paths}});function c(o){for(var n=0,l=o.length;n<l;n++){if(!(o[n] instanceof d.Object)){var m=b(g(o[n].type));o[n]=d[m].fromObject(o[n])}}return o}d.PathGroup.fromObject=function(l){var m=c(l.paths);return new d.PathGroup(m,l)}})(this);(function(d){var e=d.fabric||(d.fabric={}),g=e.util.object.extend,c=e.util.array.min,a=e.util.array.max,b=e.util.array.invoke,f=e.util.removeFromArray;if(e.Group){return}e.Group=e.util.createClass(e.Object,{type:"group",initialize:function(k,h){this.objects=k||[];this.originalState={};this.callSuper("initialize");this._calcBounds();this._updateObjectsCoords();if(h){g(this,h)}this._setOpacityIfSame();this.setCoords(true);this.saveCoords();this.activateAllObjects()},_updateObjectsCoords:function(){var k=this.left,h=this.top;this.forEachObject(function(l){var m=l.get("left"),n=l.get("top");l.set("originalLeft",m);l.set("originalTop",n);l.set("left",m-k);l.set("top",n-h);l.setCoords();l.hideCorners=true},this)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},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,l){if(typeof l=="function"){this.set(h,l(this[h]))}else{if(h==="fill"||h==="opacity"){var k=this.objects.length;this[h]=l;while(k--){this.objects[k].set(h,l)}}else{this[h]=l}}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(k){k.save();this.transform(k);var o=Math.max(this.scaleX,this.scaleY);for(var m=0,h=this.objects.length,l;l=this.objects[m];m++){var n=l.borderScaleFactor;l.borderScaleFactor=o;l.render(k);l.borderScaleFactor=n}this.hideBorders||this.drawBorders(k);this.hideCorners||this.drawCorners(k);k.restore();this.setCoords()},item:function(h){return this.getObjects()[h]},complexity:function(){return this.getObjects().reduce(function(k,h){k+=(typeof h.complexity=="function")?h.complexity():0;return k},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,this);return this},_restoreObjectState:function(l){var n=this.get("left"),o=this.get("top"),h=this.getAngle()*(Math.PI/180),m=l.get("originalLeft"),p=l.get("originalTop"),k=Math.cos(h)*l.get("top")+Math.sin(h)*l.get("left"),q=-Math.sin(h)*l.get("top")+Math.cos(h)*l.get("left");l.setAngle(l.getAngle()+this.getAngle());l.set("left",n+q*this.get("scaleX"));l.set("top",o+k*this.get("scaleY"));l.set("scaleX",l.get("scaleX")*this.get("scaleX"));l.set("scaleY",l.get("scaleY")*this.get("scaleY"));l.setCoords();l.hideCorners=false;l.setActive(false);l.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(k){k.setActive(h)});return this},forEachObject:function(m,k){var l=this.getObjects(),h=l.length;while(h--){m.call(k,l[h],h,l)}return this},_setOpacityIfSame:function(){var l=this.getObjects(),k=l[0]?l[0].get("opacity"):1;var h=l.every(function(m){return m.get("opacity")===k});if(h){this.opacity=k}},_calcBounds:function(){var t=[],r=[],q,p,l,h,n,m,v,s=0,u=this.objects.length;for(;s<u;++s){n=this.objects[s];n.setCoords();for(var k in n.oCoords){t.push(n.oCoords[k].x);r.push(n.oCoords[k].y)}}q=c(t);l=a(t);p=c(r);h=a(r);m=l-q;v=h-p;this.width=m;this.height=v;this.left=q+m/2;this.top=p+v/2},containsPoint:function(k){var n=this.get("width")/2,h=this.get("height")/2,m=this.get("left"),l=this.get("top");return m-n<k.x&&m+n>k.x&&l-h<k.y&&l+h>k.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:"Modernist_One_400",textDecoration:"",textShadow:null,fontStyle:"",lineHeight:1,strokeStyle:"",strokeWidth:1,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","fontStyle","lineHeight","strokeStyle","strokeWidth");b.util.removeFromArray(this.stateProperties,"width")},toString:function(){return"#<fabric.Text ("+this.complexity()+"): "+JSON.stringify({text:this.text,fontfamily:this.fontfamily})+">"},_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,fontStyle:this.fontStyle,lineHeight:this.lineHeight,strokeStyle:this.strokeStyle,strokeWidth:this.strokeWidth});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){e.save();this._render(e);if(this.active){this.drawBorders(e);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,path:this.path,strokeStyle:this.strokeStyle,strokeWidth:this.strokeWidth})},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.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<d.width)){normalizedHeight=~~((d.height*c)/d.width);normalizedWidth=c}else{normalizedWidth=d.width;normalizedHeight=d.height}}}return{width:normalizedWidth,height:normalizedHeight}},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(c,d){c.save();if(!d){this.transform(c)}this._render(c);if(this.active&&!d){this.drawBorders(c);this.hideCorners||this.drawCorners(c)}c.restore()},toObject:function(){return b(this.callSuper("toObject"),{src:this.getSrc()})},getSrc:function(){return this.getElement().src},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},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.Element.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 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); |