diff --git a/README.md b/README.md index 16ba7098..262c6d40 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,11 @@ Fabric.js started as a foundation for design editor on [printio.ru](http://print 3. Create a minified distribution file + # Using YUICompressor $ java -jar lib/yuicompressor-2.4.2.jar dist/all.js -o dist/all.min.js + + # or Google Closure Compiler + $ java -jar lib/google_closure_compiler.jar --js dist/all.js --js_output_file dist/all.min.js ### Examples of use diff --git a/dist/all.js b/dist/all.js index bbf05079..5693d6cc 100644 --- a/dist/all.js +++ b/dist/all.js @@ -1419,7 +1419,9 @@ fabric.util.animate = animate; memo.push({ x: parseFloat(pair[0]), y: parseFloat(pair[1]) }); return memo; }, [ ]); + if (parsedPoints.length % 2 !== 0) { + return null; } return parsedPoints; }; @@ -6764,7 +6766,7 @@ fabric.util.animate = animate; /** * @static * @method fabric.PathGroup.fromObject - * @param {Object} + * @param {Object} object * @return {fabric.PathGroup} */ fabric.PathGroup.fromObject = function(object) { @@ -7452,8 +7454,8 @@ fabric.util.animate = animate; * Width and height have to mantain the same proportion in the final image as it was in the initial one. * @method getNormalizedSize * @param {Object} oImg - * @param {Number} maximum width of the image in px - * @param {Number} maximum height of the image in px + * @param {Number} maxwidth maximum width of the image in px + * @param {Number} maxheight maximum height of the image in px */ getNormalizedSize: function(oImg, maxwidth, maxheight) { if (maxheight && maxwidth && (oImg.width > oImg.height && (oImg.width / oImg.height) < (maxwidth / maxheight))) { diff --git a/dist/all.min.js b/dist/all.min.js index fbb12412..813cfd2e 100644 --- a/dist/all.min.js +++ b/dist/all.min.js @@ -1,2 +1,2 @@ /* Fabric.js Copyright 2010, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */ -if(typeof console=="undefined"){var console={log:function(){},warn:function(){}}}if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i>>0;w=Number(w)||0;w=Math[w<0?"ceil":"floor"](w);if(w<0){w+=u}for(;w>>0;v>>0;w>>0;v>>0;v>>0;w>>0,v=0,x;if(arguments.length>1){x=arguments[1]}else{do{if(v in this){x=this[v++];break}if(++v>=u){throw new TypeError()}}while(true)}for(;v=u){u=x[v][w]}}}else{while(v--){if(x[v]>=u){u=x[v]}}}return u}function l(x,w){var v=x.length-1,u=w?x[v][w]:x[v];if(w){while(v--){if(x[v][w]-1?w(D,F.match(/opacity:\s*(\d?\.?\d*)/)[1]):D}for(var G in F){if(G==="opacity"){w(D,F[G])}else{var E=(G==="float"||G==="cssFloat")?(typeof H.styleFloat==="undefined"?"cssFloat":"styleFloat"):G;H[E]=F[G]}}return D}var B=document.createElement("div"),A=typeof B.style.opacity==="string",v=typeof B.style.filter==="string",u=document.defaultView,z=u&&typeof u.getComputedStyle!=="undefined",x=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,w=function(C){return C};if(A){w=function(C,D){C.style.opacity=D;return C}}else{if(v){w=function(C,D){var E=C.style;if(C.currentStyle&&!C.currentStyle.hasLayout){E.zoom=1}if(x.test(E.filter)){D=D>=0.9999?"":("alpha(opacity="+(D*100)+")");E.filter=E.filter.replace(x,D)}else{E.filter+=" alpha(opacity="+(D*100)+")"}return C}}}g.util.setStyle=y})();function p(u){return typeof u==="string"?document.getElementById(u):u}function n(v){var u=[],w=v.length;while(w--){u[w]=v[w]}return u}function b(v,u){var w=document.createElement(v);for(var x in u){if(x==="class"){x="className"}else{if(x==="for"){x="htmlFor"}}w.setAttribute(x,u[x])}return w}function f(u,v){if((" "+u.className+" ").indexOf(" "+v+" ")===-1){u.className+=(u.className?" ":"")+v}}function a(v,w,u){if(typeof w==="string"){w=b(w,u)}if(v.parentNode){v.parentNode.replaceChild(w,v)}w.appendChild(v);return w}function k(v){var u=0,w=0;do{u+=v.offsetTop||0;w+=v.offsetLeft||0;v=v.offsetParent}while(v);return({left:w,top:u})}function e(){return false}(function(){var u=document.documentElement.style;var v="userSelect" in u?"userSelect":"MozUserSelect" in u?"MozUserSelect":"WebkitUserSelect" in u?"WebkitUserSelect":"KhtmlUserSelect" in u?"KhtmlUserSelect":"";function w(x){if(typeof x.onselectstart!=="undefined"){x.onselectstart=e}if(v){x.style[v]="none"}else{if(typeof x.unselectable=="string"){x.unselectable="on"}}return x}g.util.makeElementUnselectable=w})();(function(){function u(x,B){var z=document.getElementsByTagName("head")[0],y=document.createElement("script"),A=true;y.type="text/javascript";y.setAttribute("runat","server");y.onload=y.onreadystatechange=function(C){if(A){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete"){return}A=false;B(C||window.event);y=y.onload=y.onreadystatechange=null}};y.src=x;z.appendChild(y)}function w(x,y){v.load(x);y()}g.util.getScript=u;var v=this.Jaxer;if(v&&v.load){g.util.getScript=w}})();function c(F){F||(F={});var v=+new Date(),z=F.duration||500,E=v+z,y,D,A=F.onChange||function(){},B=F.easing||function(G){return(-Math.cos(G*Math.PI)/2)+0.5},u="startValue" in F?F.startValue:0,C="endValue" in F?F.endValue:100,x=u>C;F.onStart&&F.onStart();var w=setInterval(function(){y=+new Date();D=y>E?1:(y-v)/z;A(x?(u-(u-C)*B(D)):(u+(C-u)*B(D)));if(y>E){clearInterval(w);F.onComplete&&F.onComplete()}},10)}g.util.getById=p;g.util.toArray=n;g.util.makeElement=b;g.util.addClass=f;g.util.wrapElement=a;g.util.getElementOffset=k;g.util.animate=c;(function(){function x(y,z){return y+(/\?/.test(y)?"&":"?")+z}var w=(function(){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()}];for(var y=B.length;y--;){try{var A=B[y]();if(A){return B[y]}}catch(z){}}})();function u(){}function v(A,z){z||(z={});var D=z.method?z.method.toUpperCase():"GET",C=z.onComplete||function(){},B=w(),y;B.onreadystatechange=function(){if(B.readyState===4){C(B);B.onreadystatechange=u}};if(D==="GET"){y=null;if(typeof z.parameters=="string"){A=x(A,z.parameters)}}B.open(D,A,true);if(D==="POST"||D==="PUT"){B.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}B.send(y);return B}g.util.request=v})();(function(){function y(B,A){var z=B.indexOf(A);if(z!==-1){B.splice(z,1)}return B}function x(A,z){return Math.floor(Math.random()*(z-A+1))+A}var v=Math.PI/180;function w(z){return z*v}function u(A,z){return parseFloat(Number(A).toFixed(z))}g.util.removeFromArray=y;g.util.degreesToRadians=w;g.util.toFixed=u;g.util.getRandomInt=x})()})(this);(function(){var f=this.fabric||(this.fabric={});var c={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};function b(l,k){if(!l){return}var n,h,g={};if(l.parentNode&&/^g$/i.test(l.parentNode.nodeName)){g=f.parseAttributes(l.parentNode,k)}var m=k.reduce(function(p,o){n=l.getAttribute(o);h=parseFloat(n);if(n){if((o==="fill"||o==="stroke")&&n==="none"){n=""}if(o==="fill-rule"){n=(n==="evenodd")?"destination-over":n}if(o==="transform"){n=f.parseTransformAttribute(n)}if(o in c){o=c[o]}p[o]=isNaN(h)?n:h}return p},{});m=f.util.object.extend(f.parseStyleAttribute(l),m);return f.util.object.extend(g,m)}f.parseTransformAttribute=(function(){function g(B,C){var D=C[0];B[0]=Math.cos(D);B[1]=Math.sin(D);B[2]=-Math.sin(D);B[3]=Math.cos(D)}function n(D,E){var C=E[0],B=(E.length===2)?E[1]:E[0];D[0]=C;D[3]=B}function y(B,C){B[2]=C[0]}function k(B,C){B[1]=C[0]}function v(B,C){B[4]=C[0];if(C.length===2){B[5]=C[1]}}var p=[1,0,0,1,0,0],h="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",z="(?:\\s+,?\\s*|,\\s*)",q="(?:(skewX)\\s*\\(\\s*("+h+")\\s*\\))",o="(?:(skewY)\\s*\\(\\s*("+h+")\\s*\\))",x="(?:(rotate)\\s*\\(\\s*("+h+")(?:"+z+"("+h+")"+z+"("+h+"))?\\s*\\))",A="(?:(scale)\\s*\\(\\s*("+h+")(?:"+z+"("+h+"))?\\s*\\))",t="(?:(translate)\\s*\\(\\s*("+h+")(?:"+z+"("+h+"))?\\s*\\))",w="(?:(matrix)\\s*\\(\\s*("+h+")"+z+"("+h+")"+z+"("+h+")"+z+"("+h+")"+z+"("+h+")"+z+"("+h+")\\s*\\))",u="(?:"+w+"|"+t+"|"+A+"|"+x+"|"+q+"|"+o+")",r="(?:"+u+"(?:"+z+u+")*)",l="^\\s*(?:"+r+"?)\\s*$",s=new RegExp(l),m=new RegExp(u);return function(C){var B=p.concat();if(!C||(C&&!s.test(C))){return B}C.replace(m,function(G){var D=new RegExp(u).exec(G).filter(function(H){return(H!==""&&H!=null)}),E=D[1],F=D.slice(2).map(parseFloat);switch(E){case"translate":v(B,F);break;case"rotate":g(B,F);break;case"scale":n(B,F);break;case"skewX":y(B,F);break;case"skewY":k(B,F);break;case"matrix":B=F;break}});return B}})();function a(h){if(!h){return null}h=h.trim().split(/\s+/);var g=h.reduce(function(k,l){l=l.split(",");k.push({x:parseFloat(l[0]),y:parseFloat(l[1])});return k},[]);if(g.length%2!==0){}return g}function e(h){var g={},k=h.getAttribute("style");if(k){if(typeof k=="string"){k=k.split(";");k.pop();g=k.reduce(function(n,q){var m=q.split(":"),o=m[0].trim(),p=m[1].trim();n[o]=p;return n},{})}else{for(var l in k){if(typeof k[l]!=="undefined"){g[l]=k[l]}}}}return g}function d(h,g){var k=h.map(function(m){var l=f[f.util.string.capitalize(m.tagName)];if(l&&l.fromElement){try{return l.fromElement(m,g)}catch(n){console.log(n.message||n)}}});k=k.filter(function(l){return l!=null});return k}f.parseSVGDocument=(function(){var g=/^(path|circle|polygon|polyline|ellipse|rect|line)$/;var k="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)";var l=new RegExp("^\\s*("+k+"+)\\s*,?\\s*("+k+"+)\\s*,?\\s*("+k+"+)\\s*,?\\s*("+k+"+)\\s*$");function h(m,n){while(m&&(m=m.parentNode)){if(m.nodeName===n){return true}}return false}return function(u,w){if(!u){return}var t=f.util.toArray(u.getElementsByTagName("*"));var m=t.filter(function(y){return g.test(y.tagName)&&!h(y,"pattern")});if(!m||(m&&!m.length)){return}var n=u.getAttribute("viewBox"),r=u.getAttribute("width"),p=u.getAttribute("height"),o=null,v=null,s,q;if(n&&(n=n.match(l))){s=parseInt(n[1],10);q=parseInt(n[2],10);o=parseInt(n[3],10);v=parseInt(n[4],10)}o=r?parseFloat(r):o;v=p?parseFloat(p):v;var x={width:o,height:v};var m=f.parseElements(m,f.util.object.clone(x));if(!m||(m&&!m.length)){return}if(w){w(m,x)}}})();f.util.object.extend(f,{parseAttributes:b,parseElements:d,parseStyleAttribute:e,parsePointsAttribute:a})})();(function(){var b=this.fabric||(this.fabric={});if(b.Point){console.warn("fabric.Point is already defined");return}function a(c,d){if(arguments.length>0){this.init(c,d)}}a.prototype={constructor:a,init:function(c,d){this.x=c;this.y=d},add:function(c){return new a(this.x+c.x,this.y+c.y)},addEquals:function(c){this.x+=c.x;this.y+=c.y;return this},scalarAdd:function(c){return new a(this.x+c,this.y+c)},scalarAddEquals:function(c){this.x+=c;this.y+=c;return this},subtract:function(c){return new a(this.x-c.x,this.y-c.y)},subtractEquals:function(c){this.x-=c.x;this.y-=c.y;return this},scalarSubtract:function(c){return new a(this.x-c,this.y-c)},scalarSubtractEquals:function(c){this.x-=c;this.y-=c;return this},multiply:function(c){return new a(this.x*c,this.y*c)},multiplyEquals:function(c){this.x*=c;this.y*=c;return this},divide:function(c){return new a(this.x/c,this.y/c)},divideEquals:function(c){this.x/=c;this.y/=c;return this},eq:function(c){return(this.x==c.x&&this.y==c.y)},lt:function(c){return(this.xc.x&&this.y>c.y)},gte:function(c){return(this.x>=c.x&&this.y>=c.y)},lerp:function(d,c){return new a(this.x+(d.x-this.x)*c,this.y+(d.y-this.y)*c)},distanceFrom:function(e){var d=this.x-e.x,c=this.y-e.y;return Math.sqrt(d*d+c*c)},min:function(c){return new a(Math.min(this.x,c.x),Math.min(this.y,c.y))},max:function(c){return new a(Math.max(this.x,c.x),Math.max(this.y,c.y))},toString:function(){return this.x+","+this.y},setXY:function(c,d){this.x=c;this.y=d},setFromPoint:function(c){this.x=c.x;this.y=c.y},swap:function(d){var c=this.x,e=this.y;this.x=d.x;this.y=d.y;d.x=c;d.y=e}};b.Point=a})();(function(){var a=this,b=a.fabric||(a.fabric={});if(b.Intersection){console.warn("fabric.Intersection is already defined");return}function c(d){if(arguments.length>0){this.init(d)}}c.prototype.init=function(d){this.status=d;this.points=[]};c.prototype.appendPoint=function(d){this.points.push(d)};c.prototype.appendPoints=function(d){this.points=this.points.concat(d)};c.intersectLineLine=function(h,f,n,m){var o,k=(m.x-n.x)*(h.y-n.y)-(m.y-n.y)*(h.x-n.x),l=(f.x-h.x)*(h.y-n.y)-(f.y-h.y)*(h.x-n.x),g=(m.y-n.y)*(f.x-h.x)-(m.x-n.x)*(f.y-h.y);if(g!=0){var e=k/g,d=l/g;if(0<=e&&e<=1&&0<=d&&d<=1){o=new c("Intersection");o.points.push(new b.Point(h.x+e*(f.x-h.x),h.y+e*(f.y-h.y)))}else{o=new c("No Intersection")}}else{if(k==0||l==0){o=new c("Coincident")}else{o=new c("Parallel")}}return o};c.intersectLinePolygon=function(e,d,m){var n=new c("No Intersection"),f=m.length;for(var h=0;h0){n.status="Intersection"}return n};c.intersectPolygonPolygon=function(k,h){var f=new c("No Intersection"),m=k.length;for(var l=0;l0){f.status="Intersection"}return f};c.intersectPolygonRectangle=function(p,e,d){var g=e.min(d),o=e.max(d),f=new b.Point(o.x,g.y),n=new b.Point(g.x,o.y),m=c.intersectLinePolygon(g,f,p),l=c.intersectLinePolygon(f,o,p),k=c.intersectLinePolygon(o,n,p),h=c.intersectLinePolygon(n,g,p),q=new c("No Intersection");q.appendPoints(m.points);q.appendPoints(l.points);q.appendPoints(k.points);q.appendPoints(h.points);if(q.points.length>0){q.status="Intersection"}return q};b.Intersection=c})();(function(){var a=this.fabric||(this.fabric={});if(a.Color){console.warn("fabric.Color is already defined.");return}a.Color=b;function b(c){if(!c){this.setSource([0,0,0,1])}else{this._tryParsingColor(c)}}b.prototype._tryParsingColor=function(c){var d=b.sourceFromHex(c);if(!d){d=b.sourceFromRgb(c)}if(d){this.setSource(d)}};b.prototype.getSource=function(){return this._source};b.prototype.setSource=function(c){this._source=c};b.prototype.toRgb=function(){var c=this.getSource();return"rgb("+c[0]+","+c[1]+","+c[2]+")"};b.prototype.toRgba=function(){var c=this.getSource();return"rgba("+c[0]+","+c[1]+","+c[2]+","+c[3]+")"};b.prototype.toHex=function(){var f=this.getSource();var e=f[0].toString(16);e=(e.length==1)?("0"+e):e;var d=f[1].toString(16);d=(d.length==1)?("0"+d):d;var c=f[2].toString(16);c=(c.length==1)?("0"+c):c;return e.toUpperCase()+d.toUpperCase()+c.toUpperCase()};b.prototype.getAlpha=function(){return this.getSource()[3]};b.prototype.setAlpha=function(d){var c=this.getSource();c[3]=d;this.setSource(c);return this};b.prototype.toGrayscale=function(){var e=this.getSource(),d=parseInt((e[0]*0.3+e[1]*0.59+e[2]*0.11).toFixed(0),10),c=e[3];this.setSource([d,d,d,c]);return this};b.prototype.toBlackWhite=function(c){var f=this.getSource(),e=(f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),d=f[3],c=c||127;e=(Number(e)0)?0:-s),this._groupSelector.ey-((r>0)?0:-r),q,p);this._oContextTop.lineWidth=this.selectionLineWidth;this._oContextTop.strokeStyle=this.selectionBorderColor;this._oContextTop.strokeRect(this._groupSelector.ex+a-((s>0)?0:q),this._groupSelector.ey+a-((r>0)?0:p),q,p)},_findSelectedObjects:function(v){var w,r,B=[],q=this._groupSelector.ex,A=this._groupSelector.ey,p=q+this._groupSelector.left,y=A+this._groupSelector.top,x,u=new fabric.Point(Math.min(q,p),Math.min(A,y)),z=new fabric.Point(Math.max(q,p),Math.max(A,y));for(var s=0,t=this._aObjects.length;s1){var 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(q,p){this._aObjects.splice(p,0,q);this.renderAll();return this},getObjects:function(){return this._aObjects},getContext:function(){return this._oContextTop},clearContext:b,clear:function(){this._aObjects.length=0;this.clearContext(this._oContextTop);this.clearContext(this._oContextContainer);this.renderAll();return this},renderAll:function(q){var p=this._oConfig.width,t=this._oConfig.height;var x=q?this._oContextTop:this._oContextContainer;this.clearContext(this._oContextTop);if(x!==this._oContextTop){this.clearContext(x)}if(q){if(!n&&this.backgroundColor==="transparent"){var v=true}if(!v){x.fillStyle=this.backgroundColor}x.fillRect(0,0,p,t)}var u=this._aObjects.length,s=this.getActiveGroup();if(u){for(var r=0;r1){var D=new fabric.PathGroup(F,C)}else{var D=F[0]}D.setSourcePath(B);if(!(D instanceof fabric.PathGroup)){fabric.util.object.extend(D,C);if(typeof C.angle!=="undefined"){D.setAngle(C.angle)}}u(D,A)})}}}},this)}catch(r){console.log(r.message)}},loadImageFromURL:(function(){var p={};return function(q,u){var t=this;function r(){var v=k.getElementById(p[q]);if(v.width&&v.height){u(new fabric.Image(v))}else{setTimeout(r,50)}}if(p[q]){r()}else{var s=new Image();s.onload=function(){s.onload=null;t._resizeImageToFit(s);var v=new fabric.Image(s);u(v)};s.className="canvas-img-clone";s.src=q;if(this.shouldCacheImages){p[q]=Element.identify(s)}k.body.appendChild(s)}}})(),loadSVGFromURL:function(p,t){var s=this;p=p.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(p,function(u){if(u){s.cache.get(p,function(w){var v=s._enlivenCachedObject(w);t(v.objects,v.options)})}else{new Ajax.Request(p,{method:"get",onComplete:r,onFailure:q})}});function r(v){var u=v.responseXML;if(!u){return}var w=u.documentElement;if(!w){return}fabric.parseSVGDocument(w,function(y,x){s.cache.set(p,{objects:y.invoke("toObject"),options:x});t(y,x)})}function q(){console.log("ERROR!")}},_enlivenCachedObject:function(r){var q=r.objects;var p=r.options;q=q.map(function(s){return d[s.type.capitalize()].fromObject(s)});return({objects:q,options:p})},remove:function(p){fabric.util.removeFromArray(this._aObjects,p);this.renderAll();return p},fxRemove:function(p,r){var q=this;p.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){q.remove(p);if(typeof r==="function"){r()}}});return this},sendToBack:function(p){fabric.util.removeFromArray(this._aObjects,p);this._aObjects.unshift(p);return this.renderAll()},bringToFront:function(p){fabric.util.removeFromArray(this._aObjects,p);this._aObjects.push(p);return this.renderAll()},sendBackwards:function(r){var q=this._aObjects.indexOf(r),p=q;if(q!==0){for(var s=q-1;s>=0;--s){if(r.intersectsWithObject(this._aObjects[s])){p=s;break}}fabric.util.removeFromArray(this._aObjects,r);this._aObjects.splice(p,0,r)}return this.renderAll()},bringForward:function(s){var u=this.getObjects(),q=u.indexOf(s),p=q;if(q!==u.length-1){for(var t=q+1,r=this._aObjects.length;t"};fabric.util.object.extend(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(s){var r=s.getContext("2d"),w=r.getImageData(0,0,s.width,s.height),u=w.data,p=w.width,v=w.height,q,t;for(i=0;i1)?e.apply(this,a.call(arguments,1)):e.call(this)},initialize:function(d){this.setOptions(d);this._importProperties();this.originalState={};this.setCoords();this.saveState()},setOptions:function(d){this.options=c.util.object.extend(this._getOptions(),d)},_getOptions:function(){return c.util.object.extend(c.util.object.clone(this._getSuperOptions()),this.options)},_getSuperOptions:function(){var f=this.constructor;if(f){var d=f.superclass;if(d){var e=d.prototype;if(e&&typeof e._getOptions=="function"){return e._getOptions()}}}return{}},_importProperties:function(){this.stateProperties.forEach(function(d){(d==="angle")?this.setAngle(this.options[d]):(this[d]=this.options[d])},this)},transform:function(d){d.globalAlpha=this.opacity;d.translate(this.left,this.top);d.rotate(this.theta);d.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toJSON:function(){return JSON.stringify(this.toObject())},toObject:function(){var d=c.util.toFixed;var e={type:this.type,left:d(this.left,this.NUM_FRACTION_DIGITS),top:d(this.top,this.NUM_FRACTION_DIGITS),width:d(this.width,this.NUM_FRACTION_DIGITS),height:d(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,scaleX:d(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:d(this.scaleY,this.NUM_FRACTION_DIGITS),angle:d(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:d(this.opacity,this.NUM_FRACTION_DIGITS)};if(!this.includeDefaultValues){e=this._removeDefaultValues(e)}return e},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(e){var d=c.Object.prototype.options;this.stateProperties.forEach(function(f){if(e[f]===d[f]){delete e[f]}});return e},isActive:function(){return !!this.active},setActive:function(d){this.active=!!d;return this},toString:function(){return"#"},set:function(e,d){var f=(e==="scaleX"||e==="scaleY")&&df.x&&g.xf.y&&k.y=l)&&(g.d.y>=l)){continue}if((g.o.x==g.d.x)&&(g.o.x>=m)){n=g.o.x;k=l}else{p=0;o=(g.d.y-g.o.y)/(g.d.x-g.o.x);f=l-p*m;e=g.o.y-o*g.o.x;n=-(f-e)/(p-o);k=f+p*n}if(n>=m){h+=1}if(h==2){break}}return h},_getImageLines:function(e,d){return{topline:{o:e.tl,d:e.tr},rightline:{o:e.tr,d:e.br},bottomline:{o:e.br,d:e.bl},leftline:{o:e.bl,d:e.tl}}},_setCornerCoords:function(){var m=this.oCoords,h=this.theta,g=this.cornersize*Math.cos(h),f=this.cornersize*Math.sin(h),k=this.cornersize/2,e=k-f,d=k,l;m.tl.x-=e;m.tl.y-=d;m.tl.corner={tl:{x:m.tl.x,y:m.tl.y},tr:{x:m.tl.x+g,y:m.tl.y+f},bl:{x:m.tl.x-f,y:m.tl.y+g}};m.tl.corner.br={x:m.tl.corner.tr.x-f,y:m.tl.corner.tr.y+g};m.tl.x+=e;m.tl.y+=d;m.tr.x+=k;m.tr.y-=k;m.tr.corner={tl:{x:m.tr.x-g,y:m.tr.y-f},tr:{x:m.tr.x,y:m.tr.y},br:{x:m.tr.x-f,y:m.tr.y+g}};m.tr.corner.bl={x:m.tr.corner.tl.x-f,y:m.tr.corner.tl.y+g};m.tr.x-=k;m.tr.y+=k;m.bl.x-=k;m.bl.y+=k;m.bl.corner={tl:{x:m.bl.x+f,y:m.bl.y-g},bl:{x:m.bl.x,y:m.bl.y},br:{x:m.bl.x+g,y:m.bl.y+f}};m.bl.corner.tr={x:m.bl.corner.br.x+f,y:m.bl.corner.br.y-g};m.bl.x+=k;m.bl.y-=k;m.br.x+=k;m.br.y+=k;m.br.corner={tr:{x:m.br.x+f,y:m.br.y-g},bl:{x:m.br.x-g,y:m.br.y-f},br:{x:m.br.x,y:m.br.y}};m.br.corner.tl={x:m.br.corner.bl.x+f,y:m.br.corner.bl.y-g};m.br.x-=k;m.br.y-=k;m.ml.x-=k;m.ml.y-=k;m.ml.corner={tl:{x:m.ml.x,y:m.ml.y},tr:{x:m.ml.x+g,y:m.ml.y+f},bl:{x:m.ml.x-f,y:m.ml.y+g}};m.ml.corner.br={x:m.ml.corner.tr.x-f,y:m.ml.corner.tr.y+g};m.ml.x+=k;m.ml.y+=k;m.mt.x-=k;m.mt.y-=k;m.mt.corner={tl:{x:m.mt.x,y:m.mt.y},tr:{x:m.mt.x+g,y:m.mt.y+f},bl:{x:m.mt.x-f,y:m.mt.y+g}};m.mt.corner.br={x:m.mt.corner.tr.x-f,y:m.mt.corner.tr.y+g};m.mt.x+=k;m.mt.y+=k;m.mr.x-=k;m.mr.y-=k;m.mr.corner={tl:{x:m.mr.x,y:m.mr.y},tr:{x:m.mr.x+g,y:m.mr.y+f},bl:{x:m.mr.x-f,y:m.mr.y+g}};m.mr.corner.br={x:m.mr.corner.tr.x-f,y:m.mr.corner.tr.y+g};m.mr.x+=k;m.mr.y+=k;m.mb.x-=k;m.mb.y-=k;m.mb.corner={tl:{x:m.mb.x,y:m.mb.y},tr:{x:m.mb.x+g,y:m.mb.y+f},bl:{x:m.mb.x-f,y:m.mb.y+g}};m.mb.corner.br={x:m.mb.corner.tr.x-f,y:m.mb.corner.tr.y+g};m.mb.x+=k;m.mb.y+=k;l=m.mb.corner;l.tl.x-=k;l.tl.y-=k;l.tr.x-=k;l.tr.y-=k;l.br.x-=k;l.br.y-=k;l.bl.x-=k;l.bl.y-=k},toGrayscale:function(){var d=this.get("fill");if(d){this.set("overlayFill",new c.Color(d).toGrayscale().toRgb())}return this},complexity:function(){return 0},getCenter:function(){return{x:this.get("left")+this.width/2,y:this.get("top")+this.height/2}},straighten:function(){var d=this._getAngleValueForStraighten();this.setAngle(d);return this},fxStraighten:function(e){e=e||{};var f=function(){},g=e.onComplete||f,d=e.onChange||f,h=this;c.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(k){h.setAngle(k);d()},onComplete:function(){h.setCoords();g()},onStart:function(){h.setActive(false)}});return this},fxRemove:function(e){e||(e={});var f=function(){},g=e.onComplete||f,d=e.onChange||f,h=this;c.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(k){h.set("opacity",k);d()},onComplete:g,onStart:function(){h.setActive(false)}});return this},_getAngleValueForStraighten:function(){var d=this.get("angle");if(d>-225&&d<=-135){return -180}else{if(d>-135&&d<=-45){return -90}else{if(d>-45&&d<=45){return 0}else{if(d>45&&d<=135){return 90}else{if(d>135&&d<=225){return 180}else{if(d>225&&d<=315){return 270}else{if(d>315){return 360}}}}}}}return 0}});c.Object.prototype.rotate=c.Object.prototype.setAngle})();(function(){var a=this.fabric||(this.fabric={});if(a.Line){return}a.Line=a.util.createClass(a.Object,{type:"line",initialize:function(c,b){if(!c){c=[0,0,0,0]}this.callSuper("initialize",b);this.set("x1",c[0]);this.set("y1",c[1]);this.set("x2",c[2]);this.set("y2",c[3]);this.set("width",this.x2-this.x1);this.set("height",this.y2-this.y1);this.set("left",this.x1+this.width/2);this.set("top",this.y1+this.height/2)},_render:function(b){b.beginPath();b.moveTo(-this.width/2,-this.height/2);b.lineTo(this.width/2,this.height/2);b.stroke()},complexity:function(){return 1},toObject:function(){return a.util.object.extend(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});a.Element.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");a.Line.fromElement=function(c,b){var e=a.parseAttributes(c,a.Element.ATTRIBUTE_NAMES);var d=[e.x1||0,e.y1||0,e.x2||0,e.y2||0];return new a.Line(d,a.util.object.extend(e,b))};a.Line.fromObject=function(b){var c=[b.x1,b.y1,b.x2,b.y2];return new a.Line(c,b)}})();(function(){var a=this,b=a.fabric||(a.fabric={}),d=Math.PI*2;if(b.Circle){console.warn("fabric.Circle is already defined.");return}b.Circle=b.util.createClass(b.Object,{type:"circle",initialize:function(e){e=e||{};this.set("radius",e.radius||0);this.callSuper("initialize",e);var f=this.get("radius")*2*this.get("scaleX");this.set("width",f).set("height",f)},toObject:function(){return b.util.object.extend(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(e){e.beginPath();e.arc(0,0,this.radius,0,d,false);if(this.fill){e.fill()}if(this.stroke){e.stroke()}},complexity:function(){return 1}});b.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");b.Circle.fromElement=function(f,e){var g=b.parseAttributes(f,b.Circle.ATTRIBUTE_NAMES);if(!c(g)){throw Error("value of `r` attribute is required and can not be negative")}return new b.Circle(b.util.object.extend(g,e))};function c(e){return(("radius" in e)&&(e.radius>0))}b.Circle.fromObject=function(e){return new b.Circle(e)}})();(function(){var a=this.fabric||(this.fabric={});if(a.Ellipse){console.warn("fabric.Ellipse is already defined.");return}a.Ellipse=a.util.createClass(a.Object,{type:"ellipse",initialize:function(b){b=b||{};this.callSuper("initialize",b);this.set("rx",b.rx||0);this.set("ry",b.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return a.util.object.extend(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(b,c){if(this.rx===0||this.ry===0){return}return this.callSuper("render",b,c)},_render:function(b){b.beginPath();b.save();b.transform(1,0,0,this.ry/this.rx,0,0);b.arc(0,0,this.rx,0,Math.PI*2,false);b.restore();if(this.stroke){b.stroke()}if(this.fill){b.fill()}},complexity:function(){return 1}});a.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");a.Ellipse.fromElement=function(c,b){var d=a.parseAttributes(c,a.Ellipse.ATTRIBUTE_NAMES);return new a.Ellipse(a.util.object.extend(d,b))};a.Ellipse.fromObject=function(b){return new a.Ellipse(b)}})();(function(){var b=this.fabric||(this.fabric={});if(b.Rect){return}b.Rect=b.util.createClass(b.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(c){this.callSuper("initialize",c);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(e){var k=this.options.rx||0,g=this.options.ry||0,c=-this.width/2,l=-this.height/2,d=this.width,f=this.height;e.beginPath();e.moveTo(c+k,l);e.lineTo(c+d-k,l);e.bezierCurveTo(c+d,l,c+d,l+g,c+d,l+g);e.lineTo(c+d,l+f-g);e.bezierCurveTo(c+d,l+f,c+d-k,l+f,c+d-k,l+f);e.lineTo(c+k,l+f);e.bezierCurveTo(c,l+f,c,l+f-g,c,l+f-g);e.lineTo(c,l+g);e.bezierCurveTo(c,l,c+k,l,c+k,l);e.closePath();if(this.fill){e.fill()}if(this.stroke){e.stroke()}},_normalizeLeftTopProperties:function(c){if(c.left){this.set("left",c.left+this.getWidth()/2)}if(c.top){this.set("top",c.top+this.getHeight()/2)}return this},complexity:function(){return 1}});b.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");function a(c){c.left=c.left||0;c.top=c.top||0;return c}b.Rect.fromElement=function(d,c){if(!d){return null}var f=b.parseAttributes(d,b.Rect.ATTRIBUTE_NAMES);f=a(f);var e=new b.Rect(b.util.object.extend(c||{},f));e._normalizeLeftTopProperties(f);return e};b.Rect.fromObject=function(c){return new b.Rect(c)}})();(function(){var b=this.fabric||(this.fabric={});if(b.Polyline){console.warn("fabric.Polyline is already defined");return}b.Polyline=b.util.createClass(b.Object,{type:"polyline",initialize:function(d,c){c=c||{};this.set("points",d);this.callSuper("initialize",c);this._calcDimensions()},_calcDimensions:function(){return b.Polygon.prototype._calcDimensions.call(this)},_toOrigin:function(){return b.Polygon.prototype._toOrigin.call(this)},toObject:function(){return b.Polygon.prototype.toObject.call(this)},_render:function(e){var d;e.beginPath();for(var f=0,c=this.points.length;f"},toObject:function(){var c=b.util.object.extend(this.callSuper("toObject"),{path:this.path});if(this.sourcePath){c.sourcePath=this.sourcePath}if(this.transformMatrix){c.transformMatrix=this.transformMatrix}return c},toDatalessObject:function(){var c=this.toObject();if(this.sourcePath){c.path=this.sourcePath}delete c.sourcePath;return c},complexity:function(){return this.path.length},set:function(d,c){if(this.stub){this.stub.set(d,c)}return this.callSuper("set",d,c)},_parsePath:function(){var d=[],f,g;for(var e=0,c=this.path.length;e"},isSameColor:function(){var c=this.getObjects()[0].get("fill");return this.getObjects().every(function(d){return d.get("fill")===c})},complexity:function(){return this.paths.reduce(function(c,d){return c+((d&&d.complexity)?d.complexity():0)},0)},toGrayscale:function(){var c=this.paths.length;while(c--){this.paths[c].toGrayscale()}return this},getObjects:function(){return this.paths}});function a(f){for(var e=0,c=f.length;e"},getObjects:function(){return this.objects},add:function(b){this._restoreObjectsState();this.objects.push(b);b.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(b){this._restoreObjectsState();a.util.removeFromArray(this.objects,b);b.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(b,d){if(typeof d=="function"){this.set(b,d(this[b]))}else{if(b==="fill"||b==="opacity"){var c=this.objects.length;this[b]=d;while(c--){this.objects[c].set(b,d)}}else{this[b]=d}}return this},contains:function(b){return this.objects.indexOf(b)>-1},toObject:function(){return a.util.object.extend(this.callSuper("toObject"),{objects:a.util.array.invoke(this.objects,"clone")})},render:function(c){c.save();this.transform(c);var f=Math.max(this.scaleX,this.scaleY);for(var d=0,b=this.objects.length;dc.x&&d-bc.y},toGrayscale:function(){var b=this.objects.length;while(b--){this.objects[b].toGrayscale()}}});a.Group.fromObject=function(b){return new a.Group(b.objects,b)}})();(function(){var a=this.fabric||(this.fabric={});if(a.Text){console.warn("fabric.Text is already defined");return}if(!a.Object){console.warn("fabric.Text requires fabric.Object");return}a.Text=a.util.createClass(a.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(c,b){this.originalState={};this.initStateProperties();this.text=c;this.setOptions(b);a.util.object.extend(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()},initStateProperties:function(){var b;if((b=this.constructor)&&(b=b.superclass)&&(b=b.prototype)&&(b=b.stateProperties)&&b.clone){this.stateProperties=b.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#"},_render:function(b){var d=Cufon.textOptions||(Cufon.textOptions={});d.left=this.left;d.top=this.top;d.context=b;d.color=this.fill;var c=this._initDummyElement();this.transform(b);Cufon.replaceElement(c,{separate:"none",fontFamily:this.fontfamily});this.width=d.width;this.height=d.height},_initDummyElement:function(){var b=document.createElement("div");b.innerHTML=this.text;b.style.fontSize="40px";b.style.fontWeight="400";b.style.fontStyle="normal";b.style.letterSpacing="normal";b.style.color="#000000";b.style.fontWeight="600";b.style.fontFamily="Verdana";return b},render:function(b){b.save();this._render(b);if(this.active){this.drawBorders(b);this.drawCorners(b)}b.restore()},toObject:function(){return a.util.object.extend(this.callSuper("toObject"),{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,path:this.path})},setColor:function(b){this.set("fill",b);return this},setFontsize:function(b){this.set("fontsize",b);this.setCoords();return this},getText:function(){return this.text},setText:function(b){this.set("text",b);this.setCoords();return this},set:function(b,c){this[b]=c;if(b==="fontfamily"){this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+c+"$3")}return this}});a.Text.fromObject=function(b){return new a.Text(b.text,a.util.object.clone(b))};a.Text.fromElement=function(b){}})();(function(){var a=this;if(!a.fabric){a.fabric={}}if(a.fabric.Image){console.warn("fabric.Image is already defined.");return}if(!fabric.Object){console.warn("fabric.Object is required for fabric.Image initialization");return}fabric.Image=fabric.util.createClass(fabric.Object,{maxwidth:null,maxheight:null,active:false,bordervisibility:false,cornervisibility:false,type:"image",__isGrayscaled:false,initialize:function(c,b){this.callSuper("initialize",b);this._initElement(c);this._initConfig(b||{})},getElement:function(){return this._element},setElement:function(b){this._element=b;return this},getNormalizedSize:function(c,b,d){if(d&&b&&(c.width>c.height&&(c.width/c.height)<(b/d))){normalizedWidth=Math.floor((c.width*d)/c.height);normalizedHeight=d}else{if(d&&((c.height==c.width)||(c.height>c.width)||(c.height>d))){normalizedWidth=Math.floor((c.width*d)/c.height);normalizedHeight=d}else{if(b&&(b'},clone:function(b){this.constructor.fromObject(this.toObject(),b)},toGrayscale:function(f){if(this.__isGrayscaled){return}var d=this.getElement(),b=document.createElement("canvas"),c=document.createElement("img"),e=this;b.width=d.width;b.height=d.height;b.getContext("2d").drawImage(d,0,0);fabric.Element.toGrayscale(b);c.onload=function(){e.setElement(c);f&&f();c.onload=b=d=imageData=null};c.width=d.width;c.height=d.height;c.src=b.toDataURL("image/png");this.__isGrayscaled=true;return this},_render:function(c){var b=this.getOriginalSize();c.drawImage(this.getElement(),-b.width/2,-b.height/2,b.width,b.height)},_adjustWidthHeightToBorders:function(b){if(b){this.currentBorder=this.borderwidth;this.width+=(2*this.currentBorder);this.height+=(2*this.currentBorder)}else{this.currentBorder=0}},_resetWidthHeight:function(){var b=this.getElement();this.set("width",b.width);this.set("height",b.height)},_initElement:function(b){this.setElement(fabric.util.getById(b));fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(b){this.setOptions(b);this._setBorder();this._setWidthHeight(b)},_setBorder:function(){if(this.bordervisibility){this.currentBorder=this.borderwidth}else{this.currentBorder=0}},_setWidthHeight:function(b){var c=2*this.currentBorder;this.width=(this.getElement().width||0)+c;this.height=(this.getElement().height||0)+c}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(c,e){var b=document.createElement("img"),d=c.src;if(c.width){b.width=c.width}if(c.height){b.height=c.height}b.onload=function(){if(e){e(new fabric.Image(b,c))}b=b.onload=null};b.src=d};fabric.Image.fromURL=function(c,e,d){var b=document.createElement("img");b.onload=function(){if(e){e(new fabric.Image(b,d))}b=b.onload=null};b.src=c}})(); \ No newline at end of file +if(typeof console=="undefined"){var console={log:function(){},warn:function(){}}}if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i>>0;w=Number(w)||0;w=Math[w<0?"ceil":"floor"](w);if(w<0){w+=u}for(;w>>0;v>>0;w>>0;v>>0;v>>0;w>>0,v=0,x;if(arguments.length>1){x=arguments[1]}else{do{if(v in this){x=this[v++];break}if(++v>=u){throw new TypeError()}}while(true)}for(;v=u){u=x[v][w]}}}else{while(v--){if(x[v]>=u){u=x[v]}}}return u}function l(x,w){var v=x.length-1,u=w?x[v][w]:x[v];if(w){while(v--){if(x[v][w]-1?w(D,F.match(/opacity:\s*(\d?\.?\d*)/)[1]):D}for(var G in F){if(G==="opacity"){w(D,F[G])}else{var E=(G==="float"||G==="cssFloat")?(typeof H.styleFloat==="undefined"?"cssFloat":"styleFloat"):G;H[E]=F[G]}}return D}var B=document.createElement("div"),A=typeof B.style.opacity==="string",v=typeof B.style.filter==="string",u=document.defaultView,z=u&&typeof u.getComputedStyle!=="undefined",x=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,w=function(C){return C};if(A){w=function(C,D){C.style.opacity=D;return C}}else{if(v){w=function(C,D){var E=C.style;if(C.currentStyle&&!C.currentStyle.hasLayout){E.zoom=1}if(x.test(E.filter)){D=D>=0.9999?"":("alpha(opacity="+(D*100)+")");E.filter=E.filter.replace(x,D)}else{E.filter+=" alpha(opacity="+(D*100)+")"}return C}}}g.util.setStyle=y})();function p(u){return typeof u==="string"?document.getElementById(u):u}function n(v){var u=[],w=v.length;while(w--){u[w]=v[w]}return u}function b(v,u){var w=document.createElement(v);for(var x in u){if(x==="class"){w.className=u[x]}else{if(x==="for"){w.htmlFor=u[x]}else{w.setAttribute(x,u[x])}}}return w}function f(u,v){if((" "+u.className+" ").indexOf(" "+v+" ")===-1){u.className+=(u.className?" ":"")+v}}function a(v,w,u){if(typeof w==="string"){w=b(w,u)}if(v.parentNode){v.parentNode.replaceChild(w,v)}w.appendChild(v);return w}function k(v){var u=0,w=0;do{u+=v.offsetTop||0;w+=v.offsetLeft||0;v=v.offsetParent}while(v);return({left:w,top:u})}function e(){return false}(function(){var u=document.documentElement.style;var v="userSelect" in u?"userSelect":"MozUserSelect" in u?"MozUserSelect":"WebkitUserSelect" in u?"WebkitUserSelect":"KhtmlUserSelect" in u?"KhtmlUserSelect":"";function w(x){if(typeof x.onselectstart!=="undefined"){x.onselectstart=e}if(v){x.style[v]="none"}else{if(typeof x.unselectable=="string"){x.unselectable="on"}}return x}g.util.makeElementUnselectable=w})();(function(){function u(x,B){var z=document.getElementsByTagName("head")[0],y=document.createElement("script"),A=true;y.type="text/javascript";y.setAttribute("runat","server");y.onload=y.onreadystatechange=function(C){if(A){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete"){return}A=false;B(C||window.event);y=y.onload=y.onreadystatechange=null}};y.src=x;z.appendChild(y)}function w(x,y){v.load(x);y()}g.util.getScript=u;var v=this.Jaxer;if(v&&v.load){g.util.getScript=w}})();function c(F){F||(F={});var v=+new Date(),z=F.duration||500,E=v+z,y,D,A=F.onChange||function(){},B=F.easing||function(G){return(-Math.cos(G*Math.PI)/2)+0.5},u="startValue" in F?F.startValue:0,C="endValue" in F?F.endValue:100,x=u>C;F.onStart&&F.onStart();var w=setInterval(function(){y=+new Date();D=y>E?1:(y-v)/z;A(x?(u-(u-C)*B(D)):(u+(C-u)*B(D)));if(y>E){clearInterval(w);F.onComplete&&F.onComplete()}},10)}g.util.getById=p;g.util.toArray=n;g.util.makeElement=b;g.util.addClass=f;g.util.wrapElement=a;g.util.getElementOffset=k;g.util.animate=c;(function(){function x(y,z){return y+(/\?/.test(y)?"&":"?")+z}var w=(function(){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()}];for(var y=B.length;y--;){try{var A=B[y]();if(A){return B[y]}}catch(z){}}})();function u(){}function v(A,z){z||(z={});var D=z.method?z.method.toUpperCase():"GET",C=z.onComplete||function(){},B=w(),y;B.onreadystatechange=function(){if(B.readyState===4){C(B);B.onreadystatechange=u}};if(D==="GET"){y=null;if(typeof z.parameters=="string"){A=x(A,z.parameters)}}B.open(D,A,true);if(D==="POST"||D==="PUT"){B.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}B.send(y);return B}g.util.request=v})();(function(){function y(B,A){var z=B.indexOf(A);if(z!==-1){B.splice(z,1)}return B}function x(A,z){return Math.floor(Math.random()*(z-A+1))+A}var v=Math.PI/180;function w(z){return z*v}function u(A,z){return parseFloat(Number(A).toFixed(z))}g.util.removeFromArray=y;g.util.degreesToRadians=w;g.util.toFixed=u;g.util.getRandomInt=x})()})(this);(function(){var f=this.fabric||(this.fabric={});var c={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};function b(l,k){if(!l){return}var n,h,g={};if(l.parentNode&&/^g$/i.test(l.parentNode.nodeName)){g=f.parseAttributes(l.parentNode,k)}var m=k.reduce(function(p,o){n=l.getAttribute(o);h=parseFloat(n);if(n){if((o==="fill"||o==="stroke")&&n==="none"){n=""}if(o==="fill-rule"){n=(n==="evenodd")?"destination-over":n}if(o==="transform"){n=f.parseTransformAttribute(n)}if(o in c){o=c[o]}p[o]=isNaN(h)?n:h}return p},{});m=f.util.object.extend(f.parseStyleAttribute(l),m);return f.util.object.extend(g,m)}f.parseTransformAttribute=(function(){function g(B,C){var D=C[0];B[0]=Math.cos(D);B[1]=Math.sin(D);B[2]=-Math.sin(D);B[3]=Math.cos(D)}function n(D,E){var C=E[0],B=(E.length===2)?E[1]:E[0];D[0]=C;D[3]=B}function y(B,C){B[2]=C[0]}function k(B,C){B[1]=C[0]}function v(B,C){B[4]=C[0];if(C.length===2){B[5]=C[1]}}var p=[1,0,0,1,0,0],h="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",z="(?:\\s+,?\\s*|,\\s*)",q="(?:(skewX)\\s*\\(\\s*("+h+")\\s*\\))",o="(?:(skewY)\\s*\\(\\s*("+h+")\\s*\\))",x="(?:(rotate)\\s*\\(\\s*("+h+")(?:"+z+"("+h+")"+z+"("+h+"))?\\s*\\))",A="(?:(scale)\\s*\\(\\s*("+h+")(?:"+z+"("+h+"))?\\s*\\))",t="(?:(translate)\\s*\\(\\s*("+h+")(?:"+z+"("+h+"))?\\s*\\))",w="(?:(matrix)\\s*\\(\\s*("+h+")"+z+"("+h+")"+z+"("+h+")"+z+"("+h+")"+z+"("+h+")"+z+"("+h+")\\s*\\))",u="(?:"+w+"|"+t+"|"+A+"|"+x+"|"+q+"|"+o+")",r="(?:"+u+"(?:"+z+u+")*)",l="^\\s*(?:"+r+"?)\\s*$",s=new RegExp(l),m=new RegExp(u);return function(C){var B=p.concat();if(!C||(C&&!s.test(C))){return B}C.replace(m,function(G){var D=new RegExp(u).exec(G).filter(function(H){return(H!==""&&H!=null)}),E=D[1],F=D.slice(2).map(parseFloat);switch(E){case"translate":v(B,F);break;case"rotate":g(B,F);break;case"scale":n(B,F);break;case"skewX":y(B,F);break;case"skewY":k(B,F);break;case"matrix":B=F;break}});return B}})();function a(h){if(!h){return null}h=h.trim().split(/\s+/);var g=h.reduce(function(k,l){l=l.split(",");k.push({x:parseFloat(l[0]),y:parseFloat(l[1])});return k},[]);if(g.length%2!==0){return null}return g}function e(h){var g={},k=h.getAttribute("style");if(k){if(typeof k=="string"){k=k.split(";");k.pop();g=k.reduce(function(n,q){var m=q.split(":"),o=m[0].trim(),p=m[1].trim();n[o]=p;return n},{})}else{for(var l in k){if(typeof k[l]!=="undefined"){g[l]=k[l]}}}}return g}function d(h,g){var k=h.map(function(m){var l=f[f.util.string.capitalize(m.tagName)];if(l&&l.fromElement){try{return l.fromElement(m,g)}catch(n){console.log(n.message||n)}}});k=k.filter(function(l){return l!=null});return k}f.parseSVGDocument=(function(){var g=/^(path|circle|polygon|polyline|ellipse|rect|line)$/;var k="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)";var l=new RegExp("^\\s*("+k+"+)\\s*,?\\s*("+k+"+)\\s*,?\\s*("+k+"+)\\s*,?\\s*("+k+"+)\\s*$");function h(m,n){while(m&&(m=m.parentNode)){if(m.nodeName===n){return true}}return false}return function(u,w){if(!u){return}var t=f.util.toArray(u.getElementsByTagName("*"));var m=t.filter(function(y){return g.test(y.tagName)&&!h(y,"pattern")});if(!m||(m&&!m.length)){return}var n=u.getAttribute("viewBox"),r=u.getAttribute("width"),p=u.getAttribute("height"),o=null,v=null,s,q;if(n&&(n=n.match(l))){s=parseInt(n[1],10);q=parseInt(n[2],10);o=parseInt(n[3],10);v=parseInt(n[4],10)}o=r?parseFloat(r):o;v=p?parseFloat(p):v;var x={width:o,height:v};var m=f.parseElements(m,f.util.object.clone(x));if(!m||(m&&!m.length)){return}if(w){w(m,x)}}})();f.util.object.extend(f,{parseAttributes:b,parseElements:d,parseStyleAttribute:e,parsePointsAttribute:a})})();(function(){var b=this.fabric||(this.fabric={});if(b.Point){console.warn("fabric.Point is already defined");return}function a(c,d){if(arguments.length>0){this.init(c,d)}}a.prototype={constructor:a,init:function(c,d){this.x=c;this.y=d},add:function(c){return new a(this.x+c.x,this.y+c.y)},addEquals:function(c){this.x+=c.x;this.y+=c.y;return this},scalarAdd:function(c){return new a(this.x+c,this.y+c)},scalarAddEquals:function(c){this.x+=c;this.y+=c;return this},subtract:function(c){return new a(this.x-c.x,this.y-c.y)},subtractEquals:function(c){this.x-=c.x;this.y-=c.y;return this},scalarSubtract:function(c){return new a(this.x-c,this.y-c)},scalarSubtractEquals:function(c){this.x-=c;this.y-=c;return this},multiply:function(c){return new a(this.x*c,this.y*c)},multiplyEquals:function(c){this.x*=c;this.y*=c;return this},divide:function(c){return new a(this.x/c,this.y/c)},divideEquals:function(c){this.x/=c;this.y/=c;return this},eq:function(c){return(this.x==c.x&&this.y==c.y)},lt:function(c){return(this.xc.x&&this.y>c.y)},gte:function(c){return(this.x>=c.x&&this.y>=c.y)},lerp:function(d,c){return new a(this.x+(d.x-this.x)*c,this.y+(d.y-this.y)*c)},distanceFrom:function(e){var d=this.x-e.x,c=this.y-e.y;return Math.sqrt(d*d+c*c)},min:function(c){return new a(Math.min(this.x,c.x),Math.min(this.y,c.y))},max:function(c){return new a(Math.max(this.x,c.x),Math.max(this.y,c.y))},toString:function(){return this.x+","+this.y},setXY:function(c,d){this.x=c;this.y=d},setFromPoint:function(c){this.x=c.x;this.y=c.y},swap:function(d){var c=this.x,e=this.y;this.x=d.x;this.y=d.y;d.x=c;d.y=e}};b.Point=a})();(function(){var a=this,b=a.fabric||(a.fabric={});if(b.Intersection){console.warn("fabric.Intersection is already defined");return}function c(d){if(arguments.length>0){this.init(d)}}c.prototype.init=function(d){this.status=d;this.points=[]};c.prototype.appendPoint=function(d){this.points.push(d)};c.prototype.appendPoints=function(d){this.points=this.points.concat(d)};c.intersectLineLine=function(h,f,n,m){var o,k=(m.x-n.x)*(h.y-n.y)-(m.y-n.y)*(h.x-n.x),l=(f.x-h.x)*(h.y-n.y)-(f.y-h.y)*(h.x-n.x),g=(m.y-n.y)*(f.x-h.x)-(m.x-n.x)*(f.y-h.y);if(g!=0){var e=k/g,d=l/g;if(0<=e&&e<=1&&0<=d&&d<=1){o=new c("Intersection");o.points.push(new b.Point(h.x+e*(f.x-h.x),h.y+e*(f.y-h.y)))}else{o=new c("No Intersection")}}else{if(k==0||l==0){o=new c("Coincident")}else{o=new c("Parallel")}}return o};c.intersectLinePolygon=function(e,d,m){var n=new c("No Intersection"),f=m.length;for(var h=0;h0){n.status="Intersection"}return n};c.intersectPolygonPolygon=function(k,h){var f=new c("No Intersection"),m=k.length;for(var l=0;l0){f.status="Intersection"}return f};c.intersectPolygonRectangle=function(p,e,d){var g=e.min(d),o=e.max(d),f=new b.Point(o.x,g.y),n=new b.Point(g.x,o.y),m=c.intersectLinePolygon(g,f,p),l=c.intersectLinePolygon(f,o,p),k=c.intersectLinePolygon(o,n,p),h=c.intersectLinePolygon(n,g,p),q=new c("No Intersection");q.appendPoints(m.points);q.appendPoints(l.points);q.appendPoints(k.points);q.appendPoints(h.points);if(q.points.length>0){q.status="Intersection"}return q};b.Intersection=c})();(function(){var a=this.fabric||(this.fabric={});if(a.Color){console.warn("fabric.Color is already defined.");return}a.Color=b;function b(c){if(!c){this.setSource([0,0,0,1])}else{this._tryParsingColor(c)}}b.prototype._tryParsingColor=function(c){var d=b.sourceFromHex(c);if(!d){d=b.sourceFromRgb(c)}if(d){this.setSource(d)}};b.prototype.getSource=function(){return this._source};b.prototype.setSource=function(c){this._source=c};b.prototype.toRgb=function(){var c=this.getSource();return"rgb("+c[0]+","+c[1]+","+c[2]+")"};b.prototype.toRgba=function(){var c=this.getSource();return"rgba("+c[0]+","+c[1]+","+c[2]+","+c[3]+")"};b.prototype.toHex=function(){var f=this.getSource();var e=f[0].toString(16);e=(e.length==1)?("0"+e):e;var d=f[1].toString(16);d=(d.length==1)?("0"+d):d;var c=f[2].toString(16);c=(c.length==1)?("0"+c):c;return e.toUpperCase()+d.toUpperCase()+c.toUpperCase()};b.prototype.getAlpha=function(){return this.getSource()[3]};b.prototype.setAlpha=function(d){var c=this.getSource();c[3]=d;this.setSource(c);return this};b.prototype.toGrayscale=function(){var e=this.getSource(),d=parseInt((e[0]*0.3+e[1]*0.59+e[2]*0.11).toFixed(0),10),c=e[3];this.setSource([d,d,d,c]);return this};b.prototype.toBlackWhite=function(c){var f=this.getSource(),e=(f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),d=f[3],c=c||127;e=(Number(e)0)?0:-s),this._groupSelector.ey-((r>0)?0:-r),q,p);this._oContextTop.lineWidth=this.selectionLineWidth;this._oContextTop.strokeStyle=this.selectionBorderColor;this._oContextTop.strokeRect(this._groupSelector.ex+a-((s>0)?0:q),this._groupSelector.ey+a-((r>0)?0:p),q,p)},_findSelectedObjects:function(v){var w,r,B=[],q=this._groupSelector.ex,A=this._groupSelector.ey,p=q+this._groupSelector.left,y=A+this._groupSelector.top,x,u=new fabric.Point(Math.min(q,p),Math.min(A,y)),z=new fabric.Point(Math.max(q,p),Math.max(A,y));for(var s=0,t=this._aObjects.length;s1){var 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(q,p){this._aObjects.splice(p,0,q);this.renderAll();return this},getObjects:function(){return this._aObjects},getContext:function(){return this._oContextTop},clearContext:b,clear:function(){this._aObjects.length=0;this.clearContext(this._oContextTop);this.clearContext(this._oContextContainer);this.renderAll();return this},renderAll:function(q){var p=this._oConfig.width,t=this._oConfig.height;var x=q?this._oContextTop:this._oContextContainer;this.clearContext(this._oContextTop);if(x!==this._oContextTop){this.clearContext(x)}if(q){if(!n&&this.backgroundColor==="transparent"){var v=true}if(!v){x.fillStyle=this.backgroundColor}x.fillRect(0,0,p,t)}var u=this._aObjects.length,s=this.getActiveGroup();if(u){for(var r=0;r1){var D=new fabric.PathGroup(F,C)}else{var D=F[0]}D.setSourcePath(B);if(!(D instanceof fabric.PathGroup)){fabric.util.object.extend(D,C);if(typeof C.angle!=="undefined"){D.setAngle(C.angle)}}u(D,A)})}}}},this)}catch(r){console.log(r.message)}},loadImageFromURL:(function(){var p={};return function(q,u){var t=this;function r(){var v=k.getElementById(p[q]);if(v.width&&v.height){u(new fabric.Image(v))}else{setTimeout(r,50)}}if(p[q]){r()}else{var s=new Image();s.onload=function(){s.onload=null;t._resizeImageToFit(s);var v=new fabric.Image(s);u(v)};s.className="canvas-img-clone";s.src=q;if(this.shouldCacheImages){p[q]=Element.identify(s)}k.body.appendChild(s)}}})(),loadSVGFromURL:function(p,t){var s=this;p=p.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(p,function(u){if(u){s.cache.get(p,function(w){var v=s._enlivenCachedObject(w);t(v.objects,v.options)})}else{new Ajax.Request(p,{method:"get",onComplete:r,onFailure:q})}});function r(v){var u=v.responseXML;if(!u){return}var w=u.documentElement;if(!w){return}fabric.parseSVGDocument(w,function(y,x){s.cache.set(p,{objects:y.invoke("toObject"),options:x});t(y,x)})}function q(){console.log("ERROR!")}},_enlivenCachedObject:function(r){var q=r.objects;var p=r.options;q=q.map(function(s){return d[s.type.capitalize()].fromObject(s)});return({objects:q,options:p})},remove:function(p){fabric.util.removeFromArray(this._aObjects,p);this.renderAll();return p},fxRemove:function(p,r){var q=this;p.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){q.remove(p);if(typeof r==="function"){r()}}});return this},sendToBack:function(p){fabric.util.removeFromArray(this._aObjects,p);this._aObjects.unshift(p);return this.renderAll()},bringToFront:function(p){fabric.util.removeFromArray(this._aObjects,p);this._aObjects.push(p);return this.renderAll()},sendBackwards:function(r){var q=this._aObjects.indexOf(r),p=q;if(q!==0){for(var s=q-1;s>=0;--s){if(r.intersectsWithObject(this._aObjects[s])){p=s;break}}fabric.util.removeFromArray(this._aObjects,r);this._aObjects.splice(p,0,r)}return this.renderAll()},bringForward:function(s){var u=this.getObjects(),q=u.indexOf(s),p=q;if(q!==u.length-1){for(var t=q+1,r=this._aObjects.length;t"};fabric.util.object.extend(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(s){var r=s.getContext("2d"),w=r.getImageData(0,0,s.width,s.height),u=w.data,p=w.width,v=w.height,q,t;for(i=0;i1)?e.apply(this,a.call(arguments,1)):e.call(this)},initialize:function(d){this.setOptions(d);this._importProperties();this.originalState={};this.setCoords();this.saveState()},setOptions:function(d){this.options=c.util.object.extend(this._getOptions(),d)},_getOptions:function(){return c.util.object.extend(c.util.object.clone(this._getSuperOptions()),this.options)},_getSuperOptions:function(){var f=this.constructor;if(f){var d=f.superclass;if(d){var e=d.prototype;if(e&&typeof e._getOptions=="function"){return e._getOptions()}}}return{}},_importProperties:function(){this.stateProperties.forEach(function(d){(d==="angle")?this.setAngle(this.options[d]):(this[d]=this.options[d])},this)},transform:function(d){d.globalAlpha=this.opacity;d.translate(this.left,this.top);d.rotate(this.theta);d.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toJSON:function(){return JSON.stringify(this.toObject())},toObject:function(){var d=c.util.toFixed;var e={type:this.type,left:d(this.left,this.NUM_FRACTION_DIGITS),top:d(this.top,this.NUM_FRACTION_DIGITS),width:d(this.width,this.NUM_FRACTION_DIGITS),height:d(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,scaleX:d(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:d(this.scaleY,this.NUM_FRACTION_DIGITS),angle:d(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:d(this.opacity,this.NUM_FRACTION_DIGITS)};if(!this.includeDefaultValues){e=this._removeDefaultValues(e)}return e},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(e){var d=c.Object.prototype.options;this.stateProperties.forEach(function(f){if(e[f]===d[f]){delete e[f]}});return e},isActive:function(){return !!this.active},setActive:function(d){this.active=!!d;return this},toString:function(){return"#"},set:function(e,d){var f=(e==="scaleX"||e==="scaleY")&&df.x&&g.xf.y&&k.y=l)&&(g.d.y>=l)){continue}if((g.o.x==g.d.x)&&(g.o.x>=m)){n=g.o.x;k=l}else{p=0;o=(g.d.y-g.o.y)/(g.d.x-g.o.x);f=l-p*m;e=g.o.y-o*g.o.x;n=-(f-e)/(p-o);k=f+p*n}if(n>=m){h+=1}if(h==2){break}}return h},_getImageLines:function(e,d){return{topline:{o:e.tl,d:e.tr},rightline:{o:e.tr,d:e.br},bottomline:{o:e.br,d:e.bl},leftline:{o:e.bl,d:e.tl}}},_setCornerCoords:function(){var m=this.oCoords,h=this.theta,g=this.cornersize*Math.cos(h),f=this.cornersize*Math.sin(h),k=this.cornersize/2,e=k-f,d=k,l;m.tl.x-=e;m.tl.y-=d;m.tl.corner={tl:{x:m.tl.x,y:m.tl.y},tr:{x:m.tl.x+g,y:m.tl.y+f},bl:{x:m.tl.x-f,y:m.tl.y+g}};m.tl.corner.br={x:m.tl.corner.tr.x-f,y:m.tl.corner.tr.y+g};m.tl.x+=e;m.tl.y+=d;m.tr.x+=k;m.tr.y-=k;m.tr.corner={tl:{x:m.tr.x-g,y:m.tr.y-f},tr:{x:m.tr.x,y:m.tr.y},br:{x:m.tr.x-f,y:m.tr.y+g}};m.tr.corner.bl={x:m.tr.corner.tl.x-f,y:m.tr.corner.tl.y+g};m.tr.x-=k;m.tr.y+=k;m.bl.x-=k;m.bl.y+=k;m.bl.corner={tl:{x:m.bl.x+f,y:m.bl.y-g},bl:{x:m.bl.x,y:m.bl.y},br:{x:m.bl.x+g,y:m.bl.y+f}};m.bl.corner.tr={x:m.bl.corner.br.x+f,y:m.bl.corner.br.y-g};m.bl.x+=k;m.bl.y-=k;m.br.x+=k;m.br.y+=k;m.br.corner={tr:{x:m.br.x+f,y:m.br.y-g},bl:{x:m.br.x-g,y:m.br.y-f},br:{x:m.br.x,y:m.br.y}};m.br.corner.tl={x:m.br.corner.bl.x+f,y:m.br.corner.bl.y-g};m.br.x-=k;m.br.y-=k;m.ml.x-=k;m.ml.y-=k;m.ml.corner={tl:{x:m.ml.x,y:m.ml.y},tr:{x:m.ml.x+g,y:m.ml.y+f},bl:{x:m.ml.x-f,y:m.ml.y+g}};m.ml.corner.br={x:m.ml.corner.tr.x-f,y:m.ml.corner.tr.y+g};m.ml.x+=k;m.ml.y+=k;m.mt.x-=k;m.mt.y-=k;m.mt.corner={tl:{x:m.mt.x,y:m.mt.y},tr:{x:m.mt.x+g,y:m.mt.y+f},bl:{x:m.mt.x-f,y:m.mt.y+g}};m.mt.corner.br={x:m.mt.corner.tr.x-f,y:m.mt.corner.tr.y+g};m.mt.x+=k;m.mt.y+=k;m.mr.x-=k;m.mr.y-=k;m.mr.corner={tl:{x:m.mr.x,y:m.mr.y},tr:{x:m.mr.x+g,y:m.mr.y+f},bl:{x:m.mr.x-f,y:m.mr.y+g}};m.mr.corner.br={x:m.mr.corner.tr.x-f,y:m.mr.corner.tr.y+g};m.mr.x+=k;m.mr.y+=k;m.mb.x-=k;m.mb.y-=k;m.mb.corner={tl:{x:m.mb.x,y:m.mb.y},tr:{x:m.mb.x+g,y:m.mb.y+f},bl:{x:m.mb.x-f,y:m.mb.y+g}};m.mb.corner.br={x:m.mb.corner.tr.x-f,y:m.mb.corner.tr.y+g};m.mb.x+=k;m.mb.y+=k;l=m.mb.corner;l.tl.x-=k;l.tl.y-=k;l.tr.x-=k;l.tr.y-=k;l.br.x-=k;l.br.y-=k;l.bl.x-=k;l.bl.y-=k},toGrayscale:function(){var d=this.get("fill");if(d){this.set("overlayFill",new c.Color(d).toGrayscale().toRgb())}return this},complexity:function(){return 0},getCenter:function(){return{x:this.get("left")+this.width/2,y:this.get("top")+this.height/2}},straighten:function(){var d=this._getAngleValueForStraighten();this.setAngle(d);return this},fxStraighten:function(e){e=e||{};var f=function(){},g=e.onComplete||f,d=e.onChange||f,h=this;c.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(k){h.setAngle(k);d()},onComplete:function(){h.setCoords();g()},onStart:function(){h.setActive(false)}});return this},fxRemove:function(e){e||(e={});var f=function(){},g=e.onComplete||f,d=e.onChange||f,h=this;c.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(k){h.set("opacity",k);d()},onComplete:g,onStart:function(){h.setActive(false)}});return this},_getAngleValueForStraighten:function(){var d=this.get("angle");if(d>-225&&d<=-135){return -180}else{if(d>-135&&d<=-45){return -90}else{if(d>-45&&d<=45){return 0}else{if(d>45&&d<=135){return 90}else{if(d>135&&d<=225){return 180}else{if(d>225&&d<=315){return 270}else{if(d>315){return 360}}}}}}}return 0}});c.Object.prototype.rotate=c.Object.prototype.setAngle})();(function(){var a=this.fabric||(this.fabric={});if(a.Line){return}a.Line=a.util.createClass(a.Object,{type:"line",initialize:function(c,b){if(!c){c=[0,0,0,0]}this.callSuper("initialize",b);this.set("x1",c[0]);this.set("y1",c[1]);this.set("x2",c[2]);this.set("y2",c[3]);this.set("width",this.x2-this.x1);this.set("height",this.y2-this.y1);this.set("left",this.x1+this.width/2);this.set("top",this.y1+this.height/2)},_render:function(b){b.beginPath();b.moveTo(-this.width/2,-this.height/2);b.lineTo(this.width/2,this.height/2);var c=b.strokeStyle;b.strokeStyle=b.fillStyle;b.stroke();b.strokeStyle=c},complexity:function(){return 1},toObject:function(){return a.util.object.extend(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});a.Element.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");a.Line.fromElement=function(c,b){var e=a.parseAttributes(c,a.Element.ATTRIBUTE_NAMES);var d=[e.x1||0,e.y1||0,e.x2||0,e.y2||0];return new a.Line(d,a.util.object.extend(e,b))};a.Line.fromObject=function(b){var c=[b.x1,b.y1,b.x2,b.y2];return new a.Line(c,b)}})();(function(){var a=this,b=a.fabric||(a.fabric={}),d=Math.PI*2;if(b.Circle){console.warn("fabric.Circle is already defined.");return}b.Circle=b.util.createClass(b.Object,{type:"circle",initialize:function(e){e=e||{};this.set("radius",e.radius||0);this.callSuper("initialize",e);var f=this.get("radius")*2*this.get("scaleX");this.set("width",f).set("height",f)},toObject:function(){return b.util.object.extend(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(e){e.beginPath();e.arc(0,0,this.radius,0,d,false);if(this.fill){e.fill()}if(this.stroke){e.stroke()}},complexity:function(){return 1}});b.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");b.Circle.fromElement=function(f,e){var g=b.parseAttributes(f,b.Circle.ATTRIBUTE_NAMES);if(!c(g)){throw Error("value of `r` attribute is required and can not be negative")}return new b.Circle(b.util.object.extend(g,e))};function c(e){return(("radius" in e)&&(e.radius>0))}b.Circle.fromObject=function(e){return new b.Circle(e)}})();(function(){var a=this.fabric||(this.fabric={});if(a.Triangle){return}a.Triangle=a.util.createClass(a.Object,{type:"triangle",initialize:function(b){b=b||{};this.callSuper("initialize",b);this.set("width",b.width||100).set("height",b.height||100)},_render:function(b){b.beginPath();b.moveTo(-this.width/2,this.height/2);b.lineTo(0,-this.height/2);b.lineTo(this.width/2,this.height/2);if(this.fill){b.fill()}if(this.stroke){b.stroke()}},complexity:function(){return 1}});a.Triangle.fromObject=function(b){return new a.Triangle(b)}})();(function(){var a=this.fabric||(this.fabric={});if(a.Ellipse){console.warn("fabric.Ellipse is already defined.");return}a.Ellipse=a.util.createClass(a.Object,{type:"ellipse",initialize:function(b){b=b||{};this.callSuper("initialize",b);this.set("rx",b.rx||0);this.set("ry",b.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return a.util.object.extend(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(b,c){if(this.rx===0||this.ry===0){return}return this.callSuper("render",b,c)},_render:function(b){b.beginPath();b.save();b.transform(1,0,0,this.ry/this.rx,0,0);b.arc(0,0,this.rx,0,Math.PI*2,false);b.restore();if(this.stroke){b.stroke()}if(this.fill){b.fill()}},complexity:function(){return 1}});a.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");a.Ellipse.fromElement=function(c,b){var d=a.parseAttributes(c,a.Ellipse.ATTRIBUTE_NAMES);return new a.Ellipse(a.util.object.extend(d,b))};a.Ellipse.fromObject=function(b){return new a.Ellipse(b)}})();(function(){var b=this.fabric||(this.fabric={});if(b.Rect){return}b.Rect=b.util.createClass(b.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(c){this.callSuper("initialize",c);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(e){var k=this.options.rx||0,g=this.options.ry||0,c=-this.width/2,l=-this.height/2,d=this.width,f=this.height;e.beginPath();e.moveTo(c+k,l);e.lineTo(c+d-k,l);e.bezierCurveTo(c+d,l,c+d,l+g,c+d,l+g);e.lineTo(c+d,l+f-g);e.bezierCurveTo(c+d,l+f,c+d-k,l+f,c+d-k,l+f);e.lineTo(c+k,l+f);e.bezierCurveTo(c,l+f,c,l+f-g,c,l+f-g);e.lineTo(c,l+g);e.bezierCurveTo(c,l,c+k,l,c+k,l);e.closePath();if(this.fill){e.fill()}if(this.stroke){e.stroke()}},_normalizeLeftTopProperties:function(c){if(c.left){this.set("left",c.left+this.getWidth()/2)}if(c.top){this.set("top",c.top+this.getHeight()/2)}return this},complexity:function(){return 1}});b.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");function a(c){c.left=c.left||0;c.top=c.top||0;return c}b.Rect.fromElement=function(d,c){if(!d){return null}var f=b.parseAttributes(d,b.Rect.ATTRIBUTE_NAMES);f=a(f);var e=new b.Rect(b.util.object.extend(c||{},f));e._normalizeLeftTopProperties(f);return e};b.Rect.fromObject=function(c){return new b.Rect(c)}})();(function(){var b=this.fabric||(this.fabric={});if(b.Polyline){console.warn("fabric.Polyline is already defined");return}b.Polyline=b.util.createClass(b.Object,{type:"polyline",initialize:function(d,c){c=c||{};this.set("points",d);this.callSuper("initialize",c);this._calcDimensions()},_calcDimensions:function(){return b.Polygon.prototype._calcDimensions.call(this)},_toOrigin:function(){return b.Polygon.prototype._toOrigin.call(this)},toObject:function(){return b.Polygon.prototype.toObject.call(this)},_render:function(e){var d;e.beginPath();for(var f=0,c=this.points.length;f"},toObject:function(){var c=b.util.object.extend(this.callSuper("toObject"),{path:this.path});if(this.sourcePath){c.sourcePath=this.sourcePath}if(this.transformMatrix){c.transformMatrix=this.transformMatrix}return c},toDatalessObject:function(){var c=this.toObject();if(this.sourcePath){c.path=this.sourcePath}delete c.sourcePath;return c},complexity:function(){return this.path.length},set:function(d,c){if(this.stub){this.stub.set(d,c)}return this.callSuper("set",d,c)},_parsePath:function(){var d=[],f,g;for(var e=0,c=this.path.length;e"},isSameColor:function(){var c=this.getObjects()[0].get("fill");return this.getObjects().every(function(d){return d.get("fill")===c})},complexity:function(){return this.paths.reduce(function(c,d){return c+((d&&d.complexity)?d.complexity():0)},0)},toGrayscale:function(){var c=this.paths.length;while(c--){this.paths[c].toGrayscale()}return this},getObjects:function(){return this.paths}});function a(f){for(var e=0,c=f.length;e"},getObjects:function(){return this.objects},add:function(b){this._restoreObjectsState();this.objects.push(b);b.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(b){this._restoreObjectsState();a.util.removeFromArray(this.objects,b);b.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(b,d){if(typeof d=="function"){this.set(b,d(this[b]))}else{if(b==="fill"||b==="opacity"){var c=this.objects.length;this[b]=d;while(c--){this.objects[c].set(b,d)}}else{this[b]=d}}return this},contains:function(b){return this.objects.indexOf(b)>-1},toObject:function(){return a.util.object.extend(this.callSuper("toObject"),{objects:a.util.array.invoke(this.objects,"clone")})},render:function(c){c.save();this.transform(c);var f=Math.max(this.scaleX,this.scaleY);for(var d=0,b=this.objects.length;dc.x&&d-bc.y},toGrayscale:function(){var b=this.objects.length;while(b--){this.objects[b].toGrayscale()}}});a.Group.fromObject=function(b){return new a.Group(b.objects,b)}})();(function(){var a=this.fabric||(this.fabric={});if(a.Text){console.warn("fabric.Text is already defined");return}if(!a.Object){console.warn("fabric.Text requires fabric.Object");return}a.Text=a.util.createClass(a.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(c,b){this.originalState={};this.initStateProperties();this.text=c;this.setOptions(b);a.util.object.extend(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()},initStateProperties:function(){var b;if((b=this.constructor)&&(b=b.superclass)&&(b=b.prototype)&&(b=b.stateProperties)&&b.clone){this.stateProperties=b.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#"},_render:function(b){var d=Cufon.textOptions||(Cufon.textOptions={});d.left=this.left;d.top=this.top;d.context=b;d.color=this.fill;var c=this._initDummyElement();this.transform(b);Cufon.replaceElement(c,{separate:"none",fontFamily:this.fontfamily});this.width=d.width;this.height=d.height},_initDummyElement:function(){var b=document.createElement("div");b.innerHTML=this.text;b.style.fontSize="40px";b.style.fontWeight="400";b.style.fontStyle="normal";b.style.letterSpacing="normal";b.style.color="#000000";b.style.fontWeight="600";b.style.fontFamily="Verdana";return b},render:function(b){b.save();this._render(b);if(this.active){this.drawBorders(b);this.drawCorners(b)}b.restore()},toObject:function(){return a.util.object.extend(this.callSuper("toObject"),{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,path:this.path})},setColor:function(b){this.set("fill",b);return this},setFontsize:function(b){this.set("fontsize",b);this.setCoords();return this},getText:function(){return this.text},setText:function(b){this.set("text",b);this.setCoords();return this},set:function(b,c){this[b]=c;if(b==="fontfamily"){this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+c+"$3")}return this}});a.Text.fromObject=function(b){return new a.Text(b.text,a.util.object.clone(b))};a.Text.fromElement=function(b){}})();(function(){var a=this;if(!a.fabric){a.fabric={}}if(a.fabric.Image){console.warn("fabric.Image is already defined.");return}if(!fabric.Object){console.warn("fabric.Object is required for fabric.Image initialization");return}fabric.Image=fabric.util.createClass(fabric.Object,{maxwidth:null,maxheight:null,active:false,bordervisibility:false,cornervisibility:false,type:"image",__isGrayscaled:false,initialize:function(c,b){this.callSuper("initialize",b);this._initElement(c);this._initConfig(b||{})},getElement:function(){return this._element},setElement:function(b){this._element=b;return this},getNormalizedSize:function(c,b,d){if(d&&b&&(c.width>c.height&&(c.width/c.height)<(b/d))){normalizedWidth=Math.floor((c.width*d)/c.height);normalizedHeight=d}else{if(d&&((c.height==c.width)||(c.height>c.width)||(c.height>d))){normalizedWidth=Math.floor((c.width*d)/c.height);normalizedHeight=d}else{if(b&&(b'},clone:function(b){this.constructor.fromObject(this.toObject(),b)},toGrayscale:function(f){if(this.__isGrayscaled){return}var d=this.getElement(),b=document.createElement("canvas"),c=document.createElement("img"),e=this;b.width=d.width;b.height=d.height;b.getContext("2d").drawImage(d,0,0);fabric.Element.toGrayscale(b);c.onload=function(){e.setElement(c);f&&f();c.onload=b=d=imageData=null};c.width=d.width;c.height=d.height;c.src=b.toDataURL("image/png");this.__isGrayscaled=true;return this},_render:function(c){var b=this.getOriginalSize();c.drawImage(this.getElement(),-b.width/2,-b.height/2,b.width,b.height)},_adjustWidthHeightToBorders:function(b){if(b){this.currentBorder=this.borderwidth;this.width+=(2*this.currentBorder);this.height+=(2*this.currentBorder)}else{this.currentBorder=0}},_resetWidthHeight:function(){var b=this.getElement();this.set("width",b.width);this.set("height",b.height)},_initElement:function(b){this.setElement(fabric.util.getById(b));fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(b){this.setOptions(b);this._setBorder();this._setWidthHeight(b)},_setBorder:function(){if(this.bordervisibility){this.currentBorder=this.borderwidth}else{this.currentBorder=0}},_setWidthHeight:function(b){var c=2*this.currentBorder;this.width=(this.getElement().width||0)+c;this.height=(this.getElement().height||0)+c}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(c,e){var b=document.createElement("img"),d=c.src;if(c.width){b.width=c.width}if(c.height){b.height=c.height}b.onload=function(){if(e){e(new fabric.Image(b,c))}b=b.onload=null};b.src=d};fabric.Image.fromURL=function(c,e,d){var b=document.createElement("img");b.onload=function(){if(e){e(new fabric.Image(b,d))}b=b.onload=null};b.src=c}})(); \ No newline at end of file diff --git a/lib/google_closure_compiler.jar b/lib/google_closure_compiler.jar new file mode 100644 index 00000000..484e8741 Binary files /dev/null and b/lib/google_closure_compiler.jar differ diff --git a/src/image.class.js b/src/image.class.js index 69f472b5..7261d416 100644 --- a/src/image.class.js +++ b/src/image.class.js @@ -65,8 +65,8 @@ * Width and height have to mantain the same proportion in the final image as it was in the initial one. * @method getNormalizedSize * @param {Object} oImg - * @param {Number} maximum width of the image in px - * @param {Number} maximum height of the image in px + * @param {Number} maxwidth maximum width of the image in px + * @param {Number} maxheight maximum height of the image in px */ getNormalizedSize: function(oImg, maxwidth, maxheight) { if (maxheight && maxwidth && (oImg.width > oImg.height && (oImg.width / oImg.height) < (maxwidth / maxheight))) { diff --git a/src/parser.js b/src/parser.js index e6eb6458..ffee44d0 100644 --- a/src/parser.js +++ b/src/parser.js @@ -211,9 +211,10 @@ memo.push({ x: parseFloat(pair[0]), y: parseFloat(pair[1]) }); return memo; }, [ ]); + // odd number of points is an error if (parsedPoints.length % 2 !== 0) { - // return null; + return null; } return parsedPoints; }; diff --git a/src/path_group.class.js b/src/path_group.class.js index 85d7a168..086d354b 100644 --- a/src/path_group.class.js +++ b/src/path_group.class.js @@ -194,7 +194,7 @@ /** * @static * @method fabric.PathGroup.fromObject - * @param {Object} + * @param {Object} object * @return {fabric.PathGroup} */ fabric.PathGroup.fromObject = function(object) {