var console=console||{log:function(){},warn:function(){}},fabric=fabric||{version:0.1};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>>0;c=Number(c)||0;c=Math[c<0?"ceil":"floor"](c);if(c<0)c+=a;for(;c>>0;a>>0;b>>0;a>>0;a>>0;g>>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=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=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*$"), 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){console.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;c0&&this.init(e,l)}var p=this.fabric||(this.fabric={});if(p.Point)console.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.ye.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)console.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;a0)d.status="Intersection";return d};h.intersectPolygonPolygon= function(e,l){for(var o=new h("No Intersection"),d=e.length,c=0;c0)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)console.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)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;t1){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;x1?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){console.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(){console.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"};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;i1?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"#"},set:function(a,b){if((a==="scaleX"||a==="scaleY")&&ba.x&&q.xa.y&&r.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)console.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)console.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)console.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"},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"},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"},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;gc.x&&m-bc.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)console.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"#"},_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 console.warn("fabric.Text requires fabric.Object")})(); (function(){var h=fabric.util.object.extend;if(!this.fabric)this.fabric={};if(this.fabric.Image)console.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.heightp.width||p.height>l)){normalizedWidth=~~(p.width*l/p.height);normalizedHeight=l}else if(e&&e'},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 console.warn("fabric.Object is required for fabric.Image initialization")})();