Document bunch of API (still incomplete, but getting there).

This commit is contained in:
kangax 2010-10-14 17:42:39 -04:00
parent e70830f7d6
commit 415205d3f2
23 changed files with 1564 additions and 846 deletions

1031
dist/all.js vendored

File diff suppressed because it is too large Load diff

329
dist/all.min.js vendored
View file

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

View file

@ -2,7 +2,18 @@
var fabric = fabric || { version: 0.1 };
/**
* Wrapper around `console.log` (when available)
* @method log
* @param {Any} Values to log
*/
fabric.log = function() { };
/**
* Wrapper around `console.warn` (when available)
* @method warn
* @param {Any} Values to log as a warning
*/
fabric.warn = function() { };
if (typeof console !== 'undefined') {

View file

@ -10,16 +10,17 @@
fabric.warn('fabric.Circle is already defined.');
return;
}
fabric.Circle = fabric.util.createClass(fabric.Object, /** @lends fabric.Circle.prototype */ {
/**
* @class Circle
* @extends fabric.Object
*/
fabric.Circle = fabric.util.createClass(fabric.Object, /** @scope fabric.Circle.prototype */ {
/**
* @field
*/
/** @property */
type: 'circle',
/**
* @constructs
* @method initialize
* @param options {Object} options object
* @return {Object} thisArg
@ -74,11 +75,14 @@
});
/**
* List of attribute names to account for when parsing SVG element (used by `fabric.Circle.fromElement`)
* @static
* @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement
*/
fabric.Circle.ATTRIBUTE_NAMES = 'cx cy r fill fill-opacity stroke stroke-width transform'.split(' ');
/**
* Returns fabric.Circle instance from an SVG element
* @static
* @method fabric.Circle.fromElement
* @param element {SVGElement} element to parse
@ -109,10 +113,11 @@
}
/**
* Returns fabric.Circle instance from an object representation
* @static
* @method fabric.Circle.fromObject
* @param object {Object} object to create an instance from
* @return {Object} instance of fabric.Circle
* @param {Object} object Object to create an instance from
* @return {Object} Instance of fabric.Circle
*/
fabric.Circle.fromObject = function(object) {
return new fabric.Circle(object);

View file

@ -7,10 +7,12 @@
return;
}
fabric.Color = Color;
/**
* @constructor
* The purpose of fabric.Color is to abstract and encapsulate common color operations;
* fabric.Color is a constructor and creates instances of fabric.Color objects.
*
* @class Color
* @memberOf fabric
* @param {String} color (optional) in hex or rgb(a) format
*/
function Color(color) {
@ -22,173 +24,191 @@
}
}
/**
* @private
* @method _tryParsingColor
*/
Color.prototype._tryParsingColor = function(color) {
var source = Color.sourceFromHex(color);
if (!source) {
source = Color.sourceFromRgb(color);
}
if (source) {
fabric.Color = Color;
fabric.Color.prototype = /** @scope fabric.Color.prototype */ {
/**
* @private
* @method _tryParsingColor
*/
_tryParsingColor: function(color) {
var source = Color.sourceFromHex(color);
if (!source) {
source = Color.sourceFromRgb(color);
}
if (source) {
this.setSource(source);
}
},
/**
* Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])
* @method getSource
* @return {Array}
*/
getSource: function() {
return this._source;
},
/**
* Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])
* @method setSource
* @param {Array} source
*/
setSource: function(source) {
this._source = source;
},
/**
* Returns color represenation in RGB format
* @method toRgb
* @return {String} ex: rgb(0-255,0-255,0-255)
*/
toRgb: function() {
var source = this.getSource();
return 'rgb(' + source[0] + ',' + source[1] + ',' + source[2] + ')';
},
/**
* Returns color represenation in RGBA format
* @method toRgba
* @return {String} ex: rgba(0-255,0-255,0-255,0-1)
*/
toRgba: function() {
var source = this.getSource();
return 'rgba(' + source[0] + ',' + source[1] + ',' + source[2] + ',' + source[3] + ')';
},
/**
* Returns color represenation in HEX format
* @method toHex
* @return {String} ex: FF5555
*/
toHex: function() {
var source = this.getSource();
var r = source[0].toString(16);
r = (r.length == 1) ? ('0' + r) : r;
var g = source[1].toString(16);
g = (g.length == 1) ? ('0' + g) : g;
var b = source[2].toString(16);
b = (b.length == 1) ? ('0' + b) : b;
return r.toUpperCase() + g.toUpperCase() + b.toUpperCase();
},
/**
* Gets value of alpha channel for this color
* @method getAlpha
* @return {Number} 0-1
*/
getAlpha: function() {
return this.getSource()[3];
},
/**
* Sets value of alpha channel for this color
* @method setAlpha
* @param {Number} 0-1
* @return {fabric.Color} thisArg
*/
setAlpha: function(alpha) {
var source = this.getSource();
source[3] = alpha;
this.setSource(source);
return this;
},
/**
* Transforms color to its grayscale representation
* @method toGrayscale
* @return {fabric.Color} thisArg
*/
toGrayscale: function() {
var source = this.getSource(),
average = parseInt((source[0] * 0.3 + source[1] * 0.59 + source[2] * 0.11).toFixed(0), 10),
currentAlpha = source[3];
this.setSource([average, average, average, currentAlpha]);
return this;
},
/**
* Transforms color to its black and white representation
* @method toGrayscale
* @return {fabric.Color} thisArg
*/
toBlackWhite: function(threshold) {
var source = this.getSource(),
average = (source[0] * 0.3 + source[1] * 0.59 + source[2] * 0.11).toFixed(0),
currentAlpha = source[3],
threshold = threshold || 127;
average = (Number(average) < Number(threshold)) ? 0 : 255;
this.setSource([average, average, average, currentAlpha]);
return this;
},
/**
* Overlays color with another color
* @method overlayWith
* @param {String|fabric.Color} otherColor
* @return {fabric.Color} thisArg
*/
overlayWith: function(otherColor) {
if (!(otherColor instanceof Color)) {
otherColor = new Color(otherColor);
}
var result = [],
alpha = this.getAlpha(),
otherAlpha = 0.5,
source = this.getSource(),
otherSource = otherColor.getSource();
for (var i = 0; i < 3; i++) {
result.push(Math.round((source[i] * (1 - otherAlpha)) + (otherSource[i] * otherAlpha)));
}
result[4] = alpha;
this.setSource(result);
return this;
}
}
/**
* @method getSource
* @return {Array}
*/
Color.prototype.getSource = function() {
return this._source;
};
/**
* @method setSource
* @param {Array} source
*/
Color.prototype.setSource = function(source) {
this._source = source;
};
/**
* @method toRgb
* @return {String} ex: rgb(0-255,0-255,0-255)
*/
Color.prototype.toRgb = function() {
var source = this.getSource();
return 'rgb(' + source[0] + ',' + source[1] + ',' + source[2] + ')';
};
/**
* @method toRgba
* @return {String} ex: rgba(0-255,0-255,0-255,0-1)
*/
Color.prototype.toRgba = function() {
var source = this.getSource();
return 'rgba(' + source[0] + ',' + source[1] + ',' + source[2] + ',' + source[3] + ')';
};
/**
* @method toHex
* @return {String} ex: FF5555
*/
Color.prototype.toHex = function() {
var source = this.getSource();
var r = source[0].toString(16);
r = (r.length == 1) ? ('0' + r) : r;
var g = source[1].toString(16);
g = (g.length == 1) ? ('0' + g) : g;
var b = source[2].toString(16);
b = (b.length == 1) ? ('0' + b) : b;
return r.toUpperCase() + g.toUpperCase() + b.toUpperCase();
};
/**
* @method getAlpha
* @return {Number} 0-1
*/
Color.prototype.getAlpha = function() {
return this.getSource()[3];
};
/**
* @method setAlpha
* @param {Number} 0-1
* @return {Color} thisArg
*/
Color.prototype.setAlpha = function(alpha) {
var source = this.getSource();
source[3] = alpha;
this.setSource(source);
return this;
};
/**
* Transforms color to its grayscale representation
* @method toGrayscale
* @return {Color} thisArg
*/
Color.prototype.toGrayscale = function() {
var source = this.getSource(),
average = parseInt((source[0] * 0.3 + source[1] * 0.59 + source[2] * 0.11).toFixed(0), 10),
currentAlpha = source[3];
this.setSource([average, average, average, currentAlpha]);
return this;
};
/**
* Transforms color to its black and white representation
* @method toGrayscale
* @return {Color} thisArg
*/
Color.prototype.toBlackWhite = function(threshold) {
var source = this.getSource(),
average = (source[0] * 0.3 + source[1] * 0.59 + source[2] * 0.11).toFixed(0),
currentAlpha = source[3],
threshold = threshold || 127;
average = (Number(average) < Number(threshold)) ? 0 : 255;
this.setSource([average, average, average, currentAlpha]);
return this;
};
/**
* Overlays color with another color
* @method overlayWith
* @param {Color} otherColor
* @return {Color} thisArg
*/
Color.prototype.overlayWith = function(otherColor) {
otherColor = new Color(otherColor);
var result = [],
alpha = this.getAlpha(),
otherAlpha = 0.5,
source = this.getSource(),
otherSource = otherColor.getSource();
for (var i = 0; i < 3; i++) {
result.push(Math.round((source[i] * (1 - otherAlpha)) + (otherSource[i] * otherAlpha)));
}
result[4] = alpha;
this.setSource(result);
return this;
};
/**
* Regex matching color in RGB or RGBA formats (ex: rgb(0, 0, 0), rgb(255, 100, 10, 0.5), rgb(1,1,1))
* @static
* @field reRGBa
* @field
*/
Color.reRGBa = /^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;
fabric.Color.reRGBa = /^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;
/**
* Regex matching color in HEX format (ex: #FF5555, 010155, aff)
* @static
* @field reHex
* @field
*/
Color.reHex = /^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;
fabric.Color.reHex = /^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;
/**
* Returns new color object, when given a color in RGB format
* @method fromRgb
* @param {String} color ex: rgb(0-255,0-255,0-255)
* @return {Color}
* @return {fabric.Color}
*/
Color.fromRgb = function(color) {
fabric.Color.fromRgb = function(color) {
return Color.fromSource(Color.sourceFromRgb(color));
};
/**
* Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format
* @method sourceFromRgb
* @param {String} color ex: rgb(0-255,0-255,0-255)
* @return {Array} source
*/
Color.sourceFromRgb = function(color) {
fabric.Color.sourceFromRgb = function(color) {
var match = color.match(Color.reRGBa);
if (match) {
return [
@ -201,28 +221,33 @@
};
/**
* Returns new color object, when given a color in RGBA format
* @static
* @function
* @method fromRgba
* @return {Color}
* @param {String} color
* @return {fabric.Color}
*/
Color.fromRgba = Color.fromRgb;
fabric.Color.fromRgba = Color.fromRgb;
/**
* Returns new color object, when given a color in HEX format
* @static
* @method fromHex
* @return {Color}
* @return {fabric.Color}
*/
Color.fromHex = function(color) {
fabric.Color.fromHex = function(color) {
return Color.fromSource(Color.sourceFromHex(color));
};
/**
* Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HEX format
* @static
* @method sourceFromHex
* @param {String} ex: FF5555
* @param {String} color ex: FF5555
* @return {Array} source
*/
Color.sourceFromHex = function(color) {
fabric.Color.sourceFromHex = function(color) {
if (color.match(Color.reHex)) {
var value = color.slice(color.indexOf('#') + 1),
isShortNotation = (value.length === 3),
@ -240,11 +265,12 @@
};
/**
* Returns new color object, when given color in array representation (ex: [200, 100, 100, 0.5])
* @static
* @method fromSource
* @return {Color}
* @return {fabric.Color}
*/
Color.fromSource = function(source) {
fabric.Color.fromSource = function(source) {
var oColor = new Color();
oColor.setSource(source);
return oColor;

View file

@ -177,10 +177,11 @@
* @return {fabric.Element} thisArg
* @chainable
*/
// TODO (kangax): test callback
setOverlayImage: function (url, callback) {
setOverlayImage: function (url, callback) { // TODO (kangax): test callback
if (url) {
var _this = this, img = new Image();
/** @ignore */
img.onload = function () {
_this.overlayImage = img;
if (callback) {
@ -194,13 +195,13 @@
},
/**
* canvas class's initialization method. This method is automatically
* called by constructor, and sets up all DOM references for
* pre-existing markup, and creates required markup if it is not
* Canvas class' initialization method; This method is automatically
* called by constructor, sets up all DOM references for
* pre-existing markup, and creates required markup if it is not.
* already present.
* @method _initElement
* @param canvasEl {HTMLElement|String} canvasEl canvas element
*
* @param {HTMLElement|String} canvasEl Canvas element
* @throws {CANVAS_INIT_ERROR} If canvas can not be initialized
*/
_initElement: function (canvasEl) {
var el = fabric.util.getById(canvasEl);
@ -1730,6 +1731,8 @@
// else append a new image element
else {
var imgEl = new Image();
/** @ignore */
imgEl.onload = function () {
imgEl.onload = null;
@ -1750,6 +1753,11 @@
}
})(),
/**
* @method loadSVGFromURL
* @param {String} url
* @param {Function} callback
*/
loadSVGFromURL: function (url, callback) {
var _this = this;
@ -1952,7 +1960,7 @@
},
/**
* Removes an active object
* Removes currently active object
* @method removeActiveObject
* @return {fabric.Element} thisArg
* @chainable
@ -1966,9 +1974,9 @@
},
/**
* Sets current group to a speicified one
* Sets active group to a speicified one
* @method setActiveGroup
* @param group {fabric.Group} group to set as a current one
* @param {fabric.Group} group Group to set as a current one
* @return {fabric.Element} thisArg
* @chainable
*/
@ -1978,7 +1986,7 @@
},
/**
* Returns current group
* Returns currently active group
* @method getActiveGroup
* @return {fabric.Group} Current group
*/
@ -1987,7 +1995,7 @@
},
/**
* Removes current group
* Removes currently active group
* @method removeActiveGroup
* @return {fabric.Element} thisArg
*/
@ -2000,6 +2008,7 @@
},
/**
* Returns object at specified index
* @method item
* @param {Number} index
* @return {fabric.Object}

View file

@ -11,14 +11,19 @@
return;
}
fabric.Ellipse = fabric.util.createClass(fabric.Object, {
/**
* @class Ellipse
* @extends fabric.Object
*/
fabric.Ellipse = fabric.util.createClass(fabric.Object, /** @scope fabric.Ellipse.prototype */ {
/** @property */
type: 'ellipse',
/**
* @constructor
* Constructor
* @method initialize
* @param options {Object} options object
* @param {Object} [options] Options object
* @return {Object} thisArg
*/
initialize: function(options) {
@ -87,11 +92,12 @@
fabric.Ellipse.ATTRIBUTE_NAMES = 'cx cy rx ry fill fill-opacity stroke stroke-width transform'.split(' ');
/**
* Returns fabric.Ellipse instance from an SVG element
* @static
* @method fabric.Ellipse.fromElement
* @param element {SVGElement} element to parse
* @param options {Object} options object
* @return {Object} instance of fabric.Ellipse
* @param {SVGElement} element Element to parse
* @param {Object} [options] Options object
* @return {fabric.Ellipse}
*/
fabric.Ellipse.fromElement = function(element, options) {
options || (options = { });
@ -106,10 +112,11 @@
};
/**
* Returns fabric.Ellipse instance from an object representation
* @static
* @method fabric.Ellipse.fromObject
* @param object {Object} object to create an instance from
* @return {Object} instance of fabric.Ellipse
* @param {Object} object Object to create an instance from
* @return {fabric.Ellipse}
*/
fabric.Ellipse.fromObject = function(object) {
return new fabric.Ellipse(object);

View file

@ -13,16 +13,20 @@
return;
}
fabric.Group = fabric.util.createClass(fabric.Object, {
/**
* @class Group
* @extends fabric.Object
*/
fabric.Group = fabric.util.createClass(fabric.Object, /** @scope fabric.Group.prototype */ {
/**
* @property type
*/
/** @property */
type: 'group',
/**
* @constructor
* Constructor
* @method initialized
* @param {Object} objects Group objects
* @param {Object} [options] Options object
* @return {Object} thisArg
*/
initialize: function(objects, options) {
@ -73,6 +77,7 @@
},
/**
* Returns string represenation of a group
* @method toString
* @return {String}
*/
@ -81,6 +86,7 @@
},
/**
* Returns an array of all objects in this group
* @method getObjects
* @return {Array} group objects
*/
@ -89,10 +95,10 @@
},
/**
* Adds an object to a group. Recalculates group's dimension, position.
* Adds an object to a group; Then recalculates group's dimension, position.
* @method add
* @param {Object} object
* @return {Object} thisArg
* @return {fabric.Group} thisArg
* @chainable
*/
add: function(object) {
@ -105,9 +111,9 @@
},
/**
* Removes an object from a group. Recalculates group's dimension, position.
* Removes an object from a group; Then recalculates group's dimension, position.
* @param {Object} object
* @return {Object} thisArg
* @return {fabric.Group} thisArg
* @chainable
*/
remove: function(object) {
@ -120,7 +126,7 @@
},
/**
* Returns a size of a group (i.e. length of an array containing its objects)
* Returns a size of a group (i.e: length of an array containing its objects)
* @return {Number} Group size
*/
size: function() {
@ -131,8 +137,8 @@
* Sets property to a given value
* @method set
* @param {String} name
* @param {Object | Function} value
* @return {Object} thisArg
* @param {Object|Function} value
* @return {fabric.Group} thisArg
* @chainable
*/
set: function(name, value) {
@ -159,7 +165,7 @@
* Returns true if a group contains an object
* @method contains
* @param {Object} object Object to check against
* @return {Boolean} true if group contains an object
* @return {Boolean} `true` if group contains an object
*/
contains: function(object) {
return this.objects.indexOf(object) > -1;
@ -179,7 +185,7 @@
/**
* Renders instance on a given context
* @method render
* @param ctx {CanvasRenderingContext2D} context to render instance on
* @param {CanvasRenderingContext2D} ctx context to render instance on
*/
render: function(ctx) {
ctx.save();
@ -200,6 +206,7 @@
},
/**
* Returns object from the group at the specified index
* @method item
* @param index {Number} index of item to get
* @return {fabric.Object}
@ -209,6 +216,7 @@
},
/**
* Returns complexity of an instance
* @method complexity
* @return {Number} complexity
*/
@ -220,7 +228,7 @@
},
/**
* Retores original state of each of group objects
* Retores original state of each of group objects (original state is that which was before group was created).
* @private
* @method _restoreObjectsState
* @return {fabric.Group} thisArg
@ -232,9 +240,11 @@
},
/**
* Restores original state of a specified object in group
* @private
* @method _restoreObjectState
* @param {fabric.Object} object
* @return {fabric.Group} thisArg
*/
_restoreObjectState: function(object) {
@ -263,6 +273,7 @@
},
/**
* Destroys a group (restoring state of its objects)
* @method destroy
* @return {fabric.Group} thisArg
* @chainable
@ -282,6 +293,10 @@
return this;
},
/**
* @method hasMoved
* @return {Boolean} true if an object was moved (since fabric.Group#saveCoords was called)
*/
hasMoved: function() {
return this._originalLeft !== this.get('left') ||
this._originalTop !== this.get('top');
@ -311,6 +326,7 @@
},
/**
* Activates (makes active) all group objects
* @method setActive
* @param {Boolean} value `true` to activate object, `false` otherwise
* @return {fabric.Group} thisArg
@ -332,9 +348,9 @@
* Callback is invoked in a context of Global Object (e.g. `window`)
* when no `context` argument is given
*
* @param {Object} context a.k.a. thisObject
* @param {Object} context Context (aka thisObject)
*
* @return {fabric.Group}
* @return {fabric.Group} thisArg
* @chainable
*/
forEachObject: function(callback, context) {

View file

@ -19,22 +19,34 @@
return;
}
fabric.Image = fabric.util.createClass(fabric.Object, {
/**
* @class Image
* @extends fabric.Object
*/
fabric.Image = fabric.util.createClass(fabric.Object, /** @scope fabric.Image.prototype */ {
/** @property */
maxwidth: null,
/** @property */
maxheight: null,
/** @property */
active: false,
/** @property */
bordervisibility: false,
/** @property */
cornervisibility: false,
/** @property */
type: 'image',
__isGrayscaled: false,
/**
* @constructor
* Constructor
* @param {HTMLImageElement | String} element Image element
* @param {Object} options optional
*/
@ -45,6 +57,7 @@
},
/**
* Returns image element which this instance if based on
* @method getElement
* @return {HTMLImageElement} image element
*/
@ -53,8 +66,11 @@
},
/**
* Sets image element for this instance to a specified one
* @method setElement
* @param {HTMLImageElement} element
* @return {fabric.Image} thisArg
* @chainable
*/
setElement: function(element) {
this._element = element;
@ -62,12 +78,12 @@
},
/**
* Method that resizes an image depending on whether maxwidth and maxheight are set up.
* Resizes an image depending on whether maxwidth and maxheight are set up;
* Width and height have to mantain the same proportion in the final image as it was in the initial one.
* @method getNormalizedSize
* @param {Object} oImg
* @param {Number} maxwidth maximum width of the image in px
* @param {Number} maxheight maximum height of the image in px
* @param {Number} maxwidth maximum width of the image (in px)
* @param {Number} maxheight maximum height of the image (in px)
*/
getNormalizedSize: function(oImg, maxwidth, maxheight) {
if (maxheight && maxwidth && (oImg.width > oImg.height && (oImg.width / oImg.height) < (maxwidth / maxheight))) {
@ -97,6 +113,7 @@
},
/**
* Returns original size of an image
* @method getOriginalSize
* @return {Object} object with "width" and "height" properties
*/
@ -109,24 +126,29 @@
},
/**
* Sets border visibility
* @method setBorderVisibility
* @param showBorder {Boolean} when true, border is being set visible
* @param {Boolean} visible When true, border is set to be visible
*/
setBorderVisibility: function(showBorder) {
setBorderVisibility: function(visible) {
this._resetWidthHeight();
this._adjustWidthHeightToBorders(showBorder);
this.setCoords();
},
/**
* Sets corner visibility
* @method setCornersVisibility
* @param {Boolean} visible When true, corners are set to be visible
*/
setCornersVisibility: function(visible) {
this.cornervisibility = !!visible;
},
/**
* Renders image on a specified context
* @method render
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
render: function(ctx, noTransform) {
ctx.save();
@ -142,8 +164,9 @@
},
/**
* Returns object representation of an instance
* @method toObject
* @return {Object} object representation of an instance
* @return {Object} Object representation of an instance
*/
toObject: function() {
return extend(this.callSuper('toObject'), {
@ -152,30 +175,34 @@
},
/**
* Returns source of an image
* @method getSrc
* @return {String} source of an image
* @return {String} Source of an image
*/
getSrc: function() {
return this.getElement().src;
},
/**
* Returns string representation of an instance
* @method toString
* @return {String} string representation of an instance
* @return {String} String representation of an instance
*/
toString: function() {
return '#<fabric.Image: { src: "' + this.getSrc() + '" }>';
},
/**
* Returns a clone of an instance
* @mthod clone
* @param {Function} callback
* @param {Function} callback Callback is invoked with a clone as a first argument
*/
clone: function(callback) {
this.constructor.fromObject(this.toObject(), callback);
},
/**
* Makes image grayscale
* @mthod toGrayscale
* @param {Function} callback
*/
@ -195,7 +222,8 @@
canvasEl.getContext('2d').drawImage(imgEl, 0, 0);
fabric.Element.toGrayscale(canvasEl);
/** @ignore */
replacement.onload = function() {
_this.setElement(replacement);
callback && callback();
@ -291,26 +319,29 @@
this.height = (this.getElement().height || 0) + sidesBorderWidth;
},
/**
* Returns complexity of an instance
* @method complexity
* @return {Number} complexity
*/
complexity: function() {
return 1;
}
});
/**
* Constant for the default CSS class name that represents a Canvas
* @property fabric.Image.CSS_CANVAS
* Default CSS class name for canvas
* @static
* @final
* @type String
*/
fabric.Image.CSS_CANVAS = "canvas-img";
/**
* Creates an instance of fabric.Image from its object representation
* @static
* @method fromObject
* @param object {Object}
* @param callback {Function} optional
* @static
*/
fabric.Image.fromObject = function(object, callback) {
var img = document.createElement('img'),
@ -322,6 +353,8 @@
if (object.height) {
img.height = object.height;
}
/** @ignore */
img.onload = function() {
if (callback) {
callback(new fabric.Image(img, object));
@ -333,14 +366,16 @@
/**
* Creates an instance of fabric.Image from an URL string
* @method fromURL
* @param url {String}
* @param callback {Function} optional
* @param imgOptions {Object} optional
* @static
* @method fromURL
* @param {String} url URL to create an image from
* @param {Function} [callback] Callback to invoke when image is created (newly created image is passed as a first argument)
* @param {Object} [imgOptions] Options object
*/
fabric.Image.fromURL = function(url, callback, imgOptions) {
var img = document.createElement('img');
/** @ignore */
img.onload = function() {
if (callback) {
callback(new fabric.Image(img, imgOptions));

View file

@ -11,25 +11,52 @@
fabric.warn('fabric.Intersection is already defined');
return;
}
/**
* @class Intersection
* @memberOf fabric
*/
function Intersection(status) {
if (arguments.length > 0) {
this.init(status);
}
}
Intersection.prototype.init = function (status) {
this.status = status;
this.points = [];
};
Intersection.prototype.appendPoint = function (point) {
this.points.push(point);
};
Intersection.prototype.appendPoints = function (points) {
this.points = this.points.concat(points);
fabric.Intersection = Intersection;
fabric.Intersection.prototype = /** @scope fabric.Intersection.prototype */ {
/**
* @method init
* @param {String} status
*/
init: function (status) {
this.status = status;
this.points = [];
},
/**
* @method appendPoint
* @param {String} status
*/
appendPoint: function (point) {
this.points.push(point);
},
/**
* @method appendPoints
* @param {String} status
*/
appendPoints: function (points) {
this.points = this.points.concat(points);
}
};
Intersection.intersectLineLine = function (a1, a2, b1, b2) {
/**
* @static
* @method intersectLineLine
*/
fabric.Intersection.intersectLineLine = function (a1, a2, b1, b2) {
var result,
ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x),
ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x),
@ -56,7 +83,10 @@
return result;
};
Intersection.intersectLinePolygon = function(a1,a2,points){
/**
* @method intersectLinePolygon
*/
fabric.Intersection.intersectLinePolygon = function(a1,a2,points){
var result = new Intersection("No Intersection"),
length = points.length;
@ -73,7 +103,10 @@
return result;
};
Intersection.intersectPolygonPolygon = function (points1, points2) {
/**
* @method intersectPolygonPolygon
*/
fabric.Intersection.intersectPolygonPolygon = function (points1, points2) {
var result = new Intersection("No Intersection"),
length = points1.length;
@ -90,7 +123,10 @@
return result;
};
Intersection.intersectPolygonRectangle = function (points, r1, r2) {
/**
* @method intersectPolygonRectangle
*/
fabric.Intersection.intersectPolygonRectangle = function (points, r1, r2) {
var min = r1.min(r2),
max = r1.max(r2),
topRight = new fabric.Point(max.x, min.y),
@ -111,6 +147,4 @@
return result;
};
fabric.Intersection = Intersection;
})();

View file

@ -1,24 +1,30 @@
//= require "object.class"
(function(){
(function() {
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend;
if (fabric.Line) {
fabric.warn('fabric.Line is already defined');
return;
}
fabric.Line = fabric.util.createClass(fabric.Object, {
/**
* @class Line
* @extends fabric.Object
*/
fabric.Line = fabric.util.createClass(fabric.Object, /** @scope fabric.Line.prototype */ {
/** @property */
type: 'line',
/**
* @constructor
* Constructor
* @method initialize
* @param points {Array} array of points
* @param options {Object} options object
* @return {Object} thisArg
* @param {Array} points Array of points
* @param {Object} [options] Options object
* @return {fabric.Line} thisArg
*/
initialize: function(points, options) {
if (!points) {
@ -41,7 +47,7 @@
/**
* @private
* @method _render
* @param ctx {CanvasRenderingContext2D} context to render on
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
_render: function(ctx) {
ctx.beginPath();
@ -68,6 +74,7 @@
},
/**
* Returns object representation of an instance
* @methd toObject
* @return {Object}
*/
@ -81,15 +88,17 @@
}
});
// http://www.w3.org/TR/SVG/shapes.html#LineElement
/**
* @see http://www.w3.org/TR/SVG/shapes.html#LineElement
*/
fabric.Element.ATTRIBUTE_NAMES = 'x1 y1 x2 y2 stroke stroke-width transform'.split(' ');
/**
* @static
* @method fabric.Line.fromElement
* @param element {SVGElement} element to parse
* @param options {Object} options object
* @return {Object} instance of fabric.Line
* @param {SVGElement} element Element to parse
* @param {Object} [options] Options object
* @return {fabric.Line} instance of fabric.Line
*/
fabric.Line.fromElement = function(element, options) {
var parsedAttributes = fabric.parseAttributes(element, fabric.Element.ATTRIBUTE_NAMES);
@ -105,8 +114,8 @@
/**
* @static
* @method fabric.Line.fromObject
* @param object {Object} object to create an instance from
* @return {Object} instance of fabric.Line
* @param {Object} object Object to create an instance from
* @return {fabric.Line} instance of fabric.Line
*/
fabric.Line.fromObject = function(object) {
var points = [object.x1, object.y1, object.x2, object.y2];

View file

@ -1,11 +1,6 @@
(function(){
var global = this,
/**
* @name Canvas
* @namespace
*/
fabric = global.fabric || (global.fabric = { }),
extend = fabric.util.object.extend,
clone = fabric.util.object.clone,
@ -20,12 +15,14 @@
/**
* @class Object
* @memberOf Canvas
* @memberOf fabric
*/
fabric.Object = fabric.util.createClass({
fabric.Object = fabric.util.createClass(/** @scope fabric.Object.prototype */ {
/** @property */
type: 'object',
/** @property */
includeDefaultValues: true,
/**
@ -48,17 +45,14 @@
*/
MIN_SCALE_LIMIT: 0.1,
/**
* @field
*/
/** @property */
stateProperties: ('top left width height scaleX scaleY flipX flipY ' +
'theta angle opacity cornersize fill overlayFill stroke ' +
'strokeWidth fillRule borderScaleFactor transformMatrix').split(' '),
/**
* @field
*/
// TODO (kangax): rename to `defaultOptions`
/** @property */
options: {
top: 0,
left: 0,
@ -85,6 +79,10 @@
transformMatrix: null
},
/**
* @method callSuper
* @param {String} methodName
*/
callSuper: function(methodName) {
var fn = this.constructor.superclass.prototype[methodName];
return (arguments.length > 1)
@ -93,8 +91,9 @@
},
/**
* @constructs
* @param options {Object} options
* Constructor
* @method initialize
* @param {Object} [options] Options object
*/
initialize: function(options) {
// overwrite default options with specified ones
@ -109,6 +108,10 @@
this.saveState();
},
/**
* @method setOptions
* @param {Object} [options]
*/
setOptions: function(options) {
// this.constructor.superclass.prototype.options -> this.options -> options
this.options = extend(this._getOptions(), options);
@ -636,17 +639,20 @@
cloneAsImage: function(callback) {
if (fabric.Image) {
var i = new Image();
/** @ignore */
i.onload = function() {
if (callback) {
callback(new fabric.Image(i), orig);
}
i = i.onload = null;
}
};
var orig = {
angle: this.get('angle'),
flipX: this.get('flipX'),
flipY: this.get('flipY')
}
};
// normalize angle
this.set('angle', 0).set('flipX', false).set('flipY', false);

View file

@ -1,5 +1,7 @@
(function(){
/** @name fabric */
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
capitalize = fabric.util.string.capitalize,
@ -18,8 +20,12 @@
};
/**
* Returns an object of attributes' name/value, given element and an array of attribute names
* Parses parent "g" nodes recursively upwards
* Returns an object of attributes' name/value, given element and an array of attribute names;
* Parses parent "g" nodes recursively upwards.
*
* @static
* @memberOf fabric
* @method parseAttributes
* @param {DOMElement} element Element to parse
* @param {Array} attributes Array of attributes to parse
* @return {Object} object containing parsed attributes' names/values
@ -70,7 +76,9 @@
/**
* @static
* @method fabric.parseTransformAttribute
* @function
* @memberOf fabric
* @method parseTransformAttribute
* @param attributeValue {String} string containing attribute value
* @return {Array} array of 6 elements representing transformation matrix
*/
@ -201,7 +209,8 @@
/**
* @static
* @method fabric.parsePointsAttribute
* @memberOf fabric
* @method parsePointsAttribute
* @param points {String} points attribute string
* @return {Array} array of points
*/
@ -239,9 +248,10 @@
/**
* @static
* @method fabric.parseStyleAttribute
* @param element {SVGElement} element to parse
* @return {Object} objects with values parsed from style attribute of an element
* @memberOf fabric
* @method parseStyleAttribute
* @param {SVGElement} element Element to parse
* @return {Object} Objects with values parsed from style attribute of an element
*/
function parseStyleAttribute(element) {
var oStyle = { },
@ -271,10 +281,11 @@
/**
* @static
* @method fabric.parseElements
* @param elements {Array} array of elements to parse
* @param options {Object} options object
* @return {Array} array of corresponding instances (transformed from SVG elements)
* @memberOf fabric
* @method parseElements
* @param {Array} elements Array of elements to parse
* @param {Object} options Options object
* @return {Array} Array of corresponding instances (transformed from SVG elements)
*/
function parseElements(elements, options) {
// transform svg elements to fabric.Path elements
@ -297,12 +308,13 @@
/**
* @static
* @method fabric.parseSVGDocument
* @param doc {SVGDocument} SVG document to parse
* @param callback {Function} callback to call when parsing is finished.
* Callback is being passed array of elements (parsed from a document)
* @function
* @memberOf fabric
* @method parseSVGDocument
* @param {SVGDocument} doc SVG document to parse
* @param {Function} callback Callback to call when parsing is finished; It's being passed an array of elements (parsed from a document).
*/
fabric.parseSVGDocument = (function(){
fabric.parseSVGDocument = (function() {
var reAllowedSVGTagNames = /^(path|circle|polygon|polyline|ellipse|rect|line)$/;

View file

@ -16,16 +16,40 @@
return;
}
// Instance methods
fabric.Path = fabric.util.createClass(fabric.Object, {
/**
* @private
*/
function getX(item) {
if (item[0] === 'H') {
return item[1];
}
return item[item.length - 2];
}
/**
* @private
*/
function getY(item) {
if (item[0] === 'V') {
return item[1];
}
return item[item.length - 1];
}
/**
* @class Path
* @extends fabric.Object
*/
fabric.Path = fabric.util.createClass(fabric.Object, /** @scope fabric.Path.prototype */ {
/** @property */
type: 'path',
/**
* @constructor
* @param path {Array | String} path data
* (i.e. sequence of coordinates and corresponding "command" tokens)
* @param options {Object} options object
* Constructor
* @method initialize
* @param {Array|String} path Path data (sequence of coordinates and corresponding "command" tokens)
* @param {Object} [options] Options object
*/
initialize: function(path, options) {
options = options || { };
@ -342,7 +366,12 @@
delete o.sourcePath;
return o;
},
/**
* Returns number representation of an instance complexity
* @method complexity
* @return {Number} complexity
*/
complexity: function() {
return this.path.length;
},
@ -366,6 +395,9 @@
return result;
},
/**
* @method _parseDimensions
*/
_parseDimensions: function() {
var aX = [],
aY = [],
@ -374,18 +406,7 @@
isLowerCase = false,
x,
y;
function getX(item) {
if (item[0] === 'H') {
return item[1];
}
return item[item.length - 2];
}
function getY(item) {
if (item[0] === 'V') {
return item[1];
}
return item[item.length - 1];
}
this.path.forEach(function(item, i) {
if (item[0] !== 'H') {
previousX = (i === 0) ? getX(item) : getX(this.path[i-1]);

View file

@ -15,11 +15,25 @@
return;
}
fabric.PathGroup = fabric.util.createClass(fabric.Path, {
/**
* @class PathGroup
* @extends fabric.Path
*/
fabric.PathGroup = fabric.util.createClass(fabric.Path, /** @scope fabric.PathGroup.prototype */ {
/** @property */
type: 'path-group',
/** @property */
forceFillOverwrite: false,
/**
* Constructor
* @method initialize
* @param {Array} paths
* @param {Object} [options] Options object
* @return {fabric.PathGroup} thisArg
*/
initialize: function(paths, options) {
options = options || { };

View file

@ -8,107 +8,179 @@
fabric.warn('fabric.Point is already defined');
return;
}
fabric.Point = Point;
/**
* @name Point
* @memberOf fabric
* @constructor
* @param {Number} x
* @param {Number} y
* @return {fabric.Point} thisArg
*/
function Point(x, y) {
if (arguments.length > 0) {
this.init(x, y);
}
}
Point.prototype = {
Point.prototype = /** @scope fabric.Point.prototype */ {
constructor: Point,
/**
* @method init
* @param {Number} x
* @param {Number} y
*/
init: function (x, y) {
this.x = x;
this.y = y;
},
/**
* @method add
* @param {fabric.Point} that
* @return {fabric.Point} new Point instance with added values
*/
add: function (that) {
return new Point(this.x + that.x, this.y + that.y);
},
/**
* @method addEquals
* @param {fabric.Point} that
* @return {fabric.Point} thisArg
*/
addEquals: function (that) {
this.x += that.x;
this.y += that.y;
return this;
},
/**
* @method scalarAdd
* @param {Number} scalar
* @return {fabric.Point} new Point with added value
*/
scalarAdd: function (scalar) {
return new Point(this.x + scalar, this.y + scalar);
},
/**
* @method scalarAddEquals
* @param {Number} scalar
* @param {fabric.Point} thisArg
*/
scalarAddEquals: function (scalar) {
this.x += scalar;
this.y += scalar;
return this;
},
/**
* @method subtract
* @param {fabric.Point} that
* @return {fabric.Point} new Point object with subtracted values
*/
subtract: function (that) {
return new Point(this.x - that.x, this.y - that.y);
},
/**
* @method subtractEquals
* @param {fabric.Point} that
* @return {fabric.Point} thisArg
*/
subtractEquals: function (that) {
this.x -= that.x;
this.y -= that.y;
return this;
},
scalarSubtract: function (scalar) {
return new Point(this.x - scalar, this.y - scalar);
},
scalarSubtractEquals: function (scalar) {
this.x -= scalar;
this.y -= scalar;
return this;
},
multiply: function (scalar) {
return new Point(this.x * scalar, this.y * scalar);
},
multiplyEquals: function (scalar) {
this.x *= scalar;
this.y *= scalar;
return this;
},
divide: function (scalar) {
return new Point(this.x / scalar, this.y / scalar);
},
divideEquals: function (scalar) {
this.x /= scalar;
this.y /= scalar;
return this;
},
eq: function (that) {
return (this.x == that.x && this.y == that.y);
},
lt: function (that) {
return (this.x < that.x && this.y < that.y);
},
lte: function (that) {
return (this.x <= that.x && this.y <= that.y);
},
gt: function (that) {
return (this.x > that.x && this.y > that.y);
},
gte: function (that) {
return (this.x >= that.x && this.y >= that.y);
},
lerp: function (that, t) {
return new Point(this.x + (that.x - this.x) * t, this.y + (that.y - this.y) * t);
},
distanceFrom: function (that) {
var dx = this.x - that.x,
dy = this.y - that.y;
return Math.sqrt(dx * dx + dy * dy);
},
min: function (that) {
return new Point(Math.min(this.x, that.x), Math.min(this.y, that.y));
},
max: function (that) {
return new Point(Math.max(this.x, that.x), Math.max(this.y, that.y));
},
toString: function () {
return this.x + "," + this.y;
},
setXY: function (x, y) {
this.x = x;
this.y = y;
},
setFromPoint: function (that) {
this.x = that.x;
this.y = that.y;
},
swap: function (that) {
var x = this.x,
y = this.y;
@ -119,6 +191,4 @@
}
};
fabric.Point = Point;
})();

View file

@ -1,6 +1,6 @@
//= require "object.class"
(function(){
(function() {
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
@ -15,16 +15,21 @@
function byX(p) { return p.x; }
function byY(p) { return p.y; }
fabric.Polygon = fabric.util.createClass(fabric.Object, {
/**
* @class Polygon
* @extends fabric.Object
*/
fabric.Polygon = fabric.util.createClass(fabric.Object, /** @scope fabric.Polygon.prototype */ {
/** @property */
type: 'polygon',
/**
* @constructor
* Constructor
* @method initialize
* @param points {Array} array of points
* @param options {Object} options object
* @return thisArg
* @param {Array} points Array of points
* @param {Object} options Options object
* @return {fabric.Polygon} thisArg
*/
initialize: function(points, options) {
options = options || { };
@ -93,15 +98,20 @@
}
});
// http://www.w3.org/TR/SVG/shapes.html#PolygonElement
/**
* List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`)
* @static
* @see: http://www.w3.org/TR/SVG/shapes.html#PolygonElement
*/
fabric.Polygon.ATTRIBUTE_NAMES = 'fill fill-opacity stroke stroke-width transform'.split(' ');
/**
* Returns fabric.Polygon instance from an SVG element
* @static
* @method fabric.Polygon.fromElement
* @param element {SVGElement} element to parse
* @param options {Object} options object
* @return {Object} instance of fabric.Polygon
* @param {SVGElement} element Element to parse
* @param {Object} options Options object
* @return {fabric.Polygon}
*/
fabric.Polygon.fromElement = function(element, options) {
if (!element) {
@ -122,10 +132,11 @@
};
/**
* Returns fabric.Polygon instance from an object representation
* @static
* @method fabric.Polygon.fromObject
* @param object {Object} object to create an instance from
* @return {Object} instance of fabric.Polygon
* @param {Object} object Object to create an instance from
* @return {fabric.Polygon}
*/
fabric.Polygon.fromObject = function(object) {
return new fabric.Polygon(object.points, object);

View file

@ -1,6 +1,6 @@
//= require "object.class"
(function(){
(function() {
var fabric = this.fabric || (this.fabric = { });
@ -9,15 +9,20 @@
return;
}
fabric.Polyline = fabric.util.createClass(fabric.Object, {
/**
* @class Polyline
* @extends fabric.Object
*/
fabric.Polyline = fabric.util.createClass(fabric.Object, /** @scope fabric.Polyline.prototype */ {
/** @property */
type: 'polyline',
/**
* @constructor
* Constructor
* @method initialize
* @param points {Array} array of points
* @param options {Object} options object
* @param {Array} points array of points
* @param {Object} [options] Options object
* @return {Object} thisArg
*/
initialize: function(points, options) {
@ -38,7 +43,7 @@
/**
* Returns object representation of an instance
* @method toObject
* @return {Object} object representation of an instance
* @return {Object} Object representation of an instance
*/
toObject: function() {
return fabric.Polygon.prototype.toObject.call(this);
@ -47,7 +52,7 @@
/**
* @private
* @method _render
* @param ctx {CanvasRenderingContext2D} context to render on
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
_render: function(ctx) {
var point;
@ -65,6 +70,7 @@
},
/**
* Returns complexity of an instance
* @method complexity
* @return {Number} complexity
*/
@ -73,14 +79,19 @@
}
});
// http://www.w3.org/TR/SVG/shapes.html#PolylineElement
/**
* List of attribute names to account for when parsing SVG element (used by `fabric.Polyline.fromElement`)
* @static
* @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement
*/
var ATTRIBUTE_NAMES = 'fill fill-opacity stroke stroke-width transform'.split(' ');
/**
* Returns fabric.Polyline instance from an SVG element
* @static
* @method fabric.Polyline.fromElement
* @param element {SVGElement} element to parse
* @param options {Object} options object
* @param {SVGElement} element Element to parse
* @param {Object} [options] Options object
* @return {Object} instance of fabric.Polyline
*/
fabric.Polyline.fromElement = function(element, options) {
@ -102,13 +113,15 @@
};
/**
* Returns fabric.Polyline instance from an object representation
* @static
* @method fabric.Polyline.fromObject
* @param object {Object} object to create an instance from
* @return {Object} instance of fabric.Polyline
* @param {Object} [object] Object to create an instance from
* @return {fabric.Polyline}
*/
fabric.Polyline.fromObject = function(object) {
var points = object.points;
return new fabric.Polyline(points, object);
}
};
})();

View file

@ -1,10 +1,11 @@
//= require "object.class"
(function(){
(function() {
var fabric = this.fabric || (this.fabric = { });
if (fabric.Rect) {
console.warn('fabric.Rect is already defined');
return;
}
@ -12,17 +13,19 @@
* @class Rect
* @extends fabric.Object
*/
fabric.Rect = fabric.util.createClass(fabric.Object, /** @lends fabric.Rect.prototype */ {
fabric.Rect = fabric.util.createClass(fabric.Object, /** @scope fabric.Rect.prototype */ {
/** @property */
type: 'rect',
/** @property */
options: {
rx: 0,
ry: 0
},
/**
* @constructs
* Constructor
* @method initialize
* @param options {Object} options object
* @return {Object} thisArg
@ -115,7 +118,7 @@
* @method fabric.Rect.fromElement
* @param element {SVGElement} element to parse
* @param options {Object} options object
* @return {Object} instance of fabric.Rect
* @return {fabric.Rect} instance of fabric.Rect
*/
fabric.Rect.fromElement = function(element, options) {
if (!element) {

View file

@ -1,6 +1,6 @@
//= require "object.class"
(function(){
(function() {
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
@ -15,8 +15,13 @@
return;
}
fabric.Text = fabric.util.createClass(fabric.Object, {
/**
* @class Text
* @extends fabric.Object
*/
fabric.Text = fabric.util.createClass(fabric.Object, /** @scope fabric.Text.prototype */ {
/** @property */
options: {
top: 10,
left: 10,
@ -26,8 +31,16 @@
path: null
},
/** @property */
type: 'text',
/**
* Constructor
* @method initialize
* @param {String} text
* @param {Object} [options]
* @return {fabric.Text} thisArg
*/
initialize: function(text, options) {
this.originalState = { };
this.initStateProperties();
@ -39,6 +52,9 @@
this.setCoords();
},
/**
* @method initStateProperties
*/
initStateProperties: function() {
var o;
if ((o = this.constructor) &&
@ -51,11 +67,21 @@
}
},
/**
* Returns string representation of an instance
* @method toString
* @return {String} String representation of text object
*/
toString: function() {
return '#<fabric.Text ('+ this.complexity() +'): ' +
JSON.stringify({ text: this.text, fontfamily: this.fontfamily }) + '>';
},
/**
* @private
* @method _render
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
_render: function(context) {
var o = Cufon.textOptions || (Cufon.textOptions = { });
@ -81,6 +107,10 @@
this.height = o.height;
},
/**
* @private
* @method _initDummyElement
*/
_initDummyElement: function() {
var el = document.createElement('div');
el.innerHTML = this.text;
@ -97,6 +127,10 @@
return el;
},
/**
* @method render
* @param ctx {CanvasRenderingContext2D} context to render on
*/
render: function(context) {
context.save();
this._render(context);
@ -109,7 +143,7 @@
/**
* @method toObject
* @return {Object} object representation of an instance
* @return {Object} Object representation of text object
*/
toObject: function() {
return extend(this.callSuper('toObject'), {
@ -153,9 +187,11 @@
},
/**
* Sets text of an instance, and updates its coordinates
* @method setText
* @param {String} value
* @return {fabric.Text} thisArg
* @chainable
*/
setText: function(value) {
this.set('text', value);
@ -163,6 +199,14 @@
return this;
},
/**
* Sets specified property to a specified value
* @method set
* @param {String} name
* @param {Any} value
* @return {fabric.Text} thisArg
* @chainable
*/
set: function(name, value) {
this[name] = value;
if (name === 'fontfamily') {
@ -173,6 +217,7 @@
});
/**
* Returns fabric.Text instance from an object representation
* @static
* @method fromObject
* @param {Object} object to create an instance from

View file

@ -1,18 +1,23 @@
(function(){
(function() {
var fabric = this.fabric || (this.fabric = { });
if (fabric.Triangle) return;
if (fabric.Triangle) {
fabric.warn('fabric.Triangle is already defined');
return;
}
fabric.Triangle = fabric.util.createClass(fabric.Object, {
/**
* @class Triangle
* @extends fabric.Object
*/
fabric.Triangle = fabric.util.createClass(fabric.Object, /** @scope fabric.Triangle.prototype */ {
/**
* @field
*/
/** @property */
type: 'triangle',
/**
* @constructs
* Constructor
* @method initialize
* @param options {Object} options object
* @return {Object} thisArg
@ -29,7 +34,7 @@
/**
* @private
* @method _render
* @param ctx {CanvasRenderingContext2D} context to render on
* @param ctx {CanvasRenderingContext2D} Context to render on
*/
_render: function(ctx) {
var widthBy2 = this.width / 2,
@ -60,6 +65,7 @@
});
/**
* Returns fabric.Triangle instance from an object representation
* @static
* @method Canvas.Trangle.fromObject
* @param object {Object} object to create an instance from

View file

@ -3,7 +3,8 @@
var fabric = this.fabric || (this.fabric = { }),
slice = Array.prototype.slice,
apply = Function.prototype.apply;
/** @namespace */
fabric.util = { };
//= require "util/misc"

View file

@ -167,5 +167,9 @@
oColor = new fabric.Color('rgb(255,255,255)');
oColor.overlayWith('rgb(0,0,0)');
equals(oColor.toRgb(), 'rgb(128,128,128)');
oColor = new fabric.Color('rgb(255,255,255)');
oColor.overlayWith(new fabric.Color('rgb(0,0,0)'));
equals(oColor.toRgb(), 'rgb(128,128,128)');
});
})();