mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-24 13:13:44 +00:00
2 lines
No EOL
79 KiB
JavaScript
2 lines
No EOL
79 KiB
JavaScript
/* Fabric.js Copyright 2010, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
|
|
if(typeof console=="undefined"){var console={log:function(){},warn:function(){}}}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(m){var g=this.fabric||(this.fabric={});g.base={};var h=Array.prototype.slice;if(!Array.prototype.indexOf){Array.prototype.indexOf=function(v,w){var u=this.length>>>0;w=Number(w)||0;w=Math[w<0?"ceil":"floor"](w);if(w<0){w+=u}for(;w<u;w++){if(w in this&&this[w]===v){return w}}return -1}}if(!Array.prototype.forEach){Array.prototype.forEach=function(x,w){for(var v=0,u=this.length>>>0;v<u;v++){if(v in this){x.call(w,this[v],v,this)}}}}if(!Array.prototype.map){Array.prototype.map=function(y,x){var v=[];for(var w=0,u=this.length>>>0;w<u;w++){if(w in this){v[w]=y.call(x,this[w],w,this)}}return v}}if(!Array.prototype.every){Array.prototype.every=function(x,w){for(var v=0,u=this.length>>>0;v<u;v++){if(v in this&&!x.call(w,this[v],v,this)){return false}}return true}}if(!Array.prototype.some){Array.prototype.some=function(x,w){for(var v=0,u=this.length>>>0;v<u;v++){if(v in this&&x.call(w,this[v],v,this)){return true}}return false}}if(!Array.prototype.filter){Array.prototype.filter=function(y,x){var v=[],z;for(var w=0,u=this.length>>>0;w<u;w++){if(w in this){z=this[w];if(y.call(x,z,w,this)){v.push(z)}}}return res}}if(!Array.prototype.reduce){Array.prototype.reduce=function(w){var u=this.length>>>0,v=0,x;if(arguments.length>1){x=arguments[1]}else{do{if(v in this){x=this[v++];break}if(++v>=u){throw new TypeError()}}while(true)}for(;v<u;v++){if(v in this){x=w.call(null,x,this[v],v,this)}}return x}}function t(z,y){var w=h.call(arguments,2),v=[];for(var x=0,u=z.length;x<u;x++){v[x]=w.length?z[x][y].apply(z[x],w):z[x][y].call(z[x])}return v}function o(x,w){var v=x.length-1,u=w?x[v][w]:x[v];if(w){while(v--){if(x[v][w]>=u){u=x[v][w]}}}else{while(v--){if(x[v]>=u){u=x[v]}}}return u}function l(x,w){var v=x.length-1,u=w?x[v][w]:x[v];if(w){while(v--){if(x[v][w]<u){u=x[v][w]}}}else{while(v--){if(x[v]<u){u=x[v]}}}return u}g.base.array={invoke:t,min:l,max:o};function q(u,w){for(var v in w){u[v]=w[v]}return u}function r(u){return q({},u)}g.base.object={extend:q,clone:r};if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}}function s(u){return u.replace(/-+(.)?/g,function(v,w){return w?w.toUpperCase():""})}function d(u){return u.charAt(0).toUpperCase()+u.slice(1).toLowerCase()}g.base.string={camelize:s,capitalize:d};if(!Function.prototype.bind){Function.prototype.bind=function(u){var w=this,v=Array.prototype.slice.call(arguments,1);return function(){return w.apply(u,v.concat(Array.prototype.slice.call(arguments)))}}}(function(){var w=(function(){for(var y in {toString:1}){if(y==="toString"){return false}}return true})();var v;if(w){v=function(y,A){if(A.toString!==Object.prototype.toString){y.prototype.toString=A.toString}if(A.valueOf!==Object.prototype.valueOf){y.prototype.valueOf=A.valueOf}for(var z in A){y.prototype[z]=A[z]}}}else{v=function(y,A){for(var z in A){y.prototype[z]=A[z]}}}function u(){}function x(){var B=null,A=h.call(arguments,0);if(typeof A[0]==="function"){B=A.shift()}function y(){this.initialize.apply(this,arguments)}y.superclass=B;y.subclasses=[];if(B){u.prototype=B.prototype;y.prototype=new u;B.subclasses.push(y)}for(var z=0,C=A.length;z<C;z++){v(y,A[z])}if(!y.prototype.initialize){y.prototype.initialize=emptyFunction}y.prototype.constructor=y;return y}g.base.createClass=x})();(function(J){function F(N){var Q=Array.prototype.slice.call(arguments,1),P,O,M=Q.length;for(O=0;O<M;O++){P=typeof N[Q[O]];if(!(/^(?:function|object|unknown)$/).test(P)){return false}}return true}var D=(function(){if(typeof document.documentElement.uniqueID!=="undefined"){return function(N){return N.uniqueID}}var M=0;return function(N){return N.__uniqueID||(N.__uniqueID="uniqueID__"+M++)}})();var A,K;(function(){var M={};A=function(N){return M[N]};K=function(O,N){M[O]=N}})();function y(M,N){return{handler:N,wrappedHandler:E(M,N)}}function E(M,N){return function(O){N.call(A(M),O||window.event)}}function z(N,M){return function(R){if(H[N]&&H[N][M]){var P=H[N][M];for(var Q=0,O=P.length;Q<O;Q++){P[Q].call(this,R||window.event)}}}}var I=(F(document.documentElement,"addEventListener","removeEventListener")&&F(window,"addEventListener","removeEventListener")),B=(F(document.documentElement,"attachEvent","detachEvent")&&F(window,"attachEvent","detachEvent")),G={},H={};if(I){addListener=function(N,M,O){N.addEventListener(M,O,false)};removeListener=function(N,M,O){N.removeEventListener(M,O,false)}}else{if(B){addListener=function(O,M,P){var N=D(O);K(N,O);if(!G[N]){G[N]={}}if(!G[N][M]){G[N][M]=[]}var Q=y(N,P);G[N][M].push(Q);O.attachEvent("on"+M,Q.wrappedHandler)};removeListener=function(Q,N,R){var P=D(Q),S;if(G[P]&&G[P][N]){for(var O=0,M=G[P][N].length;O<M;O++){S=G[P][N][O];if(S&&S.handler===R){Q.detachEvent("on"+N,S.wrappedHandler);G[P][N][O]=null}}}}}else{addListener=function(O,M,P){var N=D(O);if(!H[N]){H[N]={}}if(!H[N][M]){H[N][M]=[];var Q=O["on"+M];if(Q){H[N][M].push(Q)}O["on"+M]=z(N,M)}H[N][M].push(P)};removeListener=function(R,O,S){var Q=D(R);if(H[Q]&&H[Q][O]){var N=H[Q][O];for(var P=0,M=N.length;P<M;P++){if(N[P]===S){N.splice(P,1)}}}}}}g.base.addListener=addListener;g.base.removeListener=removeListener;var v={};function x(M,N){if(!v[M]){v[M]=[]}v[M].push(N)}function L(O,N){if(!v[O]){return}for(var P=0,M=v[O].length;P<M;P++){try{v[O][P]({memo:N})}catch(Q){setTimeout(function(){throw Q},0)}}}g.base.observeEvent=x;g.base.fireEvent=L;function C(M){return{x:w(M),y:u(M)}}function w(O){var N=document.documentElement,M=document.body||{scrollLeft:0};return O.pageX||(O.clientX+(N.scrollLeft||M.scrollLeft)-(N.clientLeft||0))}function u(O){var N=document.documentElement,M=document.body||{scrollTop:0};return O.pageY||(O.clientY+(N.scrollTop||M.scrollTop)-(N.clientTop||0))}g.base.getPointer=C})(this);(function(){function y(D,F){var H=D.style,C;if(typeof F==="string"){D.style.cssText+=";"+F;return F.indexOf("opacity")>-1?w(D,F.match(/opacity:\s*(\d?\.?\d*)/)[1]):D}for(var G in F){if(G==="opacity"){w(D,F[G])}else{var E=(G==="float"||G==="cssFloat")?(typeof H.styleFloat==="undefined"?"cssFloat":"styleFloat"):G;H[E]=F[G]}}return D}var B=document.createElement("div"),A=typeof B.style.opacity==="string",v=typeof B.style.filter==="string",u=document.defaultView,z=u&&typeof u.getComputedStyle!=="undefined",x=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,w=function(C){return C};if(A){w=function(C,D){C.style.opacity=D;return C}}else{if(v){w=function(C,D){var E=C.style;if(C.currentStyle&&!C.currentStyle.hasLayout){E.zoom=1}if(x.test(E.filter)){D=D>=0.9999?"":("alpha(opacity="+(D*100)+")");E.filter=E.filter.replace(x,D)}else{E.filter+=" alpha(opacity="+(D*100)+")"}return C}}}g.base.setStyle=y})();function p(u){return typeof u==="string"?document.getElementById(u):u}function n(v){var u=[],w=v.length;while(w--){u[w]=v[w]}return u}function b(v,u){var w=document.createElement(v);for(var x in u){if(x==="class"){x="className"}else{if(x==="for"){x="htmlFor"}}w.setAttribute(x,u[x])}return w}function f(u,v){if((" "+u.className+" ").indexOf(" "+v+" ")===-1){u.className+=(u.className?" ":"")+v}}function a(v,w,u){if(typeof w==="string"){w=b(w,u)}if(v.parentNode){v.parentNode.replaceChild(w,v)}w.appendChild(v);return w}function k(v){var u=0,w=0;do{u+=v.offsetTop||0;w+=v.offsetLeft||0;v=v.offsetParent}while(v);return({left:w,top:u})}function e(){return false}(function(){var u=document.documentElement.style;var v="userSelect" in u?"userSelect":"MozUserSelect" in u?"MozUserSelect":"WebkitUserSelect" in u?"WebkitUserSelect":"KhtmlUserSelect" in u?"KhtmlUserSelect":"";function w(x){if(typeof x.onselectstart!=="undefined"){x.onselectstart=e}if(v){x.style[v]="none"}else{if(typeof x.unselectable=="string"){x.unselectable="on"}}return x}g.base.makeElementUnselectable=w})();(function(){function u(x,B){var z=document.getElementsByTagName("head")[0],y=document.createElement("script"),A=true;y.type="text/javascript";y.setAttribute("runat","server");y.onload=y.onreadystatechange=function(C){if(A){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete"){return}A=false;B(C||window.event);y=y.onload=y.onreadystatechange=null}};y.src=x;z.appendChild(y)}function w(x,y){v.load(x);y()}g.base.getScript=u;var v=this.Jaxer;if(v&&v.load){g.base.getScript=w}})();function c(F){F||(F={});var v=+new Date(),z=F.duration||500,E=v+z,y,D,A=F.onChange||function(){},B=F.easing||function(G){return(-Math.cos(G*Math.PI)/2)+0.5},u="startValue" in F?F.startValue:0,C="endValue" in F?F.endValue:100,x=u>C;F.onStart&&F.onStart();var w=setInterval(function(){y=+new Date();D=y>E?1:(y-v)/z;A(x?(u-(u-C)*B(D)):(u+(C-u)*B(D)));if(y>E){clearInterval(w);F.onComplete&&F.onComplete()}},10)}g.base.getById=p;g.base.toArray=n;g.base.makeElement=b;g.base.addClass=f;g.base.wrapElement=a;g.base.getElementOffset=k;g.base.animate=c;(function(){function x(y,z){return y+(/\?/.test(y)?"&":"?")+z}var w=(function(){var B=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest()}];for(var y=B.length;y--;){try{var A=B[y]();if(A){return B[y]}}catch(z){}}})();function u(){}function v(A,z){z||(z={});var D=z.method?z.method.toUpperCase():"GET",C=z.onComplete||function(){},B=w(),y;B.onreadystatechange=function(){if(B.readyState===4){C(B);B.onreadystatechange=u}};if(D==="GET"){y=null;if(typeof z.parameters=="string"){A=x(A,z.parameters)}}B.open(D,A,true);if(D==="POST"||D==="PUT"){B.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}B.send(y);return B}g.base.request=v})()})(this);(function(){var e=this.fabric||(this.fabric={});if(e.util){console.warn("fabric.util is already defined");return}function f(k,h){var g=k.indexOf(h);if(g!==-1){k.splice(g,1)}return k}function d(h,g){return Math.floor(Math.random()*(g-h+1))+h}var b=Math.PI/180;function c(g){return g*b}function a(h,g){return parseFloat(Number(h).toFixed(g))}e.util={removeFromArray:f,degreesToRadians:c,toFixed:a,getRandomInt:d}})();(function(){var f=this.fabric||(this.fabric={});var c={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};function b(l,k){if(!l){return}var n,h,g={};if(l.parentNode&&/^g$/i.test(l.parentNode.nodeName)){g=f.parseAttributes(l.parentNode,k)}var m=k.reduce(function(p,o){n=l.getAttribute(o);h=parseFloat(n);if(n){if((o==="fill"||o==="stroke")&&n==="none"){n=""}if(o==="fill-rule"){n=(n==="evenodd")?"destination-over":n}if(o==="transform"){n=f.parseTransformAttribute(n)}if(o in c){o=c[o]}p[o]=isNaN(h)?n:h}return p},{});m=f.base.object.extend(f.parseStyleAttribute(l),m);return f.base.object.extend(g,m)}f.parseTransformAttribute=(function(){function g(B,C){var D=C[0];B[0]=Math.cos(D);B[1]=Math.sin(D);B[2]=-Math.sin(D);B[3]=Math.cos(D)}function n(D,E){var C=E[0],B=(E.length===2)?E[1]:E[0];D[0]=C;D[3]=B}function y(B,C){B[2]=C[0]}function k(B,C){B[1]=C[0]}function v(B,C){B[4]=C[0];if(C.length===2){B[5]=C[1]}}var p=[1,0,0,1,0,0],h="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",z="(?:\\s+,?\\s*|,\\s*)",q="(?:(skewX)\\s*\\(\\s*("+h+")\\s*\\))",o="(?:(skewY)\\s*\\(\\s*("+h+")\\s*\\))",x="(?:(rotate)\\s*\\(\\s*("+h+")(?:"+z+"("+h+")"+z+"("+h+"))?\\s*\\))",A="(?:(scale)\\s*\\(\\s*("+h+")(?:"+z+"("+h+"))?\\s*\\))",t="(?:(translate)\\s*\\(\\s*("+h+")(?:"+z+"("+h+"))?\\s*\\))",w="(?:(matrix)\\s*\\(\\s*("+h+")"+z+"("+h+")"+z+"("+h+")"+z+"("+h+")"+z+"("+h+")"+z+"("+h+")\\s*\\))",u="(?:"+w+"|"+t+"|"+A+"|"+x+"|"+q+"|"+o+")",r="(?:"+u+"(?:"+z+u+")*)",l="^\\s*(?:"+r+"?)\\s*$",s=new RegExp(l),m=new RegExp(u);return function(C){var B=p.concat();if(!C||(C&&!s.test(C))){return B}C.replace(m,function(G){var D=new RegExp(u).exec(G).filter(function(H){return(H!==""&&H!=null)}),E=D[1],F=D.slice(2).map(parseFloat);switch(E){case"translate":v(B,F);break;case"rotate":g(B,F);break;case"scale":n(B,F);break;case"skewX":y(B,F);break;case"skewY":k(B,F);break;case"matrix":B=F;break}});return B}})();function a(h){if(!h){return null}h=h.trim().split(/\s+/);var g=h.reduce(function(k,l){l=l.split(",");k.push({x:parseFloat(l[0]),y:parseFloat(l[1])});return k},[]);if(g.length%2!==0){}return g}function e(h){var g={},k=h.getAttribute("style");if(k){if(typeof k=="string"){k=k.split(";");k.pop();g=k.reduce(function(n,q){var m=q.split(":"),o=m[0].trim(),p=m[1].trim();n[o]=p;return n},{})}else{for(var l in k){if(typeof k[l]!=="undefined"){g[l]=k[l]}}}}return g}function d(h,g){var k=h.map(function(m){var l=f[f.base.string.capitalize(m.tagName)];if(l&&l.fromElement){try{return l.fromElement(m,g)}catch(n){console.log(n.message||n)}}});k=k.filter(function(l){return l!=null});return k}f.parseSVGDocument=(function(){var g=/^(path|circle|polygon|polyline|ellipse|rect|line)$/;var k="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)";var l=new RegExp("^\\s*("+k+"+)\\s*,?\\s*("+k+"+)\\s*,?\\s*("+k+"+)\\s*,?\\s*("+k+"+)\\s*$");function h(m,n){while(m&&(m=m.parentNode)){if(m.nodeName===n){return true}}return false}return function(u,w){if(!u){return}var t=f.base.toArray(u.getElementsByTagName("*"));var m=t.filter(function(y){return g.test(y.tagName)&&!h(y,"pattern")});if(!m||(m&&!m.length)){return}var n=u.getAttribute("viewBox"),r=u.getAttribute("width"),p=u.getAttribute("height"),o=null,v=null,s,q;if(n&&(n=n.match(l))){s=parseInt(n[1],10);q=parseInt(n[2],10);o=parseInt(n[3],10);v=parseInt(n[4],10)}o=r?parseFloat(r):o;v=p?parseFloat(p):v;var x={width:o,height:v};var m=f.parseElements(m,f.base.object.clone(x));if(!m||(m&&!m.length)){return}if(w){w(m,x)}}})();f.base.object.extend(f,{parseAttributes:b,parseElements:d,parseStyleAttribute:e,parsePointsAttribute:a})})();(function(){var b=this.fabric||(this.fabric={});if(b.Point){console.warn("fabric.Point is already defined");return}function a(c,d){if(arguments.length>0){this.init(c,d)}}a.prototype={constructor:a,init:function(c,d){this.x=c;this.y=d},add:function(c){return new a(this.x+c.x,this.y+c.y)},addEquals:function(c){this.x+=c.x;this.y+=c.y;return this},scalarAdd:function(c){return new a(this.x+c,this.y+c)},scalarAddEquals:function(c){this.x+=c;this.y+=c;return this},subtract:function(c){return new a(this.x-c.x,this.y-c.y)},subtractEquals:function(c){this.x-=c.x;this.y-=c.y;return this},scalarSubtract:function(c){return new a(this.x-c,this.y-c)},scalarSubtractEquals:function(c){this.x-=c;this.y-=c;return this},multiply:function(c){return new a(this.x*c,this.y*c)},multiplyEquals:function(c){this.x*=c;this.y*=c;return this},divide:function(c){return new a(this.x/c,this.y/c)},divideEquals:function(c){this.x/=c;this.y/=c;return this},eq:function(c){return(this.x==c.x&&this.y==c.y)},lt:function(c){return(this.x<c.x&&this.y<c.y)},lte:function(c){return(this.x<=c.x&&this.y<=c.y)},gt:function(c){return(this.x>c.x&&this.y>c.y)},gte:function(c){return(this.x>=c.x&&this.y>=c.y)},lerp:function(d,c){return new a(this.x+(d.x-this.x)*c,this.y+(d.y-this.y)*c)},distanceFrom:function(e){var d=this.x-e.x,c=this.y-e.y;return Math.sqrt(d*d+c*c)},min:function(c){return new a(Math.min(this.x,c.x),Math.min(this.y,c.y))},max:function(c){return new a(Math.max(this.x,c.x),Math.max(this.y,c.y))},toString:function(){return this.x+","+this.y},setXY:function(c,d){this.x=c;this.y=d},setFromPoint:function(c){this.x=c.x;this.y=c.y},swap:function(d){var c=this.x,e=this.y;this.x=d.x;this.y=d.y;d.x=c;d.y=e}};b.Point=a})();(function(){var a=this,b=a.fabric||(a.fabric={});if(b.Intersection){console.warn("fabric.Intersection is already defined");return}function c(d){if(arguments.length>0){this.init(d)}}c.prototype.init=function(d){this.status=d;this.points=[]};c.prototype.appendPoint=function(d){this.points.push(d)};c.prototype.appendPoints=function(d){this.points=this.points.concat(d)};c.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};c.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};c.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};c.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};b.Intersection=c})();(function(){var a=this.fabric||(this.fabric={});if(a.Color){console.warn("fabric.Color is already defined.");return}a.Color=b;function b(c){if(!c){this.setSource([0,0,0,1])}else{this._tryParsingColor(c)}}b.prototype._tryParsingColor=function(c){var d=b.sourceFromHex(c);if(!d){d=b.sourceFromRgb(c)}if(d){this.setSource(d)}};b.prototype.getSource=function(){return this._source};b.prototype.setSource=function(c){this._source=c};b.prototype.toRgb=function(){var c=this.getSource();return"rgb("+c[0]+","+c[1]+","+c[2]+")"};b.prototype.toRgba=function(){var c=this.getSource();return"rgba("+c[0]+","+c[1]+","+c[2]+","+c[3]+")"};b.prototype.toHex=function(){var f=this.getSource();var e=f[0].toString(16);e=(e.length==1)?("0"+e):e;var d=f[1].toString(16);d=(d.length==1)?("0"+d):d;var c=f[2].toString(16);c=(c.length==1)?("0"+c):c;return e.toUpperCase()+d.toUpperCase()+c.toUpperCase()};b.prototype.getAlpha=function(){return this.getSource()[3]};b.prototype.setAlpha=function(d){var c=this.getSource();c[3]=d;this.setSource(c);return this};b.prototype.toGrayscale=function(){var e=this.getSource(),d=parseInt((e[0]*0.3+e[1]*0.59+e[2]*0.11).toFixed(0),10),c=e[3];this.setSource([d,d,d,c]);return this};b.prototype.toBlackWhite=function(c){var f=this.getSource(),e=(f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),d=f[3],c=c||127;e=(Number(e)<Number(c))?0:255;this.setSource([e,e,e,d]);return this};b.prototype.overlayWith=function(k){k=new b(k);var c=[],h=this.getAlpha(),f=0.5,g=this.getSource(),d=k.getSource();for(var e=0;e<3;e++){c.push(Math.round((g[e]*(1-f))+(d[e]*f)))}c[4]=h;this.setSource(c);return this};b.reRGBa=/^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;b.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;b.fromRgb=function(c){return b.fromSource(b.sourceFromRgb(c))};b.sourceFromRgb=function(c){var d=c.match(b.reRGBa);if(d){return[parseInt(d[1],10),parseInt(d[2],10),parseInt(d[3],10),d[4]?parseFloat(d[4]):1]}};b.fromRgba=b.fromRgb;b.fromHex=function(c){return b.fromSource(b.sourceFromHex(c))};b.sourceFromHex=function(e){if(e.match(b.reHex)){var k=e.slice(e.indexOf("#")+1),d=(k.length===3),h=d?(k.charAt(0)+k.charAt(0)):k.substring(0,2),f=d?(k.charAt(1)+k.charAt(1)):k.substring(2,4),c=d?(k.charAt(2)+k.charAt(2)):k.substring(4,6);return[parseInt(h,16),parseInt(f,16),parseInt(c,16),1]}};b.fromSource=function(c){var d=new b();d.setSource(c);return d}})();(function(){var c=this,h=c.window,k=h.document,d=c.Canvas||(c.Canvas={});if(fabric.Element){console.warn("fabric.Element is already defined.");return}var g=new Error("Could not initialize `canvas` element"),f=500,a=0.5,m="decel",o=fabric.base.getPointer,l={tr:"ne-resize",br:"se-resize",bl:"sw-resize",tl:"nw-resize",ml:"w-resize",mt:"n-resize",mr:"e-resize",mb:"s-resize"};var e=(function(){var v=k.createElement("canvas"),s,w,u,r,q=200,x=300;v.width=v.height=x;if(!v.getContext){return}var p=v.getContext("2d");if(!p){return}s=new Date();for(r=q;r--;){p.clearRect(0,0,x,x)}w=new Date()-s;s=new Date();for(r=q;r--;){v.width=v.height}u=new Date()-s;if(u<w){return"width"}})();function b(p){p.clearRect(0,0,this._oConfig.width,this._oConfig.height);return this}var n=(function(){var q=k.createElement("canvas");if(!q||!q.getContext){return}var p=q.getContext("2d");if(!p){return}try{p.fillStyle="transparent";return true}catch(r){}return false})();fabric.Element=function(p,q){this._groupSelector=null;this._aObjects=[];this._oContext=null;this._oElement=null;this._currentTransform=null;this._activeGroup=null;this._oConfig={width:300,height:150};q=q||{};this._initElement(p);this._initConfig(q);if(q.overlayImage){this.setOverlayImage(q.overlayImage)}if(q.afterRender){this.afterRender=q.afterRender}this._createCanvasBackground();this._createCanvasContainer();this._initEvents();this.calcOffset()};fabric.base.object.extend(fabric.Element.prototype,{selectionColor:"rgba(100,100,255,0.3)",selectionBorderColor:"rgba(255,255,255,0.3)",selectionLineWidth:1,backgroundColor:"rgba(255,255,255,1)",includeDefaultValues:true,shouldCacheImages:false,CANVAS_WIDTH:600,CANVAS_HEIGHT:600,onBeforeScaleRotate:function(){},calcOffset:function(){this._offset=fabric.base.getElementOffset(this.getElement());return this},setOverlayImage:function(q,s){if(q){var r=this,p=new Image();p.onload=function(){r.overlayImage=p;if(s){s()}p=p.onload=null};p.src=q}return this},_initElement:function(q){var s=fabric.base.getById(q);this._oElement=s||k.createElement("canvas");if(typeof this._oElement.getContext==="undefined"){G_vmlCanvasManager.initElement(this._oElement)}if(typeof this._oElement.getContext==="undefined"){throw g}if(!(this._oContextTop=this._oElement.getContext("2d"))){throw g}var r=this._oElement.width||0,p=this._oElement.height||0;this._initWrapperElement(r,p);this._setElementStyle(r,p)},_initWrapperElement:function(q,p){var r=fabric.base.wrapElement(this.getElement(),"div",{className:"canvas_container"});fabric.base.setStyle(r,{width:q+"px",height:p+"px"});fabric.base.makeElementUnselectable(r);this.wrapper=r},_setElementStyle:function(q,p){fabric.base.setStyle(this.getElement(),{position:"absolute",width:q+"px",height:p+"px",left:0,top:0})},_initConfig:function(p){fabric.base.object.extend(this._oConfig,p||{});this._oConfig.width=parseInt(this._oElement.width,10)||0;this._oConfig.height=parseInt(this._oElement.height,10)||0;this._oElement.style.width=this._oConfig.width+"px";this._oElement.style.height=this._oConfig.height+"px"},_initEvents:function(){var p=this;this._onMouseDown=function(q){p.__onMouseDown(q)};this._onMouseUp=function(q){p.__onMouseUp(q)};this._onMouseMove=function(q){p.__onMouseMove(q)};this._onResize=function(q){p.calcOffset()};fabric.base.addListener(this._oElement,"mousedown",this._onMouseDown);fabric.base.addListener(k,"mousemove",this._onMouseMove);fabric.base.addListener(k,"mouseup",this._onMouseUp);fabric.base.addListener(h,"resize",this._onResize)},_createCanvasElement:function(r){var q=k.createElement("canvas");if(!q){return}q.className=r;var p=this._oElement.parentNode.insertBefore(q,this._oElement);p.width=this.getWidth();p.height=this.getHeight();p.style.width=this.getWidth()+"px";p.style.height=this.getHeight()+"px";p.style.position="absolute";p.style.left=0;p.style.top=0;if(typeof q.getContext==="undefined"){G_vmlCanvasManager.initElement(q)}if(typeof q.getContext==="undefined"){throw g}fabric.base.makeElementUnselectable(p);return p},_createCanvasContainer:function(){var p=this._createCanvasElement("canvas-container");this._oContextContainerEl=p;this._oContextContainer=p.getContext("2d")},_createCanvasBackground:function(){var p=this._createCanvasElement("canvas-container");this._oContextBackgroundEl=p;this._oContextBackground=p.getContext("2d")},getWidth:function(){return this._oConfig.width},getHeight:function(){return this._oConfig.height},setWidth:function(p){return this._setDimension("width",p)},setHeight:function(p){return this._setDimension("height",p)},setDimensions:function(p){for(var q in p){this._setDimension(q,p[q])}return this},_setDimension:function(q,p){this._oContextContainerEl[q]=p;this._oContextContainerEl.style[q]=p+"px";this._oContextBackgroundEl[q]=p;this._oContextBackgroundEl.style[q]=p+"px";this._oElement[q]=p;this._oElement.style[q]=p+"px";this._oElement.parentNode.style[q]=p+"px";this._oConfig[q]=p;this.calcOffset();this.renderAll();return this},__onMouseUp:function(u){if(this._currentTransform){var q=this._currentTransform,t=q.target;if(t.__scaling){fabric.base.fireEvent("object:scaled",{target:t});t.__scaling=false}for(var r=0,p=this._aObjects.length;r<p;++r){this._aObjects[r].setCoords()}if(t.hasStateChanged()){t.isMoving=false;fabric.base.fireEvent("object:modified",{target:t})}}this._currentTransform=null;if(this._groupSelector){this._findSelectedObjects(u)}var s=this.getActiveGroup();if(s){if(s.hasStateChanged()&&s.containsPoint(this.getPointer(u))){fabric.base.fireEvent("group:modified",{target:s})}s.setObjectsCoords();s.set("isMoving",false);this._setCursor("default")}this._groupSelector=null;this.renderAll();this._setCursorFromEvent(u,t);this._setCursor("");var v=this;setTimeout(function(){v._setCursorFromEvent(u,t)},50)},shouldClearSelection:function(r){var q=this.findTarget(r),p=this.getActiveGroup();return(!q||(q&&p&&!p.contains(q)&&p!==q&&!r.shiftKey))},__onMouseDown:function(t){if(this._currentTransform){return}var s=this.findTarget(t),u=this.getPointer(t),q=this.getActiveGroup(),r;if(this.shouldClearSelection(t)){this._groupSelector={ex:u.x,ey:u.y,top:0,left:0};this.deactivateAllWithDispatch()}else{s.saveState();if(r=s._findTargetCorner(t,this._offset)){this.onBeforeScaleRotate(s)}this._setupCurrentTransform(t,s);var p=t.shiftKey&&(q||this.getActiveObject());if(p){this._handleGroupLogic(t,s)}else{if(s!==this.getActiveGroup()){this.deactivateAll()}this.setActiveObject(s)}}this.renderAll()},getElement:function(){return this._oElement},deactivateAllWithDispatch:function(){var p=this.getActiveGroup();if(p){fabric.base.fireEvent("before:group:destroyed",{target:p})}this.deactivateAll();if(p){fabric.base.fireEvent("after:group:destroyed")}fabric.base.fireEvent("selection:cleared");return this},_setupCurrentTransform:function(s,r){var q="drag",p,t=o(s);if(p=r._findTargetCorner(s,this._offset)){q=/ml|mr/.test(p)?"scaleX":/mt|mb/.test(p)?"scaleY":"rotate"}this._currentTransform={target:r,action:q,scaleX:r.scaleX,scaleY:r.scaleY,offsetX:t.x-r.left,offsetY:t.y-r.top,ex:t.x,ey:t.y,left:r.left,top:r.top,theta:r.theta,width:r.width*r.scaleX};this._currentTransform.original={left:r.left,top:r.top}},_handleGroupLogic:function(s,r){if(r.isType("group")){r=this.findTarget(s,true);if(!r||r.isType("group")){return}}var p=this.getActiveGroup();if(p){if(p.contains(r)){p.remove(r);r.setActive(false);if(p.size()===1){this.removeActiveGroup()}}else{p.add(r)}fabric.base.fireEvent("group:selected",{target:p});p.setActive(true)}else{if(this._activeObject){if(r!==this._activeObject){var q=new fabric.Group([this._activeObject,r]);this.setActiveGroup(q);p=this.getActiveGroup()}}r.setActive(true)}if(p){p.saveCoords()}},__onMouseMove:function(t){if(this._groupSelector!==null){var u=o(t);this._groupSelector.left=u.x-this._offset.left-this._groupSelector.ex;this._groupSelector.top=u.y-this._offset.top-this._groupSelector.ey;this.renderTop()}else{if(!this._currentTransform){var r=this._oElement.style;var s=this.findTarget(t);if(!s){for(var q=this._aObjects.length;q--;){if(!this._aObjects[q].active){this._aObjects[q].setActive(false)}}r.cursor="default"}else{this._setCursorFromEvent(t,s);if(s.isActive()){s.setCornersVisibility&&s.setCornersVisibility(true)}}}else{var u=o(t),p=u.x,v=u.y;this._currentTransform.target.isMoving=true;if(this._currentTransform.action==="rotate"){if(!t.shiftKey){this._rotateObject(p,v)}this._scaleObject(p,v)}else{if(this._currentTransform.action==="scaleX"){this._scaleObject(p,v,"x")}else{if(this._currentTransform.action==="scaleY"){this._scaleObject(p,v,"y")}else{this._translateObject(p,v)}}}this.renderAll()}}},_translateObject:function(p,r){var q=this._currentTransform.target;q.set("left",p-this._currentTransform.offsetX);q.set("top",r-this._currentTransform.offsetY)},_scaleObject:function(p,u,t){var s=Math.sqrt(Math.pow(this._currentTransform.ey-this._currentTransform.top-this._offset.top,2)+Math.pow(this._currentTransform.ex-this._currentTransform.left-this._offset.left,2));var q=Math.sqrt(Math.pow(u-this._currentTransform.top-this._offset.top,2)+Math.pow(p-this._currentTransform.left-this._offset.left,2));var r=this._currentTransform.target;r.__scaling=true;if(!t){r.set("scaleX",this._currentTransform.scaleX*q/s);r.set("scaleY",this._currentTransform.scaleY*q/s)}else{if(t==="x"){r.set("scaleX",this._currentTransform.scaleX*q/s)}else{if(t==="y"){r.set("scaleY",this._currentTransform.scaleY*q/s)}}}},_rotateObject:function(p,s){var q=Math.atan2(this._currentTransform.ey-this._currentTransform.top-this._offset.top,this._currentTransform.ex-this._currentTransform.left-this._offset.left);var r=Math.atan2(s-this._currentTransform.top-this._offset.top,p-this._currentTransform.left-this._offset.left);this._currentTransform.target.set("theta",(r-q)+this._currentTransform.theta)},_setCursor:function(p){this._oElement.style.cursor=p},_setCursorFromEvent:function(u,t){var q=this._oElement.style;if(!t){q.cursor="default";return false}else{var p=this.getActiveGroup();var r=!!t._findTargetCorner&&(!p||!p.contains(t))&&t._findTargetCorner(u,this._offset);if(!r){q.cursor="move"}else{if(r in l){q.cursor=l[r]}else{q.cursor="default";return false}}}return true},_draw:function(p,q){q&&q.render(p)},_drawSelection:function(){var s=this._groupSelector.left,r=this._groupSelector.top,q=Math.abs(s),p=Math.abs(r);this._oContextTop.fillStyle=this.selectionColor;this._oContextTop.fillRect(this._groupSelector.ex-((s>0)?0:-s),this._groupSelector.ey-((r>0)?0:-r),q,p);this._oContextTop.lineWidth=this.selectionLineWidth;this._oContextTop.strokeStyle=this.selectionBorderColor;this._oContextTop.strokeRect(this._groupSelector.ex+a-((s>0)?0:q),this._groupSelector.ey+a-((r>0)?0:p),q,p)},_findSelectedObjects:function(v){var w,r,B=[],q=this._groupSelector.ex,A=this._groupSelector.ey,p=q+this._groupSelector.left,y=A+this._groupSelector.top,x,u=new fabric.Point(Math.min(q,p),Math.min(A,y)),z=new fabric.Point(Math.max(q,p),Math.max(A,y));for(var s=0,t=this._aObjects.length;s<t;++s){x=this._aObjects[s];if(x.intersectsWithRect(u,z)||x.isContainedWithinRect(u,z)){x.setActive(true);B.push(x)}}if(B.length===1){this.setActiveObject(B[0]);fabric.base.fireEvent("object:selected",{target:B[0]})}else{if(B.length>1){var B=new fabric.Group(B);this.setActiveGroup(B);B.saveCoords();fabric.base.fireEvent("group:selected",{target:B})}}this.renderAll()},add:function(){this._aObjects.push.apply(this._aObjects,arguments);this.renderAll();return this},insertAt:function(q,p){this._aObjects.splice(p,0,q);this.renderAll();return this},getObjects:function(){return this._aObjects},getContext:function(){return this._oContextTop},clearContext:b,clear:function(){this._aObjects.length=0;this.clearContext(this._oContextTop);this.clearContext(this._oContextContainer);this.renderAll();return this},renderAll:function(q){var p=this._oConfig.width,t=this._oConfig.height;var x=q?this._oContextTop:this._oContextContainer;this.clearContext(this._oContextTop);if(x!==this._oContextTop){this.clearContext(x)}if(q){if(!n&&this.backgroundColor==="transparent"){var v=true}if(!v){x.fillStyle=this.backgroundColor}x.fillRect(0,0,p,t)}var u=this._aObjects.length,s=this.getActiveGroup();if(u){for(var r=0;r<u;++r){if(!s||(s&&!s.contains(this._aObjects[r]))){this._draw(x,this._aObjects[r])}}}if(s){this._draw(this._oContextTop,s)}if(this.overlayImage){this._oContextTop.drawImage(this.overlayImage,0,0)}if(this.afterRender){this.afterRender()}return this},renderTop:function(){this.clearContext(this._oContextTop);if(this.overlayImage){this._oContextTop.drawImage(this.overlayImage,0,0)}if(this._groupSelector){this._drawSelection()}var p=this.getActiveGroup();if(p){p.render(this._oContextTop)}if(this.afterRender){this.afterRender()}return this},containsPoint:function(u,t){var v=this.getPointer(u),s=this._normalizePointer(t,v),p=s.x,w=s.y;var q=t._getImageLines(t.oCoords),r=t._findCrossPoints(p,w,q);if((r&&r%2===1)||t._findTargetCorner(u,this._offset)){return true}return false},_normalizePointer:function(q,t){var s=this.getActiveGroup(),p=t.x,u=t.y;var r=(s&&q.type!=="group"&&s.contains(q));if(r){p-=s.left;u-=s.top}return{x:p,y:u}},findTarget:function(t,q){var s,u=this.getPointer(t);var r=this.getActiveGroup();if(r&&!q&&this.containsPoint(t,r)){s=r;return s}for(var p=this._aObjects.length;p--;){if(this.containsPoint(t,this._aObjects[p])){s=this._aObjects[p];this.relatedTarget=s;break}}return s},toDataURL:function(q){var p;if(!q){q="png"}if(q==="jpeg"||q==="png"){this.renderAll(true);p=this.getElement().toDataURL("image/"+q)}return p},toDataURLWithMultiplier:function(s,w){var v=this.getWidth(),u=this.getHeight(),q=v*w,r=u*w,p=this.getActiveObject();this.setWidth(q).setHeight(r);this._oContextTop.scale(w,w);if(p){this.deactivateAll().renderAll()}var t=this.toDataURL(s);this._oContextTop.scale(1/w,1/w);this.setWidth(v).setHeight(u);if(p){this.setActiveObject(p)}this.renderAll();return t},getPointer:function(p){var q=o(p);return{x:q.x-this._offset.left,y:q.y-this._offset.top}},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(p){p.set("left",this.getCenter().left);this.renderAll();return this},fxCenterObjectH:function(r){var u=this,t=new APE.anim.Animation(),q=r.get("left"),p=u.getCenter().left,s=p-q;t.run=function(v){r.set("left",q+s*v);u.renderAll()};t.onend=function(){r.setCoords()};t.duration=f;t.transition=APE.anim.Transitions[m];t.start();return this},centerObjectV:function(p){p.set("top",this.getCenter().top);this.renderAll();return this},fxCenterObjectV:function(r){var u=this,t=new APE.anim.Animation(),q=r.get("top"),p=u.getCenter().top,s=p-q;t.run=function(v){r.set("top",q+s*v).setCoords();u.renderAll()};t.onend=function(){r.setCoords()};t.duration=f;t.transition=APE.anim.Transitions[m];t.start()},straightenObject:function(p){p.straighten();this.renderAll();return this},fxStraightenObject:function(p){p.fxStraighten({onChange:this.renderAll.bind(this)});return this},toJSON:function(){return JSON.stringify(this.toObject())},toDatalessJSON:function(){return JSON.stringify(this.toDatalessObject())},toObject:function(){return this._toObjectMethod("toObject")},toDatalessObject:function(){return this._toObjectMethod("toDatalessObject")},_toObjectMethod:function(p){return{objects:this._aObjects.map(function(q){if(!this.includeDefaultValues){var r=q.includeDefaultValues;q.includeDefaultValues=false}var s=q[p]();if(!this.includeDefaultValues){q.includeDefaultValues=r}return s},this),background:this.backgroundColor}},isEmpty:function(){return this._aObjects.length===0},loadFromJSON:function(p,s){if(!p){return}var q=JSON.parse(p);if(!q||(q&&!q.objects)){return}this.clear();var r=this;this._enlivenObjects(q.objects,function(){r.backgroundColor=q.background;if(s){s()}});return this},_enlivenObjects:function(q,t){var r=0,p=q.filter(function(u){return u.type==="image"}).length;var s=this;q.forEach(function(v){if(!v.type){return}switch(v.type){case"image":case"font":fabric[fabric.base.string.capitalize(v.type)].fromObject(v,function(w){s.add(w);if(++r===p){if(t){t()}}});break;default:var u=fabric[fabric.base.string.camelize(fabric.base.string.capitalize(v.type))];if(u&&u.fromObject){s.add(u.fromObject(v))}break}});if(p===0&&t){t()}},loadFromDatalessJSON:function(p,r){if(!p){return}var q=(typeof p==="string")?p.evalJSON():p;if(!q||(q&&!q.objects)){return}this.clear();this._enlivenDatalessObjects(q.objects,r)},_enlivenDatalessObjects:function(q,v){function u(x,w){t.insertAt(x,w);x.setCoords();if(++s===p){v&&v()}}var t=this,s=0,p=q.length;try{q.forEach(function(C,A){var x=C.paths?"paths":"path";var B=C[x];delete C[x];if(typeof B!=="string"){switch(C.type){case"image":case"text":d[C.type.capitalize()].fromObject(C,function(D){u(D)});break;default:var w=d[C.type.capitalize().camelize()];if(w&&w.fromObject){u(w.fromObject(C))}break}}else{if(C.type==="image"){t.loadImageFromURL(B,function(D){D.setSourcePath(B);fabric.base.object.extend(D,C);D.setAngle(C.angle);u(D,A)})}else{if(C.type==="text"){C.path=B;var z=fabric.Text.fromObject(C);h.__context=t;var y=function(){if(Prototype.Browser.Opera){setTimeout(function(){u(z,A)},500)}else{u(z,A)}};fabric.base.getScript(B,y)}else{t.loadSVGFromURL(B,function(F,E){if(F.length>1){var D=new fabric.PathGroup(F,C)}else{var D=F[0]}D.setSourcePath(B);if(!(D instanceof fabric.PathGroup)){fabric.base.object.extend(D,C);if(typeof C.angle!=="undefined"){D.setAngle(C.angle)}}u(D,A)})}}}},this)}catch(r){console.log(r.message)}},loadImageFromURL:(function(){var p={};return function(q,u){var t=this;function r(){var v=k.getElementById(p[q]);if(v.width&&v.height){u(new fabric.Image(v))}else{setTimeout(r,50)}}if(p[q]){r()}else{var s=new Image();s.onload=function(){s.onload=null;t._resizeImageToFit(s);var v=new fabric.Image(s);u(v)};s.className="canvas-img-clone";s.src=q;if(this.shouldCacheImages){p[q]=Element.identify(s)}k.body.appendChild(s)}}})(),loadSVGFromURL:function(p,t){var s=this;p=p.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(p,function(u){if(u){s.cache.get(p,function(w){var v=s._enlivenCachedObject(w);t(v.objects,v.options)})}else{new Ajax.Request(p,{method:"get",onComplete:r,onFailure:q})}});function r(v){var u=v.responseXML;if(!u){return}var w=u.documentElement;if(!w){return}fabric.parseSVGDocument(w,function(y,x){s.cache.set(p,{objects:y.invoke("toObject"),options:x});t(y,x)})}function q(){console.log("ERROR!")}},_enlivenCachedObject:function(r){var q=r.objects;var p=r.options;q=q.map(function(s){return d[s.type.capitalize()].fromObject(s)});return({objects:q,options:p})},remove:function(p){fabric.util.removeFromArray(this._aObjects,p);this.renderAll();return p},fxRemove:function(p,r){var q=this;p.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){q.remove(p);if(typeof r==="function"){r()}}});return this},sendToBack:function(p){fabric.util.removeFromArray(this._aObjects,p);this._aObjects.unshift(p);return this.renderAll()},bringToFront:function(p){fabric.util.removeFromArray(this._aObjects,p);this._aObjects.push(p);return this.renderAll()},sendBackwards:function(r){var q=this._aObjects.indexOf(r),p=q;if(q!==0){for(var s=q-1;s>=0;--s){if(r.intersectsWithObject(this._aObjects[s])){p=s;break}}fabric.util.removeFromArray(this._aObjects,r);this._aObjects.splice(p,0,r)}return this.renderAll()},bringForward:function(s){var u=this.getObjects(),q=u.indexOf(s),p=q;if(q!==u.length-1){for(var t=q+1,r=this._aObjects.length;t<r;++t){if(s.intersectsWithObject(u[t])){p=t;break}}fabric.util.removeFromArray(u,s);u.splice(p,0,s)}this.renderAll()},setActiveObject:function(p){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=p;p.setActive(true);this.renderAll();fabric.base.fireEvent("object:selected",{target:p});return this},getActiveObject:function(){return this._activeObject},removeActiveObject:function(){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=null;return this},setActiveGroup:function(p){this._activeGroup=p;return this},getActiveGroup:function(){return this._activeGroup},removeActiveGroup:function(){var p=this.getActiveGroup();if(p){p.destroy()}return this.setActiveGroup(null)},item:function(p){return this.getObjects()[p]},deactivateAll:function(){var q=this.getObjects(),r=0,p=q.length;for(;r<p;r++){q[r].setActive(false)}this.removeActiveGroup();this.removeActiveObject();return this},complexity:function(){return this.getObjects().reduce(function(p,q){p+=q.complexity?q.complexity():0;return p},0)},dispose:function(){this.clear();fabric.base.removeListener(this.getElement(),"mousedown",this._onMouseDown);fabric.base.removeListener(k,"mouseup",this._onMouseUp);fabric.base.removeListener(k,"mousemove",this._onMouseMove);fabric.base.removeListener(h,"resize",this._onResize);return this},clone:function(r){var p=k.createElement("canvas");p.width=this.getWidth();p.height=this.getHeight();var q=this.__clone||(this.__clone=new fabric.Element(p));return q.loadFromJSON(this.toJSON(),function(){if(r){r(q)}})},_toDataURL:function(p,q){this.clone(function(r){q(r.toDataURL(p))})},_toDataURLWithMultiplier:function(p,r,q){this.clone(function(s){q(s.toDataURLWithMultiplier(p,r))})},_resizeImageToFit:function(t){var s=t.width||t.offsetWidth,p=t.height||t.offsetHeight,r=this.getWidth()/s,q=this.getHeight()/p;if(s&&p){t.width=s*r;t.height=p*q}},cache:{has:function(p,q){q(false)},get:function(){},set:function(){}}});fabric.Element.prototype.toString=function(){return"#<fabric.Element ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"};fabric.base.object.extend(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(s){var r=s.getContext("2d"),w=r.getImageData(0,0,s.width,s.height),u=w.data,p=w.width,v=w.height,q,t;for(i=0;i<p;i++){for(j=0;j<v;j++){q=(i*4)*v+(j*4);t=(u[q]+u[q+1]+u[q+2])/3;u[q]=t;u[q+1]=t;u[q+2]=t}}r.putImageData(w,0,0)},supports:function(q){var r=k.createElement("canvas");if(!r||!r.getContext){return null}var p=r.getContext("2d");if(!p){return null}switch(q){case"getImageData":return typeof p.getImageData!=="undefined";case"toDataURL":return typeof r.toDataURL!=="undefined";default:return null}}})})();(function(){var b=this,c=b.fabric||(b.fabric={});if(c.Object){return}var a=Array.prototype.slice;c.Object=c.base.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(" "),options:{top:0,left:0,width:100,height:100,scaleX:1,scaleY:1,flipX:false,flipY:false,theta:0,opacity:1,angle:0,cornersize:10,padding:0,borderColor:"rgba(102,153,255,0.75)",cornerColor:"rgba(102,153,255,0.5)",fill:"rgb(0,0,0)",overlayFill:null,stroke:null,strokeWidth:1,fillRule:"source-over",borderOpacityWhenMoving:0.4,borderScaleFactor:1,transformMatrix:null},callSuper:function(d){var e=this.constructor.superclass.prototype[d];return(arguments.length>1)?e.apply(this,a.call(arguments,1)):e.call(this)},initialize:function(d){this.setOptions(d);this._importProperties();this.originalState={};this.setCoords();this.saveState()},setOptions:function(d){this.options=c.base.object.extend(this._getOptions(),d)},_getOptions:function(){return c.base.object.extend(c.base.object.clone(this._getSuperOptions()),this.options)},_getSuperOptions:function(){var f=this.constructor;if(f){var d=f.superclass;if(d){var e=d.prototype;if(e&&typeof e._getOptions=="function"){return e._getOptions()}}}return{}},_importProperties:function(){this.stateProperties.forEach(function(d){(d==="angle")?this.setAngle(this.options[d]):(this[d]=this.options[d])},this)},transform:function(d){d.globalAlpha=this.opacity;d.translate(this.left,this.top);d.rotate(this.theta);d.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toJSON:function(){return JSON.stringify(this.toObject())},toObject:function(){var d=c.util.toFixed;var e={type:this.type,left:d(this.left,this.NUM_FRACTION_DIGITS),top:d(this.top,this.NUM_FRACTION_DIGITS),width:d(this.width,this.NUM_FRACTION_DIGITS),height:d(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,scaleX:d(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:d(this.scaleY,this.NUM_FRACTION_DIGITS),angle:d(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:d(this.opacity,this.NUM_FRACTION_DIGITS)};if(!this.includeDefaultValues){e=this._removeDefaultValues(e)}return e},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(e){var d=c.Object.prototype.options;this.stateProperties.forEach(function(f){if(e[f]===d[f]){delete e[f]}});return e},isActive:function(){return !!this.active},setActive:function(d){this.active=!!d;return this},toString:function(){return"#<fabric."+c.base.string.capitalize(this.type)+">"},set:function(e,d){var f=(e==="scaleX"||e==="scaleY")&&d<this.MIN_SCALE_LIMIT;if(f){d=this.MIN_SCALE_LIMIT}if(e==="angle"){this.setAngle(d)}else{this[e]=d}return this},toggle:function(e){var d=this.get(e);if(typeof d==="boolean"){this.set(e,!d)}return this},setSourcePath:function(d){this.sourcePath=d;return this},get:function(d){return(d==="angle")?this.getAngle():this[d]},render:function(e,f){if(this.width===0||this.height===0){return}e.save();var d=this.transformMatrix;if(d){e.setTransform(d[0],d[1],d[2],d[3],d[4],d[5])}if(!f){this.transform(e)}if(this.stroke){e.lineWidth=this.strokeWidth;e.strokeStyle=this.stroke}if(this.overlayFill){e.fillStyle=this.overlayFill}else{if(this.fill){e.fillStyle=this.fill}}this._render(e);if(this.active&&!f){this.drawBorders(e);this.drawCorners(e)}e.restore()},getWidth:function(){return this.width*this.scaleX},getHeight:function(){return this.height*this.scaleY},scale:function(d){this.scaleX=d;this.scaleY=d;return this},scaleToWidth:function(d){return this.scale(d/this.width)},scaleToHeight:function(d){return this.scale(d/this.height)},setOpacity:function(d){this.set("opacity",d);return this},getAngle:function(){return this.theta*180/Math.PI},setAngle:function(d){this.theta=d/180*Math.PI;this.angle=d;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 l=Math.cos(this._angle+this.theta)*this._hypotenuse,k=Math.sin(this._angle+this.theta)*this._hypotenuse,f=this.theta,o=Math.sin(f),m=Math.cos(f);var r={x:this.left-l,y:this.top-k};var n={x:r.x+(this.currentWidth*m),y:r.y+(this.currentWidth*o)};var q={x:n.x-(this.currentHeight*o),y:n.y+(this.currentHeight*m)};var g={x:r.x-(this.currentHeight*o),y:r.y+(this.currentHeight*m)};var h={x:r.x-(this.currentHeight/2*o),y:r.y+(this.currentHeight/2*m)};var d={x:r.x+(this.currentWidth/2*m),y:r.y+(this.currentWidth/2*o)};var e={x:n.x-(this.currentHeight/2*o),y:n.y+(this.currentHeight/2*m)};var p={x:g.x+(this.currentWidth/2*m),y:g.y+(this.currentWidth/2*o)};this.oCoords={tl:r,tr:n,br:q,bl:g,ml:h,mt:d,mr:e,mb:p};this._setCornerCoords();return this},drawBorders:function(e){var n=this.options,m=n.padding,g=m*2;e.save();e.globalAlpha=this.isMoving?n.borderOpacityWhenMoving:1;e.strokeStyle=n.borderColor;var k=1/(this.scaleX<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleX);var f=1/(this.scaleY<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleY);e.lineWidth=1/this.borderScaleFactor;e.scale(k,f);var d=this.getWidth(),l=this.getHeight();e.strokeRect(Math.floor(-(d/2)-m)+0.5,Math.floor(-(l/2)-m)+0.5,Math.floor(d+g),Math.floor(l+g));e.restore();return this},drawCorners:function(q){var s=this.options.cornersize,o=s/2,n=this.options.padding,f=-(this.width/2),m=-(this.height/2),r,p,e=s/this.scaleX,d=s/this.scaleY,g=(n+o)/this.scaleY,h=(n+o)/this.scaleX,l=(n+o-s)/this.scaleX,k=(n+o-s)/this.scaleY;q.save();q.globalAlpha=this.isMoving?this.options.borderOpacityWhenMoving:1;q.fillStyle=this.options.cornerColor;r=f-h;p=m-g;q.fillRect(r,p,e,d);r=f+this.width-h;p=m-g;q.fillRect(r,p,e,d);r=f-h;p=m+this.height+k;q.fillRect(r,p,e,d);r=f+this.width+l;p=m+this.height+k;q.fillRect(r,p,e,d);r=f+this.width/2-h;p=m-g;q.fillRect(r,p,e,d);r=f+this.width/2-h;p=m+this.height+k;q.fillRect(r,p,e,d);r=f+this.width+l;p=m+this.height/2-g;q.fillRect(r,p,e,d);r=f-h;p=m+this.height/2-g;q.fillRect(r,p,e,d);q.restore();return this},clone:function(d){if(this.constructor.fromObject){return this.constructor.fromObject(this.toObject(),d)}return new c.Object(this.toObject())},cloneAsImage:function(f){if(c.Image){var d=new Image();d.onload=function(){if(f){f(new c.Image(d),e)}d=d.onload=null};var e={angle:this.get("angle"),flipX:this.get("flipX"),flipY:this.get("flipY")};this.set("angle",0).set("flipX",false).set("flipY",false);d.src=this.toDataURL()}return this},toDataURL:function(){var e=document.createElement("canvas");e.width=this.getWidth();e.height=this.getHeight();c.base.wrapElement(e,"div");var d=new c.Element(e);d.backgroundColor="transparent";d.renderAll();var g=this.clone();g.left=e.width/2;g.top=e.height/2;g.setActive(false);d.add(g);var f=d.toDataURL("png");d.dispose();d=g=null;return f},hasStateChanged:function(){return this.stateProperties.some(function(d){return this[d]!==this.originalState[d]},this)},saveState:function(){this.stateProperties.forEach(function(d){this.originalState[d]=this.get(d)},this);return this},intersectsWithRect:function(f,h){var m=this.oCoords,d=new c.Point(m.tl.x,m.tl.y),g=new c.Point(m.tr.x,m.tr.y),l=new c.Point(m.bl.x,m.bl.y),e=new c.Point(m.br.x,m.br.y);var k=c.Intersection.intersectPolygonRectangle([d,g,e,l],f,h);return(k.status==="Intersection")},intersectsWithObject:function(d){function e(k){return{tl:new c.Point(k.tl.x,k.tl.y),tr:new c.Point(k.tr.x,k.tr.y),bl:new c.Point(k.bl.x,k.bl.y),br:new c.Point(k.br.x,k.br.y)}}var f=e(this.oCoords),h=e(d.oCoords);var g=c.Intersection.intersectPolygonPolygon([f.tl,f.tr,f.br,f.bl],[h.tl,h.tr,h.br,h.bl]);return(g.status==="Intersection")},isContainedWithinRect:function(f,h){var l=this.oCoords,d=new c.Point(l.tl.x,l.tl.y),g=new c.Point(l.tr.x,l.tr.y),k=new c.Point(l.bl.x,l.bl.y),e=new c.Point(l.br.x,l.br.y);return d.x>f.x&&g.x<h.x&&d.y>f.y&&k.y<h.y},isType:function(d){return this.type===d},_findTargetCorner:function(l,n){var m=c.base.getPointer(l),k=m.x-n.left,f=m.y-n.top,h,d;for(var g in this.oCoords){d=this._getImageLines(this.oCoords[g].corner,g);h=this._findCrossPoints(k,f,d);if(h%2==1&&h!=0){this.__corner=g;return g}}return false},_findCrossPoints:function(m,l,d){var p,o,f,e,n,k,h=0,g;for(var q in d){g=d[q];if((g.o.y<l)&&(g.d.y<l)){continue}if((g.o.y>=l)&&(g.d.y>=l)){continue}if((g.o.x==g.d.x)&&(g.o.x>=m)){n=g.o.x;k=l}else{p=0;o=(g.d.y-g.o.y)/(g.d.x-g.o.x);f=l-p*m;e=g.o.y-o*g.o.x;n=-(f-e)/(p-o);k=f+p*n}if(n>=m){h+=1}if(h==2){break}}return h},_getImageLines:function(e,d){return{topline:{o:e.tl,d:e.tr},rightline:{o:e.tr,d:e.br},bottomline:{o:e.br,d:e.bl},leftline:{o:e.bl,d:e.tl}}},_setCornerCoords:function(){var m=this.oCoords,h=this.theta,g=this.cornersize*Math.cos(h),f=this.cornersize*Math.sin(h),k=this.cornersize/2,e=k-f,d=k,l;m.tl.x-=e;m.tl.y-=d;m.tl.corner={tl:{x:m.tl.x,y:m.tl.y},tr:{x:m.tl.x+g,y:m.tl.y+f},bl:{x:m.tl.x-f,y:m.tl.y+g}};m.tl.corner.br={x:m.tl.corner.tr.x-f,y:m.tl.corner.tr.y+g};m.tl.x+=e;m.tl.y+=d;m.tr.x+=k;m.tr.y-=k;m.tr.corner={tl:{x:m.tr.x-g,y:m.tr.y-f},tr:{x:m.tr.x,y:m.tr.y},br:{x:m.tr.x-f,y:m.tr.y+g}};m.tr.corner.bl={x:m.tr.corner.tl.x-f,y:m.tr.corner.tl.y+g};m.tr.x-=k;m.tr.y+=k;m.bl.x-=k;m.bl.y+=k;m.bl.corner={tl:{x:m.bl.x+f,y:m.bl.y-g},bl:{x:m.bl.x,y:m.bl.y},br:{x:m.bl.x+g,y:m.bl.y+f}};m.bl.corner.tr={x:m.bl.corner.br.x+f,y:m.bl.corner.br.y-g};m.bl.x+=k;m.bl.y-=k;m.br.x+=k;m.br.y+=k;m.br.corner={tr:{x:m.br.x+f,y:m.br.y-g},bl:{x:m.br.x-g,y:m.br.y-f},br:{x:m.br.x,y:m.br.y}};m.br.corner.tl={x:m.br.corner.bl.x+f,y:m.br.corner.bl.y-g};m.br.x-=k;m.br.y-=k;m.ml.x-=k;m.ml.y-=k;m.ml.corner={tl:{x:m.ml.x,y:m.ml.y},tr:{x:m.ml.x+g,y:m.ml.y+f},bl:{x:m.ml.x-f,y:m.ml.y+g}};m.ml.corner.br={x:m.ml.corner.tr.x-f,y:m.ml.corner.tr.y+g};m.ml.x+=k;m.ml.y+=k;m.mt.x-=k;m.mt.y-=k;m.mt.corner={tl:{x:m.mt.x,y:m.mt.y},tr:{x:m.mt.x+g,y:m.mt.y+f},bl:{x:m.mt.x-f,y:m.mt.y+g}};m.mt.corner.br={x:m.mt.corner.tr.x-f,y:m.mt.corner.tr.y+g};m.mt.x+=k;m.mt.y+=k;m.mr.x-=k;m.mr.y-=k;m.mr.corner={tl:{x:m.mr.x,y:m.mr.y},tr:{x:m.mr.x+g,y:m.mr.y+f},bl:{x:m.mr.x-f,y:m.mr.y+g}};m.mr.corner.br={x:m.mr.corner.tr.x-f,y:m.mr.corner.tr.y+g};m.mr.x+=k;m.mr.y+=k;m.mb.x-=k;m.mb.y-=k;m.mb.corner={tl:{x:m.mb.x,y:m.mb.y},tr:{x:m.mb.x+g,y:m.mb.y+f},bl:{x:m.mb.x-f,y:m.mb.y+g}};m.mb.corner.br={x:m.mb.corner.tr.x-f,y:m.mb.corner.tr.y+g};m.mb.x+=k;m.mb.y+=k;l=m.mb.corner;l.tl.x-=k;l.tl.y-=k;l.tr.x-=k;l.tr.y-=k;l.br.x-=k;l.br.y-=k;l.bl.x-=k;l.bl.y-=k},toGrayscale:function(){var d=this.get("fill");if(d){this.set("overlayFill",new c.Color(d).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 d=this._getAngleValueForStraighten();this.setAngle(d);return this},fxStraighten:function(e){e=e||{};var f=function(){},g=e.onComplete||f,d=e.onChange||f,h=this;c.base.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(k){h.setAngle(k);d()},onComplete:function(){h.setCoords();g()},onStart:function(){h.setActive(false)}});return this},fxRemove:function(e){e||(e={});var f=function(){},g=e.onComplete||f,d=e.onChange||f,h=this;c.base.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(k){h.set("opacity",k);d()},onComplete:g,onStart:function(){h.setActive(false)}});return this},_getAngleValueForStraighten:function(){var d=this.get("angle");if(d>-225&&d<=-135){return -180}else{if(d>-135&&d<=-45){return -90}else{if(d>-45&&d<=45){return 0}else{if(d>45&&d<=135){return 90}else{if(d>135&&d<=225){return 180}else{if(d>225&&d<=315){return 270}else{if(d>315){return 360}}}}}}}return 0}});c.Object.prototype.rotate=c.Object.prototype.setAngle})();(function(){var a=this.fabric||(this.fabric={});if(a.Line){return}a.Line=a.base.createClass(a.Object,{type:"line",initialize:function(c,b){if(!c){c=[0,0,0,0]}this.callSuper("initialize",b);this.set("x1",c[0]);this.set("y1",c[1]);this.set("x2",c[2]);this.set("y2",c[3]);this.set("width",this.x2-this.x1);this.set("height",this.y2-this.y1);this.set("left",this.x1+this.width/2);this.set("top",this.y1+this.height/2)},_render:function(b){b.beginPath();b.moveTo(-this.width/2,-this.height/2);b.lineTo(this.width/2,this.height/2);b.stroke()},complexity:function(){return 1},toObject:function(){return a.base.object.extend(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});a.Element.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");a.Line.fromElement=function(c,b){var e=a.parseAttributes(c,a.Element.ATTRIBUTE_NAMES);var d=[e.x1||0,e.y1||0,e.x2||0,e.y2||0];return new a.Line(d,a.base.object.extend(e,b))};a.Line.fromObject=function(b){var c=[b.x1,b.y1,b.x2,b.y2];return new a.Line(c,b)}})();(function(){var a=this,b=a.fabric||(a.fabric={}),d=Math.PI*2;if(b.Circle){console.warn("fabric.Circle is already defined.");return}b.Circle=b.base.createClass(b.Object,{type:"circle",initialize:function(e){e=e||{};this.set("radius",e.radius||0);this.callSuper("initialize",e);var f=this.get("radius")*2*this.get("scaleX");this.set("width",f).set("height",f)},toObject:function(){return b.base.object.extend(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(e){e.beginPath();e.arc(0,0,this.radius,0,d,false);if(this.fill){e.fill()}if(this.stroke){e.stroke()}},complexity:function(){return 1}});b.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");b.Circle.fromElement=function(f,e){var g=b.parseAttributes(f,b.Circle.ATTRIBUTE_NAMES);if(!c(g)){throw Error("value of `r` attribute is required and can not be negative")}return new b.Circle(b.base.object.extend(g,e))};function c(e){return(("radius" in e)&&(e.radius>0))}b.Circle.fromObject=function(e){return new b.Circle(e)}})();(function(){var a=this.fabric||(this.fabric={});if(a.Ellipse){console.warn("fabric.Ellipse is already defined.");return}a.Ellipse=a.base.createClass(a.Object,{type:"ellipse",initialize:function(b){b=b||{};this.callSuper("initialize",b);this.set("rx",b.rx||0);this.set("ry",b.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return a.base.object.extend(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(b,c){if(this.rx===0||this.ry===0){return}return this.callSuper("render",b,c)},_render:function(b){b.beginPath();b.save();b.transform(1,0,0,this.ry/this.rx,0,0);b.arc(0,0,this.rx,0,Math.PI*2,false);b.restore();if(this.stroke){b.stroke()}if(this.fill){b.fill()}},complexity:function(){return 1}});a.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");a.Ellipse.fromElement=function(c,b){var d=a.parseAttributes(c,a.Ellipse.ATTRIBUTE_NAMES);return new a.Ellipse(a.base.object.extend(d,b))};a.Ellipse.fromObject=function(b){return new a.Ellipse(b)}})();(function(){var b=this.fabric||(this.fabric={});if(b.Rect){return}b.Rect=b.base.createClass(b.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(c){this.callSuper("initialize",c);this._initRxRy()},_initRxRy:function(){if(this.options.rx&&!this.options.ry){this.options.ry=this.options.rx}else{if(this.options.ry&&!this.options.rx){this.options.rx=this.options.ry}}},_render:function(e){var k=this.options.rx||0,g=this.options.ry||0,c=-this.width/2,l=-this.height/2,d=this.width,f=this.height;e.beginPath();e.moveTo(c+k,l);e.lineTo(c+d-k,l);e.bezierCurveTo(c+d,l,c+d,l+g,c+d,l+g);e.lineTo(c+d,l+f-g);e.bezierCurveTo(c+d,l+f,c+d-k,l+f,c+d-k,l+f);e.lineTo(c+k,l+f);e.bezierCurveTo(c,l+f,c,l+f-g,c,l+f-g);e.lineTo(c,l+g);e.bezierCurveTo(c,l,c+k,l,c+k,l);e.closePath();if(this.fill){e.fill()}if(this.stroke){e.stroke()}},_normalizeLeftTopProperties:function(c){if(c.left){this.set("left",c.left+this.getWidth()/2)}if(c.top){this.set("top",c.top+this.getHeight()/2)}return this},complexity:function(){return 1}});b.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");function a(c){c.left=c.left||0;c.top=c.top||0;return c}b.Rect.fromElement=function(d,c){if(!d){return null}var f=b.parseAttributes(d,b.Rect.ATTRIBUTE_NAMES);f=a(f);var e=new b.Rect(b.base.object.extend(c||{},f));e._normalizeLeftTopProperties(f);return e};b.Rect.fromObject=function(c){return new b.Rect(c)}})();(function(){var b=this.fabric||(this.fabric={});if(b.Polyline){console.warn("fabric.Polyline is already defined");return}b.Polyline=b.base.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)},_toOrigin:function(){return b.Polygon.prototype._toOrigin.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}});var a="fill fill-opacity stroke stroke-width transform".split(" ");b.Polyline.fromElement=function(d,c){if(!d){return null}var e=b.parsePointsAttribute(d.getAttribute("points")),f=b.parseAttributes(d,a);return new b.Polyline(e,b.base.object.extend(f,c))};b.Polyline.fromObject=function(c){var d=c.points;return new b.Polyline(d,c)}})();(function(){var c=this.fabric||(this.fabric={});if(c.Polygon){console.warn("fabric.Polygon is already defined");return}function b(d){return d.x}function a(d){return d.y}c.Polygon=c.base.createClass(c.Object,{type:"polygon",initialize:function(e,d){d=d||{};this.points=e;this.callSuper("initialize",d);this._calcDimensions()},_calcDimensions:function(){var e=this.points,d=c.base.array.min(e,"x"),h=c.base.array.min(e,"y"),g=c.base.array.max(e,"x"),f=c.base.array.max(e,"y");this.width=g-d;this.height=f-h;this.minX=d;this.minY=h},_toOrigin:function(){this.points=this.points.map(function(d){return{x:d.x-this.minX,y:d.y-this.minY}},this)},toObject:function(){return c.base.object.extend(this.callSuper("toObject"),{points:this.points.concat()})},_render:function(f){var e;f.beginPath();for(var g=0,d=this.points.length;g<d;g++){e=this.points[g];f.lineTo(e.x,e.y)}if(this.fill){f.fill()}if(this.stroke){f.closePath();f.stroke()}},complexity:function(){return this.points.length}});c.Polygon.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");c.Polygon.fromElement=function(e,d){if(!e){return null}var f=c.parsePointsAttribute(e.getAttribute("points")),g=c.parseAttributes(e,c.Polygon.ATTRIBUTE_NAMES);return new c.Polygon(f,c.base.object.extend(g,d))};c.Polygon.fromObject=function(d){return new c.Polygon(d.points,d)}})();(function(){var b=this.fabric||(this.fabric={});if(b.Path){console.warn("fabric.Path is already defined");return}if(!b.Object){console.warn("fabric.Path requires fabric.Object");return}b.Path=b.base.createClass(b.Object,{type:"path",initialize:function(e,d){d=d||{};this.setOptions(d);this._importProperties();this.originalState={};if(!e){throw Error("`path` argument is required")}var c=Object.prototype.toString.call(e)==="[object Array]";this.path=c?e:e.match&&e.match(/[a-zA-Z][^a-zA-Z]*/g);if(!this.path){return}if(!c){this._initializeFromArray(d)}this.setCoords();if(d.sourcePath){this.setSourcePath(d.sourcePath)}},_initializeFromArray:function(d){var c="width" in d,e="height" in d;this.path=this._parsePath();if(!c||!e){b.base.object.extend(this,this._parseDimensions());if(c){this.width=this.options.width}if(e){this.height=this.options.height}}},_render:function(p){var k,n=0,m=0,c=0,q=0,g,f,d=-(this.width/2),o=-(this.height/2);for(var e=0,h=this.path.length;e<h;++e){k=this.path[e];switch(k[0]){case"l":n+=k[1];m+=k[2];p.lineTo(n+d,m+o);break;case"L":n=k[1];m=k[2];p.lineTo(n+d,m+o);break;case"h":n+=k[1];p.lineTo(n+d,m+o);break;case"H":n=k[1];p.lineTo(n+d,m+o);break;case"v":m+=k[1];p.lineTo(n+d,m+o);break;case"V":m=k[1];p.lineTo(n+d,m+o);break;case"m":n+=k[1];m+=k[2];p.moveTo(n+d,m+o);break;case"M":n=k[1];m=k[2];p.moveTo(n+d,m+o);break;case"c":g=n+k[5];f=m+k[6];c=n+k[3];q=m+k[4];p.bezierCurveTo(n+k[1]+d,m+k[2]+o,c+d,q+o,g+d,f+o);n=g;m=f;break;case"C":n=k[5];m=k[6];c=k[3];q=k[4];p.bezierCurveTo(k[1]+d,k[2]+o,c+d,q+o,n+d,m+o);break;case"s":g=n+k[3];f=m+k[4];c=2*n-c;q=2*m-q;p.bezierCurveTo(c+d,q+o,n+k[1]+d,m+k[2]+o,g+d,f+o);n=g;m=f;break;case"S":g=k[3];f=k[4];c=2*n-c;q=2*m-q;p.bezierCurveTo(c+d,q+o,k[1]+d,k[2]+o,g+d,f+o);n=g;m=f;break;case"q":n+=k[3];m+=k[4];p.quadraticCurveTo(k[1]+d,k[2]+o,n+d,m+o);break;case"Q":n=k[3];m=k[4];c=k[1];q=k[2];p.quadraticCurveTo(c+d,q+o,n+d,m+o);break;case"T":g=n;f=m;n=k[1];m=k[2];c=-c+2*g;q=-q+2*f;p.quadraticCurveTo(c+d,q+o,n+d,m+o);break;case"a":break;case"A":break;case"z":case"Z":p.closePath();break}}},render:function(d,e){d.save();var c=this.transformMatrix;if(c){d.transform(c[0],c[1],c[2],c[3],c[4],c[5])}if(!e){this.transform(d)}if(this.overlayFill){d.fillStyle=this.overlayFill}else{if(this.fill){d.fillStyle=this.fill}}if(this.stroke){d.strokeStyle=this.stroke}d.beginPath();if(this.stub){this.stub._render(d)}else{this._render(d)}if(this.fill){d.fill()}if(this.options.stroke){d.strokeStyle=this.options.stroke;d.lineWidth=this.options.strokeWidth;d.stroke()}if(!e&&this.active){this.drawBorders(d);this.hideCorners||this.drawCorners(d)}d.restore()},toString:function(){return"#<fabric.Path ("+this.complexity()+"): "+JSON.stringify({top:this.top,left:this.left})+">"},toObject:function(){var c=b.base.object.extend(this.callSuper("toObject"),{path:this.path});if(this.sourcePath){c.sourcePath=this.sourcePath}if(this.transformMatrix){c.transformMatrix=this.transformMatrix}return c},toDatalessObject:function(){var c=this.toObject();if(this.sourcePath){c.path=this.sourcePath}delete c.sourcePath;return c},complexity:function(){return this.path.length},set:function(d,c){if(this.stub){this.stub.set(d,c)}return this.callSuper("set",d,c)},_parsePath:function(){var d=[],f,g;for(var e=0,c=this.path.length;e<c;e++){f=this.path[e];g=f.slice(1).trim().replace(/(\d)-/g,"$1###-").split(/\s|,|###/);d.push([f.charAt(0)].concat(g.map(parseFloat)))}return d},_parseDimensions:function(){var k=[],g=[],l,h,m=false,p,n;function r(o){if(o[0]==="H"){return o[1]}return o[o.length-2]}function q(o){if(o[0]==="V"){return o[1]}return o[o.length-1]}this.path.forEach(function(s,o){if(s[0]!=="H"){l=(o===0)?r(s):r(this.path[o-1])}if(s[0]!=="V"){h=(o===0)?q(s):q(this.path[o-1])}if(s[0]===s[0].toLowerCase()){m=true}p=m?l+r(s):s[0]==="V"?l:r(s);n=m?h+q(s):s[0]==="H"?h:q(s);var t=parseInt(p,10);if(!isNaN(t)){k.push(t)}t=parseInt(n,10);if(!isNaN(t)){g.push(t)}},this);var e=b.base.array.min(k),d=b.base.array.min(g),f=deltaY=0;var c={top:d-deltaY,left:e-f,bottom:b.base.array.max(g)-deltaY,right:b.base.array.max(k)-f};c.width=c.right-c.left;c.height=c.bottom-c.top;return c}});b.Path.fromObject=function(c){return new b.Path(c.path,c)};var a=b.Path.ATTRIBUTE_NAMES="d fill fill-opacity fill-rule stroke stroke-width transform".split(" ");b.Path.fromElement=function(d,c){var e=b.parseAttributes(d,a),f=e.d;delete e.d;return new b.Path(f,b.base.object.extend(e,c))}})();(function(){var b=this.fabric||(this.fabric={});if(b.PathGroup){console.warn("fabric.PathGroup is already defined");return}b.PathGroup=b.base.createClass(b.Path,{type:"path-group",forceFillOverwrite:false,initialize:function(d,c){c=c||{};this.originalState={};this.paths=d;this.setOptions(c);this.initProperties();this.setCoords();if(c.sourcePath){this.setSourcePath(c.sourcePath)}},initProperties:function(){this.stateProperties.forEach(function(c){if(c==="fill"){this.set(c,this.options[c])}else{if(c==="angle"){this.setAngle(this.options[c])}else{this[c]=this.options[c]}}},this)},render:function(e){if(this.stub){e.save();this.transform(e);this.stub.render(e,false);if(this.active){this.drawBorders(e);this.drawCorners(e)}e.restore()}else{e.save();var c=this.transformMatrix;if(c){e.transform(c[0],c[1],c[2],c[3],c[4],c[5])}this.transform(e);for(var f=0,d=this.paths.length;f<d;++f){this.paths[f].render(e,true)}if(this.active){this.drawBorders(e);this.hideCorners||this.drawCorners(e)}e.restore()}},set:function(e,d){if((e==="fill"||e==="overlayFill")&&this.isSameColor()){this[e]=d;var c=this.paths.length;while(c--){this.paths[c].set(e,d)}}else{b.Object.prototype.set.call(this,e,d)}return this},toObject:function(){var c=b.Object.prototype.toObject;return b.base.object.extend(c.call(this),{paths:b.base.array.invoke(this.getObjects(),"clone"),sourcePath:this.sourcePath})},toDatalessObject:function(){var c=this.toObject();if(this.sourcePath){c.paths=this.sourcePath}return c},toString:function(){return"#<fabric.PathGroup ("+this.complexity()+"): { top: "+this.top+", left: "+this.left+" }>"},isSameColor:function(){var c=this.getObjects()[0].get("fill");return this.getObjects().every(function(d){return d.get("fill")===c})},complexity:function(){return this.paths.reduce(function(c,d){return c+((d&&d.complexity)?d.complexity():0)},0)},toGrayscale:function(){var c=this.paths.length;while(c--){this.paths[c].toGrayscale()}return this},getObjects:function(){return this.paths}});function a(f){for(var e=0,c=f.length;e<c;e++){if(!(f[e] instanceof b.Object)){var d=f[e].type.camelize().capitalize();f[e]=Canvas[d].fromObject(f[e])}}return f}b.PathGroup.fromObject=function(c){var d=a(c.paths);return new b.PathGroup(d,c)}})();(function(){var a=this.fabric||(this.fabric={});if(a.Group){return}a.Group=a.base.createClass(a.Object,{type:"group",initialize:function(c,b){this.objects=c||[];this.originalState={};this.callSuper("initialize");this._calcBounds();this._updateObjectsCoords();if(b){a.base.object.extend(this,b)}this._setOpacityIfSame();this.setCoords(true);this.saveCoords();this.activateAllObjects()},_updateObjectsCoords:function(){var c=this.left,b=this.top;this.forEachObject(function(d){var e=d.get("left"),f=d.get("top");d.set("originalLeft",e);d.set("originalTop",f);d.set("left",e-c);d.set("top",f-b);d.setCoords();d.hideCorners=true},this)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},getObjects:function(){return this.objects},add:function(b){this._restoreObjectsState();this.objects.push(b);b.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(b){this._restoreObjectsState();a.util.removeFromArray(this.objects,b);b.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(b,d){if(typeof d=="function"){this.set(b,d(this[b]))}else{if(b==="fill"||b==="opacity"){var c=this.objects.length;this[b]=d;while(c--){this.objects[c].set(b,d)}}else{this[b]=d}}return this},contains:function(b){return this.objects.indexOf(b)>-1},toObject:function(){return a.base.object.extend(this.callSuper("toObject"),{objects:a.base.array.invoke(this.objects,"clone")})},render:function(c){c.save();this.transform(c);var f=Math.max(this.scaleX,this.scaleY);for(var d=0,b=this.objects.length;d<b;d++){var e=this.objects[d].borderScaleFactor;this.objects[d].borderScaleFactor=f;this.objects[d].render(c);this.objects[d].borderScaleFactor=e}this.hideBorders||this.drawBorders(c);this.hideCorners||this.drawCorners(c);c.restore();this.setCoords()},item:function(b){return this.getObjects()[b]},complexity:function(){return this.getObjects().reduce(function(c,b){c+=(typeof b.complexity=="function")?b.complexity():0;return c},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,this);return this},_restoreObjectState:function(d){var f=this.get("left"),g=this.get("top"),b=this.getAngle()*(Math.PI/180),e=d.get("originalLeft"),h=d.get("originalTop"),c=Math.cos(b)*d.get("top")+Math.sin(b)*d.get("left"),k=-Math.sin(b)*d.get("top")+Math.cos(b)*d.get("left");d.setAngle(d.getAngle()+this.getAngle());d.set("left",f+k*this.get("scaleX"));d.set("top",g+c*this.get("scaleY"));d.set("scaleX",d.get("scaleX")*this.get("scaleX"));d.set("scaleY",d.get("scaleY")*this.get("scaleY"));d.setCoords();d.hideCorners=false;d.setActive(false);d.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(b){b.setCoords()});return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(b){this.forEachObject(function(c){c.setActive(b)});return this},forEachObject:function(e,c){var d=this.getObjects(),b=d.length;while(b--){e.call(c,d[b],b,d)}return this},_setOpacityIfSame:function(){var d=this.getObjects(),c=d[0]?d[0].get("opacity"):1;var b=d.every(function(e){return e.get("opacity")===c});if(b){this.opacity=c}},_calcBounds:function(){var m=[],k=[],h,g,d,b,f,e,p,l=0,n=this.objects.length;for(;l<n;++l){f=this.objects[l];f.setCoords();for(var c in f.oCoords){m.push(f.oCoords[c].x);k.push(f.oCoords[c].y)}}h=a.base.array.min(m);d=a.base.array.max(m);g=a.base.array.min(k);b=a.base.array.max(k);e=d-h;p=b-g;this.width=e;this.height=p;this.left=h+e/2;this.top=g+p/2},containsPoint:function(c){var f=this.get("width")/2,b=this.get("height")/2,e=this.get("left"),d=this.get("top");return e-f<c.x&&e+f>c.x&&d-b<c.y&&d+b>c.y},toGrayscale:function(){var b=this.objects.length;while(b--){this.objects[b].toGrayscale()}}});a.Group.fromObject=function(b){return new a.Group(b.objects,b)}})();(function(){var a=this.fabric||(this.fabric={});if(a.Text){console.warn("fabric.Text is already defined");return}if(!a.Object){console.warn("fabric.Text requires fabric.Object");return}a.Text=a.base.createClass(a.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(c,b){this.originalState={};this.initStateProperties();this.text=c;this.setOptions(b);a.base.object.extend(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()},initStateProperties:function(){var b;if((b=this.constructor)&&(b=b.superclass)&&(b=b.prototype)&&(b=b.stateProperties)&&b.clone){this.stateProperties=b.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#<fabric.Text ("+this.complexity()+"): "+JSON.stringify({text:this.text,fontfamily:this.fontfamily})+">"},_render:function(b){var d=Cufon.textOptions||(Cufon.textOptions={});d.left=this.left;d.top=this.top;d.context=b;d.color=this.fill;var c=this._initDummyElement();this.transform(b);Cufon.replaceElement(c,{separate:"none",fontFamily:this.fontfamily});this.width=d.width;this.height=d.height},_initDummyElement:function(){var b=document.createElement("div");b.innerHTML=this.text;b.style.fontSize="40px";b.style.fontWeight="400";b.style.fontStyle="normal";b.style.letterSpacing="normal";b.style.color="#000000";b.style.fontWeight="600";b.style.fontFamily="Verdana";return b},render:function(b){b.save();this._render(b);if(this.active){this.drawBorders(b);this.drawCorners(b)}b.restore()},toObject:function(){return a.base.object.extend(this.callSuper("toObject"),{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,path:this.path})},setColor:function(b){this.set("fill",b);return this},setFontsize:function(b){this.set("fontsize",b);this.setCoords();return this},getText:function(){return this.text},setText:function(b){this.set("text",b);this.setCoords();return this},set:function(b,c){this[b]=c;if(b==="fontfamily"){this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+c+"$3")}return this}});a.Text.fromObject=function(b){return new a.Text(b.text,a.base.object.clone(b))};a.Text.fromElement=function(b){}})();(function(){var a=this;if(!a.fabric){a.fabric={}}if(a.fabric.Image){console.warn("fabric.Image is already defined.");return}if(!fabric.Object){console.warn("fabric.Object is required for fabric.Image initialization");return}fabric.Image=fabric.base.createClass(fabric.Object,{maxwidth:null,maxheight:null,active:false,bordervisibility:false,cornervisibility:false,type:"image",__isGrayscaled:false,initialize:function(c,b){this.callSuper("initialize",b);this._initElement(c);this._initConfig(b||{})},getElement:function(){return this._element},setElement:function(b){this._element=b;return this},getNormalizedSize:function(c,b,d){if(d&&b&&(c.width>c.height&&(c.width/c.height)<(b/d))){normalizedWidth=Math.floor((c.width*d)/c.height);normalizedHeight=d}else{if(d&&((c.height==c.width)||(c.height>c.width)||(c.height>d))){normalizedWidth=Math.floor((c.width*d)/c.height);normalizedHeight=d}else{if(b&&(b<c.width)){normalizedHeight=Math.floor((c.height*b)/c.width);normalizedWidth=b}else{normalizedWidth=c.width;normalizedHeight=c.height}}}return{width:normalizedWidth,height:normalizedHeight}},getOriginalSize:function(){var b=this.getElement();return{width:b.width,height:b.height}},setBorderVisibility:function(b){this._resetWidthHeight();this._adjustWidthHeightToBorders(b);this.setCoords()},setCornersVisibility:function(b){this.cornervisibility=!!b},render:function(b,c){b.save();if(!c){this.transform(b)}this._render(b);if(this.active&&!c){this.drawBorders(b);this.hideCorners||this.drawCorners(b)}b.restore()},toObject:function(){return fabric.base.object.extend(this.callSuper("toObject"),{src:this.getSrc()})},getSrc:function(){return this.getElement().src},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},clone:function(b){this.constructor.fromObject(this.toObject(),b)},toGrayscale:function(f){if(this.__isGrayscaled){return}var d=this.getElement(),b=document.createElement("canvas"),c=document.createElement("img"),e=this;b.width=d.width;b.height=d.height;b.getContext("2d").drawImage(d,0,0);fabric.Element.toGrayscale(b);c.onload=function(){e.setElement(c);f&&f();c.onload=b=d=imageData=null};c.width=d.width;c.height=d.height;c.src=b.toDataURL("image/png");this.__isGrayscaled=true;return this},_render:function(c){var b=this.getOriginalSize();c.drawImage(this.getElement(),-b.width/2,-b.height/2,b.width,b.height)},_adjustWidthHeightToBorders:function(b){if(b){this.currentBorder=this.borderwidth;this.width+=(2*this.currentBorder);this.height+=(2*this.currentBorder)}else{this.currentBorder=0}},_resetWidthHeight:function(){var b=this.getElement();this.set("width",b.width);this.set("height",b.height)},_initElement:function(b){this.setElement(fabric.base.getById(b));fabric.base.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(b){this.setOptions(b);this._setBorder();this._setWidthHeight(b)},_setBorder:function(){if(this.bordervisibility){this.currentBorder=this.borderwidth}else{this.currentBorder=0}},_setWidthHeight:function(b){var c=2*this.currentBorder;this.width=(this.getElement().width||0)+c;this.height=(this.getElement().height||0)+c}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(c,e){var b=document.createElement("img"),d=c.src;if(c.width){b.width=c.width}if(c.height){b.height=c.height}b.onload=function(){if(e){e(new fabric.Image(b,c))}b=b.onload=null};b.src=d};fabric.Image.fromURL=function(c,e,d){var b=document.createElement("img");b.onload=function(){if(e){e(new fabric.Image(b,d))}b=b.onload=null};b.src=c}})(); |