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