diff --git a/dist/all.js b/dist/all.js index 865c7b51..7489392e 100644 --- a/dist/all.js +++ b/dist/all.js @@ -418,7 +418,8 @@ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { (function (global) { var fabric = this.fabric || (this.fabric = { }), - slice = Array.prototype.slice; + slice = Array.prototype.slice, + apply = Function.prototype.apply; fabric.util = { }; @@ -693,11 +694,12 @@ if (!Function.prototype.bind) { Function.prototype.bind = function(thisArg) { var fn = this, args = slice.call(arguments, 1); return args.length - ? function() { return fn.apply(thisArg, args.concat(slice.call(arguments))) } - : function() { return fn.apply(thisArg, arguments) }; + ? function() { return apply.call(fn, thisArg, args.concat(slice.call(arguments))); } + : function() { return apply.call(fn, thisArg, arguments) }; }; } + (function() { var IS_DONTENUM_BUGGY = (function(){ diff --git a/dist/all.min.js b/dist/all.min.js index a20176e5..d438e261 100644 --- a/dist/all.min.js +++ b/dist/all.min.js @@ -1,167 +1,167 @@ var console=console||{log:function(){},warn:function(){}},fabric=fabric||{version:0.1};if(!this.JSON)this.JSON={}; -(function(){function k(h){return h<10?"0"+h:h}function p(h){g.lastIndex=0;return g.test(h)?'"'+h.replace(g,function(o){var q=a[o];return typeof q==="string"?q:"\\u"+("0000"+o.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+h+'"'}function e(h,o){var q,r,u,x,t=d,v,w=o[h];if(w&&typeof w==="object"&&typeof w.toJSON==="function")w=w.toJSON(h);if(typeof c==="function")w=c.call(o,h,w);switch(typeof w){case "string":return p(w);case "number":return isFinite(w)?String(w):"null";case "boolean":case "null":return String(w); -case "object":if(!w)return"null";d+=b;v=[];if(Object.prototype.toString.apply(w)==="[object Array]"){x=w.length;for(q=0;q>>0;d=Number(d)||0;d=Math[d<0?"ceil":"floor"](d);if(d<0)d+=b;for(;d>>0;b>>0;a>>0;b>>0;b>>0;c>>0,b=0,a;if(arguments.length>1)a=arguments[1];else{do{if(b in this){a=this[b++];break}if(++b>=d)throw new TypeError;}while(1)}for(;b=a)a=g[b][d]}else for(;b--;)if(g[b]>=a)a=g[b];return a}};e.util.object={extend:k,clone:function(g){return k({},g)}};if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")};e.util.string={camelize:function(g){return g.replace(/-+(.)?/g, -function(d,b){return b?b.toUpperCase():""})},capitalize:function(g){return g.charAt(0).toUpperCase()+g.slice(1).toLowerCase()}};if(!Function.prototype.bind)Function.prototype.bind=function(g){var d=this,b=l.call(arguments,1);return b.length?function(){return d.apply(g,b.concat(l.call(arguments)))}:function(){return d.apply(g,arguments)}};(function(){function g(){}var d;d=function(){for(var b in{toString:1})if(b==="toString")return false;return true}()?function(b,a){if(a.toString!==Object.prototype.toString)b.prototype.toString= -a.toString;if(a.valueOf!==Object.prototype.valueOf)b.prototype.valueOf=a.valueOf;for(var c in a)b.prototype[c]=a[c]}:function(b,a){for(var c in a)b.prototype[c]=a[c]};e.util.createClass=function(){function b(){this.initialize.apply(this,arguments)}var a=null,c=l.call(arguments,0);if(typeof c[0]==="function")a=c.shift();b.superclass=a;b.subclasses=[];if(a){g.prototype=a.prototype;b.prototype=new g;a.subclasses.push(b)}a=0;for(var h=c.length;a=0.9999?"":"alpha(opacity="+h*100+")";o.filter=o.filter.replace(b,h)}else o.filter+=" alpha(opacity="+h*100+")";return c};e.util.setStyle=function(c,h){var o=c.style;if(typeof h==="string"){c.style.cssText+=";"+h;return h.indexOf("opacity")>-1?a(c,h.match(/opacity:\s*(\d?\.?\d*)/)[1]):c}for(var q in h)if(q==="opacity")a(c,h[q]);else o[q==="float"||q==="cssFloat"?typeof o.styleFloat==="undefined"?"cssFloat":"styleFloat": -q]=h[q];return c}})();(function(){var g=document.documentElement.style,d="userSelect"in g?"userSelect":"MozUserSelect"in g?"MozUserSelect":"WebkitUserSelect"in g?"WebkitUserSelect":"KhtmlUserSelect"in g?"KhtmlUserSelect":"";e.util.makeElementUnselectable=function(b){if(typeof b.onselectstart!=="undefined")b.onselectstart=e.util.falseFunction;if(d)b.style[d]="none";else if(typeof b.unselectable=="string")b.unselectable="on";return b}})();(function(){function g(b,a){d.load(b);a()}e.util.getScript=function(b, -a){var c=document.getElementsByTagName("head")[0],h=document.createElement("script"),o=true;h.type="text/javascript";h.setAttribute("runat","server");h.onload=h.onreadystatechange=function(q){if(o)if(!(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")){o=false;a(q||window.event);h=h.onload=h.onreadystatechange=null}};h.src=b;c.appendChild(h)};var d=this.Jaxer;if(d&&d.load)e.util.getScript=g})();e.util.getById=function(g){return typeof g==="string"?document.getElementById(g): -g};e.util.toArray=function(g){for(var d=[],b=g.length;b--;)d[b]=g[b];return d};e.util.makeElement=p;e.util.addClass=function(g,d){if((" "+g.className+" ").indexOf(" "+d+" ")===-1)g.className+=(g.className?" ":"")+d};e.util.wrapElement=function(g,d,b){if(typeof d==="string")d=p(d,b);g.parentNode&&g.parentNode.replaceChild(d,g);d.appendChild(g);return d};e.util.getElementOffset=function(g){var d=0,b=0;do{d+=g.offsetTop||0;b+=g.offsetLeft||0;g=g.offsetParent}while(g);return{left:b,top:d}};e.util.animate= -function(g){g||(g={});var d=+new Date,b=g.duration||500,a=d+b,c,h,o=g.onChange||function(){},q=g.easing||function(v){return-Math.cos(v*Math.PI)/2+0.5},r="startValue"in g?g.startValue:0,u="endValue"in g?g.endValue:100,x=r>u;g.onStart&&g.onStart();var t=setInterval(function(){c=+new Date;h=c>a?1:(c-d)/b;o(x?r-(r-u)*q(h):r+(u-r)*q(h));if(c>a){clearInterval(t);g.onComplete&&g.onComplete()}},10)};(function(){function g(){}var d=function(){for(var b=[function(){return new ActiveXObject("Microsoft.XMLHTTP")}, -function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}],a=b.length;a--;)try{if(b[a]())return b[a]}catch(c){}}();e.util.request=function(b,a){a||(a={});var c=a.method?a.method.toUpperCase():"GET",h=a.onComplete||function(){},o=d(),q;o.onreadystatechange=function(){if(o.readyState===4){h(o);o.onreadystatechange=g}};if(c==="GET"){q=null;if(typeof a.parameters=="string")b=b+(/\?/.test(b)?"&":"?")+a.parameters}o.open(c, -b,true);if(c==="POST"||c==="PUT")o.setRequestHeader("Content-Type","application/x-www-form-urlencoded");o.send(q);return o}})()})(this); -(function(){var k=this.fabric||(this.fabric={}),p=k.util.object.extend,e=k.util.string.capitalize,l=k.util.object.clone,g={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};k.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 b(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 c=[1,0,0,1,0,0],h=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*$"), -o=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=c.concat();if(!q||q&&!h.test(q))return r;q.replace(o,function(u){var x=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(t){return t!== -""&&t!=null});u=x[1];x=x.slice(2).map(parseFloat);switch(u){case "translate":a(r,x);break;case "rotate":d(r,x);break;case "scale":b(r,x);break;case "skewX":r[2]=x[0];break;case "skewY":r[1]=x[0];break;case "matrix":r=x;break}});return r}}();k.parseSVGDocument=function(){var d=/^(path|circle|polygon|polyline|ellipse|rect|line)$/,b=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,c){if(a){var h=k.util.toArray(a.getElementsByTagName("*")).filter(function(t){var v;if(v=d.test(t.tagName)){a:{for(t=t;t&&(t=t.parentNode);)if(t.nodeName==="pattern"){t=true;break a}t=false}v=!t}return v});if(!(!h||h&&!h.length)){var o=a.getAttribute("viewBox"),q=a.getAttribute("width"),r=a.getAttribute("height"),u=null,x=null;if(o&&(o=o.match(b))){parseInt(o[1],10);parseInt(o[2],10);u=parseInt(o[3],10);x=parseInt(o[4],10)}u=q?parseFloat(q):u;x=r?parseFloat(r):x;o={width:u,height:x}; -h=k.parseElements(h,l(o));!h||h&&!h.length||c&&c(h,o)}}}}();p(k,{parseAttributes:function(d,b){if(d){var a,c,h={};if(d.parentNode&&/^g$/i.test(d.parentNode.nodeName))h=k.parseAttributes(d.parentNode,b);var o=b.reduce(function(q,r){a=d.getAttribute(r);c=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=k.parseTransformAttribute(a);if(r in g)r=g[r];q[r]=isNaN(c)?a:c}return q},{});o=p(k.parseStyleAttribute(d), -o);return p(h,o)}},parseElements:function(d,b){var a=d.map(function(c){var h=k[e(c.tagName)];if(h&&h.fromElement)try{return h.fromElement(c,b)}catch(o){console.log(o.message||o)}});return a=a.filter(function(c){return c!=null})},parseStyleAttribute:function(d){var b={};if(d=d.getAttribute("style"))if(typeof d=="string"){d=d.split(";");d.pop();b=d.reduce(function(c,h){var o=h.split(":"),q=o[0].trim();o=o[1].trim();c[q]=o;return c},{})}else for(var a in d)if(typeof d[a]!=="undefined")b[a]=d[a];return b}, -parsePointsAttribute:function(d){if(!d)return null;d=d.trim();var b=d.indexOf(",")>-1;d=d.split(/\s+/);var a=[];if(b){b=0;for(var c=d.length;b0&&this.init(e,l)}var p=this.fabric||(this.fabric={});if(p.Point)console.warn("fabric.Point is already defined");else{k.prototype={constructor:k,init:function(e,l){this.x=e;this.y=l},add:function(e){return new k(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 k(this.x+e,this.y+e)},scalarAddEquals:function(e){this.x+=e;this.y+=e;return this},subtract:function(e){return new k(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 k(this.x-e,this.y-e)},scalarSubtractEquals:function(e){this.x-=e;this.y-=e;return this},multiply:function(e){return new k(this.x*e,this.y*e)},multiplyEquals:function(e){this.x*=e;this.y*=e;return this},divide:function(e){return new k(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 k(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 k(Math.min(this.x,e.x),Math.min(this.y,e.y))},max:function(e){return new k(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,g=this.y;this.x=e.x;this.y=e.y;e.x=l;e.y=g}};p.Point=k}})(); -(function(){function k(e){arguments.length>0&&this.init(e)}var p=this.fabric||(this.fabric={});if(p.Intersection)console.warn("fabric.Intersection is already defined");else{k.prototype.init=function(e){this.status=e;this.points=[]};k.prototype.appendPoint=function(e){this.points.push(e)};k.prototype.appendPoints=function(e){this.points=this.points.concat(e)};k.intersectLineLine=function(e,l,g,d){var b,a=(d.x-g.x)*(e.y-g.y)-(d.y-g.y)*(e.x-g.x);b=(l.x-e.x)*(e.y-g.y)-(l.y-e.y)*(e.x-g.x);g=(d.y-g.y)* -(l.x-e.x)-(d.x-g.x)*(l.y-e.y);if(g!=0){a=a/g;b=b/g;if(0<=a&&a<=1&&0<=b&&b<=1){b=new k("Intersection");b.points.push(new p.Point(e.x+a*(l.x-e.x),e.y+a*(l.y-e.y)))}else b=new k("No Intersection")}else b=a==0||b==0?new k("Coincident"):new k("Parallel");return b};k.intersectLinePolygon=function(e,l,g){for(var d=new k("No Intersection"),b=g.length,a=0;a0)d.status="Intersection";return d};k.intersectPolygonPolygon= -function(e,l){for(var g=new k("No Intersection"),d=e.length,b=0;b0)g.status="Intersection";return g};k.intersectPolygonRectangle=function(e,l,g){var d=l.min(g),b=l.max(g);g=new p.Point(b.x,d.y);var a=new p.Point(d.x,b.y);l=k.intersectLinePolygon(d,g,e);g=k.intersectLinePolygon(g,b,e);b=k.intersectLinePolygon(b,a,e);e=k.intersectLinePolygon(a,d,e);d=new k("No Intersection");d.appendPoints(l.points); -d.appendPoints(g.points);d.appendPoints(b.points);d.appendPoints(e.points);if(d.points.length>0)d.status="Intersection";return d};p.Intersection=k}})(); -(function(){function k(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=k;k.prototype._tryParsingColor=function(e){var l=k.sourceFromHex(e);l||(l=k.sourceFromRgb(e));l&&this.setSource(l)};k.prototype.getSource=function(){return this._source};k.prototype.setSource=function(e){this._source=e};k.prototype.toRgb=function(){var e=this.getSource();return"rgb("+e[0]+","+e[1]+","+e[2]+")"}; -k.prototype.toRgba=function(){var e=this.getSource();return"rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")"};k.prototype.toHex=function(){var e=this.getSource(),l=e[0].toString(16);l=l.length==1?"0"+l:l;var g=e[1].toString(16);g=g.length==1?"0"+g:g;e=e[2].toString(16);e=e.length==1?"0"+e:e;return l.toUpperCase()+g.toUpperCase()+e.toUpperCase()};k.prototype.getAlpha=function(){return this.getSource()[3]};k.prototype.setAlpha=function(e){var l=this.getSource();l[3]=e;this.setSource(l);return this};k.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};k.prototype.toBlackWhite=function(e){var l=this.getSource(),g=(l[0]*0.3+l[1]*0.59+l[2]*0.11).toFixed(0);l=l[3];e=e||127;g=Number(g)>>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+/, +"").replace(/\s+$/,"")};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:-m),f.ey-(n>0?0:-n),s,y);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(f.ex+0.5-(m>0?0:s),f.ey+0.5-(n>0?0:y),s,y)},_findSelectedObjects:function(){var f=[],m=this._groupSelector.ex,n=this._groupSelector.ey,s=m+this._groupSelector.left,y=n+this._groupSelector.top,z=new fabric.Point(w(m,s),w(n,y));n=new fabric.Point(A(m,s),A(n,y));s=0;for(y=this._objects.length;s1){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,m){this._objects.splice(m,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 m=this._config.width,n=this._config.height,s=f?this.contextTop:this.contextContainer;this.clearContext(this.contextTop);f||this.clearContext(s);s.fillStyle=this.backgroundColor;s.fillRect(0,0,m,n);f=this._objects.length;m=this.getActiveGroup(); -n=new Date;if(f)for(var y=0;y1?new fabric.PathGroup(E,C):E[0];E.setSourcePath(H);if(!(E instanceof fabric.PathGroup)){e(E,C);typeof C.angle!=="undefined"&&E.setAngle(C.angle)}n(E,F)})}, -this)}catch(B){console.log(B.message)}},loadImageFromURL:function(){var f={};return function(m,n){function s(){var B=p.getElementById(f[m]);B.width&&B.height?n(new fabric.Image(B)):setTimeout(s,50)}var y=this;if(f[m])s();else{var z=new Image;z.onload=function(){z.onload=null;y._resizeImageToFit(z);var B=new fabric.Image(z);n(B)};z.className="canvas-img-clone";z.src=m;if(this.shouldCacheImages)f[m]=Element.identify(z);p.body.appendChild(z)}}}(),loadSVGFromURL:function(f,m){function n(z){if(z=z.responseXML)(z= -z.documentElement)&&fabric.parseSVGDocument(z,function(B,C){y.cache.set(f,{objects:B.invoke("toObject"),options:C});m(B,C)})}function s(){console.log("ERROR!")}var y=this;f=f.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(f,function(z){if(z)y.cache.get(f,function(B){B=y._enlivenCachedObject(B);m(B.objects,B.options)});else new Ajax.Request(f,{method:"get",onComplete:n,onFailure:s})})},_enlivenCachedObject:function(f){var m=f.objects;f=f.options;m=m.map(function(n){return fabric[l(n.type)].fromObject(n)}); -return{objects:m,options:f}},remove:function(f){c(this._objects,f);this.renderAll();return f},fxRemove:function(f,m){var n=this;f.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){n.remove(f);typeof m==="function"&&m()}});return this},sendToBack:function(f){c(this._objects,f);this._objects.unshift(f);return this.renderAll()},bringToFront:function(f){c(this._objects,f);this._objects.push(f);return this.renderAll()},sendBackwards:function(f){var m=this._objects.indexOf(f),n=m;if(m!== -0){for(m=m-1;m>=0;--m)if(f.intersectsWithObject(this._objects[m])){n=m;break}c(this._objects,f);this._objects.splice(n,0,f)}return this.renderAll()},bringForward:function(f){var m=this.getObjects(),n=m.indexOf(f),s=n;if(n!==m.length-1){n=n+1;for(var y=this._objects.length;n0?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 m=f.getContext("2d");f=m.getImageData(0,0,f.width,f.height);var n=f.data,s=f.width,y=f.height,z,B;for(i=0;i1?c.apply(this,b.call(arguments,1)):c.call(this)}, +this.getObjects(),k=0,n=f.length;k"};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 c=k.Object.prototype.options;this.stateProperties.forEach(function(h){a[h]===c[h]&&delete a[h]}); -return a},isActive:function(){return!!this.active},setActive:function(a){this.active=!!a;return this},toString:function(){return"#"},set:function(a,c){if((a==="scaleX"||a==="scaleY")&&c"},set:function(a,b){if((a==="scaleX"||a==="scaleY")&&ba.x&&q.xa.y&&r.y=c&&r.d.y>=c)){if(r.o.x==r.d.x&&r.o.x>=a)o=r.o.x;else{o=(r.d.y-r.o.y)/(r.d.x-r.o.x);q=c-0*a;r=r.o.y-o*r.o.x;o=-(q-r)/(0-o)}if(o>=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,c=this.theta,h=this.cornersize*Math.cos(c),o=this.cornersize*Math.sin(c);c=this.cornersize/2;var q=c-o;a.tl.x-=q;a.tl.y-= -c;a.tl.corner={tl:{x:a.tl.x,y:a.tl.y},tr:{x:a.tl.x+h,y:a.tl.y+o},bl:{x:a.tl.x-o,y:a.tl.y+h}};a.tl.corner.br={x:a.tl.corner.tr.x-o,y:a.tl.corner.tr.y+h};a.tl.x+=q;a.tl.y+=c;a.tr.x+=c;a.tr.y-=c;a.tr.corner={tl:{x:a.tr.x-h,y:a.tr.y-o},tr:{x:a.tr.x,y:a.tr.y},br:{x:a.tr.x-o,y:a.tr.y+h}};a.tr.corner.bl={x:a.tr.corner.tl.x-o,y:a.tr.corner.tl.y+h};a.tr.x-=c;a.tr.y+=c;a.bl.x-=c;a.bl.y+=c;a.bl.corner={tl:{x:a.bl.x+o,y:a.bl.y-h},bl:{x:a.bl.x,y:a.bl.y},br:{x:a.bl.x+h,y:a.bl.y+o}};a.bl.corner.tr={x:a.bl.corner.br.x+ -o,y:a.bl.corner.br.y-h};a.bl.x+=c;a.bl.y-=c;a.br.x+=c;a.br.y+=c;a.br.corner={tr:{x:a.br.x+o,y:a.br.y-h},bl:{x:a.br.x-h,y:a.br.y-o},br:{x:a.br.x,y:a.br.y}};a.br.corner.tl={x:a.br.corner.bl.x+o,y:a.br.corner.bl.y-h};a.br.x-=c;a.br.y-=c;a.ml.x-=c;a.ml.y-=c;a.ml.corner={tl:{x:a.ml.x,y:a.ml.y},tr:{x:a.ml.x+h,y:a.ml.y+o},bl:{x:a.ml.x-o,y:a.ml.y+h}};a.ml.corner.br={x:a.ml.corner.tr.x-o,y:a.ml.corner.tr.y+h};a.ml.x+=c;a.ml.y+=c;a.mt.x-=c;a.mt.y-=c;a.mt.corner={tl:{x:a.mt.x,y:a.mt.y},tr:{x:a.mt.x+h,y:a.mt.y+ -o},bl:{x:a.mt.x-o,y:a.mt.y+h}};a.mt.corner.br={x:a.mt.corner.tr.x-o,y:a.mt.corner.tr.y+h};a.mt.x+=c;a.mt.y+=c;a.mr.x-=c;a.mr.y-=c;a.mr.corner={tl:{x:a.mr.x,y:a.mr.y},tr:{x:a.mr.x+h,y:a.mr.y+o},bl:{x:a.mr.x-o,y:a.mr.y+h}};a.mr.corner.br={x:a.mr.corner.tr.x-o,y:a.mr.corner.tr.y+h};a.mr.x+=c;a.mr.y+=c;a.mb.x-=c;a.mb.y-=c;a.mb.corner={tl:{x:a.mb.x,y:a.mb.y},tr:{x:a.mb.x+h,y:a.mb.y+o},bl:{x:a.mb.x-o,y:a.mb.y+h}};a.mb.corner.br={x:a.mb.corner.tr.x-o,y:a.mb.corner.tr.y+h};a.mb.x+=c;a.mb.y+=c;a=a.mb.corner; -a.tl.x-=c;a.tl.y-=c;a.tr.x-=c;a.tr.y-=c;a.br.x-=c;a.br.y-=c;a.bl.x-=c;a.bl.y-=c},toGrayscale:function(){var a=this.get("fill");a&&this.set("overlayFill",(new k.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 c=function(){},h=a.onComplete||c,o=a.onChange|| -c,q=this;k.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(r){q.setAngle(r);o()},onComplete:function(){q.setCoords();h()},onStart:function(){q.setActive(false)}});return this},fxRemove:function(a){a||(a={});var c=function(){},h=a.onComplete||c,o=a.onChange||c,q=this;k.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(r){q.set("opacity",r);o()},onComplete:h,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()}});k.Object.prototype.rotate=k.Object.prototype.setAngle}})(); -(function(){var k=this.fabric||(this.fabric={}),p=k.util.object.extend;if(!k.Line){k.Line=k.util.createClass(k.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")})}});k.Element.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");k.Line.fromElement=function(e,l){var g=k.parseAttributes(e,k.Element.ATTRIBUTE_NAMES);return new k.Line([g.x1||0,g.y1||0,g.x2||0,g.y2||0],p(g,l))}; -k.Line.fromObject=function(e){return new k.Line([e.x1,e.y1,e.x2,e.y2],e)}}})(); -(function(){var k=this.fabric||(this.fabric={}),p=Math.PI*2,e=k.util.object.extend;if(k.Circle)console.warn("fabric.Circle is already defined.");else{k.Circle=k.util.createClass(k.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,g){l.beginPath();l.arc(g? -this.left:0,g?this.top:0,this.radius,0,p,false);l.closePath();this.fill&&l.fill();this.stroke&&l.stroke()},complexity:function(){return 1}});k.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");k.Circle.fromElement=function(l,g){g||(g={});var d=k.parseAttributes(l,k.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-=g.width/2||0;if("top"in d)d.top-=g.height/ -2||0;return new k.Circle(e(d,g))};k.Circle.fromObject=function(l){return new k.Circle(l)}}})(); -(function(){var k=this.fabric||(this.fabric={});if(!k.Triangle){k.Triangle=k.util.createClass(k.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}});k.Triangle.fromObject=function(p){return new k.Triangle(p)}}})(); -(function(){var k=this.fabric||(this.fabric={}),p=Math.PI*2,e=k.util.object.extend;if(k.Ellipse)console.warn("fabric.Ellipse is already defined.");else{k.Ellipse=k.util.createClass(k.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,g){if(!(this.rx=== -0||this.ry===0))return this.callSuper("render",l,g)},_render:function(l,g){l.beginPath();l.save();l.transform(1,0,0,this.ry/this.rx,0,0);l.arc(g?this.left:0,g?this.top:0,this.rx,0,p,false);l.restore();this.stroke&&l.stroke();this.fill&&l.fill()},complexity:function(){return 1}});k.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");k.Ellipse.fromElement=function(l,g){g||(g={});var d=k.parseAttributes(l,k.Ellipse.ATTRIBUTE_NAMES);if("left"in d)d.left-=g.width/ -2||0;if("top"in d)d.top-=g.height/2||0;return new k.Ellipse(e(d,g))};k.Ellipse.fromObject=function(l){return new k.Ellipse(l)}}})(); -(function(){var k=this.fabric||(this.fabric={});if(!k.Rect){k.Rect=k.util.createClass(k.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,g=-this.width/2,d=-this.height/2,b=this.width,a=this.height;p.beginPath(); -p.moveTo(g+e,d);p.lineTo(g+b-e,d);p.bezierCurveTo(g+b,d,g+b,d+l,g+b,d+l);p.lineTo(g+b,d+a-l);p.bezierCurveTo(g+b,d+a,g+b-e,d+a,g+b-e,d+a);p.lineTo(g+e,d+a);p.bezierCurveTo(g,d+a,g,d+a-l,g,d+a-l);p.lineTo(g,d+l);p.bezierCurveTo(g,d,g+e,d,g+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}});k.Rect.ATTRIBUTE_NAMES= -"x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");k.Rect.fromElement=function(p,e){if(!p)return null;var l=k.parseAttributes(p,k.Rect.ATTRIBUTE_NAMES);l=l;l.left=l.left||0;l.top=l.top||0;l=l;var g=new k.Rect(k.util.object.extend(e||{},l));g._normalizeLeftTopProperties(l);return g};k.Rect.fromObject=function(p){return new k.Rect(p)}}})(); -(function(){var k=this.fabric||(this.fabric={});if(k.Polyline)console.warn("fabric.Polyline is already defined");else{k.Polyline=k.util.createClass(k.Object,{type:"polyline",initialize:function(e,l){l=l||{};this.set("points",e);this.callSuper("initialize",l);this._calcDimensions()},_calcDimensions:function(){return k.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return k.Polygon.prototype.toObject.call(this)},_render:function(e){var l;e.beginPath();for(var g=0,d=this.points.length;g< -d;g++){l=this.points[g];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(" ");k.Polyline.fromElement=function(e,l){if(!e)return null;l||(l={});for(var g=k.parsePointsAttribute(e.getAttribute("points")),d=k.parseAttributes(e,p),b=0,a=g.length;b"},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,b){return this.callSuper("set",d,b)},_parsePath:function(){for(var d= -[],b,a,c=0,h=this.path.length;c"},isSameColor:function(){var a=this.getObjects()[0].get("fill");return this.getObjects().every(function(c){return c.get("fill")===a})},complexity:function(){return this.paths.reduce(function(a,c){return a+(c&&c.complexity?c.complexity():0)},0)},toGrayscale:function(){for(var a=this.paths.length;a--;)this.paths[a].toGrayscale();return this},getObjects:function(){return this.paths}});k.PathGroup.fromObject=function(a){for(var c=a.paths, -h=0,o=c.length;h"},getObjects:function(){return this.objects},add:function(b){this._restoreObjectsState();this.objects.push(b);b.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(b){this._restoreObjectsState(); -d(this.objects,b);b.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(b,a){if(typeof a=="function")this.set(b,a(this[b]));else if(b==="fill"||b==="opacity"){var c=this.objects.length;for(this[b]=a;c--;)this.objects[c].set(b,a)}else this[b]=a;return this},contains:function(b){return this.objects.indexOf(b)>-1},toObject:function(){return p(this.callSuper("toObject"),{objects:g(this.objects,"clone")})},render:function(b){b.save(); -this.transform(b);for(var a=Math.max(this.scaleX,this.scaleY),c=0,h;h=this.objects[c];c++){var o=h.borderScaleFactor;h.borderScaleFactor=a;h.render(b);h.borderScaleFactor=o}this.hideBorders||this.drawBorders(b);this.hideCorners||this.drawCorners(b);b.restore();this.setCoords()},item:function(b){return this.getObjects()[b]},complexity:function(){return this.getObjects().reduce(function(b,a){b+=typeof a.complexity=="function"?a.complexity():0;return b},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState, -this);return this},_restoreObjectState:function(b){var a=this.get("left"),c=this.get("top"),h=this.getAngle()*(Math.PI/180);b.get("originalLeft");b.get("originalTop");var o=Math.cos(h)*b.get("top")+Math.sin(h)*b.get("left");h=-Math.sin(h)*b.get("top")+Math.cos(h)*b.get("left");b.setAngle(b.getAngle()+this.getAngle());b.set("left",a+h*this.get("scaleX"));b.set("top",c+o*this.get("scaleY"));b.set("scaleX",b.get("scaleX")*this.get("scaleX"));b.set("scaleY",b.get("scaleY")*this.get("scaleY"));b.setCoords(); -b.hideCorners=false;b.setActive(false);b.setCoords();return this},destroy:function(){return this._restoreObjectsState()},saveCoords:function(){this._originalLeft=this.get("left");this._originalTop=this.get("top");return this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){this.forEachObject(function(b){b.setCoords()});return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(b){this.forEachObject(function(a){a.setActive(b)}); -return this},forEachObject:function(b,a){for(var c=this.getObjects(),h=c.length;h--;)b.call(a,c[h],h,c);return this},_setOpacityIfSame:function(){var b=this.getObjects(),a=b[0]?b[0].get("opacity"):1;if(b.every(function(c){return c.get("opacity")===a}))this.opacity=a},_calcBounds:function(){var b=[],a=[],c,h;h=0;for(var o=this.objects.length;hb.x&&o-cb.y},toGrayscale:function(){for(var b=this.objects.length;b--;)this.objects[b].toGrayscale()}});k.Group.fromObject=function(b){return new k.Group(b.objects,b)}}})(); -(function(){var k=this.fabric||(this.fabric={}),p=k.util.object.extend,e=k.util.object.clone;if(k.Text)console.warn("fabric.Text is already defined");else if(k.Object){k.Text=k.util.createClass(k.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(l,g){this.originalState={};this.initStateProperties();this.text=l;this.setOptions(g);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 g=Cufon.textOptions||(Cufon.textOptions={});g.left=this.left;g.top=this.top;g.context=l;g.color=this.fill;var d=this._initDummyElement(); -this.transform(l);Cufon.replaceElement(d,{separate:"none",fontFamily:this.fontfamily});this.width=g.width;this.height=g.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,g){this[l]=g;if(l==="fontfamily")this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, -"$1"+g+"$3");return this}});k.Text.fromObject=function(l){return new k.Text(l.text,e(l))};k.Text.fromElement=function(){}}else console.warn("fabric.Text requires fabric.Object")})(); -(function(){var k=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= +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.scaleXa.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"),g=document.createElement("img"),d=this;l.width=e.width;l.height=e.height;l.getContext("2d").drawImage(e,0,0);fabric.Element.toGrayscale(l);g.onload=function(){d.setElement(g);p&&p();g.onload=l=e=imageData=null};g.width=e.width;g.height=e.height;g.src=l.toDataURL("image/png");this.__isGrayscaled=true;return this}}, +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'#'},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"),g=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=g};fabric.Image.fromURL=function(p,e,l){var g=document.createElement("img");g.onload=function(){e&&e(new fabric.Image(g,l));g=g.onload=null};g.src=p}}else console.warn("fabric.Object is required for fabric.Image initialization")})(); +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")})(); diff --git a/src/util.js b/src/util.js index 38311233..02be4ee1 100644 --- a/src/util.js +++ b/src/util.js @@ -1,7 +1,8 @@ (function (global) { var fabric = this.fabric || (this.fabric = { }), - slice = Array.prototype.slice; + slice = Array.prototype.slice, + apply = Function.prototype.apply; fabric.util = { }; diff --git a/src/util/dom_misc.js b/src/util/dom_misc.js index df2610af..3070df06 100644 --- a/src/util/dom_misc.js +++ b/src/util/dom_misc.js @@ -78,7 +78,6 @@ function getElementOffset(element) { else if (typeof element.unselectable == 'string') { element.unselectable = 'on'; } - // TODO (kangax): test return value return element; } diff --git a/src/util/lang_function.js b/src/util/lang_function.js index 03475ef9..e534b825 100644 --- a/src/util/lang_function.js +++ b/src/util/lang_function.js @@ -2,7 +2,8 @@ if (!Function.prototype.bind) { Function.prototype.bind = function(thisArg) { var fn = this, args = slice.call(arguments, 1); return args.length - ? function() { return fn.apply(thisArg, args.concat(slice.call(arguments))) } - : function() { return fn.apply(thisArg, arguments) }; + ? function() { return apply.call(fn, thisArg, args.concat(slice.call(arguments))); } + : function() { return apply.call(fn, thisArg, arguments) }; }; -} \ No newline at end of file +} + diff --git a/test/unit/util.js b/test/unit/util.js index f7e7a321..02fea62e 100644 --- a/test/unit/util.js +++ b/test/unit/util.js @@ -2,7 +2,7 @@ module('fabric.util'); - test('toFixed', function(){ + test('fabric.util.toFixed', function(){ ok(typeof fabric.util.toFixed == 'function'); function test(what) { @@ -21,7 +21,7 @@ test.call(this, 166.66666666666666666666); // number }); - test('removeFromArray', function() { + test('fabric.util.removeFromArray', function() { var testArray = [1,2,3,4,5]; ok(typeof fabric.util.removeFromArray == 'function'); @@ -47,7 +47,7 @@ same(['0'], testArray, 'should use (strict) identity comparison, rather than equality one'); }); - test('degreesToRadians', function(){ + test('fabric.util.degreesToRadians', function(){ ok(typeof fabric.util.degreesToRadians == 'function'); equals(fabric.util.degreesToRadians(0), 0); equals(fabric.util.degreesToRadians(90), Math.PI / 2); @@ -56,7 +56,7 @@ same(fabric.util.degreesToRadians(), NaN); }); - test('getRandomInt', function() { + test('fabric.util.getRandomInt', function() { ok(typeof fabric.util.getRandomInt == 'function'); var randomInts = []; @@ -73,7 +73,7 @@ ok(!areAllTheSame); }); - test('falseFunction', function() { + test('fabric.util.falseFunction', function() { ok(typeof fabric.util.falseFunction == 'function'); equals(fabric.util.falseFunction(), false); }); @@ -83,7 +83,7 @@ equals('\t\n foo bar \n \xA0 '.trim(), 'foo bar'); }); - test('camelize', function() { + test('fabric.util.string.camelize', function() { var camelize = fabric.util.string.camelize; ok(typeof camelize == 'function'); @@ -99,7 +99,7 @@ equals(camelize('--double'), 'Double'); }); - test('capitalize', function() { + test('fabric.util.string.capitalize', function() { var capitalize = fabric.util.string.capitalize; ok(typeof capitalize == 'function'); @@ -113,7 +113,7 @@ equals(capitalize('2foo'), '2foo'); }); - test('extend', function() { + test('fabric.util.object.extend', function() { var extend = fabric.util.object.extend; ok(typeof extend == 'function'); @@ -137,7 +137,7 @@ equals(source.x, 2); }); - test('clone', function() { + test('fabric.util.object.clone', function() { var clone = fabric.util.object.clone; ok(typeof clone == 'function'); @@ -150,7 +150,7 @@ equals(clone.y, obj.y); }); - test('bind', function() { + test('Function.prototype.bind', function() { ok(typeof Function.prototype.bind == 'function'); var obj = { }; @@ -168,7 +168,7 @@ same([obj, 1, 2], bound(2)); }); - test('getById', function() { + test('fabric.util.getById', function() { ok(typeof fabric.util.getById == 'function'); var el = document.createElement('div'); @@ -180,7 +180,7 @@ equals(null, fabric.util.getById('likely-non-existent-id')); }); - test('toArray', function() { + test('fabric.util.toArray', function() { ok(typeof fabric.util.toArray == 'function'); same(['x', 'y'], fabric.util.toArray({ 0: 'x', 1: 'y', length: 2 })); @@ -195,7 +195,7 @@ equals(nodelist[1], converted[1]); }); - test('makeElement', function() { + test('fabric.util.makeElement', function() { var makeElement = fabric.util.makeElement; ok(typeof makeElement == 'function'); @@ -213,7 +213,7 @@ equals(el.getAttribute('some_random-attribute'), 'woot'); }); - test('addClass', function() { + test('fabric.util.addClass', function() { var addClass = fabric.util.addClass; ok(typeof addClass == 'function'); @@ -231,7 +231,7 @@ equals(el.className, 'foo bar baz qux'); }); - test('wrapElement', function() { + test('fabric.util.wrapElement', function() { var wrapElement = fabric.util.wrapElement; ok(typeof wrapElement == 'function'); @@ -259,4 +259,25 @@ equals(wrapper.parentNode, parentEl); equals(wrapper.firstChild, childEl); }); + + test('fabric.util.makeElementUnselectable', function() { + var makeElementUnselectable = fabric.util.makeElementUnselectable; + + ok(typeof makeElementUnselectable == 'function'); + + var el = document.createElement('p'); + el.appendChild(document.createTextNode('foo')); + + equals(el, makeElementUnselectable(el), 'should be "chainable"'); + equals(el.onselectstart, fabric.util.falseFunction); + + // not sure if it's a good idea to test implementation details here + // functional test would probably make more sense + if (typeof el.unselectable == 'string') { + equals('on', el.unselectable); + } + else if (typeof el.userSelect != 'undefined') { + equals('none', el.userSelect); + } + }); })(); \ No newline at end of file