From 7041b64ad6c6dcf0050157b6b94a20375b19341c Mon Sep 17 00:00:00 2001 From: kangax Date: Tue, 10 May 2011 19:02:31 -0400 Subject: [PATCH] Update minified file. --- dist/all.min.js | 7 ++++++- test/demo/index.html | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dist/all.min.js b/dist/all.min.js index 8b7a235e..64ba3c03 100644 --- a/dist/all.min.js +++ b/dist/all.min.js @@ -1,2 +1,7 @@ /* Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */ -var fabric=fabric||{version:0.2};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 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;z=Number(z)||0;z=Math[z<0?"ceil":"floor"](z);if(z<0){z+=x}for(;z>>0;y>>0;z>>0;y>>0;y>>0;z>>0,y=0,A;if(arguments.length>1){A=arguments[1]}else{do{if(y in this){A=this[y++];break}if(++y>=x){throw new TypeError()}}while(true)}for(;y=x){x=A[y][z]}}}else{while(y--){if(A[y]>=x){x=A[y]}}}return x}function o(A,z){var y=A.length-1,x=z?A[y][z]:A[y];if(z){while(y--){if(A[y][z]-1?z(G,I.match(/opacity:\s*(\d?\.?\d*)/)[1]):G}for(var J in I){if(J==="opacity"){z(G,I[J])}else{var H=(J==="float"||J==="cssFloat")?(typeof K.styleFloat==="undefined"?"cssFloat":"styleFloat"):J;K[H]=I[J]}}return G}var E=document.createElement("div"),D=typeof E.style.opacity==="string",y=typeof E.style.filter==="string",x=document.defaultView,C=x&&typeof x.getComputedStyle!=="undefined",A=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,z=function(F){return F};if(D){z=function(F,G){F.style.opacity=G;return F}}else{if(y){z=function(F,G){var H=F.style;if(F.currentStyle&&!F.currentStyle.hasLayout){H.zoom=1}if(A.test(H.filter)){G=G>=0.9999?"":("alpha(opacity="+(G*100)+")");H.filter=H.filter.replace(A,G)}else{H.filter+=" alpha(opacity="+(G*100)+")"}return F}}}k.util.setStyle=B})();var d=Array.prototype.slice;function s(x){return typeof x==="string"?document.getElementById(x):x}function q(x){return d.call(x,0)}try{var h=q(document.childNodes) instanceof Array}catch(e){}if(!h){q=function(y){var x=new Array(y.length),z=y.length;while(z--){x[z]=y[z]}return x}}function b(y,x){var z=document.createElement(y);for(var A in x){if(A==="class"){z.className=x[A]}else{if(A==="for"){z.htmlFor=x[A]}else{z.setAttribute(A,x[A])}}}return z}function g(x,y){if((" "+x.className+" ").indexOf(" "+y+" ")===-1){x.className+=(x.className?" ":"")+y}}function a(y,z,x){if(typeof z==="string"){z=b(z,x)}if(y.parentNode){y.parentNode.replaceChild(z,y)}z.appendChild(y);return z}function n(y){var x=0,z=0;do{x+=y.offsetTop||0;z+=y.offsetLeft||0;y=y.offsetParent}while(y);return({left:z,top:x})}(function(){var x=document.documentElement.style;var y="userSelect" in x?"userSelect":"MozUserSelect" in x?"MozUserSelect":"WebkitUserSelect" in x?"WebkitUserSelect":"KhtmlUserSelect" in x?"KhtmlUserSelect":"";function z(A){if(typeof A.onselectstart!=="undefined"){A.onselectstart=k.util.falseFunction}if(y){A.style[y]="none"}else{if(typeof A.unselectable=="string"){A.unselectable="on"}}return A}k.util.makeElementUnselectable=z})();(function(){function x(A,E){var C=document.getElementsByTagName("head")[0],B=document.createElement("script"),D=true;B.type="text/javascript";B.setAttribute("runat","server");B.onload=B.onreadystatechange=function(F){if(D){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete"){return}D=false;E(F||window.event);B=B.onload=B.onreadystatechange=null}};B.src=A;C.appendChild(B)}function z(A,B){y.load(A);B()}k.util.getScript=x;var y=p.Jaxer;if(y&&y.load){k.util.getScript=z}})();function c(I){I||(I={});var y=+new Date(),C=I.duration||500,H=y+C,B,G,D=I.onChange||function(){},E=I.easing||function(J){return(-Math.cos(J*Math.PI)/2)+0.5},x="startValue" in I?I.startValue:0,F="endValue" in I?I.endValue:100,A=x>F;I.onStart&&I.onStart();var z=setInterval(function(){B=+new Date();G=B>H?1:(B-y)/C;D(A?(x-(x-F)*E(G)):(x+(F-x)*E(G)));if(B>H){clearInterval(z);I.onComplete&&I.onComplete()}},10)}k.util.getById=s;k.util.toArray=q;k.util.makeElement=b;k.util.addClass=g;k.util.wrapElement=a;k.util.getElementOffset=n;k.util.animate=c;(function(){function A(B,C){return B+(/\?/.test(B)?"&":"?")+C}var z=(function(){var E=[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 B=E.length;B--;){try{var D=E[B]();if(D){return E[B]}}catch(C){}}})();function x(){}function y(D,C){C||(C={});var G=C.method?C.method.toUpperCase():"GET",F=C.onComplete||function(){},E=z(),B;E.onreadystatechange=function(){if(E.readyState===4){F(E);E.onreadystatechange=x}};if(G==="GET"){B=null;if(typeof C.parameters=="string"){D=A(D,C.parameters)}}E.open(G,D,true);if(G==="POST"||G==="PUT"){E.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}E.send(B);return E}k.util.request=y})()})(this);(function(b){var c=b.fabric||(b.fabric={}),h=c.util.object.extend,f=c.util.string.capitalize,k=c.util.object.clone;var d={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};function o(s,r){if(!s){return}var u,q,p={};if(s.parentNode&&/^g$/i.test(s.parentNode.nodeName)){p=c.parseAttributes(s.parentNode,r)}var t=r.reduce(function(w,v){u=s.getAttribute(v);q=parseFloat(u);if(u){if((v==="fill"||v==="stroke")&&u==="none"){u=""}if(v==="fill-rule"){u=(u==="evenodd")?"destination-over":u}if(v==="transform"){u=c.parseTransformAttribute(u)}if(v in d){v=d[v]}w[v]=isNaN(q)?u:q}return w},{});t=h(t,h(a(s),c.parseStyleAttribute(s)));return h(p,t)}c.parseTransformAttribute=(function(){function p(I,J){var K=J[0];I[0]=Math.cos(K);I[1]=Math.sin(K);I[2]=-Math.sin(K);I[3]=Math.cos(K)}function u(K,L){var J=L[0],I=(L.length===2)?L[1]:L[0];K[0]=J;K[3]=I}function F(I,J){I[2]=J[0]}function r(I,J){I[1]=J[0]}function C(I,J){I[4]=J[0];if(J.length===2){I[5]=J[1]}}var w=[1,0,0,1,0,0],q="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",G="(?:\\s+,?\\s*|,\\s*)",x="(?:(skewX)\\s*\\(\\s*("+q+")\\s*\\))",v="(?:(skewY)\\s*\\(\\s*("+q+")\\s*\\))",E="(?:(rotate)\\s*\\(\\s*("+q+")(?:"+G+"("+q+")"+G+"("+q+"))?\\s*\\))",H="(?:(scale)\\s*\\(\\s*("+q+")(?:"+G+"("+q+"))?\\s*\\))",A="(?:(translate)\\s*\\(\\s*("+q+")(?:"+G+"("+q+"))?\\s*\\))",D="(?:(matrix)\\s*\\(\\s*("+q+")"+G+"("+q+")"+G+"("+q+")"+G+"("+q+")"+G+"("+q+")"+G+"("+q+")\\s*\\))",B="(?:"+D+"|"+A+"|"+H+"|"+E+"|"+x+"|"+v+")",y="(?:"+B+"(?:"+G+B+")*)",s="^\\s*(?:"+y+"?)\\s*$",z=new RegExp(s),t=new RegExp(B);return function(J){var I=w.concat();if(!J||(J&&!z.test(J))){return I}J.replace(t,function(N){var K=new RegExp(B).exec(N).filter(function(O){return(O!==""&&O!=null)}),L=K[1],M=K.slice(2).map(parseFloat);switch(L){case"translate":C(I,M);break;case"rotate":p(I,M);break;case"scale":u(I,M);break;case"skewX":F(I,M);break;case"skewY":r(I,M);break;case"matrix":I=M;break}});return I}})();function l(s){if(!s){return null}s=s.trim();var u=s.indexOf(",")>-1;s=s.split(/\s+/);var q=[];if(u){for(var r=0,p=s.length;r0){this.init(d,e)}}a.prototype={constructor:a,init:function(d,e){this.x=d;this.y=e},add:function(d){return new a(this.x+d.x,this.y+d.y)},addEquals:function(d){this.x+=d.x;this.y+=d.y;return this},scalarAdd:function(d){return new a(this.x+d,this.y+d)},scalarAddEquals:function(d){this.x+=d;this.y+=d;return this},subtract:function(d){return new a(this.x-d.x,this.y-d.y)},subtractEquals:function(d){this.x-=d.x;this.y-=d.y;return this},scalarSubtract:function(d){return new a(this.x-d,this.y-d)},scalarSubtractEquals:function(d){this.x-=d;this.y-=d;return this},multiply:function(d){return new a(this.x*d,this.y*d)},multiplyEquals:function(d){this.x*=d;this.y*=d;return this},divide:function(d){return new a(this.x/d,this.y/d)},divideEquals:function(d){this.x/=d;this.y/=d;return this},eq:function(d){return(this.x==d.x&&this.y==d.y)},lt:function(d){return(this.xd.x&&this.y>d.y)},gte:function(d){return(this.x>=d.x&&this.y>=d.y)},lerp:function(e,d){return new a(this.x+(e.x-this.x)*d,this.y+(e.y-this.y)*d)},distanceFrom:function(f){var e=this.x-f.x,d=this.y-f.y;return Math.sqrt(e*e+d*d)},min:function(d){return new a(Math.min(this.x,d.x),Math.min(this.y,d.y))},max:function(d){return new a(Math.max(this.x,d.x),Math.max(this.y,d.y))},toString:function(){return this.x+","+this.y},setXY:function(d,e){this.x=d;this.y=e},setFromPoint:function(d){this.x=d.x;this.y=d.y},swap:function(e){var d=this.x,f=this.y;this.x=e.x;this.y=e.y;e.x=d;e.y=f}}})(this);(function(a){var b=a.fabric||(a.fabric={});if(b.Intersection){b.warn("fabric.Intersection is already defined");return}function c(d){if(arguments.length>0){this.init(d)}}b.Intersection=c;b.Intersection.prototype={init:function(d){this.status=d;this.points=[]},appendPoint:function(d){this.points.push(d)},appendPoints:function(d){this.points=this.points.concat(d)}};b.Intersection.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};b.Intersection.intersectLinePolygon=function(e,d,m){var n=new c("No Intersection"),f=m.length;for(var h=0;h0){n.status="Intersection"}return n};b.Intersection.intersectPolygonPolygon=function(k,h){var f=new c("No Intersection"),m=k.length;for(var l=0;l0){f.status="Intersection"}return f};b.Intersection.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}})(this);(function(a){var b=a.fabric||(a.fabric={});if(b.Color){b.warn("fabric.Color is already defined.");return}function c(d){if(!d){this.setSource([0,0,0,1])}else{this._tryParsingColor(d)}}b.Color=c;b.Color.prototype={_tryParsingColor:function(d){var e=c.sourceFromHex(d);if(!e){e=c.sourceFromRgb(d)}if(e){this.setSource(e)}},getSource:function(){return this._source},setSource:function(d){this._source=d},toRgb:function(){var d=this.getSource();return"rgb("+d[0]+","+d[1]+","+d[2]+")"},toRgba:function(){var d=this.getSource();return"rgba("+d[0]+","+d[1]+","+d[2]+","+d[3]+")"},toHex:function(){var h=this.getSource();var f=h[0].toString(16);f=(f.length==1)?("0"+f):f;var e=h[1].toString(16);e=(e.length==1)?("0"+e):e;var d=h[2].toString(16);d=(d.length==1)?("0"+d):d;return f.toUpperCase()+e.toUpperCase()+d.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(e){var d=this.getSource();d[3]=e;this.setSource(d);return this},toGrayscale:function(){var f=this.getSource(),e=parseInt((f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),10),d=f[3];this.setSource([e,e,e,d]);return this},toBlackWhite:function(d){var g=this.getSource(),f=(g[0]*0.3+g[1]*0.59+g[2]*0.11).toFixed(0),e=g[3],d=d||127;f=(Number(f)0)?0:-F),B.ey-((E>0)?0:-E),D,C);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(B.ex+d-((F>0)?0:D),B.ey+d-((E>0)?0:C),D,C)},_findSelectedObjects:function(H){var I,D,N=[],C=this._groupSelector.ex,M=this._groupSelector.ey,B=C+this._groupSelector.left,K=M+this._groupSelector.top,J,G=new fabric.Point(r(C,B),r(M,K)),L=new fabric.Point(u(C,B),u(M,K));for(var E=0,F=this._objects.length;E1){var N=new fabric.Group(N);this.setActiveGroup(N);N.saveCoords();A("group:selected",{target:N})}}this.renderAll()},add:function(){this._objects.push.apply(this._objects,arguments);for(var B=arguments.length;B--;){this.stateful&&arguments[B].setupState();arguments[B].setCoords()}this.renderOnAddition&&this.renderAll();return this},insertAt:function(C,B){this._objects.splice(B,0,C);this.stateful&&C.setupState();C.setCoords();this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop},clearContext:function(B){B.clearRect(0,0,this.width,this.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 H=this[C?"contextTop":"contextContainer"];this.clearContext(this.contextTop);if(!C){this.clearContext(H)}H.fillStyle=this.backgroundColor;H.fillRect(0,0,this.width,this.height);var G=this._objects.length,F=this.getActiveGroup(),E=new Date();if(G){for(var D=0;D1){var P=new fabric.PathGroup(R,O)}else{var P=R[0]}P.setSourcePath(N);if(!(P instanceof fabric.PathGroup)){v(P,O);if(typeof O.angle!=="undefined"){P.setAngle(O.angle)}}G(P,M)})}}}},this)}catch(D){fabric.log(D.message)}},loadImageFromURL:(function(){var B={};return function(C,G){var F=this;function D(){var H=p.getElementById(B[C]);if(H.width&&H.height){G(new fabric.Image(H))}else{setTimeout(D,50)}}if(B[C]){D()}else{var E=new Image();E.onload=function(){E.onload=null;if(E.width&&E.height){G(new fabric.Image(E))}};E.className="canvas-img-clone";E.src=C;if(this.shouldCacheImages){B[C]=Element.identify(E)}p.body.appendChild(E)}}})(),loadSVGFromURL:function(B,E){var D=this;B=B.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(B,function(F){if(F){D.cache.get(B,function(H){var G=D._enlivenCachedObject(H);E(G.objects,G.options)})}else{new fabric.util.request(B,{method:"get",onComplete:C})}});function C(G){var F=G.responseXML;if(!F){return}var H=F.documentElement;if(!H){return}fabric.parseSVGDocument(H,function(J,I){D.cache.set(B,{objects:fabric.util.array.invoke(J,"toObject"),options:I});E(J,I)})}},_enlivenCachedObject:function(D){var C=D.objects,B=D.options;C=C.map(function(E){return fabric[k(E.type)].fromObject(E)});return({objects:C,options:B})},remove:function(B){m(this._objects,B);if(this.getActiveObject()===B){this.removeActiveObject()}this.renderAll();return B},fxRemove:function(B,D){var C=this;B.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){C.remove(B);if(typeof D==="function"){D()}}});return this},sendToBack:function(B){m(this._objects,B);this._objects.unshift(B);return this.renderAll()},bringToFront:function(B){m(this._objects,B);this._objects.push(B);return this.renderAll()},sendBackwards:function(D){var C=this._objects.indexOf(D),B=C;if(C!==0){for(var E=C-1;E>=0;--E){if(D.intersectsWithObject(this._objects[E])){B=E;break}}m(this._objects,D);this._objects.splice(B,0,D)}return this.renderAll()},bringForward:function(E){var G=this.getObjects(),C=G.indexOf(E),B=C;if(C!==G.length-1){for(var F=C+1,D=this._objects.length;F"};v(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(E){var D=E.getContext("2d"),I=D.getImageData(0,0,E.width,E.height),G=I.data,B=I.width,H=I.height,C,F;for(i=0;i1)?m.apply(this,h.call(arguments,1)):m.call(this)},initialize:function(l){l&&this.setOptions(l)},setOptions:function(l){var m=this.stateProperties.length,n;while(m--){n=this.stateProperties[m];if(n in l){(n==="angle")?this.setAngle(l[n]):(this[n]=l[n])}}},transform:function(l){l.globalAlpha=this.opacity;l.translate(this.left,this.top);l.rotate(this.theta);l.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toObject:function(){var l={type:this.type,left:c(this.left,this.NUM_FRACTION_DIGITS),top:c(this.top,this.NUM_FRACTION_DIGITS),width:c(this.width,this.NUM_FRACTION_DIGITS),height:c(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,scaleX:c(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:c(this.scaleY,this.NUM_FRACTION_DIGITS),angle:c(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:c(this.opacity,this.NUM_FRACTION_DIGITS)};if(!this.includeDefaultValues){l=this._removeDefaultValues(l)}return l},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(m){var l=d.Object.prototype.options;this.stateProperties.forEach(function(n){if(m[n]===l[n]){delete m[n]}});return m},isActive:function(){return !!this.active},setActive:function(l){this.active=!!l;return this},toString:function(){return"#"},set:function(m,l){var n=(m==="scaleX"||m==="scaleY")&&ln.x&&o.xn.y&&q.y=r)&&(o.d.y>=r)){continue}if((o.o.x==o.d.x)&&(o.o.x>=s)){t=o.o.x;q=r}else{v=0;u=(o.d.y-o.o.y)/(o.d.x-o.o.x);n=r-v*s;m=o.o.y-u*o.o.x;t=-(n-m)/(v-u);q=n+v*t}if(t>=s){p+=1}if(p==2){break}}return p},_getImageLines:function(m,l){return{topline:{o:m.tl,d:m.tr},rightline:{o:m.tr,d:m.br},bottomline:{o:m.br,d:m.bl},leftline:{o:m.bl,d:m.tl}}},_setCornerCoords:function(){var p=this.oCoords,m=b(45-this.getAngle()),o=Math.sqrt(2*Math.pow(this.cornersize,2))/2,l=o*Math.cos(m),n=o*Math.sin(m);p.tl.corner={tl:{x:p.tl.x-n,y:p.tl.y-l},tr:{x:p.tl.x+l,y:p.tl.y-n},bl:{x:p.tl.x-l,y:p.tl.y+n},br:{x:p.tl.x+n,y:p.tl.y+l}};p.tr.corner={tl:{x:p.tr.x-n,y:p.tr.y-l},tr:{x:p.tr.x+l,y:p.tr.y-n},br:{x:p.tr.x+n,y:p.tr.y+l},bl:{x:p.tr.x-l,y:p.tr.y+n}};p.bl.corner={tl:{x:p.bl.x-n,y:p.bl.y-l},bl:{x:p.bl.x-l,y:p.bl.y+n},br:{x:p.bl.x+n,y:p.bl.y+l},tr:{x:p.bl.x+l,y:p.bl.y-n}};p.br.corner={tr:{x:p.br.x+l,y:p.br.y-n},bl:{x:p.br.x-l,y:p.br.y+n},br:{x:p.br.x+n,y:p.br.y+l},tl:{x:p.br.x-n,y:p.br.y-l}};p.ml.corner={tl:{x:p.ml.x-n,y:p.ml.y-l},tr:{x:p.ml.x+l,y:p.ml.y-n},bl:{x:p.ml.x-l,y:p.ml.y+n},br:{x:p.ml.x+n,y:p.ml.y+l}};p.mt.corner={tl:{x:p.mt.x-n,y:p.mt.y-l},tr:{x:p.mt.x+l,y:p.mt.y-n},bl:{x:p.mt.x-l,y:p.mt.y+n},br:{x:p.mt.x+n,y:p.mt.y+l}};p.mr.corner={tl:{x:p.mr.x-n,y:p.mr.y-l},tr:{x:p.mr.x+l,y:p.mr.y-n},bl:{x:p.mr.x-l,y:p.mr.y+n},br:{x:p.mr.x+n,y:p.mr.y+l}};p.mb.corner={tl:{x:p.mb.x-n,y:p.mb.y-l},tr:{x:p.mb.x+l,y:p.mb.y-n},bl:{x:p.mb.x-l,y:p.mb.y+n},br:{x:p.mb.x+n,y:p.mb.y+l}}},toGrayscale:function(){var l=this.get("fill");if(l){this.set("overlayFill",new d.Color(l).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 l=this._getAngleValueForStraighten();this.setAngle(l);return this},fxStraighten:function(m){m=m||{};var n=function(){},o=m.onComplete||n,l=m.onChange||n,p=this;d.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(q){p.setAngle(q);l()},onComplete:function(){p.setCoords();o()},onStart:function(){p.setActive(false)}});return this},fxRemove:function(m){m||(m={});var n=function(){},o=m.onComplete||n,l=m.onChange||n,p=this;d.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(q){p.set("opacity",q);l()},onComplete:o,onStart:function(){p.setActive(false)}});return this},_getAngleValueForStraighten:function(){var l=this.get("angle");if(l>-225&&l<=-135){return -180}else{if(l>-135&&l<=-45){return -90}else{if(l>-45&&l<=45){return 0}else{if(l>45&&l<=135){return 90}else{if(l>135&&l<=225){return 180}else{if(l>225&&l<=315){return 270}else{if(l>315){return 360}}}}}}}return 0},toJSON:function(){return this.toObject()},setGradientFill:function(l,m){this.set("fill",d.Gradient.forObject(this,l,m))}});d.Object.prototype.rotate=d.Object.prototype.setAngle})(this);(function(a){var b=a.fabric||(a.fabric={}),c=b.util.object.extend;if(b.Line){b.warn("fabric.Line is already defined");return}b.Line=b.util.createClass(b.Object,{type:"line",initialize:function(e,d){if(!e){e=[0,0,0,0]}this.callSuper("initialize",d);this.set("x1",e[0]);this.set("y1",e[1]);this.set("x2",e[2]);this.set("y2",e[3]);this.set("width",(this.x2-this.x1)||1);this.set("height",(this.y2-this.y1)||1);this.set("left",this.x1+this.width/2);this.set("top",this.y1+this.height/2)},_render:function(d){d.beginPath();d.moveTo(-this.width/2,-this.height/2);d.lineTo(this.width/2,this.height/2);var e=d.strokeStyle;d.strokeStyle=d.fillStyle;d.stroke();d.strokeStyle=e},complexity:function(){return 1},toObject:function(){return c(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});b.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");b.Line.fromElement=function(e,d){var g=b.parseAttributes(e,b.Line.ATTRIBUTE_NAMES);var f=[g.x1||0,g.y1||0,g.x2||0,g.y2||0];return new b.Line(f,c(g,d))};b.Line.fromObject=function(d){var e=[d.x1,d.y1,d.x2,d.y2];return new b.Line(e,d)}})(this);(function(a){var b=a.fabric||(a.fabric={}),d=Math.PI*2,e=b.util.object.extend;if(b.Circle){b.warn("fabric.Circle is already defined.");return}b.Circle=b.util.createClass(b.Object,{type:"circle",initialize:function(f){f=f||{};this.set("radius",f.radius||0);this.callSuper("initialize",f);var g=this.get("radius")*2*this.get("scaleX");this.set("width",g).set("height",g)},toObject:function(){return e(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(f,g){f.beginPath();f.arc(g?this.left:0,g?this.top:0,this.radius,0,d,false);f.closePath();if(this.fill){f.fill()}if(this.stroke){f.stroke()}},complexity:function(){return 1}});b.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");b.Circle.fromElement=function(g,f){f||(f={});var h=b.parseAttributes(g,b.Circle.ATTRIBUTE_NAMES);if(!c(h)){throw Error("value of `r` attribute is required and can not be negative")}if("left" in h){h.left-=(f.width/2)||0}if("top" in h){h.top-=(f.height/2)||0}return new b.Circle(e(h,f))};function c(f){return(("radius" in f)&&(f.radius>0))}b.Circle.fromObject=function(f){return new b.Circle(f)}})(this);(function(a){var b=a.fabric||(a.fabric={});if(b.Triangle){b.warn("fabric.Triangle is already defined");return}b.Triangle=b.util.createClass(b.Object,{type:"triangle",initialize:function(c){c=c||{};this.callSuper("initialize",c);this.set("width",c.width||100).set("height",c.height||100)},_render:function(c){var d=this.width/2,e=this.height/2;c.beginPath();c.moveTo(-d,e);c.lineTo(0,-e);c.lineTo(d,e);c.closePath();if(this.fill){c.fill()}if(this.stroke){c.stroke()}},complexity:function(){return 1}});b.Triangle.fromObject=function(c){return new b.Triangle(c)}})(this);(function(a){var b=a.fabric||(a.fabric={}),c=Math.PI*2,d=b.util.object.extend;if(b.Ellipse){b.warn("fabric.Ellipse is already defined.");return}b.Ellipse=b.util.createClass(b.Object,{type:"ellipse",initialize:function(e){e=e||{};this.callSuper("initialize",e);this.set("rx",e.rx||0);this.set("ry",e.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return d(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(e,f){if(this.rx===0||this.ry===0){return}return this.callSuper("render",e,f)},_render:function(e,f){e.beginPath();e.save();e.transform(1,0,0,this.ry/this.rx,0,0);e.arc(f?this.left:0,f?this.top:0,this.rx,0,c,false);e.restore();if(this.stroke){e.stroke()}if(this.fill){e.fill()}},complexity:function(){return 1}});b.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");b.Ellipse.fromElement=function(f,e){e||(e={});var g=b.parseAttributes(f,b.Ellipse.ATTRIBUTE_NAMES);if("left" in g){g.left-=(e.width/2)||0}if("top" in g){g.top-=(e.height/2)||0}return new b.Ellipse(d(g,e))};b.Ellipse.fromObject=function(e){return new b.Ellipse(e)}})(this);(function(b){var c=b.fabric||(b.fabric={});if(c.Rect){console.warn("fabric.Rect is already defined");return}c.Rect=c.util.createClass(c.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(d){this._initStateProperties();this.callSuper("initialize",d);this._initRxRy()},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat(["rx","ry"])},_initRxRy:function(){if(this.rx&&!this.ry){this.ry=this.rx}else{if(this.ry&&!this.rx){this.rx=this.ry}}},_render:function(f){var l=this.rx||0,k=this.ry||0,d=-this.width/2,m=-this.height/2,e=this.width,g=this.height;f.beginPath();f.moveTo(d+l,m);f.lineTo(d+e-l,m);f.bezierCurveTo(d+e,m,d+e,m+k,d+e,m+k);f.lineTo(d+e,m+g-k);f.bezierCurveTo(d+e,m+g,d+e-l,m+g,d+e-l,m+g);f.lineTo(d+l,m+g);f.bezierCurveTo(d,m+g,d,m+g-k,d,m+g-k);f.lineTo(d,m+k);f.bezierCurveTo(d,m,d+l,m,d+l,m);f.closePath();if(this.fill){f.fill()}if(this.stroke){f.stroke()}},_normalizeLeftTopProperties:function(d){if(d.left){this.set("left",d.left+this.getWidth()/2)}if(d.top){this.set("top",d.top+this.getHeight()/2)}return this},complexity:function(){return 1}});c.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");function a(d){d.left=d.left||0;d.top=d.top||0;return d}c.Rect.fromElement=function(e,d){if(!e){return null}var g=c.parseAttributes(e,c.Rect.ATTRIBUTE_NAMES);g=a(g);var f=new c.Rect(c.util.object.extend(d||{},g));f._normalizeLeftTopProperties(g);return f};c.Rect.fromObject=function(d){return new c.Rect(d)}})(this);(function(a){var b=a.fabric||(a.fabric={});if(b.Polyline){b.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)},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 k=h(this.callSuper("toObject"),{path:this.path});if(this.sourcePath){k.sourcePath=this.sourcePath}if(this.transformMatrix){k.transformMatrix=this.transformMatrix}return k},toDatalessObject:function(){var k=this.toObject();if(this.sourcePath){k.path=this.sourcePath}delete k.sourcePath;return k},complexity:function(){return this.path.length},_parsePath:function(){var l=[],p,q;for(var o=0,m,n,k=this.path.length;o"},isSameColor:function(){var l=this.getObjects()[0].get("fill");return this.getObjects().every(function(m){return m.get("fill")===l})},complexity:function(){return this.paths.reduce(function(l,m){return l+((m&&m.complexity)?m.complexity():0)},0)},toGrayscale:function(){var l=this.paths.length;while(l--){this.paths[l].toGrayscale()}return this},getObjects:function(){return this.paths}});function c(o){for(var n=0,l=o.length;n"},getObjects:function(){return this.objects},add:function(h){this._restoreObjectsState();this.objects.push(h);h.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(h){this._restoreObjectsState();f(this.objects,h);h.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(h,l){if(typeof l=="function"){this.set(h,l(this[h]))}else{if(h==="fill"||h==="opacity"){var k=this.objects.length;this[h]=l;while(k--){this.objects[k].set(h,l)}}else{this[h]=l}}return this},contains:function(h){return this.objects.indexOf(h)>-1},toObject:function(){return g(this.callSuper("toObject"),{objects:b(this.objects,"clone")})},render:function(k){k.save();this.transform(k);var o=Math.max(this.scaleX,this.scaleY);for(var m=0,h=this.objects.length,l;l=this.objects[m];m++){var n=l.borderScaleFactor;l.borderScaleFactor=o;l.render(k);l.borderScaleFactor=n}this.hideBorders||this.drawBorders(k);this.hideCorners||this.drawCorners(k);k.restore();this.setCoords()},item:function(h){return this.getObjects()[h]},complexity:function(){return this.getObjects().reduce(function(k,h){k+=(typeof h.complexity=="function")?h.complexity():0;return k},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,this);return this},_restoreObjectState:function(l){var n=this.get("left"),o=this.get("top"),h=this.getAngle()*(Math.PI/180),m=l.get("originalLeft"),p=l.get("originalTop"),k=Math.cos(h)*l.get("top")+Math.sin(h)*l.get("left"),q=-Math.sin(h)*l.get("top")+Math.cos(h)*l.get("left");l.setAngle(l.getAngle()+this.getAngle());l.set("left",n+q*this.get("scaleX"));l.set("top",o+k*this.get("scaleY"));l.set("scaleX",l.get("scaleX")*this.get("scaleX"));l.set("scaleY",l.get("scaleY")*this.get("scaleY"));l.setCoords();l.hideCorners=false;l.setActive(false);l.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(h){h.setCoords()});return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(h){this.forEachObject(function(k){k.setActive(h)});return this},forEachObject:function(m,k){var l=this.getObjects(),h=l.length;while(h--){m.call(k,l[h],h,l)}return this},_setOpacityIfSame:function(){var l=this.getObjects(),k=l[0]?l[0].get("opacity"):1;var h=l.every(function(m){return m.get("opacity")===k});if(h){this.opacity=k}},_calcBounds:function(){var t=[],r=[],q,p,l,h,n,m,v,s=0,u=this.objects.length;for(;sk.x&&l-hk.y},toGrayscale:function(){var h=this.objects.length;while(h--){this.objects[h].toGrayscale()}}});e.Group.fromObject=function(h){return new e.Group(h.objects,h)}})(this);(function(a){var b=fabric.util.object.extend;if(!a.fabric){a.fabric={}}if(a.fabric.Image){fabric.warn("fabric.Image is already defined.");return}if(!fabric.Object){fabric.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(d,c){this.callSuper("initialize",c);this._initElement(d);this._initConfig(c||{})},getElement:function(){return this._element},setElement:function(c){this._element=c;return this},getNormalizedSize:function(d,c,e){if(e&&c&&(d.width>d.height&&(d.width/d.height)<(c/e))){normalizedWidth=~~((d.width*e)/d.height);normalizedHeight=e}else{if(e&&((d.height==d.width)||(d.height>d.width)||(d.height>e))){normalizedWidth=~~((d.width*e)/d.height);normalizedHeight=e}else{if(c&&(c'},clone:function(c){this.constructor.fromObject(this.toObject(),c)},toGrayscale:function(g){if(this.__isGrayscaled){return}var e=this.getElement(),c=document.createElement("canvas"),d=document.createElement("img"),f=this;c.width=e.width;c.height=e.height;c.getContext("2d").drawImage(e,0,0);fabric.Element.toGrayscale(c);d.onload=function(){f.setElement(d);g&&g();d.onload=c=e=imageData=null};d.width=e.width;d.height=e.height;d.src=c.toDataURL("image/png");this.__isGrayscaled=true;return this},_render:function(d){var c=this.getOriginalSize();d.drawImage(this.getElement(),-c.width/2,-c.height/2,c.width,c.height)},_adjustWidthHeightToBorders:function(c){if(c){this.currentBorder=this.borderwidth;this.width+=(2*this.currentBorder);this.height+=(2*this.currentBorder)}else{this.currentBorder=0}},_resetWidthHeight:function(){var c=this.getElement();this.set("width",c.width);this.set("height",c.height)},_initElement:function(c){this.setElement(fabric.util.getById(c));fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(c){this.setOptions(c);this._setBorder();this._setWidthHeight(c)},_setBorder:function(){if(this.bordervisibility){this.currentBorder=this.borderwidth}else{this.currentBorder=0}},_setWidthHeight:function(c){var d=2*this.currentBorder;this.width=(this.getElement().width||0)+d;this.height=(this.getElement().height||0)+d},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(d,f){var c=document.createElement("img"),e=d.src;if(d.width){c.width=d.width}if(d.height){c.height=d.height}c.onload=function(){if(f){f(new fabric.Image(c,d))}c=c.onload=null};c.src=e};fabric.Image.fromURL=function(d,f,e){var c=document.createElement("img");c.onload=function(){if(f){f(new fabric.Image(c,e))}c=c.onload=null};c.src=d};fabric.Image.ATTRIBUTE_NAMES="x y width height fill fill-opacity stroke stroke-width transform xlink:href".split(" ");fabric.Image.fromElement=function(d,f,c){c||(c={});var e=fabric.parseAttributes(d,fabric.Image.ATTRIBUTE_NAMES);fabric.Image.fromURL(e["xlink:href"],f,b(e,c))};fabric.Image.fromElement.async=true})(this); \ No newline at end of file +var fabric=fabric||{version:"0.2.2"};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 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=A.length+I){D()}else{setTimeout(arguments.callee,10)}});return function(F){if(C){F()}else{B.push(F)}}})(),supports:function(C,B){var A=document.createElement("span").style;if(A[C]===undefined){return false}A[C]=B;return A[C]===B},textAlign:function(D,C,A,B){if(C.get("textAlign")=="right"){if(A>0){D=" "+D}}else{if(A400}if(H==500){H=400}for(var I in F){I=parseInt(I,10);if(!E||IC){C=I}J.push(I)}if(HC){H=C}J.sort(function(L,K){return(D?(L>H&&K>H)?LK:(LK:LT){T=O}if(N>R){R=N}if(Ow){w=h}h=0;continue}var A=Z.glyphs[ad[Y]]||Z.missingGlyph;if(!A){continue}h+=C=Number(A.w||Z.w)+S}h=Math.max(w,h);if(C===null){return null}T+=(G.width-C);B+=G.minX;var v,p;if(n){v=I;p=I.firstChild}else{v=document.createElement("span");v.className="cufon cufon-canvas";v.alt=D;p=document.createElement("canvas");v.appendChild(p);if(z.printable){var W=document.createElement("span");W.className="cufon-alt";W.appendChild(document.createTextNode(D));v.appendChild(W)}}var ae=v.style;var M=p.style;var m=o.convert(G.height-H+R);var ac=Math.ceil(m);var Q=ac/m;p.width=Math.ceil(o.convert(h+T-B)*Q);p.height=ac;H+=G.minY;M.top=Math.round(o.convert(H-Z.ascent))+"px";M.left=Math.round(o.convert(B))+"px";var k=Math.ceil(o.convert(h*Q));var t=k+"px";var s=o.convert(Z.height);var E=(z.lineHeight-1)*o.convert(-Z.ascent/5)*(K-1);Cufon.textOptions.width=k;Cufon.textOptions.height=(s*K)+E;Cufon.textOptions.lines=K;if(a){ae.width=t;ae.height=s+"px"}else{ae.paddingLeft=t;ae.paddingBottom=(s-1)+"px"}var ab=Cufon.textOptions.context||p.getContext("2d"),J=ac/G.height;ab.save();ab.scale(J,J);ab.translate(-B-((1/J*p.width)/2)+(Cufon.fonts[Z.family].offsetLeft||0),-H-(Cufon.textOptions.height/J)/2);ab.lineWidth=Z.face["underline-thickness"];ab.save();function q(l,g){ab.strokeStyle=g;ab.beginPath();ab.moveTo(0,l);ab.lineTo(h,l);ab.stroke()}var r=z.enableTextDecoration?Cufon.CSS.textDecoration(aa,U):{},u=z.fontStyle==="italic";ab.fillStyle=Cufon.textOptions.color||U.get("color");function X(){var ag=0;for(var y=0,x=ad.length;y.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}}');function c(e,f){return a(e,/(?:em|ex|%)$/i.test(f)?"1em":f)}function a(h,k){if(/px$/i.test(k)){return parseFloat(k)}var g=h.style.left,f=h.runtimeStyle.left;h.runtimeStyle.left=h.currentStyle.left;h.style.left=k;var e=h.style.pixelLeft;h.style.left=g;h.runtimeStyle.left=f;return e}return function(U,A,P,x,E,V,N){var h=(A===null);if(h){A=E.alt}var C=U.viewBox;var m=P.computedFontSize||(P.computedFontSize=new Cufon.CSS.Size(c(V,P.get("fontSize"))+"px",U.baseSize));var M=P.computedLSpacing;if(M==undefined){M=P.get("letterSpacing");P.computedLSpacing=M=(M=="normal")?0:~~m.convertFrom(a(V,M))}var u,n;if(h){u=E;n=E.firstChild}else{u=document.createElement("span");u.className="cufon cufon-vml";u.alt=A;n=document.createElement("span");n.className="cufon-vml-canvas";u.appendChild(n);if(x.printable){var S=document.createElement("span");S.className="cufon-alt";S.appendChild(document.createTextNode(A));u.appendChild(S)}if(!N){u.appendChild(document.createElement("cvml:shape"))}}var aa=u.style;var H=n.style;var f=m.convert(C.height),X=Math.ceil(f);var L=X/f;var K=C.minX,J=C.minY;H.height=X;H.top=Math.round(m.convert(J-U.ascent));H.left=Math.round(m.convert(K));aa.height=m.convert(U.height)+"px";var q=x.enableTextDecoration?Cufon.CSS.textDecoration(V,P):{};var z=P.get("color");var Y=Cufon.CSS.textTransform(A,P).split("");var e=0,I=0,r=null;var y,s,B=x.textShadow;for(var T=0,R=0,Q=Y.length;T>>0;z=Number(z)||0;z=Math[z<0?"ceil":"floor"](z);if(z<0){z+=x}for(;z>>0;y>>0;z>>0;y>>0;y>>0;z>>0,y=0,A;if(arguments.length>1){A=arguments[1]}else{do{if(y in this){A=this[y++];break}if(++y>=x){throw new TypeError()}}while(true)}for(;y=x){x=A[y][z]}}}else{while(y--){if(A[y]>=x){x=A[y]}}}return x}function o(A,z){var y=A.length-1,x=z?A[y][z]:A[y];if(z){while(y--){if(A[y][z]-1?z(G,I.match(/opacity:\s*(\d?\.?\d*)/)[1]):G}for(var J in I){if(J==="opacity"){z(G,I[J])}else{var H=(J==="float"||J==="cssFloat")?(typeof K.styleFloat==="undefined"?"cssFloat":"styleFloat"):J;K[H]=I[J]}}return G}var E=document.createElement("div"),D=typeof E.style.opacity==="string",y=typeof E.style.filter==="string",x=document.defaultView,C=x&&typeof x.getComputedStyle!=="undefined",A=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,z=function(F){return F};if(D){z=function(F,G){F.style.opacity=G;return F}}else{if(y){z=function(F,G){var H=F.style;if(F.currentStyle&&!F.currentStyle.hasLayout){H.zoom=1}if(A.test(H.filter)){G=G>=0.9999?"":("alpha(opacity="+(G*100)+")");H.filter=H.filter.replace(A,G)}else{H.filter+=" alpha(opacity="+(G*100)+")"}return F}}}k.util.setStyle=B})();var d=Array.prototype.slice;function s(x){return typeof x==="string"?document.getElementById(x):x}function q(x){return d.call(x,0)}try{var h=q(document.childNodes) instanceof Array}catch(e){}if(!h){q=function(y){var x=new Array(y.length),z=y.length;while(z--){x[z]=y[z]}return x}}function b(y,x){var z=document.createElement(y);for(var A in x){if(A==="class"){z.className=x[A]}else{if(A==="for"){z.htmlFor=x[A]}else{z.setAttribute(A,x[A])}}}return z}function g(x,y){if((" "+x.className+" ").indexOf(" "+y+" ")===-1){x.className+=(x.className?" ":"")+y}}function a(y,z,x){if(typeof z==="string"){z=b(z,x)}if(y.parentNode){y.parentNode.replaceChild(z,y)}z.appendChild(y);return z}function n(y){var x=0,z=0;do{x+=y.offsetTop||0;z+=y.offsetLeft||0;y=y.offsetParent}while(y);return({left:z,top:x})}(function(){var x=document.documentElement.style;var y="userSelect" in x?"userSelect":"MozUserSelect" in x?"MozUserSelect":"WebkitUserSelect" in x?"WebkitUserSelect":"KhtmlUserSelect" in x?"KhtmlUserSelect":"";function z(A){if(typeof A.onselectstart!=="undefined"){A.onselectstart=k.util.falseFunction}if(y){A.style[y]="none"}else{if(typeof A.unselectable=="string"){A.unselectable="on"}}return A}k.util.makeElementUnselectable=z})();(function(){function x(A,E){var C=document.getElementsByTagName("head")[0],B=document.createElement("script"),D=true;B.type="text/javascript";B.setAttribute("runat","server");B.onload=B.onreadystatechange=function(F){if(D){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete"){return}D=false;E(F||window.event);B=B.onload=B.onreadystatechange=null}};B.src=A;C.appendChild(B)}function z(A,B){y.load(A);B()}k.util.getScript=x;var y=p.Jaxer;if(y&&y.load){k.util.getScript=z}})();function c(J){J||(J={});var y=+new Date(),C=J.duration||500,I=y+C,B,H,E=J.onChange||function(){},D=J.abort||function(){return false},F=J.easing||function(K){return(-Math.cos(K*Math.PI)/2)+0.5},x="startValue" in J?J.startValue:0,G="endValue" in J?J.endValue:100,A=x>G;J.onStart&&J.onStart();var z=setInterval(function(){B=+new Date();H=B>I?1:(B-y)/C;E(A?(x-(x-G)*F(H)):(x+(G-x)*F(H)));if(B>I||D()){clearInterval(z);J.onComplete&&J.onComplete()}},10);return z}k.util.getById=s;k.util.toArray=q;k.util.makeElement=b;k.util.addClass=g;k.util.wrapElement=a;k.util.getElementOffset=n;k.util.animate=c;(function(){function A(B,C){return B+(/\?/.test(B)?"&":"?")+C}var z=(function(){var E=[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 B=E.length;B--;){try{var D=E[B]();if(D){return E[B]}}catch(C){}}})();function x(){}function y(D,C){C||(C={});var G=C.method?C.method.toUpperCase():"GET",F=C.onComplete||function(){},E=z(),B;E.onreadystatechange=function(){if(E.readyState===4){F(E);E.onreadystatechange=x}};if(G==="GET"){B=null;if(typeof C.parameters=="string"){D=A(D,C.parameters)}}E.open(G,D,true);if(G==="POST"||G==="PUT"){E.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}E.send(B);return E}k.util.request=y})()})(this);(function(b){var c=b.fabric||(b.fabric={}),h=c.util.object.extend,f=c.util.string.capitalize,k=c.util.object.clone;var d={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};function o(s,r){if(!s){return}var u,q,p={};if(s.parentNode&&/^g$/i.test(s.parentNode.nodeName)){p=c.parseAttributes(s.parentNode,r)}var t=r.reduce(function(w,v){u=s.getAttribute(v);q=parseFloat(u);if(u){if((v==="fill"||v==="stroke")&&u==="none"){u=""}if(v==="fill-rule"){u=(u==="evenodd")?"destination-over":u}if(v==="transform"){u=c.parseTransformAttribute(u)}if(v in d){v=d[v]}w[v]=isNaN(q)?u:q}return w},{});t=h(t,h(a(s),c.parseStyleAttribute(s)));return h(p,t)}c.parseTransformAttribute=(function(){function p(I,J){var K=J[0];I[0]=Math.cos(K);I[1]=Math.sin(K);I[2]=-Math.sin(K);I[3]=Math.cos(K)}function u(K,L){var J=L[0],I=(L.length===2)?L[1]:L[0];K[0]=J;K[3]=I}function F(I,J){I[2]=J[0]}function r(I,J){I[1]=J[0]}function C(I,J){I[4]=J[0];if(J.length===2){I[5]=J[1]}}var w=[1,0,0,1,0,0],q="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",G="(?:\\s+,?\\s*|,\\s*)",x="(?:(skewX)\\s*\\(\\s*("+q+")\\s*\\))",v="(?:(skewY)\\s*\\(\\s*("+q+")\\s*\\))",E="(?:(rotate)\\s*\\(\\s*("+q+")(?:"+G+"("+q+")"+G+"("+q+"))?\\s*\\))",H="(?:(scale)\\s*\\(\\s*("+q+")(?:"+G+"("+q+"))?\\s*\\))",A="(?:(translate)\\s*\\(\\s*("+q+")(?:"+G+"("+q+"))?\\s*\\))",D="(?:(matrix)\\s*\\(\\s*("+q+")"+G+"("+q+")"+G+"("+q+")"+G+"("+q+")"+G+"("+q+")"+G+"("+q+")\\s*\\))",B="(?:"+D+"|"+A+"|"+H+"|"+E+"|"+x+"|"+v+")",y="(?:"+B+"(?:"+G+B+")*)",s="^\\s*(?:"+y+"?)\\s*$",z=new RegExp(s),t=new RegExp(B);return function(J){var I=w.concat();if(!J||(J&&!z.test(J))){return I}J.replace(t,function(N){var K=new RegExp(B).exec(N).filter(function(O){return(O!==""&&O!=null)}),L=K[1],M=K.slice(2).map(parseFloat);switch(L){case"translate":C(I,M);break;case"rotate":p(I,M);break;case"scale":u(I,M);break;case"skewX":F(I,M);break;case"skewY":r(I,M);break;case"matrix":I=M;break}});return I}})();function l(s){if(!s){return null}s=s.trim();var u=s.indexOf(",")>-1;s=s.split(/\s+/);var q=[];if(u){for(var r=0,p=s.length;r0){this.init(d,e)}}a.prototype={constructor:a,init:function(d,e){this.x=d;this.y=e},add:function(d){return new a(this.x+d.x,this.y+d.y)},addEquals:function(d){this.x+=d.x;this.y+=d.y;return this},scalarAdd:function(d){return new a(this.x+d,this.y+d)},scalarAddEquals:function(d){this.x+=d;this.y+=d;return this},subtract:function(d){return new a(this.x-d.x,this.y-d.y)},subtractEquals:function(d){this.x-=d.x;this.y-=d.y;return this},scalarSubtract:function(d){return new a(this.x-d,this.y-d)},scalarSubtractEquals:function(d){this.x-=d;this.y-=d;return this},multiply:function(d){return new a(this.x*d,this.y*d)},multiplyEquals:function(d){this.x*=d;this.y*=d;return this},divide:function(d){return new a(this.x/d,this.y/d)},divideEquals:function(d){this.x/=d;this.y/=d;return this},eq:function(d){return(this.x==d.x&&this.y==d.y)},lt:function(d){return(this.xd.x&&this.y>d.y)},gte:function(d){return(this.x>=d.x&&this.y>=d.y)},lerp:function(e,d){return new a(this.x+(e.x-this.x)*d,this.y+(e.y-this.y)*d)},distanceFrom:function(f){var e=this.x-f.x,d=this.y-f.y;return Math.sqrt(e*e+d*d)},min:function(d){return new a(Math.min(this.x,d.x),Math.min(this.y,d.y))},max:function(d){return new a(Math.max(this.x,d.x),Math.max(this.y,d.y))},toString:function(){return this.x+","+this.y},setXY:function(d,e){this.x=d;this.y=e},setFromPoint:function(d){this.x=d.x;this.y=d.y},swap:function(e){var d=this.x,f=this.y;this.x=e.x;this.y=e.y;e.x=d;e.y=f}}})(this);(function(a){var b=a.fabric||(a.fabric={});if(b.Intersection){b.warn("fabric.Intersection is already defined");return}function c(d){if(arguments.length>0){this.init(d)}}b.Intersection=c;b.Intersection.prototype={init:function(d){this.status=d;this.points=[]},appendPoint:function(d){this.points.push(d)},appendPoints:function(d){this.points=this.points.concat(d)}};b.Intersection.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};b.Intersection.intersectLinePolygon=function(e,d,m){var n=new c("No Intersection"),f=m.length;for(var h=0;h0){n.status="Intersection"}return n};b.Intersection.intersectPolygonPolygon=function(k,h){var f=new c("No Intersection"),m=k.length;for(var l=0;l0){f.status="Intersection"}return f};b.Intersection.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}})(this);(function(a){var b=a.fabric||(a.fabric={});if(b.Color){b.warn("fabric.Color is already defined.");return}function c(d){if(!d){this.setSource([0,0,0,1])}else{this._tryParsingColor(d)}}b.Color=c;b.Color.prototype={_tryParsingColor:function(d){var e=c.sourceFromHex(d);if(!e){e=c.sourceFromRgb(d)}if(e){this.setSource(e)}},getSource:function(){return this._source},setSource:function(d){this._source=d},toRgb:function(){var d=this.getSource();return"rgb("+d[0]+","+d[1]+","+d[2]+")"},toRgba:function(){var d=this.getSource();return"rgba("+d[0]+","+d[1]+","+d[2]+","+d[3]+")"},toHex:function(){var h=this.getSource();var f=h[0].toString(16);f=(f.length==1)?("0"+f):f;var e=h[1].toString(16);e=(e.length==1)?("0"+e):e;var d=h[2].toString(16);d=(d.length==1)?("0"+d):d;return f.toUpperCase()+e.toUpperCase()+d.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(e){var d=this.getSource();d[3]=e;this.setSource(d);return this},toGrayscale:function(){var f=this.getSource(),e=parseInt((f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),10),d=f[3];this.setSource([e,e,e,d]);return this},toBlackWhite:function(d){var g=this.getSource(),f=(g[0]*0.3+g[1]*0.59+g[2]*0.11).toFixed(0),e=g[3],d=d||127;f=(Number(f)0)?0:-F),B.ey-((E>0)?0:-E),D,C);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(B.ex+d-((F>0)?0:D),B.ey+d-((E>0)?0:C),D,C)},_findSelectedObjects:function(H){var I,D,N=[],C=this._groupSelector.ex,M=this._groupSelector.ey,B=C+this._groupSelector.left,K=M+this._groupSelector.top,J,G=new fabric.Point(r(C,B),r(M,K)),L=new fabric.Point(u(C,B),u(M,K));for(var E=0,F=this._objects.length;E1){var N=new fabric.Group(N);this.setActiveGroup(N);N.saveCoords();A("group:selected",{target:N})}}this.renderAll()},add:function(){this._objects.push.apply(this._objects,arguments);for(var B=arguments.length;B--;){this.stateful&&arguments[B].setupState();arguments[B].setCoords()}this.renderOnAddition&&this.renderAll();return this},insertAt:function(C,B){this._objects.splice(B,0,C);this.stateful&&C.setupState();C.setCoords();this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop},clearContext:function(B){B.clearRect(0,0,this.width,this.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 H=this[C?"contextTop":"contextContainer"];this.clearContext(this.contextTop);if(!C){this.clearContext(H)}H.fillStyle=this.backgroundColor;H.fillRect(0,0,this.width,this.height);var G=this._objects.length,F=this.getActiveGroup(),E=new Date();if(this.clipTo){H.beginPath();this.clipTo(H);H.clip()}if(G){for(var D=0;D1){var P=new fabric.PathGroup(R,O)}else{var P=R[0]}P.setSourcePath(N);if(!(P instanceof fabric.PathGroup)){v(P,O);if(typeof O.angle!=="undefined"){P.setAngle(O.angle)}}G(P,M)})}}}},this)}catch(D){fabric.log(D.message)}},loadImageFromURL:(function(){var B={};return function(C,G){var F=this;function D(){var H=p.getElementById(B[C]);if(H.width&&H.height){G(new fabric.Image(H))}else{setTimeout(D,50)}}if(B[C]){D()}else{var E=new Image();E.onload=function(){E.onload=null;if(E.width&&E.height){G(new fabric.Image(E))}};E.className="canvas-img-clone";E.src=C;if(this.shouldCacheImages){B[C]=Element.identify(E)}p.body.appendChild(E)}}})(),loadSVGFromURL:function(B,E){var D=this;B=B.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(B,function(F){if(F){D.cache.get(B,function(H){var G=D._enlivenCachedObject(H);E(G.objects,G.options)})}else{new fabric.util.request(B,{method:"get",onComplete:C})}});function C(G){var F=G.responseXML;if(!F){return}var H=F.documentElement;if(!H){return}fabric.parseSVGDocument(H,function(J,I){D.cache.set(B,{objects:fabric.util.array.invoke(J,"toObject"),options:I});E(J,I)})}},_enlivenCachedObject:function(D){var C=D.objects,B=D.options;C=C.map(function(E){return fabric[k(E.type)].fromObject(E)});return({objects:C,options:B})},remove:function(B){m(this._objects,B);if(this.getActiveObject()===B){this.removeActiveObject()}this.renderAll();return B},fxRemove:function(B,D){var C=this;B.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){C.remove(B);if(typeof D==="function"){D()}}});return this},sendToBack:function(B){m(this._objects,B);this._objects.unshift(B);return this.renderAll()},bringToFront:function(B){m(this._objects,B);this._objects.push(B);return this.renderAll()},sendBackwards:function(D){var C=this._objects.indexOf(D),B=C;if(C!==0){for(var E=C-1;E>=0;--E){if(D.intersectsWithObject(this._objects[E])){B=E;break}}m(this._objects,D);this._objects.splice(B,0,D)}return this.renderAll()},bringForward:function(E){var G=this.getObjects(),C=G.indexOf(E),B=C;if(C!==G.length-1){for(var F=C+1,D=this._objects.length;F"};v(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(E){var D=E.getContext("2d"),I=D.getImageData(0,0,E.width,E.height),G=I.data,B=I.width,H=I.height,C,F;for(i=0;i1)?m.apply(this,h.call(arguments,1)):m.call(this)},initialize:function(l){l&&this.setOptions(l)},setOptions:function(l){var m=this.stateProperties.length,n;while(m--){n=this.stateProperties[m];if(n in l){(n==="angle")?this.setAngle(l[n]):(this[n]=l[n])}}},transform:function(l){l.globalAlpha=this.opacity;l.translate(this.left,this.top);l.rotate(this.theta);l.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toObject:function(){var l={type:this.type,left:c(this.left,this.NUM_FRACTION_DIGITS),top:c(this.top,this.NUM_FRACTION_DIGITS),width:c(this.width,this.NUM_FRACTION_DIGITS),height:c(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,scaleX:c(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:c(this.scaleY,this.NUM_FRACTION_DIGITS),angle:c(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:c(this.opacity,this.NUM_FRACTION_DIGITS)};if(!this.includeDefaultValues){l=this._removeDefaultValues(l)}return l},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(m){var l=d.Object.prototype.options;if(l){this.stateProperties.forEach(function(n){if(m[n]===l[n]){delete m[n]}})}return m},isActive:function(){return !!this.active},setActive:function(l){this.active=!!l;return this},toString:function(){return"#"},set:function(m,l){var n=(m==="scaleX"||m==="scaleY")&&ln.x&&o.xn.y&&q.y=r)&&(o.d.y>=r)){continue}if((o.o.x==o.d.x)&&(o.o.x>=s)){t=o.o.x;q=r}else{v=0;u=(o.d.y-o.o.y)/(o.d.x-o.o.x);n=r-v*s;m=o.o.y-u*o.o.x;t=-(n-m)/(v-u);q=n+v*t}if(t>=s){p+=1}if(p==2){break}}return p},_getImageLines:function(m,l){return{topline:{o:m.tl,d:m.tr},rightline:{o:m.tr,d:m.br},bottomline:{o:m.br,d:m.bl},leftline:{o:m.bl,d:m.tl}}},_setCornerCoords:function(){var p=this.oCoords,m=b(45-this.getAngle()),o=Math.sqrt(2*Math.pow(this.cornersize,2))/2,l=o*Math.cos(m),n=o*Math.sin(m);p.tl.corner={tl:{x:p.tl.x-n,y:p.tl.y-l},tr:{x:p.tl.x+l,y:p.tl.y-n},bl:{x:p.tl.x-l,y:p.tl.y+n},br:{x:p.tl.x+n,y:p.tl.y+l}};p.tr.corner={tl:{x:p.tr.x-n,y:p.tr.y-l},tr:{x:p.tr.x+l,y:p.tr.y-n},br:{x:p.tr.x+n,y:p.tr.y+l},bl:{x:p.tr.x-l,y:p.tr.y+n}};p.bl.corner={tl:{x:p.bl.x-n,y:p.bl.y-l},bl:{x:p.bl.x-l,y:p.bl.y+n},br:{x:p.bl.x+n,y:p.bl.y+l},tr:{x:p.bl.x+l,y:p.bl.y-n}};p.br.corner={tr:{x:p.br.x+l,y:p.br.y-n},bl:{x:p.br.x-l,y:p.br.y+n},br:{x:p.br.x+n,y:p.br.y+l},tl:{x:p.br.x-n,y:p.br.y-l}};p.ml.corner={tl:{x:p.ml.x-n,y:p.ml.y-l},tr:{x:p.ml.x+l,y:p.ml.y-n},bl:{x:p.ml.x-l,y:p.ml.y+n},br:{x:p.ml.x+n,y:p.ml.y+l}};p.mt.corner={tl:{x:p.mt.x-n,y:p.mt.y-l},tr:{x:p.mt.x+l,y:p.mt.y-n},bl:{x:p.mt.x-l,y:p.mt.y+n},br:{x:p.mt.x+n,y:p.mt.y+l}};p.mr.corner={tl:{x:p.mr.x-n,y:p.mr.y-l},tr:{x:p.mr.x+l,y:p.mr.y-n},bl:{x:p.mr.x-l,y:p.mr.y+n},br:{x:p.mr.x+n,y:p.mr.y+l}};p.mb.corner={tl:{x:p.mb.x-n,y:p.mb.y-l},tr:{x:p.mb.x+l,y:p.mb.y-n},bl:{x:p.mb.x-l,y:p.mb.y+n},br:{x:p.mb.x+n,y:p.mb.y+l}}},toGrayscale:function(){var l=this.get("fill");if(l){this.set("overlayFill",new d.Color(l).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 l=this._getAngleValueForStraighten();this.setAngle(l);return this},fxStraighten:function(m){m=m||{};var n=function(){},o=m.onComplete||n,l=m.onChange||n,p=this;d.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(q){p.setAngle(q);l()},onComplete:function(){p.setCoords();o()},onStart:function(){p.setActive(false)}});return this},fxRemove:function(m){m||(m={});var n=function(){},o=m.onComplete||n,l=m.onChange||n,p=this;d.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(q){p.set("opacity",q);l()},onComplete:o,onStart:function(){p.setActive(false)}});return this},_getAngleValueForStraighten:function(){var l=this.get("angle");if(l>-225&&l<=-135){return -180}else{if(l>-135&&l<=-45){return -90}else{if(l>-45&&l<=45){return 0}else{if(l>45&&l<=135){return 90}else{if(l>135&&l<=225){return 180}else{if(l>225&&l<=315){return 270}else{if(l>315){return 360}}}}}}}return 0},toJSON:function(){return this.toObject()},setGradientFill:function(l,m){this.set("fill",d.Gradient.forObject(this,l,m))}});d.Object.prototype.rotate=d.Object.prototype.setAngle})(this);(function(a){var b=a.fabric||(a.fabric={}),c=b.util.object.extend;if(b.Line){b.warn("fabric.Line is already defined");return}b.Line=b.util.createClass(b.Object,{type:"line",initialize:function(e,d){if(!e){e=[0,0,0,0]}this.callSuper("initialize",d);this.set("x1",e[0]);this.set("y1",e[1]);this.set("x2",e[2]);this.set("y2",e[3]);this.set("width",(this.x2-this.x1)||1);this.set("height",(this.y2-this.y1)||1);this.set("left",this.x1+this.width/2);this.set("top",this.y1+this.height/2)},_render:function(d){d.beginPath();d.moveTo(-this.width/2,-this.height/2);d.lineTo(this.width/2,this.height/2);var e=d.strokeStyle;d.strokeStyle=d.fillStyle;d.stroke();d.strokeStyle=e},complexity:function(){return 1},toObject:function(){return c(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});b.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");b.Line.fromElement=function(e,d){var g=b.parseAttributes(e,b.Line.ATTRIBUTE_NAMES);var f=[g.x1||0,g.y1||0,g.x2||0,g.y2||0];return new b.Line(f,c(g,d))};b.Line.fromObject=function(d){var e=[d.x1,d.y1,d.x2,d.y2];return new b.Line(e,d)}})(this);(function(a){var b=a.fabric||(a.fabric={}),d=Math.PI*2,e=b.util.object.extend;if(b.Circle){b.warn("fabric.Circle is already defined.");return}b.Circle=b.util.createClass(b.Object,{type:"circle",initialize:function(f){f=f||{};this.set("radius",f.radius||0);this.callSuper("initialize",f);var g=this.get("radius")*2*this.get("scaleX");this.set("width",g).set("height",g)},toObject:function(){return e(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(f,g){f.beginPath();f.arc(g?this.left:0,g?this.top:0,this.radius,0,d,false);f.closePath();if(this.fill){f.fill()}if(this.stroke){f.stroke()}},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},complexity:function(){return 1}});b.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");b.Circle.fromElement=function(g,f){f||(f={});var h=b.parseAttributes(g,b.Circle.ATTRIBUTE_NAMES);if(!c(h)){throw Error("value of `r` attribute is required and can not be negative")}if("left" in h){h.left-=(f.width/2)||0}if("top" in h){h.top-=(f.height/2)||0}return new b.Circle(e(h,f))};function c(f){return(("radius" in f)&&(f.radius>0))}b.Circle.fromObject=function(f){return new b.Circle(f)}})(this);(function(a){var b=a.fabric||(a.fabric={});if(b.Triangle){b.warn("fabric.Triangle is already defined");return}b.Triangle=b.util.createClass(b.Object,{type:"triangle",initialize:function(c){c=c||{};this.callSuper("initialize",c);this.set("width",c.width||100).set("height",c.height||100)},_render:function(c){var d=this.width/2,e=this.height/2;c.beginPath();c.moveTo(-d,e);c.lineTo(0,-e);c.lineTo(d,e);c.closePath();if(this.fill){c.fill()}if(this.stroke){c.stroke()}},complexity:function(){return 1}});b.Triangle.fromObject=function(c){return new b.Triangle(c)}})(this);(function(a){var b=a.fabric||(a.fabric={}),c=Math.PI*2,d=b.util.object.extend;if(b.Ellipse){b.warn("fabric.Ellipse is already defined.");return}b.Ellipse=b.util.createClass(b.Object,{type:"ellipse",initialize:function(e){e=e||{};this.callSuper("initialize",e);this.set("rx",e.rx||0);this.set("ry",e.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return d(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(e,f){if(this.rx===0||this.ry===0){return}return this.callSuper("render",e,f)},_render:function(e,f){e.beginPath();e.save();e.transform(1,0,0,this.ry/this.rx,0,0);e.arc(f?this.left:0,f?this.top:0,this.rx,0,c,false);e.restore();if(this.stroke){e.stroke()}if(this.fill){e.fill()}},complexity:function(){return 1}});b.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");b.Ellipse.fromElement=function(f,e){e||(e={});var g=b.parseAttributes(f,b.Ellipse.ATTRIBUTE_NAMES);if("left" in g){g.left-=(e.width/2)||0}if("top" in g){g.top-=(e.height/2)||0}return new b.Ellipse(d(g,e))};b.Ellipse.fromObject=function(e){return new b.Ellipse(e)}})(this);(function(b){var c=b.fabric||(b.fabric={});if(c.Rect){console.warn("fabric.Rect is already defined");return}c.Rect=c.util.createClass(c.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(d){this._initStateProperties();this.callSuper("initialize",d);this._initRxRy()},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat(["rx","ry"])},_initRxRy:function(){if(this.rx&&!this.ry){this.ry=this.rx}else{if(this.ry&&!this.rx){this.rx=this.ry}}},_render:function(f){var l=this.rx||0,k=this.ry||0,d=-this.width/2,m=-this.height/2,e=this.width,g=this.height;f.beginPath();f.moveTo(d+l,m);f.lineTo(d+e-l,m);f.bezierCurveTo(d+e,m,d+e,m+k,d+e,m+k);f.lineTo(d+e,m+g-k);f.bezierCurveTo(d+e,m+g,d+e-l,m+g,d+e-l,m+g);f.lineTo(d+l,m+g);f.bezierCurveTo(d,m+g,d,m+g-k,d,m+g-k);f.lineTo(d,m+k);f.bezierCurveTo(d,m,d+l,m,d+l,m);f.closePath();if(this.fill){f.fill()}if(this.stroke){f.stroke()}},_normalizeLeftTopProperties:function(d){if(d.left){this.set("left",d.left+this.getWidth()/2)}if(d.top){this.set("top",d.top+this.getHeight()/2)}return this},complexity:function(){return 1}});c.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");function a(d){d.left=d.left||0;d.top=d.top||0;return d}c.Rect.fromElement=function(e,d){if(!e){return null}var g=c.parseAttributes(e,c.Rect.ATTRIBUTE_NAMES);g=a(g);var f=new c.Rect(c.util.object.extend((d?c.util.object.clone(d):{}),g));f._normalizeLeftTopProperties(g);return f};c.Rect.fromObject=function(d){return new c.Rect(d)}})(this);(function(a){var b=a.fabric||(a.fabric={});if(b.Polyline){b.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)},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 k=h(this.callSuper("toObject"),{path:this.path});if(this.sourcePath){k.sourcePath=this.sourcePath}if(this.transformMatrix){k.transformMatrix=this.transformMatrix}return k},toDatalessObject:function(){var k=this.toObject();if(this.sourcePath){k.path=this.sourcePath}delete k.sourcePath;return k},complexity:function(){return this.path.length},_parsePath:function(){var l=[],p,q;for(var o=0,m,n,k=this.path.length;o"},isSameColor:function(){var l=this.getObjects()[0].get("fill");return this.getObjects().every(function(m){return m.get("fill")===l})},complexity:function(){return this.paths.reduce(function(l,m){return l+((m&&m.complexity)?m.complexity():0)},0)},toGrayscale:function(){var l=this.paths.length;while(l--){this.paths[l].toGrayscale()}return this},getObjects:function(){return this.paths}});function c(o){for(var n=0,l=o.length;n"},getObjects:function(){return this.objects},add:function(h){this._restoreObjectsState();this.objects.push(h);h.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(h){this._restoreObjectsState();f(this.objects,h);h.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(h,l){if(typeof l=="function"){this.set(h,l(this[h]))}else{if(h==="fill"||h==="opacity"){var k=this.objects.length;this[h]=l;while(k--){this.objects[k].set(h,l)}}else{this[h]=l}}return this},contains:function(h){return this.objects.indexOf(h)>-1},toObject:function(){return g(this.callSuper("toObject"),{objects:b(this.objects,"clone")})},render:function(k){k.save();this.transform(k);var o=Math.max(this.scaleX,this.scaleY);for(var m=0,h=this.objects.length,l;l=this.objects[m];m++){var n=l.borderScaleFactor;l.borderScaleFactor=o;l.render(k);l.borderScaleFactor=n}this.hideBorders||this.drawBorders(k);this.hideCorners||this.drawCorners(k);k.restore();this.setCoords()},item:function(h){return this.getObjects()[h]},complexity:function(){return this.getObjects().reduce(function(k,h){k+=(typeof h.complexity=="function")?h.complexity():0;return k},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,this);return this},_restoreObjectState:function(l){var n=this.get("left"),o=this.get("top"),h=this.getAngle()*(Math.PI/180),m=l.get("originalLeft"),p=l.get("originalTop"),k=Math.cos(h)*l.get("top")+Math.sin(h)*l.get("left"),q=-Math.sin(h)*l.get("top")+Math.cos(h)*l.get("left");l.setAngle(l.getAngle()+this.getAngle());l.set("left",n+q*this.get("scaleX"));l.set("top",o+k*this.get("scaleY"));l.set("scaleX",l.get("scaleX")*this.get("scaleX"));l.set("scaleY",l.get("scaleY")*this.get("scaleY"));l.setCoords();l.hideCorners=false;l.setActive(false);l.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(h){h.setCoords()});return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(h){this.forEachObject(function(k){k.setActive(h)});return this},forEachObject:function(m,k){var l=this.getObjects(),h=l.length;while(h--){m.call(k,l[h],h,l)}return this},_setOpacityIfSame:function(){var l=this.getObjects(),k=l[0]?l[0].get("opacity"):1;var h=l.every(function(m){return m.get("opacity")===k});if(h){this.opacity=k}},_calcBounds:function(){var t=[],r=[],q,p,l,h,n,m,v,s=0,u=this.objects.length;for(;sk.x&&l-hk.y},toGrayscale:function(){var h=this.objects.length;while(h--){this.objects[h].toGrayscale()}}});e.Group.fromObject=function(h){return new e.Group(h.objects,h)}})(this);(function(a){var b=a.fabric||(a.fabric={}),d=b.util.object.extend,c=b.util.object.clone;if(b.Text){b.warn("fabric.Text is already defined");return}if(!b.Object){b.warn("fabric.Text requires fabric.Object");return}b.Text=b.util.createClass(b.Object,{fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",textDecoration:"",textShadow:null,fontStyle:"",lineHeight:1,strokeStyle:"",strokeWidth:1,path:null,type:"text",initialize:function(f,e){this._initStateProperties();this.text=f;this.setOptions(e);this.theta=this.angle*Math.PI/180;this.width=this.getWidth();this.setCoords()},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat();this.stateProperties.push("fontfamily","fontweight","path","text","textDecoration","textShadow","fontStyle","lineHeight","strokeStyle","strokeWidth");b.util.removeFromArray(this.stateProperties,"width")},toString:function(){return"#"},_render:function(e){var g=Cufon.textOptions||(Cufon.textOptions={});g.left=this.left;g.top=this.top;g.context=e;g.color=this.fill;var f=this._initDummyElement();this.transform(e);Cufon.replaceElement(f,{separate:"none",fontFamily:this.fontfamily,enableTextDecoration:true,textDecoration:this.textDecoration,textShadow:this.textShadow,fontStyle:this.fontStyle,lineHeight:this.lineHeight,strokeStyle:this.strokeStyle,strokeWidth:this.strokeWidth});this.width=g.width;this.height=g.height;this.setCoords()},_initDummyElement:function(){var f=document.createElement("div"),e=document.createElement("div");e.appendChild(f);f.innerHTML=this.text;f.style.fontSize="40px";f.style.fontWeight="400";f.style.letterSpacing="normal";f.style.color="#000000";f.style.fontWeight="600";f.style.fontFamily="Verdana";return f},render:function(e){e.save();this._render(e);if(this.active){this.drawBorders(e);this.drawCorners(e)}e.restore()},toObject:function(){return d(this.callSuper("toObject"),{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,fontStyle:this.fontStyle,lineHeight:this.lineHeight,textDecoration:this.textDecoration,textShadow:this.textShadow,path:this.path,strokeStyle:this.strokeStyle,strokeWidth:this.strokeWidth})},setColor:function(e){this.set("fill",e);return this},setFontsize:function(e){this.set("fontsize",e);this.setCoords();return this},getText:function(){return this.text},setText:function(e){this.set("text",e);this.setCoords();return this},set:function(e,f){this[e]=f;if(e==="fontfamily"){this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+f+"$3")}return this}});b.Text.fromObject=function(e){return new b.Text(e.text,c(e))};b.Text.fromElement=function(e){}})(this);(function(a){var b=fabric.util.object.extend;if(!a.fabric){a.fabric={}}if(a.fabric.Image){fabric.warn("fabric.Image is already defined.");return}if(!fabric.Object){fabric.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(d,c){this.callSuper("initialize",c);this._initElement(d);this._initConfig(c||{})},getElement:function(){return this._element},setElement:function(c){this._element=c;return this},getNormalizedSize:function(d,c,e){if(e&&c&&(d.width>d.height&&(d.width/d.height)<(c/e))){normalizedWidth=~~((d.width*e)/d.height);normalizedHeight=e}else{if(e&&((d.height==d.width)||(d.height>d.width)||(d.height>e))){normalizedWidth=~~((d.width*e)/d.height);normalizedHeight=e}else{if(c&&(c'},clone:function(c){this.constructor.fromObject(this.toObject(),c)},toGrayscale:function(g){if(this.__isGrayscaled){return}var e=this.getElement(),c=document.createElement("canvas"),d=document.createElement("img"),f=this;c.width=e.width;c.height=e.height;c.getContext("2d").drawImage(e,0,0);fabric.Element.toGrayscale(c);d.onload=function(){f.setElement(d);g&&g();d.onload=c=e=imageData=null};d.width=e.width;d.height=e.height;d.src=c.toDataURL("image/png");this.__isGrayscaled=true;return this},_render:function(d){var c=this.getOriginalSize();d.drawImage(this.getElement(),-c.width/2,-c.height/2,c.width,c.height)},_adjustWidthHeightToBorders:function(c){if(c){this.currentBorder=this.borderwidth;this.width+=(2*this.currentBorder);this.height+=(2*this.currentBorder)}else{this.currentBorder=0}},_resetWidthHeight:function(){var c=this.getElement();this.set("width",c.width);this.set("height",c.height)},_initElement:function(c){this.setElement(fabric.util.getById(c));fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(c){this.setOptions(c);this._setBorder();this._setWidthHeight(c)},_setBorder:function(){if(this.bordervisibility){this.currentBorder=this.borderwidth}else{this.currentBorder=0}},_setWidthHeight:function(c){var d=2*this.currentBorder;this.width=(this.getElement().width||0)+d;this.height=(this.getElement().height||0)+d},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(d,f){var c=document.createElement("img"),e=d.src;if(d.width){c.width=d.width}if(d.height){c.height=d.height}c.onload=function(){if(f){f(new fabric.Image(c,d))}c=c.onload=null};c.src=e};fabric.Image.fromURL=function(d,f,e){var c=document.createElement("img");c.onload=function(){if(f){f(new fabric.Image(c,e))}c=c.onload=null};c.src=d};fabric.Image.ATTRIBUTE_NAMES="x y width height fill fill-opacity stroke stroke-width transform xlink:href".split(" ");fabric.Image.fromElement=function(d,f,c){c||(c={});var e=fabric.parseAttributes(d,fabric.Image.ATTRIBUTE_NAMES);fabric.Image.fromURL(e["xlink:href"],f,b(e,c))};fabric.Image.fromElement.async=true})(this); \ No newline at end of file diff --git a/test/demo/index.html b/test/demo/index.html index 649754ea..958139ef 100644 --- a/test/demo/index.html +++ b/test/demo/index.html @@ -10,7 +10,7 @@ - + @@ -20,6 +20,10 @@

Demo of a Fabric.js — interactive object model on top of canvas element. + + + Flattr this +