diff --git a/dist/all.js b/dist/all.js index 8a0ab229..539374cd 100644 --- a/dist/all.js +++ b/dist/all.js @@ -3671,6 +3671,19 @@ fabric.util.animate = animate; /* NOOP */ }, + /** + * Callback; invoked every time active object is moved + * @method onObjectMove + * @param {fabric.Object} object that's being moved + */ + onObjectMove: null, + + /** + * Callback; invoked when a mouseup event occurs, and at the end of all other transformations + * @method onMouseUp + */ + onMouseUp: null, + /** * Calculates canvas element offset relative to the document * This method is also attached as "resize" event handler of window @@ -3998,12 +4011,17 @@ fabric.util.animate = animate; this.renderAll(); this._setCursorFromEvent(e, target); + this._setCursor(''); var _this = this; setTimeout(function () { _this._setCursorFromEvent(e, target); }, 50); + + if (this.onMouseUp) { + this.onMouseUp(); + } }, _shouldClearSelection: function (e) { @@ -4331,6 +4349,9 @@ fabric.util.animate = animate; } else { this._translateObject(x, y); + if (this.onObjectMove) { + this.onObjectMove(this._currentTransform.target); + } } this.renderAll(); } diff --git a/dist/all.min-via-goog-cc.js b/dist/all.min-via-goog-cc.js deleted file mode 100644 index 32b5b9b9..00000000 --- a/dist/all.min-via-goog-cc.js +++ /dev/null @@ -1,165 +0,0 @@ -if(typeof console=="undefined")var console={log:function(){},warn:function(){}};if(!this.JSON)this.JSON={}; -(function(){function e(k){return k<10?"0"+k:k}function f(k){g.lastIndex=0;return g.test(k)?'"'+k.replace(g,function(m){var n=b[m];return typeof n==="string"?n:"\\u"+("0000"+m.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+k+'"'}function a(k,m){var n,o,s,r,u=h,q,p=m[k];if(p&&typeof p==="object"&&typeof p.toJSON==="function")p=p.toJSON(k);if(typeof d==="function")p=d.call(m,k,p);switch(typeof p){case "string":return f(p);case "number":return isFinite(p)?String(p):"null";case "boolean":case "null":return String(p); -case "object":if(!p)return"null";h+=l;q=[];if(Object.prototype.toString.apply(p)==="[object Array]"){r=p.length;for(n=0;n>>0;l=Number(l)||0;l=Math[l<0?"ceil":"floor"](l);if(l<0)l+=b;for(;l>>0;b>>0;d>>0;b>>0;b>>0;k>>0,b=0,d;if(arguments.length>1)d=arguments[1];else{do{if(b in this){d=this[b++];break}if(++b>=l)throw new TypeError;}while(1)}for(;b< -l;b++)if(b in this)d=h.call(null,d,this[b],b,this);return d};c.util.array={invoke:function(h,l){for(var b=g.call(arguments,2),d=[],k=0,m=h.length;k=d)d=h[b][l]}else for(;b--;)if(h[b]>=d)d=h[b];return d}};c.util.object= -{extend:e,clone:function(h){return e({},h)}};if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")};c.util.string={camelize:function(h){return h.replace(/-+(.)?/g,function(l,b){return b?b.toUpperCase():""})},capitalize:function(h){return h.charAt(0).toUpperCase()+h.slice(1).toLowerCase()}};if(!Function.prototype.bind)Function.prototype.bind=function(h){var l=this,b=Array.prototype.slice.call(arguments,1);return function(){return l.apply(h,b.concat(Array.prototype.slice.call(arguments)))}}; -(function(){function h(){}var l;l=function(){for(var b in{toString:1})if(b==="toString")return false;return true}()?function(b,d){if(d.toString!==Object.prototype.toString)b.prototype.toString=d.toString;if(d.valueOf!==Object.prototype.valueOf)b.prototype.valueOf=d.valueOf;for(var k in d)b.prototype[k]=d[k]}:function(b,d){for(var k in d)b.prototype[k]=d[k]};c.util.createClass=function(){function b(){this.initialize.apply(this,arguments)}var d=null,k=g.call(arguments,0);if(typeof k[0]==="function")d= -k.shift();b.superclass=d;b.subclasses=[];if(d){h.prototype=d.prototype;b.prototype=new h;d.subclasses.push(b)}d=0;for(var m=k.length;d=0.9999?"":"alpha(opacity="+m*100+")";n.filter=n.filter.replace(b,m)}else n.filter+=" alpha(opacity="+m*100+")";return k};c.util.setStyle=function(k,m){var n=k.style;if(typeof m==="string"){k.style.cssText+= -";"+m;return m.indexOf("opacity")>-1?d(k,m.match(/opacity:\s*(\d?\.?\d*)/)[1]):k}for(var o in m)if(o==="opacity")d(k,m[o]);else n[o==="float"||o==="cssFloat"?typeof n.styleFloat==="undefined"?"cssFloat":"styleFloat":o]=m[o];return k}})();(function(){var h=document.documentElement.style,l="userSelect"in h?"userSelect":"MozUserSelect"in h?"MozUserSelect":"WebkitUserSelect"in h?"WebkitUserSelect":"KhtmlUserSelect"in h?"KhtmlUserSelect":"";c.util.makeElementUnselectable=function(b){if(typeof b.onselectstart!== -"undefined")b.onselectstart=a;if(l)b.style[l]="none";else if(typeof b.unselectable=="string")b.unselectable="on";return b}})();(function(){function h(b,d){l.load(b);d()}c.util.getScript=function(b,d){var k=document.getElementsByTagName("head")[0],m=document.createElement("script"),n=true;m.type="text/javascript";m.setAttribute("runat","server");m.onload=m.onreadystatechange=function(o){if(n)if(!(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")){n=false;d(o|| -window.event);m=m.onload=m.onreadystatechange=null}};m.src=b;k.appendChild(m)};var l=this.Jaxer;if(l&&l.load)c.util.getScript=h})();c.util.getById=function(h){return typeof h==="string"?document.getElementById(h):h};c.util.toArray=function(h){for(var l=[],b=h.length;b--;)l[b]=h[b];return l};c.util.makeElement=f;c.util.addClass=function(h,l){if((" "+h.className+" ").indexOf(" "+l+" ")===-1)h.className+=(h.className?" ":"")+l};c.util.wrapElement=function(h,l,b){if(typeof l==="string")l=f(l,b);h.parentNode&& -h.parentNode.replaceChild(l,h);l.appendChild(h);return l};c.util.getElementOffset=function(h){var l=0,b=0;do{l+=h.offsetTop||0;b+=h.offsetLeft||0;h=h.offsetParent}while(h);return{left:b,top:l}};c.util.animate=function(h){h||(h={});var l=+new Date,b=h.duration||500,d=l+b,k,m,n=h.onChange||function(){},o=h.easing||function(p){return-Math.cos(p*Math.PI)/2+0.5},s="startValue"in h?h.startValue:0,r="endValue"in h?h.endValue:100,u=s>r;h.onStart&&h.onStart();var q=setInterval(function(){k=+new Date;m=k>d? -1:(k-l)/b;n(u?s-(s-r)*o(m):s+(r-s)*o(m));if(k>d){clearInterval(q);h.onComplete&&h.onComplete()}},10)};(function(){function h(){}var l=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}],d=b.length;d--;)try{if(b[d]())return b[d]}catch(k){}}();c.util.request=function(b,d){d||(d={});var k=d.method?d.method.toUpperCase():"GET", -m=d.onComplete||function(){},n=l(),o;n.onreadystatechange=function(){if(n.readyState===4){m(n);n.onreadystatechange=h}};if(k==="GET"){o=null;if(typeof d.parameters=="string")b=b+(/\?/.test(b)?"&":"?")+d.parameters}n.open(k,b,true);if(k==="POST"||k==="PUT")n.setRequestHeader("Content-Type","application/x-www-form-urlencoded");n.send(o);return n}})();(function(){var h=Math.PI/180;c.util.removeFromArray=function(l,b){var d=l.indexOf(b);d!==-1&&l.splice(d,1);return l};c.util.degreesToRadians=function(l){return l* -h};c.util.toFixed=function(l,b){return parseFloat(Number(l).toFixed(b))};c.util.getRandomInt=function(l,b){return Math.floor(Math.random()*(b-l+1))+l}})()})(this); -(function(){var e=this.fabric||(this.fabric={}),f={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};e.parseTransformAttribute=function(){function a(d,k){var m=k[0];d[0]=Math.cos(m);d[1]=Math.sin(m);d[2]=-Math.sin(m);d[3]=Math.cos(m)}function c(d,k){var m=k.length===2?k[1]:k[0];d[0]=k[0];d[3]=m}function g(d,k){d[4]=k[0];if(k.length===2)d[5]=k[1]}var h=[1,0,0,1,0,0],l=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*$"), -b=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(d){var k=h.concat();if(!d||d&&!l.test(d))return k;d.replace(b,function(m){var n=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(m).filter(function(o){return o!== -""&&o!=null});m=n[1];n=n.slice(2).map(parseFloat);switch(m){case "translate":g(k,n);break;case "rotate":a(k,n);break;case "scale":c(k,n);break;case "skewX":k[2]=n[0];break;case "skewY":k[1]=n[0];break;case "matrix":k=n;break}});return k}}();e.parseSVGDocument=function(){var a=/^(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(g,h){if(g){var l=e.util.toArray(g.getElementsByTagName("*")).filter(function(o){var s;if(s=a.test(o.tagName)){a:{for(o=o;o&&(o=o.parentNode);)if(o.nodeName==="pattern"){o=true;break a}o=false}s=!o}return s});if(!(!l||l&&!l.length)){var b=g.getAttribute("viewBox"),d=g.getAttribute("width"),k=g.getAttribute("height"),m=null,n=null;if(b&&(b=b.match(c))){parseInt(b[1],10);parseInt(b[2],10);m=parseInt(b[3],10);n=parseInt(b[4],10)}m=d?parseFloat(d):m;n=k?parseFloat(k):n;b={width:m,height:n}; -l=e.parseElements(l,e.util.object.clone(b));!l||l&&!l.length||h&&h(l,b)}}}}();e.util.object.extend(e,{parseAttributes:function(a,c){if(a){var g,h,l={};if(a.parentNode&&/^g$/i.test(a.parentNode.nodeName))l=e.parseAttributes(a.parentNode,c);var b=c.reduce(function(d,k){g=a.getAttribute(k);h=parseFloat(g);if(g){if((k==="fill"||k==="stroke")&&g==="none")g="";if(k==="fill-rule")g=g==="evenodd"?"destination-over":g;if(k==="transform")g=e.parseTransformAttribute(g);if(k in f)k=f[k];d[k]=isNaN(h)?g:h}return d}, -{});b=e.util.object.extend(e.parseStyleAttribute(a),b);return e.util.object.extend(l,b)}},parseElements:function(a,c){var g=a.map(function(h){var l=e[e.util.string.capitalize(h.tagName)];if(l&&l.fromElement)try{return l.fromElement(h,c)}catch(b){console.log(b.message||b)}});return g=g.filter(function(h){return h!=null})},parseStyleAttribute:function(a){var c={};if(a=a.getAttribute("style"))if(typeof a=="string"){a=a.split(";");a.pop();c=a.reduce(function(h,l){var b=l.split(":"),d=b[0].trim();b=b[1].trim(); -h[d]=b;return h},{})}else for(var g in a)if(typeof a[g]!=="undefined")c[g]=a[g];return c},parsePointsAttribute:function(a){if(!a)return null;a=a.trim().split(/\s+/);a=a.reduce(function(c,g){g=g.split(",");c.push({x:parseFloat(g[0]),y:parseFloat(g[1])});return c},[]);if(a.length%2!==0)return null;return a}})})(); -(function(){function e(a,c){arguments.length>0&&this.init(a,c)}var f=this.fabric||(this.fabric={});if(f.Point)console.warn("fabric.Point is already defined");else{e.prototype={constructor:e,init:function(a,c){this.x=a;this.y=c},add:function(a){return new e(this.x+a.x,this.y+a.y)},addEquals:function(a){this.x+=a.x;this.y+=a.y;return this},scalarAdd:function(a){return new e(this.x+a,this.y+a)},scalarAddEquals:function(a){this.x+=a;this.y+=a;return this},subtract:function(a){return new e(this.x-a.x, -this.y-a.y)},subtractEquals:function(a){this.x-=a.x;this.y-=a.y;return this},scalarSubtract:function(a){return new e(this.x-a,this.y-a)},scalarSubtractEquals:function(a){this.x-=a;this.y-=a;return this},multiply:function(a){return new e(this.x*a,this.y*a)},multiplyEquals:function(a){this.x*=a;this.y*=a;return this},divide:function(a){return new e(this.x/a,this.y/a)},divideEquals:function(a){this.x/=a;this.y/=a;return this},eq:function(a){return this.x==a.x&&this.y==a.y},lt:function(a){return this.x< -a.x&&this.ya.x&&this.y>a.y},gte:function(a){return this.x>=a.x&&this.y>=a.y},lerp:function(a,c){return new e(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c)},distanceFrom:function(a){var c=this.x-a.x;a=this.y-a.y;return Math.sqrt(c*c+a*a)},min:function(a){return new e(Math.min(this.x,a.x),Math.min(this.y,a.y))},max:function(a){return new e(Math.max(this.x,a.x),Math.max(this.y,a.y))},toString:function(){return this.x+ -","+this.y},setXY:function(a,c){this.x=a;this.y=c},setFromPoint:function(a){this.x=a.x;this.y=a.y},swap:function(a){var c=this.x,g=this.y;this.x=a.x;this.y=a.y;a.x=c;a.y=g}};f.Point=e}})(); -(function(){function e(a){arguments.length>0&&this.init(a)}var f=this.fabric||(this.fabric={});if(f.Intersection)console.warn("fabric.Intersection is already defined");else{e.prototype.init=function(a){this.status=a;this.points=[]};e.prototype.appendPoint=function(a){this.points.push(a)};e.prototype.appendPoints=function(a){this.points=this.points.concat(a)};e.intersectLineLine=function(a,c,g,h){var l,b=(h.x-g.x)*(a.y-g.y)-(h.y-g.y)*(a.x-g.x);l=(c.x-a.x)*(a.y-g.y)-(c.y-a.y)*(a.x-g.x);g=(h.y-g.y)* -(c.x-a.x)-(h.x-g.x)*(c.y-a.y);if(g!=0){b=b/g;l=l/g;if(0<=b&&b<=1&&0<=l&&l<=1){l=new e("Intersection");l.points.push(new f.Point(a.x+b*(c.x-a.x),a.y+b*(c.y-a.y)))}else l=new e("No Intersection")}else l=b==0||l==0?new e("Coincident"):new e("Parallel");return l};e.intersectLinePolygon=function(a,c,g){for(var h=new e("No Intersection"),l=g.length,b=0;b0)h.status="Intersection";return h};e.intersectPolygonPolygon= -function(a,c){for(var g=new e("No Intersection"),h=a.length,l=0;l0)g.status="Intersection";return g};e.intersectPolygonRectangle=function(a,c,g){var h=c.min(g),l=c.max(g);g=new f.Point(l.x,h.y);var b=new f.Point(h.x,l.y);c=e.intersectLinePolygon(h,g,a);g=e.intersectLinePolygon(g,l,a);l=e.intersectLinePolygon(l,b,a);a=e.intersectLinePolygon(b,h,a);h=new e("No Intersection");h.appendPoints(c.points); -h.appendPoints(g.points);h.appendPoints(l.points);h.appendPoints(a.points);if(h.points.length>0)h.status="Intersection";return h};f.Intersection=e}})(); -(function(){function e(a){a?this._tryParsingColor(a):this.setSource([0,0,0,1])}var f=this.fabric||(this.fabric={});if(f.Color)console.warn("fabric.Color is already defined.");else{f.Color=e;e.prototype._tryParsingColor=function(a){var c=e.sourceFromHex(a);c||(c=e.sourceFromRgb(a));c&&this.setSource(c)};e.prototype.getSource=function(){return this._source};e.prototype.setSource=function(a){this._source=a};e.prototype.toRgb=function(){var a=this.getSource();return"rgb("+a[0]+","+a[1]+","+a[2]+")"}; -e.prototype.toRgba=function(){var a=this.getSource();return"rgba("+a[0]+","+a[1]+","+a[2]+","+a[3]+")"};e.prototype.toHex=function(){var a=this.getSource(),c=a[0].toString(16);c=c.length==1?"0"+c:c;var g=a[1].toString(16);g=g.length==1?"0"+g:g;a=a[2].toString(16);a=a.length==1?"0"+a:a;return c.toUpperCase()+g.toUpperCase()+a.toUpperCase()};e.prototype.getAlpha=function(){return this.getSource()[3]};e.prototype.setAlpha=function(a){var c=this.getSource();c[3]=a;this.setSource(c);return this};e.prototype.toGrayscale= -function(){var a=this.getSource(),c=parseInt((a[0]*0.3+a[1]*0.59+a[2]*0.11).toFixed(0),10);this.setSource([c,c,c,a[3]]);return this};e.prototype.toBlackWhite=function(a){var c=this.getSource(),g=(c[0]*0.3+c[1]*0.59+c[2]*0.11).toFixed(0);c=c[3];a=a||127;g=Number(g)0?0:-b),this._groupSelector.ey-(d>0?0:-d),k,m);this._oContextTop.lineWidth=this.selectionLineWidth;this._oContextTop.strokeStyle=this.selectionBorderColor;this._oContextTop.strokeRect(this._groupSelector.ex+0.5-(b>0?0:k),this._groupSelector.ey+0.5-(d>0? -0:m),k,m)},_findSelectedObjects:function(){var b=[],d=this._groupSelector.ex,k=this._groupSelector.ey,m=d+this._groupSelector.left,n=k+this._groupSelector.top,o=new fabric.Point(Math.min(d,m),Math.min(k,n));k=new fabric.Point(Math.max(d,m),Math.max(k,n));m=0;for(n=this._aObjects.length;m -1){b=new fabric.Group(b);this.setActiveGroup(b);b.saveCoords();fabric.util.fireEvent("group:selected",{target:b})}this.renderAll()},add:function(){this._aObjects.push.apply(this._aObjects,arguments);this.renderAll();return this},insertAt:function(b,d){this._aObjects.splice(d,0,b);this.renderAll();return this},getObjects:function(){return this._aObjects},getContext:function(){return this._oContextTop},clearContext:function(b){b.clearRect(0,0,this._oConfig.width,this._oConfig.height);return this},clear:function(){this._aObjects.length= -0;this.clearContext(this._oContextTop);this.clearContext(this._oContextContainer);this.renderAll();return this},renderAll:function(b){var d=this._oConfig.width,k=this._oConfig.height,m=b?this._oContextTop:this._oContextContainer;this.clearContext(this._oContextTop);m!==this._oContextTop&&this.clearContext(m);if(b){if(!l&&this.backgroundColor==="transparent")var n=true;if(!n)m.fillStyle=this.backgroundColor;m.fillRect(0,0,d,k)}b=this._aObjects.length;d=this.getActiveGroup();if(b)for(k=0;k1?new fabric.PathGroup(t,r):t[0];t.setSourcePath(p);if(!(t instanceof fabric.PathGroup)){fabric.util.object.extend(t,r);typeof r.angle!=="undefined"&&t.setAngle(r.angle)}k(t,u)})},this)}catch(s){console.log(s.message)}},loadImageFromURL:function(){var b= -{};return function(d,k){function m(){var s=f.getElementById(b[d]);s.width&&s.height?k(new fabric.Image(s)):setTimeout(m,50)}var n=this;if(b[d])m();else{var o=new Image;o.onload=function(){o.onload=null;n._resizeImageToFit(o);var s=new fabric.Image(o);k(s)};o.className="canvas-img-clone";o.src=d;if(this.shouldCacheImages)b[d]=Element.identify(o);f.body.appendChild(o)}}}(),loadSVGFromURL:function(b,d){function k(o){if(o=o.responseXML)(o=o.documentElement)&&fabric.parseSVGDocument(o,function(s,r){n.cache.set(b, -{objects:s.invoke("toObject"),options:r});d(s,r)})}function m(){console.log("ERROR!")}var n=this;b=b.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(b,function(o){if(o)n.cache.get(b,function(s){s=n._enlivenCachedObject(s);d(s.objects,s.options)});else new Ajax.Request(b,{method:"get",onComplete:k,onFailure:m})})},_enlivenCachedObject:function(b){var d=b.objects;b=b.options;d=d.map(function(k){return a[k.type.capitalize()].fromObject(k)});return{objects:d,options:b}},remove:function(b){fabric.util.removeFromArray(this._aObjects, -b);this.renderAll();return b},fxRemove:function(b,d){var k=this;b.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){k.remove(b);typeof d==="function"&&d()}});return this},sendToBack:function(b){fabric.util.removeFromArray(this._aObjects,b);this._aObjects.unshift(b);return this.renderAll()},bringToFront:function(b){fabric.util.removeFromArray(this._aObjects,b);this._aObjects.push(b);return this.renderAll()},sendBackwards:function(b){var d=this._aObjects.indexOf(b),k=d;if(d!==0){for(d= -d-1;d>=0;--d)if(b.intersectsWithObject(this._aObjects[d])){k=d;break}fabric.util.removeFromArray(this._aObjects,b);this._aObjects.splice(k,0,b)}return this.renderAll()},bringForward:function(b){var d=this.getObjects(),k=d.indexOf(b),m=k;if(k!==d.length-1){k=k+1;for(var n=this._aObjects.length;k"};fabric.util.object.extend(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(b){var d=b.getContext("2d");b=d.getImageData(0,0,b.width,b.height);var k= -b.data,m=b.width,n=b.height,o,s;for(i=0;i1?c.apply(this,f.call(arguments,1)):c.call(this)},initialize:function(a){this.setOptions(a);this._importProperties();this.originalState= -{};this.setCoords();this.saveState()},setOptions:function(a){this.options=e.util.object.extend(this._getOptions(),a)},_getOptions:function(){return e.util.object.extend(e.util.object.clone(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))},toJSON:function(){return JSON.stringify(this.toObject())},toObject:function(){var a=e.util.toFixed;a={type:this.type,left:a(this.left,this.NUM_FRACTION_DIGITS),top:a(this.top,this.NUM_FRACTION_DIGITS),width:a(this.width,this.NUM_FRACTION_DIGITS),height:a(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill, -overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,scaleX:a(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:a(this.scaleY,this.NUM_FRACTION_DIGITS),angle:a(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:a(this.opacity,this.NUM_FRACTION_DIGITS)};this.includeDefaultValues||(a=this._removeDefaultValues(a));return a},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(a){var c=e.Object.prototype.options;this.stateProperties.forEach(function(g){a[g]=== -c[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,c){if((a==="scaleX"||a==="scaleY")&&ca.x&&l.xa.y&&b.y=c&&b.d.y>=c)){if(b.o.x==b.d.x&&b.o.x>=a)h=b.o.x;else{h=(b.d.y-b.o.y)/(b.d.x-b.o.x);l=c-0*a;b=b.o.y-h*b.o.x;h=-(l-b)/(0-h)}if(h>=a)d+=1;if(d==2)break}}return d},_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,g=this.cornersize*Math.cos(c),h=this.cornersize*Math.sin(c);c=this.cornersize/2;var l=c-h;a.tl.x-=l;a.tl.y-=c;a.tl.corner={tl:{x:a.tl.x,y:a.tl.y},tr:{x:a.tl.x+g,y:a.tl.y+h},bl:{x:a.tl.x-h,y:a.tl.y+g}};a.tl.corner.br={x:a.tl.corner.tr.x-h,y:a.tl.corner.tr.y+g};a.tl.x+=l;a.tl.y+=c;a.tr.x+=c;a.tr.y-=c;a.tr.corner={tl:{x:a.tr.x-g,y:a.tr.y-h},tr:{x:a.tr.x,y:a.tr.y},br:{x:a.tr.x-h,y:a.tr.y+g}};a.tr.corner.bl={x:a.tr.corner.tl.x-h,y:a.tr.corner.tl.y+g};a.tr.x-=c;a.tr.y+=c;a.bl.x-=c;a.bl.y+= -c;a.bl.corner={tl:{x:a.bl.x+h,y:a.bl.y-g},bl:{x:a.bl.x,y:a.bl.y},br:{x:a.bl.x+g,y:a.bl.y+h}};a.bl.corner.tr={x:a.bl.corner.br.x+h,y:a.bl.corner.br.y-g};a.bl.x+=c;a.bl.y-=c;a.br.x+=c;a.br.y+=c;a.br.corner={tr:{x:a.br.x+h,y:a.br.y-g},bl:{x:a.br.x-g,y:a.br.y-h},br:{x:a.br.x,y:a.br.y}};a.br.corner.tl={x:a.br.corner.bl.x+h,y:a.br.corner.bl.y-g};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+g,y:a.ml.y+h},bl:{x:a.ml.x-h,y:a.ml.y+g}};a.ml.corner.br={x:a.ml.corner.tr.x- -h,y:a.ml.corner.tr.y+g};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+g,y:a.mt.y+h},bl:{x:a.mt.x-h,y:a.mt.y+g}};a.mt.corner.br={x:a.mt.corner.tr.x-h,y:a.mt.corner.tr.y+g};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+g,y:a.mr.y+h},bl:{x:a.mr.x-h,y:a.mr.y+g}};a.mr.corner.br={x:a.mr.corner.tr.x-h,y:a.mr.corner.tr.y+g};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+g,y:a.mb.y+ -h},bl:{x:a.mb.x-h,y:a.mb.y+g}};a.mb.corner.br={x:a.mb.corner.tr.x-h,y:a.mb.corner.tr.y+g};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 e.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(){},g=a.onComplete||c,h=a.onChange||c,l=this;e.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(b){l.setAngle(b);h()},onComplete:function(){l.setCoords();g()},onStart:function(){l.setActive(false)}});return this},fxRemove:function(a){a||(a={});var c=function(){},g=a.onComplete||c,h=a.onChange||c,l=this;e.util.animate({startValue:this.get("opacity"),endValue:0, -duration:this.FX_DURATION,onChange:function(b){l.set("opacity",b);h()},onComplete:g,onStart:function(){l.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}});e.Object.prototype.rotate=e.Object.prototype.setAngle}})(); -(function(){var e=this.fabric||(this.fabric={});if(!e.Line){e.Line=e.util.createClass(e.Object,{type:"line",initialize:function(f,a){f||(f=[0,0,0,0]);this.callSuper("initialize",a);this.set("x1",f[0]);this.set("y1",f[1]);this.set("x2",f[2]);this.set("y2",f[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(f){f.beginPath();f.moveTo(-this.width/2,-this.height/2);f.lineTo(this.width/2, -this.height/2);var a=f.strokeStyle;f.strokeStyle=f.fillStyle;f.stroke();f.strokeStyle=a},complexity:function(){return 1},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});e.Element.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");e.Line.fromElement=function(f,a){var c=e.parseAttributes(f,e.Element.ATTRIBUTE_NAMES);return new e.Line([c.x1||0,c.y1||0,c.x2||0,c.y2||0],e.util.object.extend(c, -a))};e.Line.fromObject=function(f){return new e.Line([f.x1,f.y1,f.x2,f.y2],f)}}})(); -(function(){var e=this.fabric||(this.fabric={}),f=Math.PI*2;if(e.Circle)console.warn("fabric.Circle is already defined.");else{e.Circle=e.util.createClass(e.Object,{type:"circle",initialize:function(a){a=a||{};this.set("radius",a.radius||0);this.callSuper("initialize",a);a=this.get("radius")*2*this.get("scaleX");this.set("width",a).set("height",a)},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(a){a.beginPath();a.arc(0,0,this.radius, -0,f,false);this.fill&&a.fill();this.stroke&&a.stroke()},complexity:function(){return 1}});e.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");e.Circle.fromElement=function(a,c){var g=e.parseAttributes(a,e.Circle.ATTRIBUTE_NAMES);if(!("radius"in g&&g.radius>0))throw Error("value of `r` attribute is required and can not be negative");return new e.Circle(e.util.object.extend(g,c))};e.Circle.fromObject=function(a){return new e.Circle(a)}}})(); -(function(){var e=this.fabric||(this.fabric={});if(!e.Triangle){e.Triangle=e.util.createClass(e.Object,{type:"triangle",initialize:function(f){f=f||{};this.callSuper("initialize",f);this.set("width",f.width||100).set("height",f.height||100)},_render:function(f){f.beginPath();f.moveTo(-this.width/2,this.height/2);f.lineTo(0,-this.height/2);f.lineTo(this.width/2,this.height/2);this.fill&&f.fill();this.stroke&&f.stroke()},complexity:function(){return 1}});e.Triangle.fromObject=function(f){return new e.Triangle(f)}}})(); -(function(){var e=this.fabric||(this.fabric={});if(e.Ellipse)console.warn("fabric.Ellipse is already defined.");else{e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",initialize:function(f){f=f||{};this.callSuper("initialize",f);this.set("rx",f.rx||0);this.set("ry",f.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(f,a){if(!(this.rx=== -0||this.ry===0))return this.callSuper("render",f,a)},_render:function(f){f.beginPath();f.save();f.transform(1,0,0,this.ry/this.rx,0,0);f.arc(0,0,this.rx,0,Math.PI*2,false);f.restore();this.stroke&&f.stroke();this.fill&&f.fill()},complexity:function(){return 1}});e.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");e.Ellipse.fromElement=function(f,a){var c=e.parseAttributes(f,e.Ellipse.ATTRIBUTE_NAMES);return new e.Ellipse(e.util.object.extend(c,a))};e.Ellipse.fromObject= -function(f){return new e.Ellipse(f)}}})(); -(function(){var e=this.fabric||(this.fabric={});if(!e.Rect){e.Rect=e.util.createClass(e.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(f){this.callSuper("initialize",f);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(f){var a=this.options.rx||0,c=this.options.ry||0,g=-this.width/2,h=-this.height/2,l=this.width,b=this.height;f.beginPath(); -f.moveTo(g+a,h);f.lineTo(g+l-a,h);f.bezierCurveTo(g+l,h,g+l,h+c,g+l,h+c);f.lineTo(g+l,h+b-c);f.bezierCurveTo(g+l,h+b,g+l-a,h+b,g+l-a,h+b);f.lineTo(g+a,h+b);f.bezierCurveTo(g,h+b,g,h+b-c,g,h+b-c);f.lineTo(g,h+c);f.bezierCurveTo(g,h,g+a,h,g+a,h);f.closePath();this.fill&&f.fill();this.stroke&&f.stroke()},_normalizeLeftTopProperties:function(f){f.left&&this.set("left",f.left+this.getWidth()/2);f.top&&this.set("top",f.top+this.getHeight()/2);return this},complexity:function(){return 1}});e.Rect.ATTRIBUTE_NAMES= -"x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");e.Rect.fromElement=function(f,a){if(!f)return null;var c=e.parseAttributes(f,e.Rect.ATTRIBUTE_NAMES);c=c;c.left=c.left||0;c.top=c.top||0;c=c;var g=new e.Rect(e.util.object.extend(a||{},c));g._normalizeLeftTopProperties(c);return g};e.Rect.fromObject=function(f){return new e.Rect(f)}}})(); -(function(){var e=this.fabric||(this.fabric={});if(e.Polyline)console.warn("fabric.Polyline is already defined");else{e.Polyline=e.util.createClass(e.Object,{type:"polyline",initialize:function(a,c){c=c||{};this.set("points",a);this.callSuper("initialize",c);this._calcDimensions()},_calcDimensions:function(){return e.Polygon.prototype._calcDimensions.call(this)},_toOrigin:function(){return e.Polygon.prototype._toOrigin.call(this)},toObject:function(){return e.Polygon.prototype.toObject.call(this)}, -_render:function(a){var c;a.beginPath();for(var g=0,h=this.points.length;g"},toObject:function(){var a=e.util.object.extend(this.callSuper("toObject"),{path:this.path});if(this.sourcePath)a.sourcePath=this.sourcePath;if(this.transformMatrix)a.transformMatrix=this.transformMatrix;return a},toDatalessObject:function(){var a=this.toObject();if(this.sourcePath)a.path=this.sourcePath;delete a.sourcePath;return a},complexity:function(){return this.path.length},set:function(a,c){this.stub&&this.stub.set(a, -c);return this.callSuper("set",a,c)},_parsePath:function(){for(var a=[],c,g,h=0,l=this.path.length;h"}, -isSameColor:function(){var f=this.getObjects()[0].get("fill");return this.getObjects().every(function(a){return a.get("fill")===f})},complexity:function(){return this.paths.reduce(function(f,a){return f+(a&&a.complexity?a.complexity():0)},0)},toGrayscale:function(){for(var f=this.paths.length;f--;)this.paths[f].toGrayscale();return this},getObjects:function(){return this.paths}});e.PathGroup.fromObject=function(f){for(var a=f.paths,c=0,g=a.length;c"},getObjects:function(){return this.objects},add:function(f){this._restoreObjectsState();this.objects.push(f);f.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(f){this._restoreObjectsState();e.util.removeFromArray(this.objects,f);f.setActive(false);this._calcBounds(); -this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(f,a){if(typeof a=="function")this.set(f,a(this[f]));else if(f==="fill"||f==="opacity"){var c=this.objects.length;for(this[f]=a;c--;)this.objects[c].set(f,a)}else this[f]=a;return this},contains:function(f){return this.objects.indexOf(f)>-1},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{objects:e.util.array.invoke(this.objects,"clone")})},render:function(f){f.save(); -this.transform(f);for(var a=Math.max(this.scaleX,this.scaleY),c=0,g=this.objects.length;cf.x&&h-cf.y},toGrayscale:function(){for(var f=this.objects.length;f--;)this.objects[f].toGrayscale()}});e.Group.fromObject= -function(f){return new e.Group(f.objects,f)}}})(); -(function(){var e=this.fabric||(this.fabric={});if(e.Text)console.warn("fabric.Text is already defined");else if(e.Object){e.Text=e.util.createClass(e.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(f,a){this.originalState={};this.initStateProperties();this.text=f;this.setOptions(a);e.util.object.extend(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()},initStateProperties:function(){var f; -if((f=this.constructor)&&(f=f.superclass)&&(f=f.prototype)&&(f=f.stateProperties)&&f.clone){this.stateProperties=f.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#"},_render:function(f){var a=Cufon.textOptions||(Cufon.textOptions={});a.left=this.left;a.top=this.top;a.context=f;a.color=this.fill;var c=this._initDummyElement();this.transform(f);Cufon.replaceElement(c, -{separate:"none",fontFamily:this.fontfamily});this.width=a.width;this.height=a.height},_initDummyElement:function(){var f=document.createElement("div");f.innerHTML=this.text;f.style.fontSize="40px";f.style.fontWeight="400";f.style.fontStyle="normal";f.style.letterSpacing="normal";f.style.color="#000000";f.style.fontWeight="600";f.style.fontFamily="Verdana";return f},render:function(f){f.save();this._render(f);if(this.active){this.drawBorders(f);this.drawCorners(f)}f.restore()},toObject:function(){return e.util.object.extend(this.callSuper("toObject"), -{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,path:this.path})},setColor:function(f){this.set("fill",f);return this},setFontsize:function(f){this.set("fontsize",f);this.setCoords();return this},getText:function(){return this.text},setText:function(f){this.set("text",f);this.setCoords();return this},set:function(f,a){this[f]=a;if(f==="fontfamily")this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+a+"$3");return this}});e.Text.fromObject=function(f){return new e.Text(f.text, -e.util.object.clone(f))};e.Text.fromElement=function(){}}else console.warn("fabric.Text requires fabric.Object")})(); -(function(){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(e,f){this.callSuper("initialize",f);this._initElement(e);this._initConfig(f||{})},getElement:function(){return this._element},setElement:function(e){this._element=e;return this}, -getNormalizedSize:function(e,f,a){if(a&&f&&e.width>e.height&&e.width/e.heighte.width||e.height>a)){normalizedWidth=Math.floor(e.width*a/e.height);normalizedHeight=a}else if(f&&f'},clone:function(e){this.constructor.fromObject(this.toObject(),e)},toGrayscale:function(e){if(!this.__isGrayscaled){var f=this.getElement(),a=document.createElement("canvas"),c=document.createElement("img"),g=this;a.width=f.width;a.height=f.height;a.getContext("2d").drawImage(f,0,0);fabric.Element.toGrayscale(a);c.onload=function(){g.setElement(c);e&&e();c.onload=a=f=imageData=null};c.width=f.width;c.height=f.height;c.src=a.toDataURL("image/png"); -this.__isGrayscaled=true;return this}},_render:function(e){var f=this.getOriginalSize();e.drawImage(this.getElement(),-f.width/2,-f.height/2,f.width,f.height)},_adjustWidthHeightToBorders:function(e){if(e){this.currentBorder=this.borderwidth;this.width+=2*this.currentBorder;this.height+=2*this.currentBorder}else this.currentBorder=0},_resetWidthHeight:function(){var e=this.getElement();this.set("width",e.width);this.set("height",e.height)},_initElement:function(e){this.setElement(fabric.util.getById(e)); -fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(e){this.setOptions(e);this._setBorder();this._setWidthHeight(e)},_setBorder:function(){this.currentBorder=this.bordervisibility?this.borderwidth:0},_setWidthHeight:function(){var e=2*this.currentBorder;this.width=(this.getElement().width||0)+e;this.height=(this.getElement().height||0)+e}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(e,f){var a=document.createElement("img"),c=e.src;if(e.width)a.width= -e.width;if(e.height)a.height=e.height;a.onload=function(){f&&f(new fabric.Image(a,e));a=a.onload=null};a.src=c};fabric.Image.fromURL=function(e,f,a){var c=document.createElement("img");c.onload=function(){f&&f(new fabric.Image(c,a));c=c.onload=null};c.src=e}}else console.warn("fabric.Object is required for fabric.Image initialization")})(); diff --git a/dist/all.min-via-goog-cc.js.gz b/dist/all.min-via-goog-cc.js.gz deleted file mode 100644 index 85b87ec4..00000000 Binary files a/dist/all.min-via-goog-cc.js.gz and /dev/null differ diff --git a/dist/all.min.js b/dist/all.min.js index b5bd8c47..bf96dd33 100644 --- a/dist/all.min.js +++ b/dist/all.min.js @@ -1,196 +1,196 @@ var fabric=fabric||{version:0.1};fabric.log=function(){};fabric.warn=function(){};if(typeof console!=="undefined"){if(typeof console.log!=="undefined"&&console.log.apply)fabric.log=function(){return console.log.apply(console,arguments)};if(typeof console.warn!=="undefined"&&console.warn.apply)fabric.warn=function(){return console.warn.apply(console,arguments)}}if(!this.JSON)this.JSON={}; -(function(){function m(g){return g<10?"0"+g:g}function o(g){p.lastIndex=0;return p.test(g)?'"'+g.replace(p,function(n){var q=a[n];return typeof q==="string"?q:"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+g+'"'}function f(g,n){var q,s,w,y,A=l,u,v=n[g];if(v&&typeof v==="object"&&typeof v.toJSON==="function")v=v.toJSON(g);if(typeof c==="function")v=c.call(n,g,v);switch(typeof v){case "string":return o(v);case "number":return isFinite(v)?String(v):"null";case "boolean":case "null":return String(v); -case "object":if(!v)return"null";l+=e;u=[];if(Object.prototype.toString.apply(v)==="[object Array]"){y=v.length;for(q=0;q400;if(k==500)k=400;for(var G in r){G=parseInt(G, -10);if(!B||GC)C=G;z.push(G)}if(kC)k=C;z.sort(function(F,H){return(x?F>k&&H>k?FH:FH:F=d.length+r)for(t=true;r=b.shift();r());else setTimeout(arguments.callee,10)});return function(r){t?r():b.push(r)}}(),supports:function(t,b){var d=document.createElement("span").style;if(d[t]===undefined)return false;d[t]=b;return d[t]===b},textAlign:function(t,b,d,k){if(b.get("textAlign")=="right"){if(d>0)t=" "+t}else if(du)u=r;if(k>v)v=k;if(r.cufon-vml-canvas{text-indent:0}@media screen{cvml\\:shape,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute}.cufon-vml-canvas{position:absolute;text-align:left}.cufon-vml{display:inline-block;position:relative;vertical-align:middle}.cufon-vml .cufon-alt{position:absolute;left:-10000in;font-size:1px}a .cufon-vml{cursor:pointer}}@media print{.cufon-vml *{display:none}.cufon-vml .cufon-alt{display:inline}}'); -return function(f,h,p,l,e,a,c){var g=h===null;if(g)h=e.alt;var n=f.viewBox,q;if(!(q=p.computedFontSize)){q=Cufon.CSS.Size;var s;s=p.get("fontSize");s=m(a,/(?:em|ex|%)$/i.test(s)?"1em":s);q=p.computedFontSize=new q(s+"px",f.baseSize)}q=q;s=p.computedLSpacing;if(s==undefined){s=p.get("letterSpacing");p.computedLSpacing=s=s=="normal"?0:~~q.convertFrom(m(a,s))}var w;if(g){w=e;e=e.firstChild}else{w=document.createElement("span");w.className="cufon cufon-vml";w.alt=h;e=document.createElement("span");e.className= -"cufon-vml-canvas";w.appendChild(e);if(l.printable){var y=document.createElement("span");y.className="cufon-alt";y.appendChild(document.createTextNode(h));w.appendChild(y)}c||w.appendChild(document.createElement("cvml:shape"))}c=w.style;var A=e.style,u=q.convert(n.height);y=Math.ceil(u);u=y/u;var v=n.minX,E=n.minY;A.height=y;A.top=Math.round(q.convert(E-f.ascent));A.left=Math.round(q.convert(v));c.height=q.convert(f.height)+"px";l.enableTextDecoration&&Cufon.CSS.textDecoration(a,p);a=p.get("color"); -h=Cufon.CSS.textTransform(h,p).split("");A=p=0;var D=null,t;l=l.textShadow;for(var b=0,d=0,k=h.length;b>>0;e=Number(e)||0;e=Math[e<0?"ceil":"floor"](e);if(e<0)e+=a;for(;e>>0;a>>0;c>>0;a>>0;a>>0;g>>0,a=0,c;if(arguments.length>1)c=arguments[1];else{do{if(a in this){c=this[a++];break}if(++a>=e)throw new TypeError;}while(1)}for(;a=c)c=l[a][e]}else for(;a--;)if(l[a]>=c)c=l[a];return c}};f.util.object={extend:m,clone:function(l){return m({},l)}};if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/, -"").replace(/[\s\xA0]+$/,"")};f.util.string={camelize:function(l){return l.replace(/-+(.)?/g,function(e,a){return a?a.toUpperCase():""})},capitalize:function(l){return l.charAt(0).toUpperCase()+l.slice(1).toLowerCase()}};if(!Function.prototype.bind)Function.prototype.bind=function(l){var e=this,a=h.call(arguments,1);return a.length?function(){return p.call(e,l,a.concat(h.call(arguments)))}:function(){return p.call(e,l,arguments)}};(function(){function l(){}var e;e=function(){for(var a in{toString:1})if(a=== -"toString")return false;return true}()?function(a,c){if(c.toString!==Object.prototype.toString)a.prototype.toString=c.toString;if(c.valueOf!==Object.prototype.valueOf)a.prototype.valueOf=c.valueOf;for(var g in c)a.prototype[g]=c[g]}:function(a,c){for(var g in c)a.prototype[g]=c[g]};f.util.createClass=function(){function a(){this.initialize.apply(this,arguments)}var c=null,g=h.call(arguments,0);if(typeof g[0]==="function")c=g.shift();a.superclass=c;a.subclasses=[];if(c){l.prototype=c.prototype;a.prototype= -new l;c.subclasses.push(a)}c=0;for(var n=g.length;c=0.9999?"":"alpha(opacity="+n*100+")";q.filter=q.filter.replace(a,n)}else q.filter+=" alpha(opacity="+n*100+")";return g};f.util.setStyle=function(g,n){var q=g.style;if(typeof n==="string"){g.style.cssText+=";"+n;return n.indexOf("opacity")>-1?c(g,n.match(/opacity:\s*(\d?\.?\d*)/)[1]):g}for(var s in n)if(s==="opacity")c(g,n[s]); -else q[s==="float"||s==="cssFloat"?typeof q.styleFloat==="undefined"?"cssFloat":"styleFloat":s]=n[s];return g}})();(function(){var l=document.documentElement.style,e="userSelect"in l?"userSelect":"MozUserSelect"in l?"MozUserSelect":"WebkitUserSelect"in l?"WebkitUserSelect":"KhtmlUserSelect"in l?"KhtmlUserSelect":"";f.util.makeElementUnselectable=function(a){if(typeof a.onselectstart!=="undefined")a.onselectstart=f.util.falseFunction;if(e)a.style[e]="none";else if(typeof a.unselectable=="string")a.unselectable= -"on";return a}})();(function(){function l(a,c){e.load(a);c()}f.util.getScript=function(a,c){var g=document.getElementsByTagName("head")[0],n=document.createElement("script"),q=true;n.type="text/javascript";n.setAttribute("runat","server");n.onload=n.onreadystatechange=function(s){if(q)if(!(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")){q=false;c(s||window.event);n=n.onload=n.onreadystatechange=null}};n.src=a;g.appendChild(n)};var e=this.Jaxer;if(e&&e.load)f.util.getScript= -l})();f.util.getById=function(l){return typeof l==="string"?document.getElementById(l):l};f.util.toArray=function(l){for(var e=[],a=l.length;a--;)e[a]=l[a];return e};f.util.makeElement=o;f.util.addClass=function(l,e){if((" "+l.className+" ").indexOf(" "+e+" ")===-1)l.className+=(l.className?" ":"")+e};f.util.wrapElement=function(l,e,a){if(typeof e==="string")e=o(e,a);l.parentNode&&l.parentNode.replaceChild(e,l);e.appendChild(l);return e};f.util.getElementOffset=function(l){var e=0,a=0;do{e+=l.offsetTop|| -0;a+=l.offsetLeft||0;l=l.offsetParent}while(l);return{left:a,top:e}};f.util.animate=function(l){l||(l={});var e=+new Date,a=l.duration||500,c=e+a,g,n,q=l.onChange||function(){},s=l.easing||function(v){return-Math.cos(v*Math.PI)/2+0.5},w="startValue"in l?l.startValue:0,y="endValue"in l?l.endValue:100,A=w>y;l.onStart&&l.onStart();var u=setInterval(function(){g=+new Date;n=g>c?1:(g-e)/a;q(A?w-(w-y)*s(n):w+(y-w)*s(n));if(g>c){clearInterval(u);l.onComplete&&l.onComplete()}},10)};(function(){function l(){} -var e=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}],c=a.length;c--;)try{if(a[c]())return a[c]}catch(g){}}();f.util.request=function(a,c){c||(c={});var g=c.method?c.method.toUpperCase():"GET",n=c.onComplete||function(){},q=e(),s;q.onreadystatechange=function(){if(q.readyState===4){n(q);q.onreadystatechange=l}};if(g=== -"GET"){s=null;if(typeof c.parameters=="string")a=a+(/\?/.test(a)?"&":"?")+c.parameters}q.open(g,a,true);if(g==="POST"||g==="PUT")q.setRequestHeader("Content-Type","application/x-www-form-urlencoded");q.send(s);return q}})()})(this); -(function(){var m=this.fabric||(this.fabric={}),o=m.util.object.extend,f=m.util.string.capitalize,h=m.util.object.clone,p={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};m.parseTransformAttribute=function(){function l(q,s){var w=s[0];q[0]=Math.cos(w);q[1]=Math.sin(w);q[2]=-Math.sin(w);q[3]=Math.cos(w)}function e(q,s){var w=s.length===2?s[1]:s[0];q[0]=s[0];q[3]=w}function a(q,s){q[4]=s[0];if(s.length=== -2)q[5]=s[1]}var c=[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*$"), -n=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 s=c.concat();if(!q||q&&!g.test(q))return s;q.replace(n,function(w){var y=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(w).filter(function(A){return A!== -""&&A!=null});w=y[1];y=y.slice(2).map(parseFloat);switch(w){case "translate":a(s,y);break;case "rotate":l(s,y);break;case "scale":e(s,y);break;case "skewX":s[2]=y[0];break;case "skewY":s[1]=y[0];break;case "matrix":s=y;break}});return s}}();m.parseSVGDocument=function(){var l=/^(path|circle|polygon|polyline|ellipse|rect|line)$/,e=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 g=m.util.toArray(a.getElementsByTagName("*")).filter(function(A){var u;if(u=l.test(A.tagName)){a:{for(A=A;A&&(A=A.parentNode);)if(A.nodeName==="pattern"){A=true;break a}A=false}u=!A}return u});if(!(!g||g&&!g.length)){var n=a.getAttribute("viewBox"),q=a.getAttribute("width"),s=a.getAttribute("height"),w=null,y=null;if(n&&(n=n.match(e))){parseInt(n[1],10);parseInt(n[2],10);w=parseInt(n[3],10);y=parseInt(n[4],10)}w=q?parseFloat(q):w;y=s?parseFloat(s):y;n={width:w,height:y}; -g=m.parseElements(g,h(n));!g||g&&!g.length||c&&c(g,n)}}}}();o(m,{parseAttributes:function(l,e){if(l){var a,c,g={};if(l.parentNode&&/^g$/i.test(l.parentNode.nodeName))g=m.parseAttributes(l.parentNode,e);var n=e.reduce(function(q,s){a=l.getAttribute(s);c=parseFloat(a);if(a){if((s==="fill"||s==="stroke")&&a==="none")a="";if(s==="fill-rule")a=a==="evenodd"?"destination-over":a;if(s==="transform")a=m.parseTransformAttribute(a);if(s in p)s=p[s];q[s]=isNaN(c)?a:c}return q},{});n=o(m.parseStyleAttribute(l), -n);return o(g,n)}},parseElements:function(l,e){var a=l.map(function(c){var g=m[f(c.tagName)];if(g&&g.fromElement)try{return g.fromElement(c,e)}catch(n){m.log(n.message||n)}});return a=a.filter(function(c){return c!=null})},parseStyleAttribute:function(l){var e={};if(l=l.getAttribute("style"))if(typeof l=="string"){l=l.split(";");l.pop();e=l.reduce(function(c,g){var n=g.split(":"),q=n[0].trim();n=n[1].trim();c[q]=n;return c},{})}else for(var a in l)if(typeof l[a]!=="undefined")e[a]=l[a];return e}, -parsePointsAttribute:function(l){if(!l)return null;l=l.trim();var e=l.indexOf(",")>-1;l=l.split(/\s+/);var a=[];if(e){e=0;for(var c=l.length;e0&&this.init(f,h)}var o=this.fabric||(this.fabric={});if(o.Point)o.warn("fabric.Point is already defined");else{o.Point=m;m.prototype={constructor:m,init:function(f,h){this.x=f;this.y=h},add:function(f){return new m(this.x+f.x,this.y+f.y)},addEquals:function(f){this.x+=f.x;this.y+=f.y;return this},scalarAdd:function(f){return new m(this.x+f,this.y+f)},scalarAddEquals:function(f){this.x+=f;this.y+=f;return this},subtract:function(f){return new m(this.x- -f.x,this.y-f.y)},subtractEquals:function(f){this.x-=f.x;this.y-=f.y;return this},scalarSubtract:function(f){return new m(this.x-f,this.y-f)},scalarSubtractEquals:function(f){this.x-=f;this.y-=f;return this},multiply:function(f){return new m(this.x*f,this.y*f)},multiplyEquals:function(f){this.x*=f;this.y*=f;return this},divide:function(f){return new m(this.x/f,this.y/f)},divideEquals:function(f){this.x/=f;this.y/=f;return this},eq:function(f){return this.x==f.x&&this.y==f.y},lt:function(f){return this.x< -f.x&&this.yf.x&&this.y>f.y},gte:function(f){return this.x>=f.x&&this.y>=f.y},lerp:function(f,h){return new m(this.x+(f.x-this.x)*h,this.y+(f.y-this.y)*h)},distanceFrom:function(f){var h=this.x-f.x;f=this.y-f.y;return Math.sqrt(h*h+f*f)},min:function(f){return new m(Math.min(this.x,f.x),Math.min(this.y,f.y))},max:function(f){return new m(Math.max(this.x,f.x),Math.max(this.y,f.y))},toString:function(){return this.x+ -","+this.y},setXY:function(f,h){this.x=f;this.y=h},setFromPoint:function(f){this.x=f.x;this.y=f.y},swap:function(f){var h=this.x,p=this.y;this.x=f.x;this.y=f.y;f.x=h;f.y=p}}}})(); -(function(){function m(f){arguments.length>0&&this.init(f)}var o=this.fabric||(this.fabric={});if(o.Intersection)o.warn("fabric.Intersection is already defined");else{o.Intersection=m;o.Intersection.prototype={init:function(f){this.status=f;this.points=[]},appendPoint:function(f){this.points.push(f)},appendPoints:function(f){this.points=this.points.concat(f)}};o.Intersection.intersectLineLine=function(f,h,p,l){var e,a=(l.x-p.x)*(f.y-p.y)-(l.y-p.y)*(f.x-p.x);e=(h.x-f.x)*(f.y-p.y)-(h.y-f.y)*(f.x-p.x); -p=(l.y-p.y)*(h.x-f.x)-(l.x-p.x)*(h.y-f.y);if(p!=0){a=a/p;e=e/p;if(0<=a&&a<=1&&0<=e&&e<=1){e=new m("Intersection");e.points.push(new o.Point(f.x+a*(h.x-f.x),f.y+a*(h.y-f.y)))}else e=new m("No Intersection")}else e=a==0||e==0?new m("Coincident"):new m("Parallel");return e};o.Intersection.intersectLinePolygon=function(f,h,p){for(var l=new m("No Intersection"),e=p.length,a=0;a0)l.status="Intersection";return l}; -o.Intersection.intersectPolygonPolygon=function(f,h){for(var p=new m("No Intersection"),l=f.length,e=0;e0)p.status="Intersection";return p};o.Intersection.intersectPolygonRectangle=function(f,h,p){var l=h.min(p),e=h.max(p);p=new o.Point(e.x,l.y);var a=new o.Point(l.x,e.y);h=m.intersectLinePolygon(l,p,f);p=m.intersectLinePolygon(p,e,f);e=m.intersectLinePolygon(e,a,f);f=m.intersectLinePolygon(a,l,f); -l=new m("No Intersection");l.appendPoints(h.points);l.appendPoints(p.points);l.appendPoints(e.points);l.appendPoints(f.points);if(l.points.length>0)l.status="Intersection";return l}}})(); -(function(){function m(f){f?this._tryParsingColor(f):this.setSource([0,0,0,1])}var o=this.fabric||(this.fabric={});if(o.Color)o.warn("fabric.Color is already defined.");else{o.Color=m;o.Color.prototype={_tryParsingColor:function(f){var h=m.sourceFromHex(f);h||(h=m.sourceFromRgb(f));h&&this.setSource(h)},getSource:function(){return this._source},setSource:function(f){this._source=f},toRgb:function(){var f=this.getSource();return"rgb("+f[0]+","+f[1]+","+f[2]+")"},toRgba:function(){var f=this.getSource(); -return"rgba("+f[0]+","+f[1]+","+f[2]+","+f[3]+")"},toHex:function(){var f=this.getSource(),h=f[0].toString(16);h=h.length==1?"0"+h:h;var p=f[1].toString(16);p=p.length==1?"0"+p:p;f=f[2].toString(16);f=f.length==1?"0"+f:f;return h.toUpperCase()+p.toUpperCase()+f.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(f){var h=this.getSource();h[3]=f;this.setSource(h);return this},toGrayscale:function(){var f=this.getSource(),h=parseInt((f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0), -10);this.setSource([h,h,h,f[3]]);return this},toBlackWhite:function(f){var h=this.getSource(),p=(h[0]*0.3+h[1]*0.59+h[2]*0.11).toFixed(0);h=h[3];f=f||127;p=Number(p)0?0:-d),b.ey-(k>0?0:-k),r,x);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(b.ex+0.5-(d>0?0:r),b.ey+0.5-(k>0?0:x),r,x)},_findSelectedObjects:function(){var b=[],d=this._groupSelector.ex,k=this._groupSelector.ey,r=d+this._groupSelector.left,x=k+this._groupSelector.top,z=new fabric.Point(v(d,r),v(k,x));k=new fabric.Point(E(d,r),E(k,x));r=0;for(x=this._objects.length;r1){b=new fabric.Group(b);this.setActiveGroup(b);b.saveCoords();l("group:selected",{target:b})}this.renderAll()},add:function(){this._objects.push.apply(this._objects,arguments);this.renderAll();return this},insertAt:function(b,d){this._objects.splice(d,0,b);this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop}, -clearContext:function(b){b.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(b){var d=this._config.width,k=this._config.height,r=b?this.contextTop:this.contextContainer;this.clearContext(this.contextTop);b||this.clearContext(r);r.fillStyle=this.backgroundColor;r.fillRect(0,0,d,k);b=this._objects.length;d=this.getActiveGroup(); -k=new Date;if(b)for(var x=0;x1?new fabric.PathGroup(I,C):I[0];I.setSourcePath(H);if(!(I instanceof fabric.PathGroup)){f(I,C);typeof C.angle!=="undefined"&&I.setAngle(C.angle)}k(I,G)})}, -this)}catch(B){fabric.log(B.message)}},loadImageFromURL:function(){var b={};return function(d,k){function r(){var B=o.getElementById(b[d]);B.width&&B.height?k(new fabric.Image(B)):setTimeout(r,50)}var x=this;if(b[d])r();else{var z=new Image;z.onload=function(){z.onload=null;x._resizeImageToFit(z);var B=new fabric.Image(z);k(B)};z.className="canvas-img-clone";z.src=d;if(this.shouldCacheImages)b[d]=Element.identify(z);o.body.appendChild(z)}}}(),loadSVGFromURL:function(b,d){function k(z){if(z=z.responseXML)(z= -z.documentElement)&&fabric.parseSVGDocument(z,function(B,C){x.cache.set(b,{objects:B.invoke("toObject"),options:C});d(B,C)})}function r(){fabric.log("ERROR!")}var x=this;b=b.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(b,function(z){if(z)x.cache.get(b,function(B){B=x._enlivenCachedObject(B);d(B.objects,B.options)});else new Ajax.Request(b,{method:"get",onComplete:k,onFailure:r})})},_enlivenCachedObject:function(b){var d=b.objects;b=b.options;d=d.map(function(k){return fabric[h(k.type)].fromObject(k)}); -return{objects:d,options:b}},remove:function(b){c(this._objects,b);this.renderAll();return b},fxRemove:function(b,d){var k=this;b.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){k.remove(b);typeof d==="function"&&d()}});return this},sendToBack:function(b){c(this._objects,b);this._objects.unshift(b);return this.renderAll()},bringToFront:function(b){c(this._objects,b);this._objects.push(b);return this.renderAll()},sendBackwards:function(b){var d=this._objects.indexOf(b),k=d;if(d!== -0){for(d=d-1;d>=0;--d)if(b.intersectsWithObject(this._objects[d])){k=d;break}c(this._objects,b);this._objects.splice(k,0,b)}return this.renderAll()},bringForward:function(b){var d=this.getObjects(),k=d.indexOf(b),r=k;if(k!==d.length-1){k=k+1;for(var x=this._objects.length;k"};f(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(b){var d=b.getContext("2d");b=d.getImageData(0,0,b.width,b.height);var k=b.data,r=b.width,x=b.height,z,B;for(i=0;i1?c.apply(this,e.call(arguments,1)):c.call(this)}, -initialize:function(a){this.setOptions(a);this._importProperties();this.originalState={};this.setCoords();this.saveState()},setOptions:function(a){this.options=o(this._getOptions(),a)},_getOptions:function(){return o(f(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:h(this.left,this.NUM_FRACTION_DIGITS),top:h(this.top,this.NUM_FRACTION_DIGITS),width:h(this.width,this.NUM_FRACTION_DIGITS),height:h(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke, -strokeWidth:this.strokeWidth,scaleX:h(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:h(this.scaleY,this.NUM_FRACTION_DIGITS),angle:h(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:h(this.opacity,this.NUM_FRACTION_DIGITS)};this.includeDefaultValues||(a=this._removeDefaultValues(a));return a},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(a){var c=m.Object.prototype.options;this.stateProperties.forEach(function(g){a[g]===c[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,c){if((a==="scaleX"||a==="scaleY")&&c400;if(d==500)d=400;for(var E in n){E=parseInt(E, +10);if(!y||ED)D=E;x.push(E)}if(dD)d=D;x.sort(function(G,H){return(u?G>d&&H>d?GH:GH:G=c.length+n)for(r=true;n=s.shift();n());else setTimeout(arguments.callee,10)});return function(n){r?n():s.push(n)}}(),supports:function(r,s){var c=document.createElement("span").style;if(c[r]===undefined)return false;c[r]=s;return c[r]===s},textAlign:function(r,s,c,d){if(s.get("textAlign")=="right"){if(c>0)r=" "+r}else if(cB)B=n;if(d>v)v=d;if(n.cufon-vml-canvas{text-indent:0}@media screen{cvml\\:shape,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute}.cufon-vml-canvas{position:absolute;text-align:left}.cufon-vml{display:inline-block;position:relative;vertical-align:middle}.cufon-vml .cufon-alt{position:absolute;left:-10000in;font-size:1px}a .cufon-vml{cursor:pointer}}@media print{.cufon-vml *{display:none}.cufon-vml .cufon-alt{display:inline}}'); +return function(f,k,m,p,h,e,a){var b=k===null;if(b)k=h.alt;var g=f.viewBox,o;if(!(o=m.computedFontSize)){o=Cufon.CSS.Size;var q;q=m.get("fontSize");q=z(e,/(?:em|ex|%)$/i.test(q)?"1em":q);o=m.computedFontSize=new o(q+"px",f.baseSize)}o=o;q=m.computedLSpacing;if(q==undefined){q=m.get("letterSpacing");m.computedLSpacing=q=q=="normal"?0:~~o.convertFrom(z(e,q))}var t;if(b){t=h;h=h.firstChild}else{t=document.createElement("span");t.className="cufon cufon-vml";t.alt=k;h=document.createElement("span");h.className= +"cufon-vml-canvas";t.appendChild(h);if(p.printable){var A=document.createElement("span");A.className="cufon-alt";A.appendChild(document.createTextNode(k));t.appendChild(A)}a||t.appendChild(document.createElement("cvml:shape"))}a=t.style;var w=h.style,B=o.convert(g.height);A=Math.ceil(B);B=A/B;var v=g.minX,C=g.minY;w.height=A;w.top=Math.round(o.convert(C-f.ascent));w.left=Math.round(o.convert(v));a.height=o.convert(f.height)+"px";p.enableTextDecoration&&Cufon.CSS.textDecoration(e,m);e=m.get("color"); +k=Cufon.CSS.textTransform(k,m).split("");w=m=0;var F=null,r;p=p.textShadow;for(var s=0,c=0,d=k.length;s>>0;e=Number(e)||0;e=Math[e<0?"ceil":"floor"](e);if(e<0)e+=a;for(;e>>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>=e)throw new TypeError;}while(1)}for(;a=b)b=h[a][e]}else for(;a--;)if(h[a]>=b)b=h[a];return b}};k.util.object={extend:l,clone:function(h){return l({},h)}};if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")}; +k.util.string={camelize:function(h){return h.replace(/-+(.)?/g,function(e,a){return a?a.toUpperCase():""})},capitalize:function(h){return h.charAt(0).toUpperCase()+h.slice(1).toLowerCase()}};if(!Function.prototype.bind)Function.prototype.bind=function(h){var e=this,a=m.call(arguments,1);return a.length?function(){return p.call(e,h,a.concat(m.call(arguments)))}:function(){return p.call(e,h,arguments)}};(function(){function h(){}var e;e=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]};k.util.createClass=function(){function a(){this.initialize.apply(this,arguments)}var b=null,g=m.call(arguments,0);if(typeof g[0]==="function")b=g.shift();a.superclass=b;a.subclasses=[];if(b){h.prototype=b.prototype;a.prototype=new h;b.subclasses.push(a)}b= +0;for(var o=g.length;b=0.9999?"":"alpha(opacity="+o*100+")";q.filter=q.filter.replace(a,o)}else q.filter+=" alpha(opacity="+o*100+")";return g};k.util.setStyle=function(g,o){var q=g.style;if(typeof o==="string"){g.style.cssText+=";"+o;return o.indexOf("opacity")>-1?b(g,o.match(/opacity:\s*(\d?\.?\d*)/)[1]):g}for(var t in o)if(t==="opacity")b(g,o[t]);else q[t==="float"||t==="cssFloat"?typeof q.styleFloat=== +"undefined"?"cssFloat":"styleFloat":t]=o[t];return g}})();(function(){var h=document.documentElement.style,e="userSelect"in h?"userSelect":"MozUserSelect"in h?"MozUserSelect":"WebkitUserSelect"in h?"WebkitUserSelect":"KhtmlUserSelect"in h?"KhtmlUserSelect":"";k.util.makeElementUnselectable=function(a){if(typeof a.onselectstart!=="undefined")a.onselectstart=k.util.falseFunction;if(e)a.style[e]="none";else if(typeof a.unselectable=="string")a.unselectable="on";return a}})();(function(){function h(a, +b){e.load(a);b()}k.util.getScript=function(a,b){var g=document.getElementsByTagName("head")[0],o=document.createElement("script"),q=true;o.type="text/javascript";o.setAttribute("runat","server");o.onload=o.onreadystatechange=function(t){if(q)if(!(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")){q=false;b(t||window.event);o=o.onload=o.onreadystatechange=null}};o.src=a;g.appendChild(o)};var e=z.Jaxer;if(e&&e.load)k.util.getScript=h})();k.util.getById=function(h){return typeof h=== +"string"?document.getElementById(h):h};k.util.toArray=function(h){for(var e=[],a=h.length;a--;)e[a]=h[a];return e};k.util.makeElement=f;k.util.addClass=function(h,e){if((" "+h.className+" ").indexOf(" "+e+" ")===-1)h.className+=(h.className?" ":"")+e};k.util.wrapElement=function(h,e,a){if(typeof e==="string")e=f(e,a);h.parentNode&&h.parentNode.replaceChild(e,h);e.appendChild(h);return e};k.util.getElementOffset=function(h){var e=0,a=0;do{e+=h.offsetTop||0;a+=h.offsetLeft||0;h=h.offsetParent}while(h); +return{left:a,top:e}};k.util.animate=function(h){h||(h={});var e=+new Date,a=h.duration||500,b=e+a,g,o,q=h.onChange||function(){},t=h.easing||function(C){return-Math.cos(C*Math.PI)/2+0.5},A="startValue"in h?h.startValue:0,w="endValue"in h?h.endValue:100,B=A>w;h.onStart&&h.onStart();var v=setInterval(function(){g=+new Date;o=g>b?1:(g-e)/a;q(B?A-(A-w)*t(o):A+(w-A)*t(o));if(g>b){clearInterval(v);h.onComplete&&h.onComplete()}},10)};(function(){function h(){}var e=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){}}();k.util.request=function(a,b){b||(b={});var g=b.method?b.method.toUpperCase():"GET",o=b.onComplete||function(){},q=e(),t;q.onreadystatechange=function(){if(q.readyState===4){o(q);q.onreadystatechange=h}};if(g==="GET"){t=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(t);return q}})()})(this); +(function(z){var l=z.fabric||(z.fabric={}),f=l.util.object.extend,k=l.util.string.capitalize,m=l.util.object.clone,p={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};l.parseTransformAttribute=function(){function h(q,t){var A=t[0];q[0]=Math.cos(A);q[1]=Math.sin(A);q[2]=-Math.sin(A);q[3]=Math.cos(A)}function e(q,t){var A=t.length===2?t[1]:t[0];q[0]=t[0];q[3]=A}function a(q,t){q[4]=t[0];if(t.length=== +2)q[5]=t[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*$"), +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 t=b.concat();if(!q||q&&!g.test(q))return t;q.replace(o,function(A){var w=RegExp("(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\)))").exec(A).filter(function(B){return B!== +""&&B!=null});A=w[1];w=w.slice(2).map(parseFloat);switch(A){case "translate":a(t,w);break;case "rotate":h(t,w);break;case "scale":e(t,w);break;case "skewX":t[2]=w[0];break;case "skewY":t[1]=w[0];break;case "matrix":t=w;break}});return t}}();l.parseSVGDocument=function(){var h=/^(path|circle|polygon|polyline|ellipse|rect|line)$/,e=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=l.util.toArray(a.getElementsByTagName("*")).filter(function(B){var v;if(v=h.test(B.tagName)){a:{for(B=B;B&&(B=B.parentNode);)if(B.nodeName==="pattern"){B=true;break a}B=false}v=!B}return v});if(!(!g||g&&!g.length)){var o=a.getAttribute("viewBox"),q=a.getAttribute("width"),t=a.getAttribute("height"),A=null,w=null;if(o&&(o=o.match(e))){parseInt(o[1],10);parseInt(o[2],10);A=parseInt(o[3],10);w=parseInt(o[4],10)}A=q?parseFloat(q):A;w=t?parseFloat(t):w;o={width:A,height:w}; +g=l.parseElements(g,m(o));!g||g&&!g.length||b&&b(g,o)}}}}();f(l,{parseAttributes:function(h,e){if(h){var a,b,g={};if(h.parentNode&&/^g$/i.test(h.parentNode.nodeName))g=l.parseAttributes(h.parentNode,e);var o=e.reduce(function(q,t){a=h.getAttribute(t);b=parseFloat(a);if(a){if((t==="fill"||t==="stroke")&&a==="none")a="";if(t==="fill-rule")a=a==="evenodd"?"destination-over":a;if(t==="transform")a=l.parseTransformAttribute(a);if(t in p)t=p[t];q[t]=isNaN(b)?a:b}return q},{});o=f(l.parseStyleAttribute(h), +o);return f(g,o)}},parseElements:function(h,e){var a=h.map(function(b){var g=l[k(b.tagName)];if(g&&g.fromElement)try{return g.fromElement(b,e)}catch(o){l.log(o.message||o)}});return a=a.filter(function(b){return b!=null})},parseStyleAttribute:function(h){var e={};if(h=h.getAttribute("style"))if(typeof h=="string"){h=h.split(";");h.pop();e=h.reduce(function(b,g){var o=g.split(":"),q=o[0].trim();o=o[1].trim();b[q]=o;return b},{})}else for(var a in h)if(typeof h[a]!=="undefined")e[a]=h[a];return e}, +parsePointsAttribute:function(h){if(!h)return null;h=h.trim();var e=h.indexOf(",")>-1;h=h.split(/\s+/);var a=[];if(e){e=0;for(var b=h.length;e0&&this.init(f,k)}z=z.fabric||(z.fabric={});if(z.Point)z.warn("fabric.Point is already defined");else{z.Point=l;l.prototype={constructor:l,init:function(f,k){this.x=f;this.y=k},add:function(f){return new l(this.x+f.x,this.y+f.y)},addEquals:function(f){this.x+=f.x;this.y+=f.y;return this},scalarAdd:function(f){return new l(this.x+f,this.y+f)},scalarAddEquals:function(f){this.x+=f;this.y+=f;return this},subtract:function(f){return new l(this.x-f.x,this.y- +f.y)},subtractEquals:function(f){this.x-=f.x;this.y-=f.y;return this},scalarSubtract:function(f){return new l(this.x-f,this.y-f)},scalarSubtractEquals:function(f){this.x-=f;this.y-=f;return this},multiply:function(f){return new l(this.x*f,this.y*f)},multiplyEquals:function(f){this.x*=f;this.y*=f;return this},divide:function(f){return new l(this.x/f,this.y/f)},divideEquals:function(f){this.x/=f;this.y/=f;return this},eq:function(f){return this.x==f.x&&this.y==f.y},lt:function(f){return this.xf.x&&this.y>f.y},gte:function(f){return this.x>=f.x&&this.y>=f.y},lerp:function(f,k){return new l(this.x+(f.x-this.x)*k,this.y+(f.y-this.y)*k)},distanceFrom:function(f){var k=this.x-f.x;f=this.y-f.y;return Math.sqrt(k*k+f*f)},min:function(f){return new l(Math.min(this.x,f.x),Math.min(this.y,f.y))},max:function(f){return new l(Math.max(this.x,f.x),Math.max(this.y,f.y))},toString:function(){return this.x+","+this.y}, +setXY:function(f,k){this.x=f;this.y=k},setFromPoint:function(f){this.x=f.x;this.y=f.y},swap:function(f){var k=this.x,m=this.y;this.x=f.x;this.y=f.y;f.x=k;f.y=m}}}})(this); +(function(z){function l(k){arguments.length>0&&this.init(k)}var f=z.fabric||(z.fabric={});if(f.Intersection)f.warn("fabric.Intersection is already defined");else{f.Intersection=l;f.Intersection.prototype={init:function(k){this.status=k;this.points=[]},appendPoint:function(k){this.points.push(k)},appendPoints:function(k){this.points=this.points.concat(k)}};f.Intersection.intersectLineLine=function(k,m,p,h){var e,a=(h.x-p.x)*(k.y-p.y)-(h.y-p.y)*(k.x-p.x);e=(m.x-k.x)*(k.y-p.y)-(m.y-k.y)*(k.x-p.x);p= +(h.y-p.y)*(m.x-k.x)-(h.x-p.x)*(m.y-k.y);if(p!=0){a=a/p;e=e/p;if(0<=a&&a<=1&&0<=e&&e<=1){e=new l("Intersection");e.points.push(new f.Point(k.x+a*(m.x-k.x),k.y+a*(m.y-k.y)))}else e=new l("No Intersection")}else e=a==0||e==0?new l("Coincident"):new l("Parallel");return e};f.Intersection.intersectLinePolygon=function(k,m,p){for(var h=new l("No Intersection"),e=p.length,a=0;a0)h.status="Intersection";return h}; +f.Intersection.intersectPolygonPolygon=function(k,m){for(var p=new l("No Intersection"),h=k.length,e=0;e0)p.status="Intersection";return p};f.Intersection.intersectPolygonRectangle=function(k,m,p){var h=m.min(p),e=m.max(p);p=new f.Point(e.x,h.y);var a=new f.Point(h.x,e.y);m=l.intersectLinePolygon(h,p,k);p=l.intersectLinePolygon(p,e,k);e=l.intersectLinePolygon(e,a,k);k=l.intersectLinePolygon(a,h,k); +h=new l("No Intersection");h.appendPoints(m.points);h.appendPoints(p.points);h.appendPoints(e.points);h.appendPoints(k.points);if(h.points.length>0)h.status="Intersection";return h}}})(this); +(function(z){function l(f){f?this._tryParsingColor(f):this.setSource([0,0,0,1])}z=z.fabric||(z.fabric={});if(z.Color)z.warn("fabric.Color is already defined.");else{z.Color=l;z.Color.prototype={_tryParsingColor:function(f){var k=l.sourceFromHex(f);k||(k=l.sourceFromRgb(f));k&&this.setSource(k)},getSource:function(){return this._source},setSource:function(f){this._source=f},toRgb:function(){var f=this.getSource();return"rgb("+f[0]+","+f[1]+","+f[2]+")"},toRgba:function(){var f=this.getSource();return"rgba("+ +f[0]+","+f[1]+","+f[2]+","+f[3]+")"},toHex:function(){var f=this.getSource(),k=f[0].toString(16);k=k.length==1?"0"+k:k;var m=f[1].toString(16);m=m.length==1?"0"+m:m;f=f[2].toString(16);f=f.length==1?"0"+f:f;return k.toUpperCase()+m.toUpperCase()+f.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(f){var k=this.getSource();k[3]=f;this.setSource(k);return this},toGrayscale:function(){var f=this.getSource(),k=parseInt((f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),10);this.setSource([k, +k,k,f[3]]);return this},toBlackWhite:function(f){var k=this.getSource(),m=(k[0]*0.3+k[1]*0.59+k[2]*0.11).toFixed(0);k=k[3];f=f||127;m=Number(m)0?0:-d),c.ey-(n>0?0:-n),u,x);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(c.ex+0.5-(d>0?0:u),c.ey+0.5-(n>0?0:x),u,x)},_findSelectedObjects:function(){var c=[],d=this._groupSelector.ex,n=this._groupSelector.ey,u=d+this._groupSelector.left, +x=n+this._groupSelector.top,y=new fabric.Point(C(d,u),C(n,x));n=new fabric.Point(F(d,u),F(n,x));u=0;for(x=this._objects.length;u1){c=new fabric.Group(c);this.setActiveGroup(c);c.saveCoords();h("group:selected",{target:c})}this.renderAll()},add:function(){this._objects.push.apply(this._objects, +arguments);this.renderAll();return this},insertAt:function(c,d){this._objects.splice(d,0,c);this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop},clearContext:function(c){c.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(c){var d=this._config.width,n= +this._config.height,u=c?this.contextTop:this.contextContainer;this.clearContext(this.contextTop);c||this.clearContext(u);u.fillStyle=this.backgroundColor;u.fillRect(0,0,d,n);c=this._objects.length;d=this.getActiveGroup();n=new Date;if(c)for(var x=0;x1?new fabric.PathGroup(I,E):I[0];I.setSourcePath(J); +if(!(I instanceof fabric.PathGroup)){k(I,E);typeof E.angle!=="undefined"&&I.setAngle(E.angle)}n(I,G)})},this)}catch(D){fabric.log(D.message)}},loadImageFromURL:function(){var c={};return function(d,n){function u(){var D=f.getElementById(c[d]);D.width&&D.height?n(new fabric.Image(D)):setTimeout(u,50)}var x=this;if(c[d])u();else{var y=new Image;y.onload=function(){y.onload=null;x._resizeImageToFit(y);var D=new fabric.Image(y);n(D)};y.className="canvas-img-clone";y.src=d;if(this.shouldCacheImages)c[d]= +Element.identify(y);f.body.appendChild(y)}}}(),loadSVGFromURL:function(c,d){function n(y){if(y=y.responseXML)(y=y.documentElement)&&fabric.parseSVGDocument(y,function(D,E){x.cache.set(c,{objects:D.invoke("toObject"),options:E});d(D,E)})}function u(){fabric.log("ERROR!")}var x=this;c=c.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(c,function(y){if(y)x.cache.get(c,function(D){D=x._enlivenCachedObject(D);d(D.objects,D.options)});else new Ajax.Request(c,{method:"get",onComplete:n,onFailure:u})})}, +_enlivenCachedObject:function(c){var d=c.objects;c=c.options;d=d.map(function(n){return fabric[m(n.type)].fromObject(n)});return{objects:d,options:c}},remove:function(c){b(this._objects,c);this.renderAll();return c},fxRemove:function(c,d){var n=this;c.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){n.remove(c);typeof d==="function"&&d()}});return this},sendToBack:function(c){b(this._objects,c);this._objects.unshift(c);return this.renderAll()},bringToFront:function(c){b(this._objects, +c);this._objects.push(c);return this.renderAll()},sendBackwards:function(c){var d=this._objects.indexOf(c),n=d;if(d!==0){for(d=d-1;d>=0;--d)if(c.intersectsWithObject(this._objects[d])){n=d;break}b(this._objects,c);this._objects.splice(n,0,c)}return this.renderAll()},bringForward:function(c){var d=this.getObjects(),n=d.indexOf(c),u=n;if(n!==d.length-1){n=n+1;for(var x=this._objects.length;n"};k(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(c){var d=c.getContext("2d");c=d.getImageData(0,0,c.width,c.height);var n=c.data,u=c.width,x=c.height,y,D;for(i=0;i1?b.apply(this,e.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=f(this._getOptions(),a)},_getOptions:function(){return f(k(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:m(this.left,this.NUM_FRACTION_DIGITS),top:m(this.top,this.NUM_FRACTION_DIGITS),width:m(this.width,this.NUM_FRACTION_DIGITS),height:m(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke, +strokeWidth:this.strokeWidth,scaleX:m(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:m(this.scaleY,this.NUM_FRACTION_DIGITS),angle:m(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:m(this.opacity,this.NUM_FRACTION_DIGITS)};this.includeDefaultValues||(a=this._removeDefaultValues(a));return a},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(a){var b=l.Object.prototype.options;this.stateProperties.forEach(function(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&&s.y=c&&s.d.y>=c)){if(s.o.x==s.d.x&&s.o.x>=a)n=s.o.x;else{n=(s.d.y-s.o.y)/(s.d.x-s.o.x);q=c-0*a;s=s.o.y-n*s.o.x;n=-(q-s)/(0-n)}if(n>=a)w+=1;if(w==2)break}}return w},_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,g=this.cornersize*Math.cos(c),n=this.cornersize*Math.sin(c);c=this.cornersize/2;var q=c-n;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+g,y:a.tl.y+n},bl:{x:a.tl.x-n,y:a.tl.y+g}};a.tl.corner.br={x:a.tl.corner.tr.x-n,y:a.tl.corner.tr.y+g};a.tl.x+=q;a.tl.y+=c;a.tr.x+=c;a.tr.y-=c;a.tr.corner={tl:{x:a.tr.x-g,y:a.tr.y-n},tr:{x:a.tr.x,y:a.tr.y},br:{x:a.tr.x-n,y:a.tr.y+g}};a.tr.corner.bl={x:a.tr.corner.tl.x-n,y:a.tr.corner.tl.y+g};a.tr.x-=c;a.tr.y+=c;a.bl.x-=c;a.bl.y+=c;a.bl.corner={tl:{x:a.bl.x+n,y:a.bl.y-g},bl:{x:a.bl.x,y:a.bl.y},br:{x:a.bl.x+g,y:a.bl.y+n}};a.bl.corner.tr={x:a.bl.corner.br.x+ -n,y:a.bl.corner.br.y-g};a.bl.x+=c;a.bl.y-=c;a.br.x+=c;a.br.y+=c;a.br.corner={tr:{x:a.br.x+n,y:a.br.y-g},bl:{x:a.br.x-g,y:a.br.y-n},br:{x:a.br.x,y:a.br.y}};a.br.corner.tl={x:a.br.corner.bl.x+n,y:a.br.corner.bl.y-g};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+g,y:a.ml.y+n},bl:{x:a.ml.x-n,y:a.ml.y+g}};a.ml.corner.br={x:a.ml.corner.tr.x-n,y:a.ml.corner.tr.y+g};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+g,y:a.mt.y+ -n},bl:{x:a.mt.x-n,y:a.mt.y+g}};a.mt.corner.br={x:a.mt.corner.tr.x-n,y:a.mt.corner.tr.y+g};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+g,y:a.mr.y+n},bl:{x:a.mr.x-n,y:a.mr.y+g}};a.mr.corner.br={x:a.mr.corner.tr.x-n,y:a.mr.corner.tr.y+g};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+g,y:a.mb.y+n},bl:{x:a.mb.x-n,y:a.mb.y+g}};a.mb.corner.br={x:a.mb.corner.tr.x-n,y:a.mb.corner.tr.y+g};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 m.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(){},g=a.onComplete||c,n=a.onChange|| -c,q=this;m.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(s){q.setAngle(s);n()},onComplete:function(){q.setCoords();g()},onStart:function(){q.setActive(false)}});return this},fxRemove:function(a){a||(a={});var c=function(){},g=a.onComplete||c,n=a.onChange||c,q=this;m.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(s){q.set("opacity",s);n()},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()}});m.Object.prototype.rotate=m.Object.prototype.setAngle}})(); -(function(){var m=this.fabric||(this.fabric={}),o=m.util.object.extend;if(m.Line)m.warn("fabric.Line is already defined");else{m.Line=m.util.createClass(m.Object,{type:"line",initialize:function(f,h){f||(f=[0,0,0,0]);this.callSuper("initialize",h);this.set("x1",f[0]);this.set("y1",f[1]);this.set("x2",f[2]);this.set("y2",f[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(f){f.beginPath(); -f.moveTo(-this.width/2,-this.height/2);f.lineTo(this.width/2,this.height/2);var h=f.strokeStyle;f.strokeStyle=f.fillStyle;f.stroke();f.strokeStyle=h},complexity:function(){return 1},toObject:function(){return o(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});m.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");m.Line.fromElement=function(f,h){var p=m.parseAttributes(f,m.Line.ATTRIBUTE_NAMES);return new m.Line([p.x1|| -0,p.y1||0,p.x2||0,p.y2||0],o(p,h))};m.Line.fromObject=function(f){return new m.Line([f.x1,f.y1,f.x2,f.y2],f)}}})(); -(function(){var m=this.fabric||(this.fabric={}),o=Math.PI*2,f=m.util.object.extend;if(m.Circle)m.warn("fabric.Circle is already defined.");else{m.Circle=m.util.createClass(m.Object,{type:"circle",initialize:function(h){h=h||{};this.set("radius",h.radius||0);this.callSuper("initialize",h);h=this.get("radius")*2*this.get("scaleX");this.set("width",h).set("height",h)},toObject:function(){return f(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(h,p){h.beginPath();h.arc(p?this.left: -0,p?this.top:0,this.radius,0,o,false);h.closePath();this.fill&&h.fill();this.stroke&&h.stroke()},complexity:function(){return 1}});m.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");m.Circle.fromElement=function(h,p){p||(p={});var l=m.parseAttributes(h,m.Circle.ATTRIBUTE_NAMES);if(!("radius"in l&&l.radius>0))throw Error("value of `r` attribute is required and can not be negative");if("left"in l)l.left-=p.width/2||0;if("top"in l)l.top-=p.height/2||0;return new m.Circle(f(l, -p))};m.Circle.fromObject=function(h){return new m.Circle(h)}}})(); -(function(){var m=this.fabric||(this.fabric={});if(m.Triangle)m.warn("fabric.Triangle is already defined");else{m.Triangle=m.util.createClass(m.Object,{type:"triangle",initialize:function(o){o=o||{};this.callSuper("initialize",o);this.set("width",o.width||100).set("height",o.height||100)},_render:function(o){var f=this.width/2,h=this.height/2;o.beginPath();o.moveTo(-f,h);o.lineTo(0,-h);o.lineTo(f,h);o.closePath();this.fill&&o.fill();this.stroke&&o.stroke()},complexity:function(){return 1}});m.Triangle.fromObject= -function(o){return new m.Triangle(o)}}})(); -(function(){var m=this.fabric||(this.fabric={}),o=Math.PI*2,f=m.util.object.extend;if(m.Ellipse)m.warn("fabric.Ellipse is already defined.");else{m.Ellipse=m.util.createClass(m.Object,{type:"ellipse",initialize:function(h){h=h||{};this.callSuper("initialize",h);this.set("rx",h.rx||0);this.set("ry",h.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return f(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(h,p){if(!(this.rx=== -0||this.ry===0))return this.callSuper("render",h,p)},_render:function(h,p){h.beginPath();h.save();h.transform(1,0,0,this.ry/this.rx,0,0);h.arc(p?this.left:0,p?this.top:0,this.rx,0,o,false);h.restore();this.stroke&&h.stroke();this.fill&&h.fill()},complexity:function(){return 1}});m.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");m.Ellipse.fromElement=function(h,p){p||(p={});var l=m.parseAttributes(h,m.Ellipse.ATTRIBUTE_NAMES);if("left"in l)l.left-=p.width/ -2||0;if("top"in l)l.top-=p.height/2||0;return new m.Ellipse(f(l,p))};m.Ellipse.fromObject=function(h){return new m.Ellipse(h)}}})(); -(function(){var m=this.fabric||(this.fabric={});if(m.Rect)console.warn("fabric.Rect is already defined");else{m.Rect=m.util.createClass(m.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(o){this.callSuper("initialize",o);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(o){var f=this.options.rx||0,h=this.options.ry||0,p=-this.width/2,l=-this.height/ -2,e=this.width,a=this.height;o.beginPath();o.moveTo(p+f,l);o.lineTo(p+e-f,l);o.bezierCurveTo(p+e,l,p+e,l+h,p+e,l+h);o.lineTo(p+e,l+a-h);o.bezierCurveTo(p+e,l+a,p+e-f,l+a,p+e-f,l+a);o.lineTo(p+f,l+a);o.bezierCurveTo(p,l+a,p,l+a-h,p,l+a-h);o.lineTo(p,l+h);o.bezierCurveTo(p,l,p+f,l,p+f,l);o.closePath();this.fill&&o.fill();this.stroke&&o.stroke()},_normalizeLeftTopProperties:function(o){o.left&&this.set("left",o.left+this.getWidth()/2);o.top&&this.set("top",o.top+this.getHeight()/2);return this},complexity:function(){return 1}}); -m.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");m.Rect.fromElement=function(o,f){if(!o)return null;var h=m.parseAttributes(o,m.Rect.ATTRIBUTE_NAMES);h=h;h.left=h.left||0;h.top=h.top||0;h=h;var p=new m.Rect(m.util.object.extend(f||{},h));p._normalizeLeftTopProperties(h);return p};m.Rect.fromObject=function(o){return new m.Rect(o)}}})(); -(function(){var m=this.fabric||(this.fabric={});if(m.Polyline)m.warn("fabric.Polyline is already defined");else{m.Polyline=m.util.createClass(m.Object,{type:"polyline",initialize:function(o,f){f=f||{};this.set("points",o);this.callSuper("initialize",f);this._calcDimensions()},_calcDimensions:function(){return m.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return m.Polygon.prototype.toObject.call(this)},_render:function(o){var f;o.beginPath();for(var h=0,p=this.points.length;h< -p;h++){f=this.points[h];o.lineTo(f.x,f.y)}this.fill&&o.fill();this.stroke&&o.stroke()},complexity:function(){return this.get("points").length}});m.Polyline.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");m.Polyline.fromElement=function(o,f){if(!o)return null;f||(f={});for(var h=m.parsePointsAttribute(o.getAttribute("points")),p=m.parseAttributes(o,m.Polyline.ATTRIBUTE_NAMES),l=0,e=h.length;l"},toObject:function(){var e=l(this.callSuper("toObject"),{path:this.path});if(this.sourcePath)e.sourcePath=this.sourcePath;if(this.transformMatrix)e.transformMatrix=this.transformMatrix;return e},toDatalessObject:function(){var e=this.toObject();if(this.sourcePath)e.path= -this.sourcePath;delete e.sourcePath;return e},complexity:function(){return this.path.length},_parsePath:function(){for(var e=[],a,c,g=0,n=this.path.length;g"},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}});m.PathGroup.fromObject=function(a){for(var c=a.paths, -g=0,n=c.length;g"},getObjects:function(){return this.objects},add:function(e){this._restoreObjectsState();this.objects.push(e);e.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(e){this._restoreObjectsState(); -l(this.objects,e);e.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(e,a){if(typeof a=="function")this.set(e,a(this[e]));else if(e==="fill"||e==="opacity"){var c=this.objects.length;for(this[e]=a;c--;)this.objects[c].set(e,a)}else this[e]=a;return this},contains:function(e){return this.objects.indexOf(e)>-1},toObject:function(){return o(this.callSuper("toObject"),{objects:p(this.objects,"clone")})},render:function(e){e.save(); -this.transform(e);for(var a=Math.max(this.scaleX,this.scaleY),c=0,g;g=this.objects[c];c++){var n=g.borderScaleFactor;g.borderScaleFactor=a;g.render(e);g.borderScaleFactor=n}this.hideBorders||this.drawBorders(e);this.hideCorners||this.drawCorners(e);e.restore();this.setCoords()},item:function(e){return this.getObjects()[e]},complexity:function(){return this.getObjects().reduce(function(e,a){e+=typeof a.complexity=="function"?a.complexity():0;return e},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState, -this);return this},_restoreObjectState:function(e){var a=this.get("left"),c=this.get("top"),g=this.getAngle()*(Math.PI/180);e.get("originalLeft");e.get("originalTop");var n=Math.cos(g)*e.get("top")+Math.sin(g)*e.get("left");g=-Math.sin(g)*e.get("top")+Math.cos(g)*e.get("left");e.setAngle(e.getAngle()+this.getAngle());e.set("left",a+g*this.get("scaleX"));e.set("top",c+n*this.get("scaleY"));e.set("scaleX",e.get("scaleX")*this.get("scaleX"));e.set("scaleY",e.get("scaleY")*this.get("scaleY"));e.setCoords(); +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,o=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*o};var q={x:a.x-this.currentHeight*o,y:a.y+this.currentHeight*g};this.oCoords={tl:a,tr:b,br:{x:b.x-this.currentHeight*o,y:b.y+this.currentHeight*g},bl:q,ml:{x:a.x-this.currentHeight/ +2*o,y:a.y+this.currentHeight/2*g},mt:{x:a.x+this.currentWidth/2*g,y:a.y+this.currentWidth/2*o},mr:{x:b.x-this.currentHeight/2*o,y:b.y+this.currentHeight/2*g},mb:{x:q.x+this.currentWidth/2*g,y:q.y+this.currentWidth/2*o}};this._setCornerCoords();return this},drawBorders:function(a){var b=this.options,g=b.padding,o=g*2;a.save();a.globalAlpha=this.isMoving?b.borderOpacityWhenMoving:1;a.strokeStyle=b.borderColor;b=1/(this.scaleXa.x&&q.xa.y&&t.y=b&&t.d.y>=b)){if(t.o.x==t.d.x&&t.o.x>=a)o=t.o.x;else{o=(t.d.y-t.o.y)/(t.d.x-t.o.x);q=b-0*a;t=t.o.y-o*t.o.x;o=-(q-t)/(0-o)}if(o>=a)A+=1;if(A==2)break}}return A},_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),o=this.cornersize*Math.sin(b);b=this.cornersize/2;var q=b-o;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+o},bl:{x:a.tl.x-o,y:a.tl.y+g}};a.tl.corner.br={x:a.tl.corner.tr.x-o,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-o},tr:{x:a.tr.x,y:a.tr.y},br:{x:a.tr.x-o,y:a.tr.y+g}};a.tr.corner.bl={x:a.tr.corner.tl.x-o,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+o,y:a.bl.y-g},bl:{x:a.bl.x,y:a.bl.y},br:{x:a.bl.x+g,y:a.bl.y+o}};a.bl.corner.tr={x:a.bl.corner.br.x+ +o,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+o,y:a.br.y-g},bl:{x:a.br.x-g,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-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+o},bl:{x:a.ml.x-o,y:a.ml.y+g}};a.ml.corner.br={x:a.ml.corner.tr.x-o,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+ +o},bl:{x:a.mt.x-o,y:a.mt.y+g}};a.mt.corner.br={x:a.mt.corner.tr.x-o,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+o},bl:{x:a.mr.x-o,y:a.mr.y+g}};a.mr.corner.br={x:a.mr.corner.tr.x-o,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+o},bl:{x:a.mb.x-o,y:a.mb.y+g}};a.mb.corner.br={x:a.mb.corner.tr.x-o,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 l.Color(a)).toGrayscale().toRgb());return this},complexity:function(){return 0},getCenter:function(){return{x:this.get("left")+this.width/2,y:this.get("top")+this.height/2}},straighten:function(){this.setAngle(this._getAngleValueForStraighten());return this},fxStraighten:function(a){a=a||{};var b=function(){},g=a.onComplete||b,o=a.onChange|| +b,q=this;l.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){q.setAngle(t);o()},onComplete:function(){q.setCoords();g()},onStart:function(){q.setActive(false)}});return this},fxRemove:function(a){a||(a={});var b=function(){},g=a.onComplete||b,o=a.onChange||b,q=this;l.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(t){q.set("opacity",t);o()},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()}});l.Object.prototype.rotate=l.Object.prototype.setAngle}})(this); +(function(z){var l=z.fabric||(z.fabric={}),f=l.util.object.extend;if(l.Line)l.warn("fabric.Line is already defined");else{l.Line=l.util.createClass(l.Object,{type:"line",initialize:function(k,m){k||(k=[0,0,0,0]);this.callSuper("initialize",m);this.set("x1",k[0]);this.set("y1",k[1]);this.set("x2",k[2]);this.set("y2",k[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(k){k.beginPath(); +k.moveTo(-this.width/2,-this.height/2);k.lineTo(this.width/2,this.height/2);var m=k.strokeStyle;k.strokeStyle=k.fillStyle;k.stroke();k.strokeStyle=m},complexity:function(){return 1},toObject:function(){return f(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});l.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");l.Line.fromElement=function(k,m){var p=l.parseAttributes(k,l.Line.ATTRIBUTE_NAMES);return new l.Line([p.x1|| +0,p.y1||0,p.x2||0,p.y2||0],f(p,m))};l.Line.fromObject=function(k){return new l.Line([k.x1,k.y1,k.x2,k.y2],k)}}})(this); +(function(z){var l=z.fabric||(z.fabric={}),f=Math.PI*2,k=l.util.object.extend;if(l.Circle)l.warn("fabric.Circle is already defined.");else{l.Circle=l.util.createClass(l.Object,{type:"circle",initialize:function(m){m=m||{};this.set("radius",m.radius||0);this.callSuper("initialize",m);m=this.get("radius")*2*this.get("scaleX");this.set("width",m).set("height",m)},toObject:function(){return k(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(m,p){m.beginPath();m.arc(p?this.left: +0,p?this.top:0,this.radius,0,f,false);m.closePath();this.fill&&m.fill();this.stroke&&m.stroke()},complexity:function(){return 1}});l.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");l.Circle.fromElement=function(m,p){p||(p={});var h=l.parseAttributes(m,l.Circle.ATTRIBUTE_NAMES);if(!("radius"in h&&h.radius>0))throw Error("value of `r` attribute is required and can not be negative");if("left"in h)h.left-=p.width/2||0;if("top"in h)h.top-=p.height/2||0;return new l.Circle(k(h, +p))};l.Circle.fromObject=function(m){return new l.Circle(m)}}})(this); +(function(z){var l=z.fabric||(z.fabric={});if(l.Triangle)l.warn("fabric.Triangle is already defined");else{l.Triangle=l.util.createClass(l.Object,{type:"triangle",initialize:function(f){f=f||{};this.callSuper("initialize",f);this.set("width",f.width||100).set("height",f.height||100)},_render:function(f){var k=this.width/2,m=this.height/2;f.beginPath();f.moveTo(-k,m);f.lineTo(0,-m);f.lineTo(k,m);f.closePath();this.fill&&f.fill();this.stroke&&f.stroke()},complexity:function(){return 1}});l.Triangle.fromObject= +function(f){return new l.Triangle(f)}}})(this); +(function(z){var l=z.fabric||(z.fabric={}),f=Math.PI*2,k=l.util.object.extend;if(l.Ellipse)l.warn("fabric.Ellipse is already defined.");else{l.Ellipse=l.util.createClass(l.Object,{type:"ellipse",initialize:function(m){m=m||{};this.callSuper("initialize",m);this.set("rx",m.rx||0);this.set("ry",m.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return k(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(m,p){if(!(this.rx=== +0||this.ry===0))return this.callSuper("render",m,p)},_render:function(m,p){m.beginPath();m.save();m.transform(1,0,0,this.ry/this.rx,0,0);m.arc(p?this.left:0,p?this.top:0,this.rx,0,f,false);m.restore();this.stroke&&m.stroke();this.fill&&m.fill()},complexity:function(){return 1}});l.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");l.Ellipse.fromElement=function(m,p){p||(p={});var h=l.parseAttributes(m,l.Ellipse.ATTRIBUTE_NAMES);if("left"in h)h.left-=p.width/ +2||0;if("top"in h)h.top-=p.height/2||0;return new l.Ellipse(k(h,p))};l.Ellipse.fromObject=function(m){return new l.Ellipse(m)}}})(this); +(function(z){var l=z.fabric||(z.fabric={});if(l.Rect)console.warn("fabric.Rect is already defined");else{l.Rect=l.util.createClass(l.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(f){this.callSuper("initialize",f);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(f){var k=this.options.rx||0,m=this.options.ry||0,p=-this.width/2,h=-this.height/ +2,e=this.width,a=this.height;f.beginPath();f.moveTo(p+k,h);f.lineTo(p+e-k,h);f.bezierCurveTo(p+e,h,p+e,h+m,p+e,h+m);f.lineTo(p+e,h+a-m);f.bezierCurveTo(p+e,h+a,p+e-k,h+a,p+e-k,h+a);f.lineTo(p+k,h+a);f.bezierCurveTo(p,h+a,p,h+a-m,p,h+a-m);f.lineTo(p,h+m);f.bezierCurveTo(p,h,p+k,h,p+k,h);f.closePath();this.fill&&f.fill();this.stroke&&f.stroke()},_normalizeLeftTopProperties:function(f){f.left&&this.set("left",f.left+this.getWidth()/2);f.top&&this.set("top",f.top+this.getHeight()/2);return this},complexity:function(){return 1}}); +l.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");l.Rect.fromElement=function(f,k){if(!f)return null;var m=l.parseAttributes(f,l.Rect.ATTRIBUTE_NAMES);m=m;m.left=m.left||0;m.top=m.top||0;m=m;var p=new l.Rect(l.util.object.extend(k||{},m));p._normalizeLeftTopProperties(m);return p};l.Rect.fromObject=function(f){return new l.Rect(f)}}})(this); +(function(z){var l=z.fabric||(z.fabric={});if(l.Polyline)l.warn("fabric.Polyline is already defined");else{l.Polyline=l.util.createClass(l.Object,{type:"polyline",initialize:function(f,k){k=k||{};this.set("points",f);this.callSuper("initialize",k);this._calcDimensions()},_calcDimensions:function(){return l.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return l.Polygon.prototype.toObject.call(this)},_render:function(f){var k;f.beginPath();for(var m=0,p=this.points.length;m"},toObject:function(){var e=h(this.callSuper("toObject"),{path:this.path});if(this.sourcePath)e.sourcePath=this.sourcePath;if(this.transformMatrix)e.transformMatrix=this.transformMatrix;return e},toDatalessObject:function(){var e=this.toObject();if(this.sourcePath)e.path=this.sourcePath;delete e.sourcePath; +return e},complexity:function(){return this.path.length},_parsePath:function(){for(var e=[],a,b,g=0,o=this.path.length;g"},isSameColor:function(){var a=this.getObjects()[0].get("fill");return this.getObjects().every(function(b){return b.get("fill")===a})},complexity:function(){return this.paths.reduce(function(a,b){return a+(b&&b.complexity?b.complexity():0)},0)},toGrayscale:function(){for(var a=this.paths.length;a--;)this.paths[a].toGrayscale();return this},getObjects:function(){return this.paths}});l.PathGroup.fromObject=function(a){for(var b=a.paths, +g=0,o=b.length;g"},getObjects:function(){return this.objects},add:function(e){this._restoreObjectsState();this.objects.push(e);e.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(e){this._restoreObjectsState(); +h(this.objects,e);e.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(e,a){if(typeof a=="function")this.set(e,a(this[e]));else if(e==="fill"||e==="opacity"){var b=this.objects.length;for(this[e]=a;b--;)this.objects[b].set(e,a)}else this[e]=a;return this},contains:function(e){return this.objects.indexOf(e)>-1},toObject:function(){return f(this.callSuper("toObject"),{objects:p(this.objects,"clone")})},render:function(e){e.save(); +this.transform(e);for(var a=Math.max(this.scaleX,this.scaleY),b=0,g;g=this.objects[b];b++){var o=g.borderScaleFactor;g.borderScaleFactor=a;g.render(e);g.borderScaleFactor=o}this.hideBorders||this.drawBorders(e);this.hideCorners||this.drawCorners(e);e.restore();this.setCoords()},item:function(e){return this.getObjects()[e]},complexity:function(){return this.getObjects().reduce(function(e,a){e+=typeof a.complexity=="function"?a.complexity():0;return e},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState, +this);return this},_restoreObjectState:function(e){var a=this.get("left"),b=this.get("top"),g=this.getAngle()*(Math.PI/180);e.get("originalLeft");e.get("originalTop");var o=Math.cos(g)*e.get("top")+Math.sin(g)*e.get("left");g=-Math.sin(g)*e.get("top")+Math.cos(g)*e.get("left");e.setAngle(e.getAngle()+this.getAngle());e.set("left",a+g*this.get("scaleX"));e.set("top",b+o*this.get("scaleY"));e.set("scaleX",e.get("scaleX")*this.get("scaleX"));e.set("scaleY",e.get("scaleY")*this.get("scaleY"));e.setCoords(); e.hideCorners=false;e.setActive(false);e.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(e){e.setCoords()});return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(e){this.forEachObject(function(a){a.setActive(e)}); -return this},forEachObject:function(e,a){for(var c=this.getObjects(),g=c.length;g--;)e.call(a,c[g],g,c);return this},_setOpacityIfSame:function(){var e=this.getObjects(),a=e[0]?e[0].get("opacity"):1;if(e.every(function(c){return c.get("opacity")===a}))this.opacity=a},_calcBounds:function(){var e=[],a=[],c,g;g=0;for(var n=this.objects.length;ge.x&&n-ce.y},toGrayscale:function(){for(var e=this.objects.length;e--;)this.objects[e].toGrayscale()}});m.Group.fromObject=function(e){return new m.Group(e.objects,e)}}})(); -(function(){var m=this.fabric||(this.fabric={}),o=m.util.object.extend,f=m.util.object.clone;if(m.Text)m.warn("fabric.Text is already defined");else if(m.Object){m.Text=m.util.createClass(m.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(h,p){this.originalState={};this._initStateProperties();this.text=h;this.setOptions(p);o(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()}, -_initStateProperties:function(){var h;if((h=this.constructor)&&(h=h.superclass)&&(h=h.prototype)&&(h=h.stateProperties)&&h.clone){this.stateProperties=h.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#"},_render:function(h){var p=Cufon.textOptions||(Cufon.textOptions={});p.left=this.left;p.top=this.top;p.context=h;p.color=this.fill;var l=this._initDummyElement(); -this.transform(h);Cufon.replaceElement(l,{separate:"none",fontFamily:this.fontfamily});this.width=p.width;this.height=p.height},_initDummyElement:function(){var h=document.createElement("div");h.innerHTML=this.text;h.style.fontSize="40px";h.style.fontWeight="400";h.style.fontStyle="normal";h.style.letterSpacing="normal";h.style.color="#000000";h.style.fontWeight="600";h.style.fontFamily="Verdana";return h},render:function(h){h.save();this._render(h);if(this.active){this.drawBorders(h);this.drawCorners(h)}h.restore()}, -toObject:function(){return o(this.callSuper("toObject"),{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,path:this.path})},setColor:function(h){this.set("fill",h);return this},setFontsize:function(h){this.set("fontsize",h);this.setCoords();return this},getText:function(){return this.text},setText:function(h){this.set("text",h);this.setCoords();return this},set:function(h,p){this[h]=p;if(h==="fontfamily")this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, -"$1"+p+"$3");return this}});m.Text.fromObject=function(h){return new m.Text(h.text,f(h))};m.Text.fromElement=function(){}}else m.warn("fabric.Text requires fabric.Object")})(); -(function(){var m=fabric.util.object.extend;if(!this.fabric)this.fabric={};if(this.fabric.Image)fabric.warn("fabric.Image is already defined.");else if(fabric.Object){fabric.Image=fabric.util.createClass(fabric.Object,{maxwidth:null,maxheight:null,active:false,bordervisibility:false,cornervisibility:false,type:"image",__isGrayscaled:false,initialize:function(o,f){this.callSuper("initialize",f);this._initElement(o);this._initConfig(f||{})},getElement:function(){return this._element},setElement:function(o){this._element= -o;return this},getNormalizedSize:function(o,f,h){if(h&&f&&o.width>o.height&&o.width/o.heighto.width||o.height>h)){normalizedWidth=~~(o.width*h/o.height);normalizedHeight=h}else if(f&&f'},clone:function(o){this.constructor.fromObject(this.toObject(),o)},toGrayscale:function(o){if(!this.__isGrayscaled){var f=this.getElement(),h=document.createElement("canvas"),p=document.createElement("img"),l=this;h.width=f.width;h.height=f.height;h.getContext("2d").drawImage(f,0,0);fabric.Element.toGrayscale(h);p.onload=function(){l.setElement(p);o&&o();p.onload=h=f=imageData=null};p.width=f.width;p.height=f.height;p.src=h.toDataURL("image/png"); -this.__isGrayscaled=true;return this}},_render:function(o){var f=this.getOriginalSize();o.drawImage(this.getElement(),-f.width/2,-f.height/2,f.width,f.height)},_adjustWidthHeightToBorders:function(o){if(o){this.currentBorder=this.borderwidth;this.width+=2*this.currentBorder;this.height+=2*this.currentBorder}else this.currentBorder=0},_resetWidthHeight:function(){var o=this.getElement();this.set("width",o.width);this.set("height",o.height)},_initElement:function(o){this.setElement(fabric.util.getById(o)); -fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(o){this.setOptions(o);this._setBorder();this._setWidthHeight(o)},_setBorder:function(){this.currentBorder=this.bordervisibility?this.borderwidth:0},_setWidthHeight:function(){var o=2*this.currentBorder;this.width=(this.getElement().width||0)+o;this.height=(this.getElement().height||0)+o},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(o,f){var h=document.createElement("img"), -p=o.src;if(o.width)h.width=o.width;if(o.height)h.height=o.height;h.onload=function(){f&&f(new fabric.Image(h,o));h=h.onload=null};h.src=p};fabric.Image.fromURL=function(o,f,h){var p=document.createElement("img");p.onload=function(){f&&f(new fabric.Image(p,h));p=p.onload=null};p.src=o}}else fabric.warn("fabric.Object is required for fabric.Image initialization")})(); +return this},forEachObject:function(e,a){for(var b=this.getObjects(),g=b.length;g--;)e.call(a,b[g],g,b);return this},_setOpacityIfSame:function(){var e=this.getObjects(),a=e[0]?e[0].get("opacity"):1;if(e.every(function(b){return b.get("opacity")===a}))this.opacity=a},_calcBounds:function(){var e=[],a=[],b,g;g=0;for(var o=this.objects.length;ge.x&&o-be.y},toGrayscale:function(){for(var e=this.objects.length;e--;)this.objects[e].toGrayscale()}});l.Group.fromObject=function(e){return new l.Group(e.objects,e)}}})(this); +(function(z){var l=z.fabric||(z.fabric={}),f=l.util.object.extend,k=l.util.object.clone;if(l.Text)l.warn("fabric.Text is already defined");else if(l.Object){l.Text=l.util.createClass(l.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(m,p){this.originalState={};this._initStateProperties();this.text=m;this.setOptions(p);f(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()}, +_initStateProperties:function(){var m;if((m=this.constructor)&&(m=m.superclass)&&(m=m.prototype)&&(m=m.stateProperties)&&m.clone){this.stateProperties=m.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#"},_render:function(m){var p=Cufon.textOptions||(Cufon.textOptions={});p.left=this.left;p.top=this.top;p.context=m;p.color=this.fill;var h=this._initDummyElement(); +this.transform(m);Cufon.replaceElement(h,{separate:"none",fontFamily:this.fontfamily});this.width=p.width;this.height=p.height},_initDummyElement:function(){var m=document.createElement("div");m.innerHTML=this.text;m.style.fontSize="40px";m.style.fontWeight="400";m.style.fontStyle="normal";m.style.letterSpacing="normal";m.style.color="#000000";m.style.fontWeight="600";m.style.fontFamily="Verdana";return m},render:function(m){m.save();this._render(m);if(this.active){this.drawBorders(m);this.drawCorners(m)}m.restore()}, +toObject:function(){return f(this.callSuper("toObject"),{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,path:this.path})},setColor:function(m){this.set("fill",m);return this},setFontsize:function(m){this.set("fontsize",m);this.setCoords();return this},getText:function(){return this.text},setText:function(m){this.set("text",m);this.setCoords();return this},set:function(m,p){this[m]=p;if(m==="fontfamily")this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/, +"$1"+p+"$3");return this}});l.Text.fromObject=function(m){return new l.Text(m.text,k(m))};l.Text.fromElement=function(){}}else l.warn("fabric.Text requires fabric.Object")})(this); +(function(z){var l=fabric.util.object.extend;if(!z.fabric)z.fabric={};if(z.fabric.Image)fabric.warn("fabric.Image is already defined.");else if(fabric.Object){fabric.Image=fabric.util.createClass(fabric.Object,{maxwidth:null,maxheight:null,active:false,bordervisibility:false,cornervisibility:false,type:"image",__isGrayscaled:false,initialize:function(f,k){this.callSuper("initialize",k);this._initElement(f);this._initConfig(k||{})},getElement:function(){return this._element},setElement:function(f){this._element= +f;return this},getNormalizedSize:function(f,k,m){if(m&&k&&f.width>f.height&&f.width/f.heightf.width||f.height>m)){normalizedWidth=~~(f.width*m/f.height);normalizedHeight=m}else if(k&&k'},clone:function(f){this.constructor.fromObject(this.toObject(),f)},toGrayscale:function(f){if(!this.__isGrayscaled){var k=this.getElement(),m=document.createElement("canvas"),p=document.createElement("img"),h=this;m.width=k.width;m.height=k.height;m.getContext("2d").drawImage(k,0,0);fabric.Element.toGrayscale(m);p.onload=function(){h.setElement(p);f&&f();p.onload=m=k=imageData=null};p.width=k.width;p.height=k.height;p.src=m.toDataURL("image/png"); +this.__isGrayscaled=true;return this}},_render:function(f){var k=this.getOriginalSize();f.drawImage(this.getElement(),-k.width/2,-k.height/2,k.width,k.height)},_adjustWidthHeightToBorders:function(f){if(f){this.currentBorder=this.borderwidth;this.width+=2*this.currentBorder;this.height+=2*this.currentBorder}else this.currentBorder=0},_resetWidthHeight:function(){var f=this.getElement();this.set("width",f.width);this.set("height",f.height)},_initElement:function(f){this.setElement(fabric.util.getById(f)); +fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(f){this.setOptions(f);this._setBorder();this._setWidthHeight(f)},_setBorder:function(){this.currentBorder=this.bordervisibility?this.borderwidth:0},_setWidthHeight:function(){var f=2*this.currentBorder;this.width=(this.getElement().width||0)+f;this.height=(this.getElement().height||0)+f},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(f,k){var m=document.createElement("img"), +p=f.src;if(f.width)m.width=f.width;if(f.height)m.height=f.height;m.onload=function(){k&&k(new fabric.Image(m,f));m=m.onload=null};m.src=p};fabric.Image.fromURL=function(f,k,m){var p=document.createElement("img");p.onload=function(){k&&k(new fabric.Image(p,m));p=p.onload=null};p.src=f}}else fabric.warn("fabric.Object is required for fabric.Image initialization")})(this); diff --git a/dist/all.min.js.gz b/dist/all.min.js.gz deleted file mode 100644 index fc28b80b..00000000 Binary files a/dist/all.min.js.gz and /dev/null differ diff --git a/src/element.class.js b/src/element.class.js index d7254d6b..ab2c4564 100644 --- a/src/element.class.js +++ b/src/element.class.js @@ -223,6 +223,19 @@ /* NOOP */ }, + /** + * Callback; invoked every time active object is moved + * @method onObjectMove + * @param {fabric.Object} object that's being moved + */ + onObjectMove: null, + + /** + * Callback; invoked when a mouseup event occurs, and at the end of all other transformations + * @method onMouseUp + */ + onMouseUp: null, + /** * Calculates canvas element offset relative to the document * This method is also attached as "resize" event handler of window @@ -557,6 +570,7 @@ this.renderAll(); this._setCursorFromEvent(e, target); + // fix for FF this._setCursor(''); @@ -564,6 +578,10 @@ setTimeout(function () { _this._setCursorFromEvent(e, target); }, 50); + + if (this.onMouseUp) { + this.onMouseUp(); + } }, _shouldClearSelection: function (e) { @@ -897,7 +915,7 @@ var pointer = getPointer(e), x = pointer.x, y = pointer.y; - + this._currentTransform.target.isMoving = true; if (this._currentTransform.action === 'rotate') { @@ -917,6 +935,9 @@ } else { this._translateObject(x, y); + if (this.onObjectMove) { + this.onObjectMove(this._currentTransform.target); + } } // only commit here. when we are actually moving the pictures this.renderAll(); diff --git a/test/demo/centering_guidelines.js b/test/demo/centering_guidelines.js new file mode 100644 index 00000000..3e550b5f --- /dev/null +++ b/test/demo/centering_guidelines.js @@ -0,0 +1,74 @@ +/** + * Augments canvas by assigning to `onObjectMove` and `onAfterRender`. + * This kind of sucks because other code using those methods will stop functioning. + * Need to fix it by replacing callbacks with pub/sub kind of subscription model. + * (or maybe use existing fabric.util.fireEvent/observeEvent (if it won't be too slow)) + */ +function initCenteringGuidelines(canvas) { + + var canvasWidth = canvas.getWidth(), + canvasHeight = canvas.getHeight(), + canvasWidthCenter = canvasWidth / 2, + canvasHeightCenter = canvasHeight / 2, + canvasWidthCenterMap = { }, + canvasHeightCenterMap = { }, + centerLineMargin = 4, + centerLineColor = 'rgba(255,0,241,0.5)', + centerLineWidth = 1, + ctx = canvas.getContext(); + + for (var i = canvasWidthCenter - centerLineMargin, len = canvasWidthCenter + centerLineMargin; i <= len; i++) { + canvasWidthCenterMap[i] = true; + } + for (var i = canvasHeightCenter - centerLineMargin, len = canvasHeightCenter + centerLineMargin; i <= len; i++) { + canvasHeightCenterMap[i] = true; + } + + function showVerticalCenterLine() { + showCenterLine(canvasWidthCenter + 0.5, 0, canvasWidthCenter + 0.5, canvasHeight); + } + + function showHorizontalCenterLine() { + showCenterLine(0, canvasHeightCenter + 0.5, canvasWidth, canvasHeightCenter + 0.5); + } + + function showCenterLine(x1, y1, x2, y2) { + ctx.save(); + ctx.strokeStyle = centerLineColor; + ctx.lineWidth = centerLineWidth; + ctx.beginPath(); + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.stroke(); + ctx.restore(); + } + + canvas.onObjectMove = function(object) { + var isInVerticalCenter = object.get('left') in canvasWidthCenterMap, + isInHorizontalCenter = object.get('top') in canvasHeightCenterMap; + + if (isInVerticalCenter || isInHorizontalCenter) { + canvas.afterRender = function() { + if (isInHorizontalCenter) { + showHorizontalCenterLine(); + } + if (isInVerticalCenter) { + showVerticalCenterLine(); + } + }; + if (isInHorizontalCenter) { + object.set('top', canvasHeightCenter); + } + if (isInVerticalCenter) { + object.set('left', canvasWidthCenter); + } + } + else { + canvas.afterRender = null; + } + }; + canvas.onMouseUp = function() { + canvas.afterRender = null; + canvas.renderAll(); + }; +} \ No newline at end of file diff --git a/test/demo/demo.js b/test/demo/demo.js index af53e7a4..a335ed8b 100644 --- a/test/demo/demo.js +++ b/test/demo/demo.js @@ -331,4 +331,6 @@ canvas.calcOffset(); }, 100); + initCenteringGuidelines(canvas); + })(this); \ No newline at end of file diff --git a/test/demo/index.html b/test/demo/index.html index 6f468b7d..249896f1 100644 --- a/test/demo/index.html +++ b/test/demo/index.html @@ -4,7 +4,7 @@ - Canvas demo + Demo of a Fabric.js — HTML5/Javascript canvas library and an SVG parser