From: Dmitry Baranovskiy Date: Thu, 18 Mar 2010 22:19:19 +0000 (+1100) Subject: 1.3.2 X-Git-Tag: v1.3.2~1^2 X-Git-Url: http://git.roojs.org/?p=raphael;a=commitdiff_plain;h=7d132c6d7c8f4c65d9875e551e72197ed70fc10c 1.3.2 • fixed hsb2rgb & rgb2hsb caching • Dramatically improved path rendering in IE • Fixed scale issues • Fixed getPointAtLength --- diff --git a/raphael-min.js b/raphael-min.js index a9ba36d..01a448f 100644 --- a/raphael-min.js +++ b/raphael-min.js @@ -4,4 +4,4 @@ * Copyright (c) 2009 Dmitry Baranovskiy (http://raphaeljs.com) * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. */ -Raphael=(function(){var a=/[, ]+/,aS=/^(circle|rect|path|ellipse|text|image)$/,T="hasOwnProperty",M=document,ax=window,l={was:ax[T]("Raphael"),is:ax.Raphael},ap=function(){if(ap.is(arguments[0],"array")){var d=arguments[0],e=w[a0](ap,d.splice(0,3+ap.is(d[0],am))),S=e.set();for(var R=0,a5=d[m];R

";if(ah.childNodes[m]!=2){return null;}}ap.svg=!(ap.vml=ap.type=="VML");aX[a2]=ap[a2];ap._id=0;ap._oid=0;ap.fn={};ap.is=function(e,d){d=a4.call(d);return((d=="object"||d=="undefined")&&typeof e==d)||(e==null&&d=="null")||a4.call(aA.call(e).slice(8,-1))==d;};ap.setWindow=function(d){ax=d;M=ax.document;};var aH=function(e){if(ap.vml){var d=/^\s+|\s+$/g;aH=ak(function(R){var S;R=(R+aw)[aT](d,aw);try{var a5=new ActiveXObject("htmlfile");a5.write("");a5.close();S=a5.body;}catch(a7){S=createPopup().document.body;}var i=S.createTextRange();try{S.style.color=R;var a6=i.queryCommandValue("ForeColor");a6=((a6&255)<<16)|(a6&65280)|((a6&16711680)>>>16);return"#"+("000000"+a6[aE](16)).slice(-6);}catch(a7){return"none";}});}else{var E=M.createElement("i");E.title="Rapha\xebl Colour Picker";E.style.display="none";M.body[aP](E);aH=ak(function(i){E.style.color=i;return M.defaultView.getComputedStyle(E,aw).getPropertyValue("color");});}return aH(e);};ap.hsb2rgb=ak(function(a8,a6,bc){if(ap.is(a8,"object")&&"h" in a8&&"s" in a8&&"b" in a8){bc=a8.b;a6=a8.s;a8=a8.h;}var R,S,bd;if(bc==0){return{r:0,g:0,b:0,hex:"#000"};}if(a8>1||a6>1||bc>1){a8/=255;a6/=255;bc/=255;}var a5=~~(a8*6),a9=(a8*6)-a5,E=bc*(1-a6),e=bc*(1-(a6*a9)),be=bc*(1-(a6*(1-a9)));R=[bc,e,E,E,be,bc,bc][a5];S=[be,bc,bc,e,E,E,be][a5];bd=[E,E,be,bc,bc,e,E][a5];R*=255;S*=255;bd*=255;var ba={r:R,g:S,b:bd},d=(~~R)[aE](16),a7=(~~S)[aE](16),bb=(~~bd)[aE](16);d=d[aT](aY,"0");a7=a7[aT](aY,"0");bb=bb[aT](aY,"0");ba.hex="#"+d+a7+bb;return ba;},ap);ap.rgb2hsb=ak(function(d,e,a6){if(ap.is(d,"object")&&"r" in d&&"g" in d&&"b" in d){a6=d.b;e=d.g;d=d.r;}if(ap.is(d,"string")){var a8=ap.getRGB(d);d=a8.r;e=a8.g;a6=a8.b;}if(d>1||e>1||a6>1){d/=255;e/=255;a6/=255;}var a5=g(d,e,a6),i=aM(d,e,a6),R,E,S=a5;if(i==a5){return{h:0,s:0,b:a5};}else{var a7=(a5-i);E=a7/a5;if(d==a5){R=(e-a6)/a7;}else{if(e==a5){R=2+((a6-d)/a7);}else{R=4+((d-e)/a7);}}R/=6;R<0&&R++;R>1&&R--;}return{h:R,s:E,b:S};},ap);var aI=/,?([achlmqrstvxz]),?/gi;ap._path2string=function(){return this.join(",")[aT](aI,"$1");};function ak(E,e,d){function i(){var R=Array[a2].slice.call(arguments,0),a5=R[aD]("\u25ba"),S=i.cache=i.cache||{},a6=i.count=i.count||[];if(S[T](a5)){return d?d(S[a5]):S[a5];}a6[m]>=1000&&delete S[a6.shift()];a6[f](a5);S[a5]=E[a0](e,R);return d?d(S[a5]):S[a5];}return i;}ap.getRGB=ak(function(d){if(!d||!!((d=d+aw).indexOf("-")+1)){return{r:-1,g:-1,b:-1,hex:"none",error:1};}if(d=="none"){return{r:-1,g:-1,b:-1,hex:"none"};}!(({hs:1,rg:1})[T](d.substring(0,2))||d.charAt()=="#")&&(d=aH(d));var S,i,E,a7,a8,a5=d.match(x);if(a5){if(a5[2]){a7=H(a5[2].substring(5),16);E=H(a5[2].substring(3,5),16);i=H(a5[2].substring(1,3),16);}if(a5[3]){a7=H((a8=a5[3].charAt(3))+a8,16);E=H((a8=a5[3].charAt(2))+a8,16);i=H((a8=a5[3].charAt(1))+a8,16);}if(a5[4]){a5=a5[4][z](/\s*,\s*/);i=X(a5[0]);E=X(a5[1]);a7=X(a5[2]);}if(a5[5]){a5=a5[5][z](/\s*,\s*/);i=X(a5[0])*2.55;E=X(a5[1])*2.55;a7=X(a5[2])*2.55;}if(a5[6]){a5=a5[6][z](/\s*,\s*/);i=X(a5[0]);E=X(a5[1]);a7=X(a5[2]);return ap.hsb2rgb(i,E,a7);}if(a5[7]){a5=a5[7][z](/\s*,\s*/);i=X(a5[0])*2.55;E=X(a5[1])*2.55;a7=X(a5[2])*2.55;return ap.hsb2rgb(i,E,a7);}a5={r:i,g:E,b:a7};var e=(~~i)[aE](16),R=(~~E)[aE](16),a6=(~~a7)[aE](16);e=e[aT](aY,"0");R=R[aT](aY,"0");a6=a6[aT](aY,"0");a5.hex="#"+e+R+a6;return a5;}return{r:-1,g:-1,b:-1,hex:"none",error:1};},ap);ap.getColor=function(e){var i=this.getColor.start=this.getColor.start||{h:0,s:1,b:e||0.75},d=this.hsb2rgb(i.h,i.s,i.b);i.h+=0.075;if(i.h>1){i.h=0;i.s-=0.2;i.s<=0&&(this.getColor.start={h:0,s:1,b:i.b});}return d.hex;};ap.getColor.reset=function(){delete this.start;};var ay=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,an=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig;ap.parsePathString=ak(function(d){if(!d){return null;}var i={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},e=[];if(ap.is(d,"array")&&ap.is(d[0],"array")){e=az(d);}if(!e[m]){(d+aw)[aT](ay,function(R,E,a6){var a5=[],S=a4.call(E);a6[aT](an,function(a8,a7){a7&&a5[f](+a7);});if(S=="m"&&a5[m]>2){e[f]([E][aW](a5.splice(0,2)));S="l";E=E=="m"?"l":"L";}while(a5[m]>=i[S]){e[f]([E][aW](a5.splice(0,i[S])));if(!i[S]){break;}}});}e[aE]=ap._path2string;return e;});ap.findDotsAtSegment=function(e,d,bj,bh,a5,R,a7,a6,bd){var bb=1-bd,ba=aQ(bb,3)*e+aQ(bb,2)*3*bd*bj+bb*3*bd*bd*a5+aQ(bd,3)*a7,a8=aQ(bb,3)*d+aQ(bb,2)*3*bd*bh+bb*3*bd*bd*R+aQ(bd,3)*a6,bf=e+2*bd*(bj-e)+bd*bd*(a5-2*bj+e),be=d+2*bd*(bh-d)+bd*bd*(R-2*bh+d),bi=bj+2*bd*(a5-bj)+bd*bd*(a7-2*a5+bj),bg=bh+2*bd*(R-bh)+bd*bd*(a6-2*R+bh),bc=(1-bd)*e+bd*bj,a9=(1-bd)*d+bd*bh,E=(1-bd)*a5+bd*a7,i=(1-bd)*R+bd*a6,S=(90-ac.atan((bf-bi)/(be-bg))*180/ac.PI);(bf>bi||be1){bD=ac.sqrt(bD);bn=bD*bn;bl=bD*bl;}var E=bn*bn,bw=bl*bl,by=(a9==S?-1:1)*ac.sqrt(ac.abs((E*bw-E*bs*bs-bw*bt*bt)/(E*bs*bs+bw*bt*bt))),bi=by*bn*bs/bl+(be+bd)/2,bh=by*-bl*bt/bn+(bJ+bI)/2,a8=ac.asin(((bJ-bh)/bl).toFixed(7)),a7=ac.asin(((bI-bh)/bl).toFixed(7));a8=bea7){a8=a8-R*2;}if(!S&&a7>a8){a7=a7-R*2;}}else{a8=bg[0];a7=bg[1];bi=bg[2];bh=bg[3];}var bc=a7-a8;if(ac.abs(bc)>bk){var bj=a7,bm=bd,ba=bI;a7=a8+bk*(S&&a7>a8?1:-1);bd=bi+bn*ac.cos(a7);bI=bh+bl*ac.sin(a7);br=L(bd,bI,bn,bl,bf,0,S,bm,ba,[a7,bj,bi,bh]);}bc=a7-a8;var a6=ac.cos(a8),bH=ac.sin(a8),a5=ac.cos(a7),bG=ac.sin(a7),bu=ac.tan(bc/4),bx=4/3*bn*bu,bv=4/3*bl*bu,bE=[be,bJ],bC=[be+bx*bH,bJ-bv*a6],bB=[bd+bx*bG,bI-bv*a5],bz=[bd,bI];bC[0]=2*bE[0]-bC[0];bC[1]=2*bE[1]-bC[1];if(bg){return[bC,bB,bz][aW](br);}else{br=[bC,bB,bz][aW](br)[aD]()[z](",");var bp=[];for(var bA=0,bq=br[m];bA1000000000000&&(a5=0.5);ac.abs(S)>1000000000000&&(S=0.5);if(a5>0&&a5<1){e=N(i,d,R,E,be,bd,ba,a7,a5);bb[f](e.x);a8[f](e.y);}if(S>0&&S<1){e=N(i,d,R,E,be,bd,ba,a7,S);bb[f](e.x);a8[f](e.y);}bc=(bd-2*E+d)-(a7-2*bd+E);a9=2*(E-d)-2*(bd-E);a6=d-E;a5=(-a9+ac.sqrt(a9*a9-4*bc*a6))/2/bc;S=(-a9-ac.sqrt(a9*a9-4*bc*a6))/2/bc;ac.abs(a5)>1000000000000&&(a5=0.5);ac.abs(S)>1000000000000&&(S=0.5);if(a5>0&&a5<1){e=N(i,d,R,E,be,bd,ba,a7,a5);bb[f](e.x);a8[f](e.y);}if(S>0&&S<1){e=N(i,d,R,E,be,bd,ba,a7,S);bb[f](e.x);a8[f](e.y);}return{min:{x:aM[a0](0,bb),y:aM[a0](0,a8)},max:{x:g[a0](0,bb),y:g[a0](0,a8)}};}),I=ak(function(be,a9){var R=r(be),ba=a9&&r(a9),bb={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},d={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},a5=function(bf,bg){var i,bh;if(!bf){return["C",bg.x,bg.y,bg.x,bg.y,bg.x,bg.y];}!(bf[0] in {T:1,Q:1})&&(bg.qx=bg.qy=null);switch(bf[0]){case"M":bg.X=bf[1];bg.Y=bf[2];break;case"A":bf=["C"][aW](L[a0](0,[bg.x,bg.y][aW](bf.slice(1))));break;case"S":i=bg.x+(bg.x-(bg.bx||bg.x));bh=bg.y+(bg.y-(bg.by||bg.y));bf=["C",i,bh][aW](bf.slice(1));break;case"T":bg.qx=bg.x+(bg.x-(bg.qx||bg.x));bg.qy=bg.y+(bg.y-(bg.qy||bg.y));bf=["C"][aW](aO(bg.x,bg.y,bg.qx,bg.qy,bf[1],bf[2]));break;case"Q":bg.qx=bf[1];bg.qy=bf[2];bf=["C"][aW](aO(bg.x,bg.y,bf[1],bf[2],bf[3],bf[4]));break;case"L":bf=["C"][aW](a1(bg.x,bg.y,bf[1],bf[2]));break;case"H":bf=["C"][aW](a1(bg.x,bg.y,bf[1],bg.y));break;case"V":bf=["C"][aW](a1(bg.x,bg.y,bg.x,bf[1]));break;case"Z":bf=["C"][aW](a1(bg.x,bg.y,bg.X,bg.Y));break;}return bf;},e=function(bf,bg){if(bf[bg][m]>7){bf[bg].shift();var bh=bf[bg];while(bh[m]){bf.splice(bg++,0,["C"][aW](bh.splice(0,6)));}bf.splice(bg,1);bc=g(R[m],ba&&ba[m]||0);}},E=function(bj,bi,bg,bf,bh){if(bj&&bi&&bj[bh][0]=="M"&&bi[bh][0]!="M"){bi.splice(bh,0,["M",bf.x,bf.y]);bg.bx=0;bg.by=0;bg.x=bj[bh][1];bg.y=bj[bh][2];bc=g(R[m],ba&&ba[m]||0);}};for(var a7=0,bc=g(R[m],ba&&ba[m]||0);a73){return{container:1,x:arguments[0],y:arguments[1],width:arguments[2],height:arguments[3]};}}},aK=function(d,i){var e=this;for(var E in i){if(i[T](E)&&!(E in d)){switch(typeof i[E]){case"function":(function(R){d[E]=d===e?R:function(){return R[a0](e,arguments);};})(i[E]);break;case"object":d[E]=d[E]||{};aK.call(this,d[E],i[E]);break;default:d[E]=i[E];break;}}}},al=function(d,e){d==e.top&&(e.top=d.prev);d==e.bottom&&(e.bottom=d.next);d.next&&(d.next.prev=d.prev);d.prev&&(d.prev.next=d.next);},Z=function(d,e){if(e.top===d){return;}al(d,e);d.next=null;d.prev=e.top;e.top.next=d;e.top=d;},k=function(d,e){if(e.bottom===d){return;}al(d,e);d.next=e.bottom;d.prev=null;e.bottom.prev=d;e.bottom=d;},A=function(e,d,i){al(e,i);d==i.top&&(i.top=e);d.next&&(d.next.prev=e);e.next=d.next;e.prev=d;d.next=e;},at=function(e,d,i){al(e,i);d==i.bottom&&(i.bottom=e);d.prev&&(d.prev.next=e);e.prev=d.prev;d.prev=e;e.next=d;},s=function(d){return function(){throw new Error("Rapha\xebl: you are calling to method \u201c"+d+"\u201d of removed object");};},av=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/;if(ap.svg){aX[a2].svgns="http://www.w3.org/2000/svg";aX[a2].xlink="http://www.w3.org/1999/xlink";var P=function(d){return +d+(~~d===d)*0.5;},W=function(S){for(var e=0,E=S[m];e0.5)*2-1);aQ(a6-0.5,2)+aQ(S-0.5,2)>0.25&&(S=ac.sqrt(0.25-aQ(a6-0.5,2))*bf+0.5)&&S!=0.5&&(S=S.toFixed(5)-0.00001*bf);}return aw;});bc=bc[z](/\s*\-\s*/);if(a9=="linear"){var a5=bc.shift();a5=-X(a5);if(isNaN(a5)){return null;}var R=[0,0,ac.cos(a5*ac.PI/180),ac.sin(a5*ac.PI/180)],bb=1/(g(ac.abs(R[2]),ac.abs(R[3]))||1);R[2]*=bb;R[3]*=bb;if(R[2]<0){R[0]=-R[2];R[2]=0;}if(R[3]<0){R[1]=-R[3];R[3]=0;}}var a8=p(bc);if(!a8){return null;}var e=aN(a9+"Gradient");e.id="r"+(ap._id++)[aE](36);aN(e,a9=="radial"?{fx:a6,fy:S}:{x1:R[0],y1:R[1],x2:R[2],y2:R[3]});d.defs[aP](e);for(var a7=0,bd=a8[m];a7a6.height)&&(a6.height=a5.y+a5.height-a6.y);(a5.x+a5.width-a6.x>a6.width)&&(a6.width=a5.x+a5.width-a6.x);}}E&&this.hide();return a6;};aB[a2].attr=function(){if(this.removed){return this;}if(arguments[m]==0){var R={};for(var E in this.attrs){if(this.attrs[T](E)){R[E]=this.attrs[E];}}this._.rt.deg&&(R.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(R.scale=this.scale());R.gradient&&R.fill=="none"&&(R.fill=R.gradient)&&delete R.gradient;return R;}if(arguments[m]==1&&ap.is(arguments[0],"string")){if(arguments[0]=="translation"){return t.call(this);}if(arguments[0]=="rotation"){return this.rotate();}if(arguments[0]=="scale"){return this.scale();}if(arguments[0]=="fill"&&this.attrs.fill=="none"&&this.attrs.gradient){return this.attrs.gradient;}return this.attrs[arguments[0]];}if(arguments[m]==1&&ap.is(arguments[0],"array")){var d={};for(var e in arguments[0]){if(arguments[0][T](e)){d[arguments[0][e]]=this.attrs[arguments[0][e]];}}return d;}if(arguments[m]==2){var S={};S[arguments[0]]=arguments[1];ab(this,S);}else{if(arguments[m]==1&&ap.is(arguments[0],"object")){ab(this,arguments[0]);}}return this;};aB[a2].toFront=function(){if(this.removed){return this;}this.node.parentNode[aP](this.node);var d=this.paper;d.top!=this&&Z(this,d);return this;};aB[a2].toBack=function(){if(this.removed){return this;}if(this.node.parentNode.firstChild!=this.node){this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild);k(this,this.paper);var d=this.paper;}return this;};aB[a2].insertAfter=function(d){if(this.removed){return this;}var e=d.node;if(e.nextSibling){e.parentNode.insertBefore(this.node,e.nextSibling);}else{e.parentNode[aP](this.node);}A(this,d,this.paper);return this;};aB[a2].insertBefore=function(d){if(this.removed){return this;}var e=d.node;e.parentNode.insertBefore(this.node,e);at(this,d,this.paper);return this;};var Q=function(e,d,S,R){d=P(d);S=P(S);var E=aN("circle");e.canvas&&e.canvas[aP](E);var i=new aB(E,e);i.attrs={cx:d,cy:S,r:R,fill:"none",stroke:"#000"};i.type="circle";aN(E,i.attrs);return i;};var aJ=function(i,d,a6,e,S,a5){d=P(d);a6=P(a6);var R=aN("rect");i.canvas&&i.canvas[aP](R);var E=new aB(R,i);E.attrs={x:d,y:a6,width:e,height:S,r:a5||0,rx:a5||0,ry:a5||0,fill:"none",stroke:"#000"};E.type="rect";aN(R,E.attrs);return E;};var aj=function(e,d,a5,S,R){d=P(d);a5=P(a5);var E=aN("ellipse");e.canvas&&e.canvas[aP](E);var i=new aB(E,e);i.attrs={cx:d,cy:a5,rx:S,ry:R,fill:"none",stroke:"#000"};i.type="ellipse";aN(E,i.attrs);return i;};var o=function(i,a5,d,a6,e,S){var R=aN("image");aN(R,{x:d,y:a6,width:e,height:S,preserveAspectRatio:"none"});R.setAttributeNS(i.xlink,"href",a5);i.canvas&&i.canvas[aP](R);var E=new aB(R,i);E.attrs={x:d,y:a6,width:e,height:S,src:a5};E.type="image";return E;};var Y=function(e,d,S,R){var E=aN("text");aN(E,{x:d,y:S,"text-anchor":"middle"});e.canvas&&e.canvas[aP](E);var i=new aB(E,e);i.attrs={x:d,y:S,"text-anchor":"middle",text:R,font:j.font,stroke:"none",fill:"#000"};i.type="text";ab(i,i.attrs);return i;};var aZ=function(e,d){this.width=e||this.width;this.height=d||this.height;this.canvas[v]("width",this.width);this.canvas[v]("height",this.height);return this;};var w=function(){var E=aq[a0](null,arguments),i=E&&E.container,e=E.x,a5=E.y,R=E.width,d=E.height;if(!i){throw new Error("SVG container not found.");}var S=aN("svg");R=R||512;d=d||342;aN(S,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:R,height:d});if(i==1){S.style.cssText="position:absolute;left:"+e+"px;top:"+a5+"px";M.body[aP](S);}else{if(i.firstChild){i.insertBefore(S,i.firstChild);}else{i[aP](S);}}i=new aX;i.width=R;i.height=d;i.canvas=S;aK.call(i,i,ap.fn);i.clear();return i;};aX[a2].clear=function(){var d=this.canvas;while(d.firstChild){d.removeChild(d.firstChild);}this.bottom=this.top=null;(this.desc=aN("desc"))[aP](M.createTextNode("Created with Rapha\xebl"));d[aP](this.desc);d[aP](this.defs=aN("defs"));};aX[a2].remove=function(){this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas);for(var d in this){this[d]=s(d);}};}if(ap.vml){var D={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},au=/([clmz]),?([^clmz]*)/gi,a3=/-?[^,\s-]+/g,aL=function(ba){var a7=/[ahqstv]/ig,E=r;(ba+aw).match(a7)&&(E=I);a7=/[clmz]/g;if(E==r&&!(ba+aw).match(a7)){var a6=(ba+aw)[aT](au,function(bd,bf,bb){var be=[],i=a4.call(bf)=="m",bc=D[bf];bb[aT](a3,function(bg){if(i&&be[m]==2){bc+=be+D[bf=="m"?"l":"L"];be=[];}be[f](P(bg));});return bc+be;});return a6;}var a8=E(ba),e,a6=[],d;for(var S=0,a9=a8[m];S1&&(e=1);bc.opacity=e;}bd.fill&&(bc.on=true);if(bc.on==null||bd.fill=="none"){bc.on=false;}if(bc.on&&bd.fill){var i=bd.fill.match(c);if(i){bc.src=i[1];bc.type="tile";}else{bc.color=ap.getRGB(bd.fill).hex;bc.src=aw;bc.type="solid";if(ap.getRGB(bd.fill).error&&(bi.type in {circle:1,ellipse:1}||(bd.fill+aw).charAt()!="r")&&b(bi,bd.fill)){be.fill="none";be.gradient=bd.fill;}}}bf&&bb[aP](bc);var R=(bb.getElementsByTagName("stroke")&&bb.getElementsByTagName("stroke")[0]),bg=false;!R&&(bg=R=ai("stroke"));if((bd.stroke&&bd.stroke!="none")||bd["stroke-width"]||bd["stroke-opacity"]!=null||bd["stroke-dasharray"]||bd["stroke-miterlimit"]||bd["stroke-linejoin"]||bd["stroke-linecap"]){R.on=true;}(bd.stroke=="none"||R.on==null||bd.stroke==0||bd["stroke-width"]==0)&&(R.on=false);R.on&&bd.stroke&&(R.color=ap.getRGB(bd.stroke).hex);var e=((+be["stroke-opacity"]+1||2)-1)*((+be.opacity+1||2)-1),a9=(X(bd["stroke-width"])||1)*0.75;e<0&&(e=0);e>1&&(e=1);bd["stroke-width"]==null&&(a9=be["stroke-width"]);bd["stroke-width"]&&(R.weight=a9);a9&&a9<1&&(e*=a9)&&(R.weight=1);R.opacity=e;bd["stroke-linejoin"]&&(R.joinstyle=bd["stroke-linejoin"]||"miter");R.miterlimit=bd["stroke-miterlimit"]||8;bd["stroke-linecap"]&&(R.endcap=bd["stroke-linecap"]=="butt"?"flat":bd["stroke-linecap"]=="square"?"square":"round");if(bd["stroke-dasharray"]){var ba={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};R.dashstyle=ba[T](bd["stroke-dasharray"])?ba[bd["stroke-dasharray"]]:aw;}bg&&bb[aP](R);}if(bi.type=="text"){var a5=bi.paper.span.style;be.font&&(a5.font=be.font);be["font-family"]&&(a5.fontFamily=be["font-family"]);be["font-size"]&&(a5.fontSize=be["font-size"]);be["font-weight"]&&(a5.fontWeight=be["font-weight"]);be["font-style"]&&(a5.fontStyle=be["font-style"]);bi.node.string&&(bi.paper.span.innerHTML=(bi.node.string+aw)[aT](/"));bi.W=be.w=bi.paper.span.offsetWidth;bi.H=be.h=bi.paper.span.offsetHeight;bi.X=be.x;bi.Y=be.y+P(bi.H/2);switch(be["text-anchor"]){case"start":bi.node.style["v-text-align"]="left";bi.bbx=P(bi.W/2);break;case"end":bi.node.style["v-text-align"]="right";bi.bbx=-P(bi.W/2);break;default:bi.node.style["v-text-align"]="center";break;}}};var b=function(d,a6){d.attrs=d.attrs||{};var a7=d.attrs,a9=d.node.getElementsByTagName("fill"),S="linear",a5=".5 .5";d.attrs.gradient=a6;a6=(a6+aw)[aT](av,function(bb,bc,i){S="radial";if(bc&&i){bc=X(bc);i=X(i);aQ(bc-0.5,2)+aQ(i-0.5,2)>0.25&&(i=ac.sqrt(0.25-aQ(bc-0.5,2))*((i>0.5)*2-1)+0.5);a5=bc+ao+i;}return aw;});a6=a6[z](/\s*\-\s*/);if(S=="linear"){var e=a6.shift();e=-X(e);if(isNaN(e)){return null;}}var R=p(a6);if(!R){return null;}d=d.shape||d.node;a9=a9[0]||ai("fill");if(R[m]){a9.on=true;a9.method="none";a9.type=(S=="radial")?"gradientradial":"gradient";a9.color=R[0].color;a9.color2=R[R[m]-1].color;var ba=[];for(var E=0,a8=R[m];E');};}catch(ag){ai=function(d){return M.createElement("<"+d+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');};}var w=function(){var i=aq[a0](null,arguments),d=i.container,a7=i.height,a8,e=i.width,a6=i.x,a5=i.y;if(!d){throw new Error("VML container not found.");}var R=new aX,S=R.canvas=M.createElement("div"),E=S.style;e=e||512;a7=a7||342;e==+e&&(e+="px");a7==+a7&&(a7+="px");R.width=1000;R.height=1000;R.coordsize="1000 1000";R.coordorigin="0 0";R.span=M.createElement("span");R.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";S[aP](R.span);E.cssText=ap.format("width:{0};height:{1};position:absolute;clip:rect(0 {0} {1} 0);overflow:hidden",e,a7);if(d==1){M.body[aP](S);E.left=a6+"px";E.top=a5+"px";}else{d.style.width=e;d.style.height=a7;if(d.firstChild){d.insertBefore(S,d.firstChild);}else{d[aP](S);}}aK.call(R,R,ap.fn);return R;};aX[a2].clear=function(){this.canvas.innerHTML=aw;this.span=M.createElement("span");this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";this.canvas[aP](this.span);this.bottom=this.top=null;};aX[a2].remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var d in this){this[d]=s(d);}};}if((/^Apple|^Google/).test(navigator.vendor)&&!(navigator.userAgent.indexOf("Version/4.0")+1)){aX[a2].safari=function(){var d=this.rect(-99,-99,this.width+99,this.height+99);setTimeout(function(){d.remove();});};}else{aX[a2].safari=function(){};}var af=(function(){if(M.addEventListener){return function(R,i,e,d){var E=function(S){return e.call(d,S);};R.addEventListener(i,E,false);return function(){R.removeEventListener(i,E,false);return true;};};}else{if(M.attachEvent){return function(S,E,i,e){var R=function(a5){return i.call(e,a5||ax.event);};S.attachEvent("on"+E,R);var d=function(){S.detachEvent("on"+E,R);return true;};return d;};}}})();for(var ad=G[m];ad--;){(function(d){aB[a2][d]=function(e){if(ap.is(e,"function")){this.events=this.events||[];this.events.push({name:d,f:e,unbind:af(this.shape||this.node,d,e,this)});}return this;};aB[a2]["un"+d]=function(E){var i=this.events,e=i[m];while(e--){if(i[e].name==d&&i[e].f==E){i[e].unbind();i.splice(e,1);!i.length&&delete this.events;return this;}}return this;};})(G[ad]);}aB[a2].hover=function(e,d){return this.mouseover(e).mouseout(d);};aB[a2].unhover=function(e,d){return this.unmouseover(e).unmouseout(d);};aX[a2].circle=function(d,i,e){return Q(this,d||0,i||0,e||0);};aX[a2].rect=function(d,R,e,i,E){return aJ(this,d||0,R||0,e||0,i||0,E||0);};aX[a2].ellipse=function(d,E,i,e){return aj(this,d||0,E||0,i||0,e||0);};aX[a2].path=function(d){d&&!ap.is(d,"string")&&!ap.is(d[0],"array")&&(d+=aw);return q(ap.format[a0](ap,arguments),this);};aX[a2].image=function(E,d,R,e,i){return o(this,E||"about:blank",d||0,R||0,e||0,i||0);};aX[a2].text=function(d,i,e){return Y(this,d||0,i||0,e||aw);};aX[a2].set=function(d){arguments[m]>1&&(d=Array[a2].splice.call(arguments,0,arguments[m]));return new U(d);};aX[a2].setSize=aZ;aX[a2].top=aX[a2].bottom=null;aX[a2].raphael=ap;function u(){return this.x+ao+this.y;}aB[a2].scale=function(bc,ba,E,e){if(bc==null&&ba==null){return{x:this._.sx,y:this._.sy,toString:u};}ba=ba||bc;!+ba&&(ba=bc);var bg,be,bf,bd,br=this.attrs;if(bc!=0){var a9=this.getBBox(),a6=a9.x+a9.width/2,R=a9.y+a9.height/2,bq=bc/this._.sx,bp=ba/this._.sy;E=(+E||E==0)?E:a6;e=(+e||e==0)?e:R;var a8=~~(bc/ac.abs(bc)),a5=~~(ba/ac.abs(ba)),bj=this.node.style,bt=E+(a6-E)*bq,bs=e+(R-e)*bp;switch(this.type){case"rect":case"image":var a7=br.width*a8*bq,bi=br.height*a5*bp;this.attr({height:bi,r:br.r*aM(a8*bq,a5*bp),width:a7,x:bt-a7/2,y:bs-bi/2});break;case"circle":case"ellipse":this.attr({rx:br.rx*a8*bq,ry:br.ry*a5*bp,r:br.r*aM(a8*bq,a5*bp),cx:bt,cy:bs});break;case"path":var bl=ae(br.path),bm=true;for(var bo=0,bh=bl[m];boS){if(e&&!bd.start){bb=ap.findDotsAtSegment(ba,a9,E[1],E[2],E[3],E[4],E[5],E[6],(S-a8)/a6);R+=["C",bb.start.x,bb.start.y,bb.m.x,bb.m.y,bb.x,bb.y];if(a5){return R;}bd.start=R;R=["M",bb.x,bb.y+"C",bb.n.x,bb.n.y,bb.end.x,bb.end.y,E[5],E[6]][aD]();a8+=a6;ba=+E[5];a9=+E[6];continue;}if(!d&&!e){bb=ap.findDotsAtSegment(ba,a9,E[1],E[2],E[3],E[4],E[5],E[6],(S-a8)/a6);return{x:bb.x,y:bb.y,alpha:bb.alpha};}}a8+=a6;ba=+E[5];a9=+E[6];}R+=E;}bd.end=R;bb=d?a8:e?bd:ap.findDotsAtSegment(ba,a9,E[1],E[2],E[3],E[4],E[5],E[6],1);bb.alpha&&(bb={x:bb.x,y:bb.y,alpha:bb.alpha});return bb;};},n=ak(function(E,d,a5,S,bb,ba,a9,a8){var R={x:0,y:0},a7=0;for(var a6=0;a6<1.01;a6+=0.01){var e=N(E,d,a5,S,bb,ba,a9,a8,a6);a6&&(a7+=ac.sqrt(aQ(R.x-e.x,2)+aQ(R.y-e.y,2)));R=e;}return a7;});var ar=aF(1),C=aF(),K=aF(0,1);aB[a2].getTotalLength=function(){if(this.type!="path"){return;}return ar(this.attrs.path);};aB[a2].getPointAtLength=function(d){if(this.type!="path"){return;}return C(this.attrs.path,d);};aB[a2].getSubpath=function(i,e){if(this.type!="path"){return;}if(ac.abs(this.getTotalLength()-e)<0.000001){return K(this.attrs.path,i).end;}var d=K(this.attrs.path,e,1);return i?K(d,i).end:d;};ap.easing_formulas={linear:function(d){return d;},"<":function(d){return aQ(d,3);},">":function(d){return aQ(d-1,3)+1;},"<>":function(d){d=d*2;if(d<1){return aQ(d,3)/2;}d-=2;return(aQ(d,3)+2)/2;},backIn:function(e){var d=1.70158;return e*e*((d+1)*e-d);},backOut:function(e){e=e-1;var d=1.70158;return e*e*((d+1)*e+d)+1;},elastic:function(i){if(i==0||i==1){return i;}var e=0.3,d=e/4;return aQ(2,-10*i)*ac.sin((i-d)*(2*ac.PI)/e)+1;},bounce:function(E){var e=7.5625,i=2.75,d;if(E<(1/i)){d=e*E*E;}else{if(E<(2/i)){E-=(1.5/i);d=e*E*E+0.75;}else{if(E<(2.5/i)){E-=(2.25/i);d=e*E*E+0.9375;}else{E-=(2.625/i);d=e*E*E+0.984375;}}}return d;}};var J={length:0},aV=function(){var a7=+new Date;for(var bj in J){if(bj!="length"&&J[T](bj)){var bo=J[bj];if(bo.stop||bo.el.removed){delete J[bj];J[m]--;continue;}var a5=a7-bo.start,bg=bo.ms,bf=bo.easing,bk=bo.from,bc=bo.diff,E=bo.to,bb=bo.t,be=bo.prev||0,a6=bo.el,R=bo.callback,bd={},d;if(a5255?255:(d<0?0:d);},t=function(d,i){if(d==null){return{x:this._.tx,y:this._.ty,toString:u};}this._.tx+=+d;this._.ty+=+i;switch(this.type){case"circle":case"ellipse":this.attr({cx:+d+this.attrs.cx,cy:+i+this.attrs.cy});break;case"rect":case"image":case"text":this.attr({x:+d+this.attrs.x,y:+i+this.attrs.y});break;case"path":var e=ae(this.attrs.path);e[0][1]+=+d;e[0][2]+=+i;this.attr({path:e});break;}return this;};aB[a2].animateWith=function(e,i,d,R,E){J[e.id]&&(i.start=J[e.id].start);return this.animate(i,d,R,E);};aB[a2].animateAlong=aC();aB[a2].animateAlongBack=aC(1);function aC(d){return function(E,i,e,S){var R={back:d};ap.is(e,"function")?(S=e):(R.rot=e);E&&E.constructor==aB&&(E=E.attrs.path);E&&(R.along=E);return this.animate(R,i,S);};}aB[a2].onAnimation=function(d){this._run=d||0;return this;};aB[a2].animate=function(bj,ba,a9,E){if(ap.is(a9,"function")||!a9){E=a9||null;}var be={},e={},a7={};for(var bb in bj){if(bj[T](bb)){if(aa[T](bb)){be[bb]=this.attr(bb);(be[bb]==null)&&(be[bb]=j[bb]);e[bb]=bj[bb];switch(aa[bb]){case"along":var bh=ar(bj[bb]),bc=C(bj[bb],bh*!!bj.back),R=this.getBBox();a7[bb]=bh/ba;a7.tx=R.x;a7.ty=R.y;a7.sx=bc.x;a7.sy=bc.y;e.rot=bj.rot;e.back=bj.back;e.len=bh;bj.rot&&(a7.r=X(this.rotate())||0);break;case"number":a7[bb]=(e[bb]-be[bb])/ba;break;case"colour":be[bb]=ap.getRGB(be[bb]);var bd=ap.getRGB(e[bb]);a7[bb]={r:(bd.r-be[bb].r)/ba,g:(bd.g-be[bb].g)/ba,b:(bd.b-be[bb].b)/ba};break;case"path":var S=I(be[bb],e[bb]);be[bb]=S[0];var a8=S[1];a7[bb]=[];for(var bg=0,a6=be[bb][m];bg

";if(ak.childNodes[n]!=2){return au.type=null;}ak=null;}au.svg=!(au.vml=au.type=="VML");a4[a9]=au[a9];au._id=0;au._oid=0;au.fn={};au.is=function(e,d){d=bb.call(d);return((d=="object"||d=="undefined")&&typeof e==d)||(e==null&&d=="null")||bb.call(aE.call(e).slice(8,-1))==d;};au.setWindow=function(d){aB=d;P=aB.document;};var aM=function(e){if(au.vml){var d=/^\s+|\s+$/g;aM=an(function(R){var S;R=(R+aA)[aZ](d,aA);try{var bc=new aB.ActiveXObject("htmlfile");bc.write("");bc.close();S=bc.body;}catch(be){S=aB.createPopup().document.body;}var i=S.createTextRange();try{S.style.color=R;var bd=i.queryCommandValue("ForeColor");bd=((bd&255)<<16)|(bd&65280)|((bd&16711680)>>>16);return"#"+("000000"+bd[aJ](16)).slice(-6);}catch(be){return"none";}});}else{var E=P.createElement("i");E.title="Rapha\xebl Colour Picker";E.style.display="none";P.body[aU](E);aM=an(function(i){E.style.color=i;return P.defaultView.getComputedStyle(E,aA).getPropertyValue("color");});}return aM(e);};var ao=function(){return"hsb("+[this.h,this.s,this.b]+")";},w=function(){return this.hex;};au.hsb2rgb=an(function(bf,bd,bj){if(au.is(bf,"object")&&"h" in bf&&"s" in bf&&"b" in bf){bj=bf.b;bd=bf.s;bf=bf.h;}var R,S,bk;if(bj==0){return{r:0,g:0,b:0,hex:"#000"};}if(bf>1||bd>1||bj>1){bf/=255;bd/=255;bj/=255;}var bc=~~(bf*6),bg=(bf*6)-bc,E=bj*(1-bd),e=bj*(1-(bd*bg)),bl=bj*(1-(bd*(1-bg)));R=[bj,e,E,E,bl,bj,bj][bc];S=[bl,bj,bj,e,E,E,bl][bc];bk=[E,E,bl,bj,bj,e,E][bc];R*=255;S*=255;bk*=255;var bh={r:R,g:S,b:bk,toString:w},d=(~~R)[aJ](16),be=(~~S)[aJ](16),bi=(~~bk)[aJ](16);d=d[aZ](a5,"0");be=be[aZ](a5,"0");bi=bi[aZ](a5,"0");bh.hex="#"+d+be+bi;return bh;},au);au.rgb2hsb=an(function(d,e,bd){if(au.is(d,"object")&&"r" in d&&"g" in d&&"b" in d){bd=d.b;e=d.g;d=d.r;}if(au.is(d,"string")){var bf=au.getRGB(d);d=bf.r;e=bf.g;bd=bf.b;}if(d>1||e>1||bd>1){d/=255;e/=255;bd/=255;}var bc=h(d,e,bd),i=aR(d,e,bd),R,E,S=bc;if(i==bc){return{h:0,s:0,b:bc};}else{var be=(bc-i);E=be/bc;if(d==bc){R=(e-bd)/be;}else{if(e==bc){R=2+((bd-d)/be);}else{R=4+((d-e)/be);}}R/=6;R<0&&R++;R>1&&R--;}return{h:R,s:E,b:S,toString:ao};},au);var aN=/,?([achlmqrstvxz]),?/gi;au._path2string=function(){return this.join(",")[aZ](aN,"$1");};function an(E,e,d){function i(){var R=Array[a9].slice.call(arguments,0),bc=R[aH]("\u25ba"),S=i.cache=i.cache||{},bd=i.count=i.count||[];if(S[W](bc)){return d?d(S[bc]):S[bc];}bd[n]>=1000&&delete S[bd.shift()];bd[f](bc);S[bc]=E[a7](e,R);return d?d(S[bc]):S[bc];}return i;}au.getRGB=an(function(d){if(!d||!!((d=d+aA).indexOf("-")+1)){return{r:-1,g:-1,b:-1,hex:"none",error:1};}if(d=="none"){return{r:-1,g:-1,b:-1,hex:"none"};}!(({hs:1,rg:1})[W](d.substring(0,2))||d.charAt()=="#")&&(d=aM(d));var S,i,E,be,bf,bc=d.match(A);if(bc){if(bc[2]){be=K(bc[2].substring(5),16);E=K(bc[2].substring(3,5),16);i=K(bc[2].substring(1,3),16);}if(bc[3]){be=K((bf=bc[3].charAt(3))+bf,16);E=K((bf=bc[3].charAt(2))+bf,16);i=K((bf=bc[3].charAt(1))+bf,16);}if(bc[4]){bc=bc[4][C](/\s*,\s*/);i=aa(bc[0]);E=aa(bc[1]);be=aa(bc[2]);}if(bc[5]){bc=bc[5][C](/\s*,\s*/);i=aa(bc[0])*2.55;E=aa(bc[1])*2.55;be=aa(bc[2])*2.55;}if(bc[6]){bc=bc[6][C](/\s*,\s*/);i=aa(bc[0]);E=aa(bc[1]);be=aa(bc[2]);return au.hsb2rgb(i,E,be);}if(bc[7]){bc=bc[7][C](/\s*,\s*/);i=aa(bc[0])*2.55;E=aa(bc[1])*2.55;be=aa(bc[2])*2.55;return au.hsb2rgb(i,E,be);}bc={r:i,g:E,b:be};var e=(~~i)[aJ](16),R=(~~E)[aJ](16),bd=(~~be)[aJ](16);e=e[aZ](a5,"0");R=R[aZ](a5,"0");bd=bd[aZ](a5,"0");bc.hex="#"+e+R+bd;return bc;}return{r:-1,g:-1,b:-1,hex:"none",error:1};},au);au.getColor=function(e){var i=this.getColor.start=this.getColor.start||{h:0,s:1,b:e||0.75},d=this.hsb2rgb(i.h,i.s,i.b);i.h+=0.075;if(i.h>1){i.h=0;i.s-=0.2;i.s<=0&&(this.getColor.start={h:0,s:1,b:i.b});}return d.hex;};au.getColor.reset=function(){delete this.start;};var aC=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,ar=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig;au.parsePathString=an(function(d){if(!d){return null;}var i={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},e=[];if(au.is(d,"array")&&au.is(d[0],"array")){e=aD(d);}if(!e[n]){(d+aA)[aZ](aC,function(R,E,bd){var bc=[],S=bb.call(E);bd[aZ](ar,function(bf,be){be&&bc[f](+be);});if(S=="m"&&bc[n]>2){e[f]([E][a2](bc.splice(0,2)));S="l";E=E=="m"?"l":"L";}while(bc[n]>=i[S]){e[f]([E][a2](bc.splice(0,i[S])));if(!i[S]){break;}}});}e[aJ]=au._path2string;return e;});au.findDotsAtSegment=function(e,d,bq,bo,bc,R,be,bd,bk){var bi=1-bk,bh=aV(bi,3)*e+aV(bi,2)*3*bk*bq+bi*3*bk*bk*bc+aV(bk,3)*be,bf=aV(bi,3)*d+aV(bi,2)*3*bk*bo+bi*3*bk*bk*R+aV(bk,3)*bd,bm=e+2*bk*(bq-e)+bk*bk*(bc-2*bq+e),bl=d+2*bk*(bo-d)+bk*bk*(R-2*bo+d),bp=bq+2*bk*(bc-bq)+bk*bk*(be-2*bc+bq),bn=bo+2*bk*(R-bo)+bk*bk*(bd-2*R+bo),bj=(1-bk)*e+bk*bq,bg=(1-bk)*d+bk*bo,E=(1-bk)*bc+bk*be,i=(1-bk)*R+bk*bd,S=(90-af.atan((bm-bp)/(bl-bn))*180/af.PI);(bm>bp||bl1){bK=af.sqrt(bK);bu=bK*bu;bs=bK*bs;}var E=bu*bu,bD=bs*bs,bF=(bg==S?-1:1)*af.sqrt(af.abs((E*bD-E*bz*bz-bD*bA*bA)/(E*bz*bz+bD*bA*bA))),bp=bF*bu*bz/bs+(bl+bk)/2,bo=bF*-bs*bA/bu+(bQ+bP)/2,bf=af.asin(((bQ-bo)/bs).toFixed(7)),be=af.asin(((bP-bo)/bs).toFixed(7));bf=blbe){bf=bf-R*2;}if(!S&&be>bf){be=be-R*2;}}else{bf=bn[0];be=bn[1];bp=bn[2];bo=bn[3];}var bj=be-bf;if(af.abs(bj)>br){var bq=be,bt=bk,bh=bP;be=bf+br*(S&&be>bf?1:-1);bk=bp+bu*af.cos(be);bP=bo+bs*af.sin(be);by=O(bk,bP,bu,bs,bm,0,S,bt,bh,[be,bq,bp,bo]);}bj=be-bf;var bd=af.cos(bf),bO=af.sin(bf),bc=af.cos(be),bN=af.sin(be),bB=af.tan(bj/4),bE=4/3*bu*bB,bC=4/3*bs*bB,bL=[bl,bQ],bJ=[bl+bE*bO,bQ-bC*bd],bI=[bk+bE*bN,bP-bC*bc],bG=[bk,bP];bJ[0]=2*bL[0]-bJ[0];bJ[1]=2*bL[1]-bJ[1];if(bn){return[bJ,bI,bG][a2](by);}else{by=[bJ,bI,bG][a2](by)[aH]()[C](",");var bw=[];for(var bH=0,bx=by[n];bH1000000000000&&(bc=0.5);af.abs(S)>1000000000000&&(S=0.5);if(bc>0&&bc<1){e=T(i,d,R,E,bl,bk,bh,be,bc);bi[f](e.x);bf[f](e.y);}if(S>0&&S<1){e=T(i,d,R,E,bl,bk,bh,be,S);bi[f](e.x);bf[f](e.y);}bj=(bk-2*E+d)-(be-2*bk+E);bg=2*(E-d)-2*(bk-E);bd=d-E;bc=(-bg+af.sqrt(bg*bg-4*bj*bd))/2/bj;S=(-bg-af.sqrt(bg*bg-4*bj*bd))/2/bj;af.abs(bc)>1000000000000&&(bc=0.5);af.abs(S)>1000000000000&&(S=0.5);if(bc>0&&bc<1){e=T(i,d,R,E,bl,bk,bh,be,bc);bi[f](e.x);bf[f](e.y);}if(S>0&&S<1){e=T(i,d,R,E,bl,bk,bh,be,S);bi[f](e.x);bf[f](e.y);}return{min:{x:aR[a7](0,bi),y:aR[a7](0,bf)},max:{x:h[a7](0,bi),y:h[a7](0,bf)}};}),L=an(function(bl,bg){var R=t(bl),bh=bg&&t(bg),bi={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},d={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},bc=function(bm,bn){var i,bo;if(!bm){return["C",bn.x,bn.y,bn.x,bn.y,bn.x,bn.y];}!(bm[0] in {T:1,Q:1})&&(bn.qx=bn.qy=null);switch(bm[0]){case"M":bn.X=bm[1];bn.Y=bm[2];break;case"A":bm=["C"][a2](O[a7](0,[bn.x,bn.y][a2](bm.slice(1))));break;case"S":i=bn.x+(bn.x-(bn.bx||bn.x));bo=bn.y+(bn.y-(bn.by||bn.y));bm=["C",i,bo][a2](bm.slice(1));break;case"T":bn.qx=bn.x+(bn.x-(bn.qx||bn.x));bn.qy=bn.y+(bn.y-(bn.qy||bn.y));bm=["C"][a2](aT(bn.x,bn.y,bn.qx,bn.qy,bm[1],bm[2]));break;case"Q":bn.qx=bm[1];bn.qy=bm[2];bm=["C"][a2](aT(bn.x,bn.y,bm[1],bm[2],bm[3],bm[4]));break;case"L":bm=["C"][a2](a8(bn.x,bn.y,bm[1],bm[2]));break;case"H":bm=["C"][a2](a8(bn.x,bn.y,bm[1],bn.y));break;case"V":bm=["C"][a2](a8(bn.x,bn.y,bn.x,bm[1]));break;case"Z":bm=["C"][a2](a8(bn.x,bn.y,bn.X,bn.Y));break;}return bm;},e=function(bm,bn){if(bm[bn][n]>7){bm[bn].shift();var bo=bm[bn];while(bo[n]){bm.splice(bn++,0,["C"][a2](bo.splice(0,6)));}bm.splice(bn,1);bj=h(R[n],bh&&bh[n]||0);}},E=function(bq,bp,bn,bm,bo){if(bq&&bp&&bq[bo][0]=="M"&&bp[bo][0]!="M"){bp.splice(bo,0,["M",bm.x,bm.y]);bn.bx=0;bn.by=0;bn.x=bq[bo][1];bn.y=bq[bo][2];bj=h(R[n],bh&&bh[n]||0);}};for(var be=0,bj=h(R[n],bh&&bh[n]||0);be0.5)*2-1);aV(be-0.5,2)+aV(bc-0.5,2)>0.25&&(bc=af.sqrt(0.25-aV(be-0.5,2))*bn+0.5)&&bc!=0.5&&(bc=bc.toFixed(5)-0.00001*bn);}return aA;});bk=bk[C](/\s*\-\s*/);if(bh=="linear"){var bd=bk.shift();bd=-aa(bd);if(isNaN(bd)){return null;}var S=[0,0,af.cos(bd*af.PI/180),af.sin(bd*af.PI/180)],bj=1/(h(af.abs(S[2]),af.abs(S[3]))||1);S[2]*=bj;S[3]*=bj;if(S[2]<0){S[0]=-S[2];S[2]=0;}if(S[3]<0){S[1]=-S[3];S[3]=0;}}var bg=r(bk);if(!bg){return null;}var e=R.getAttribute("fill");e=e.match(/^url\(#(.*)\)$/);e&&d.defs.removeChild(P.getElementById(e[1]));var E=aS(bh+"Gradient");E.id="r"+(au._id++)[aJ](36);aS(E,bh=="radial"?{fx:be,fy:bc}:{x1:S[0],y1:S[1],x2:S[2],y2:S[3]});d.defs[aU](E);for(var bf=0,bl=bg[n];bfbd.height)&&(bd.height=bc.y+bc.height-bd.y);(bc.x+bc.width-bd.x>bd.width)&&(bd.width=bc.x+bc.width-bd.x);}}E&&this.hide();return bd;};aF[a9].attr=function(E,bd){if(this.removed){return this;}if(E==null){var S={};for(var R in this.attrs){if(this.attrs[W](R)){S[R]=this.attrs[R];}}this._.rt.deg&&(S.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(S.scale=this.scale());S.gradient&&S.fill=="none"&&(S.fill=S.gradient)&&delete S.gradient;return S;}if(bd==null&&au.is(E,"string")){if(E=="translation"){return v.call(this);}if(E=="rotation"){return this.rotate();}if(E=="scale"){return this.scale();}if(E=="fill"&&this.attrs.fill=="none"&&this.attrs.gradient){return this.attrs.gradient;}return this.attrs[E];}if(bd==null&&au.is(E,"array")){var d={};for(var e=0,bc=E.length;e1&&(e=1);bj.opacity=e;}bk.fill&&(bj.on=true);if(bj.on==null||bk.fill=="none"){bj.on=false;}if(bj.on&&bk.fill){var i=bk.fill.match(c);if(i){bj.src=i[1];bj.type="tile";}else{bj.color=au.getRGB(bk.fill).hex;bj.src=aA;bj.type="solid";if(au.getRGB(bk.fill).error&&(bp.type in {circle:1,ellipse:1}||(bk.fill+aA).charAt()!="r")&&b(bp,bk.fill)){bl.fill="none";bl.gradient=bk.fill;}}}bm&&bi[aU](bj);var R=(bi.getElementsByTagName("stroke")&&bi.getElementsByTagName("stroke")[0]),bn=false;!R&&(bn=R=al("stroke"));if((bk.stroke&&bk.stroke!="none")||bk["stroke-width"]||bk["stroke-opacity"]!=null||bk["stroke-dasharray"]||bk["stroke-miterlimit"]||bk["stroke-linejoin"]||bk["stroke-linecap"]){R.on=true;}(bk.stroke=="none"||R.on==null||bk.stroke==0||bk["stroke-width"]==0)&&(R.on=false);R.on&&bk.stroke&&(R.color=au.getRGB(bk.stroke).hex);e=((+bl["stroke-opacity"]+1||2)-1)*((+bl.opacity+1||2)-1);var bg=(aa(bk["stroke-width"])||1)*0.75;e<0&&(e=0);e>1&&(e=1);bk["stroke-width"]==null&&(bg=bl["stroke-width"]);bk["stroke-width"]&&(R.weight=bg);bg&&bg<1&&(e*=bg)&&(R.weight=1);R.opacity=e;bk["stroke-linejoin"]&&(R.joinstyle=bk["stroke-linejoin"]||"miter");R.miterlimit=bk["stroke-miterlimit"]||8;bk["stroke-linecap"]&&(R.endcap=bk["stroke-linecap"]=="butt"?"flat":bk["stroke-linecap"]=="square"?"square":"round");if(bk["stroke-dasharray"]){var bh={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};R.dashstyle=bh[W](bk["stroke-dasharray"])?bh[bk["stroke-dasharray"]]:aA;}bn&&bi[aU](R);}if(bp.type=="text"){bc=bp.paper.span.style;bl.font&&(bc.font=bl.font);bl["font-family"]&&(bc.fontFamily=bl["font-family"]);bl["font-size"]&&(bc.fontSize=bl["font-size"]);bl["font-weight"]&&(bc.fontWeight=bl["font-weight"]);bl["font-style"]&&(bc.fontStyle=bl["font-style"]);bp.node.string&&(bp.paper.span.innerHTML=(bp.node.string+aA)[aZ](/"));bp.W=bl.w=bp.paper.span.offsetWidth;bp.H=bl.h=bp.paper.span.offsetHeight;bp.X=bl.x;bp.Y=bl.y+U(bp.H/2);switch(bl["text-anchor"]){case"start":bp.node.style["v-text-align"]="left";bp.bbx=U(bp.W/2);break;case"end":bp.node.style["v-text-align"]="right";bp.bbx=-U(bp.W/2);break;default:bp.node.style["v-text-align"]="center";break;}}};b=function(d,bd){d.attrs=d.attrs||{};var be=d.attrs,bg=d.node.getElementsByTagName("fill"),S="linear",bc=".5 .5";d.attrs.gradient=bd;bd=(bd+aA)[aZ](az,function(bi,bj,i){S="radial";if(bj&&i){bj=aa(bj);i=aa(i);aV(bj-0.5,2)+aV(i-0.5,2)>0.25&&(i=af.sqrt(0.25-aV(bj-0.5,2))*((i>0.5)*2-1)+0.5);bc=bj+at+i;}return aA;});bd=bd[C](/\s*\-\s*/);if(S=="linear"){var e=bd.shift();e=-aa(e);if(isNaN(e)){return null;}}var R=r(bd);if(!R){return null;}d=d.shape||d.node;bg=bg[0]||al("fill");if(R[n]){bg.on=true;bg.method="none";bg.type=(S=="radial")?"gradientradial":"gradient";bg.color=R[0].color;bg.color2=R[R[n]-1].color;var bh=[];for(var E=0,bf=R[n];E');};}catch(aj){al=function(d){return P.createElement("<"+d+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');};}z=function(){var i=av[a7](0,arguments),d=i.container,be=i.height,bf,e=i.width,bd=i.x,bc=i.y;if(!d){throw new Error("VML container not found.");}var R=new a4,S=R.canvas=P.createElement("div"),E=S.style;e=e||512;be=be||342;e==+e&&(e+="px");be==+be&&(be+="px");R.width=1000;R.height=1000;R.coordsize=p*1000+at+p*1000;R.coordorigin="0 0";R.span=P.createElement("span");R.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";S[aU](R.span);E.cssText=au.format("width:{0};height:{1};position:absolute;clip:rect(0 {0} {1} 0);overflow:hidden",e,be);if(d==1){P.body[aU](S);E.left=bd+"px";E.top=bc+"px";}else{d.style.width=e;d.style.height=be;if(d.firstChild){d.insertBefore(S,d.firstChild);}else{d[aU](S);}}aP.call(R,R,au.fn);return R;};a4[a9].clear=function(){this.canvas.innerHTML=aA;this.span=P.createElement("span");this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";this.canvas[aU](this.span);this.bottom=this.top=null;};a4[a9].remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var d in this){this[d]=u(d);}return true;};}if((/^Apple|^Google/).test(aB.navigator.vendor)&&!(aB.navigator.userAgent.indexOf("Version/4.0")+1)){a4[a9].safari=function(){var d=this.rect(-99,-99,this.width+99,this.height+99);aB.setTimeout(function(){d.remove();});};}else{a4[a9].safari=function(){};}var ai=(function(){if(P.addEventListener){return function(R,i,e,d){var E=function(S){return e.call(d,S);};R.addEventListener(i,E,false);return function(){R.removeEventListener(i,E,false);return true;};};}else{if(P.attachEvent){return function(S,E,i,e){var R=function(bc){return i.call(e,bc||aB.event);};S.attachEvent("on"+E,R);var d=function(){S.detachEvent("on"+E,R);return true;};return d;};}}})();for(var ag=J[n];ag--;){(function(d){aF[a9][d]=function(e){if(au.is(e,"function")){this.events=this.events||[];this.events.push({name:d,f:e,unbind:ai(this.shape||this.node,d,e,this)});}return this;};aF[a9]["un"+d]=function(E){var i=this.events,e=i[n];while(e--){if(i[e].name==d&&i[e].f==E){i[e].unbind();i.splice(e,1);!i.length&&delete this.events;return this;}}return this;};})(J[ag]);}aF[a9].hover=function(e,d){return this.mouseover(e).mouseout(d);};aF[a9].unhover=function(e,d){return this.unmouseover(e).unmouseout(d);};a4[a9].circle=function(d,i,e){return V(this,d||0,i||0,e||0);};a4[a9].rect=function(d,R,e,i,E){return aO(this,d||0,R||0,e||0,i||0,E||0);};a4[a9].ellipse=function(d,E,i,e){return am(this,d||0,E||0,i||0,e||0);};a4[a9].path=function(d){d&&!au.is(d,"string")&&!au.is(d[0],"array")&&(d+=aA);return s(au.format[a7](au,arguments),this);};a4[a9].image=function(E,d,R,e,i){return q(this,E||"about:blank",d||0,R||0,e||0,i||0);};a4[a9].text=function(d,i,e){return ab(this,d||0,i||0,e||aA);};a4[a9].set=function(d){arguments[n]>1&&(d=Array[a9].splice.call(arguments,0,arguments[n]));return new X(d);};a4[a9].setSize=a6;a4[a9].top=a4[a9].bottom=null;a4[a9].raphael=au;function x(){return this.x+at+this.y;}aF[a9].scale=function(bi,bh,E,e){if(bi==null&&bh==null){return{x:this._.sx,y:this._.sy,toString:x};}bh=bh||bi;!+bh&&(bh=bi);var bm,bk,bl,bj,by=this.attrs;if(bi!=0){var bg=this.getBBox(),bd=bg.x+bg.width/2,R=bg.y+bg.height/2,bx=bi/this._.sx,bw=bh/this._.sy;E=(+E||E==0)?E:bd;e=(+e||e==0)?e:R;var bf=~~(bi/af.abs(bi)),bc=~~(bh/af.abs(bh)),bp=this.node.style,bA=E+(bd-E)*bx,bz=e+(R-e)*bw;switch(this.type){case"rect":case"image":var be=by.width*bf*bx,bo=by.height*bc*bw;this.attr({height:bo,r:by.r*aR(bf*bx,bc*bw),width:be,x:bA-be/2,y:bz-bo/2});break;case"circle":case"ellipse":this.attr({rx:by.rx*bf*bx,ry:by.ry*bc*bw,r:by.r*aR(bf*bx,bc*bw),cx:bA,cy:bz});break;case"path":var br=ah(by.path),bs=true;for(var bu=0,bn=br[n];bu=R){return e;}S=e;}}),aK=function(d,e){return function(bl,S,bc){bl=L(bl);var bh,bg,E,bd,R="",bk={},bi,bf=0;for(var be=0,bj=bl.length;beS){if(e&&!bk.start){bi=g(bh,bg,E[1],E[2],E[3],E[4],E[5],E[6],S-bf);R+=["C",bi.start.x,bi.start.y,bi.m.x,bi.m.y,bi.x,bi.y];if(bc){return R;}bk.start=R;R=["M",bi.x,bi.y+"C",bi.n.x,bi.n.y,bi.end.x,bi.end.y,E[5],E[6]][aH]();bf+=bd;bh=+E[5];bg=+E[6];continue;}if(!d&&!e){bi=g(bh,bg,E[1],E[2],E[3],E[4],E[5],E[6],S-bf);return{x:bi.x,y:bi.y,alpha:bi.alpha};}}bf+=bd;bh=+E[5];bg=+E[6];}R+=E;}bk.end=R;bi=d?bf:e?bk:au.findDotsAtSegment(bh,bg,E[1],E[2],E[3],E[4],E[5],E[6],1);bi.alpha&&(bi={x:bi.x,y:bi.y,alpha:bi.alpha});return bi;};},o=an(function(E,d,bc,S,bi,bh,bg,bf){var R={x:0,y:0},be=0;for(var bd=0;bd<1.01;bd+=0.01){var e=T(E,d,bc,S,bi,bh,bg,bf,bd);bd&&(be+=aV(aV(R.x-e.x,2)+aV(R.y-e.y,2),0.5));R=e;}return be;});var aw=aK(1),G=aK(),N=aK(0,1);aF[a9].getTotalLength=function(){if(this.type!="path"){return;}return aw(this.attrs.path);};aF[a9].getPointAtLength=function(d){if(this.type!="path"){return;}return G(this.attrs.path,d);};aF[a9].getSubpath=function(i,e){if(this.type!="path"){return;}if(af.abs(this.getTotalLength()-e)<0.000001){return N(this.attrs.path,i).end;}var d=N(this.attrs.path,e,1);return i?N(d,i).end:d;};au.easing_formulas={linear:function(d){return d;},"<":function(d){return aV(d,3);},">":function(d){return aV(d-1,3)+1;},"<>":function(d){d=d*2;if(d<1){return aV(d,3)/2;}d-=2;return(aV(d,3)+2)/2;},backIn:function(e){var d=1.70158;return e*e*((d+1)*e-d);},backOut:function(e){e=e-1;var d=1.70158;return e*e*((d+1)*e+d)+1;},elastic:function(i){if(i==0||i==1){return i;}var e=0.3,d=e/4;return aV(2,-10*i)*af.sin((i-d)*(2*af.PI)/e)+1;},bounce:function(E){var e=7.5625,i=2.75,d;if(E<(1/i)){d=e*E*E;}else{if(E<(2/i)){E-=(1.5/i);d=e*E*E+0.75;}else{if(E<(2.5/i)){E-=(2.25/i);d=e*E*E+0.9375;}else{E-=(2.625/i);d=e*E*E+0.984375;}}}return d;}};var M={length:0},a1=function(){var be=+new Date;for(var bq in M){if(bq!="length"&&M[W](bq)){var bv=M[bq];if(bv.stop||bv.el.removed){delete M[bq];M[n]--;continue;}var bc=be-bv.start,bn=bv.ms,bm=bv.easing,br=bv.from,bj=bv.diff,E=bv.to,bi=bv.t,bl=bv.prev||0,bd=bv.el,R=bv.callback,bk={},d;if(bc255?255:(d<0?0:d);},v=function(d,i){if(d==null){return{x:this._.tx,y:this._.ty,toString:x};}this._.tx+=+d;this._.ty+=+i;switch(this.type){case"circle":case"ellipse":this.attr({cx:+d+this.attrs.cx,cy:+i+this.attrs.cy});break;case"rect":case"image":case"text":this.attr({x:+d+this.attrs.x,y:+i+this.attrs.y});break;case"path":var e=ah(this.attrs.path);e[0][1]+=+d;e[0][2]+=+i;this.attr({path:e});break;}return this;};aF[a9].animateWith=function(e,i,d,R,E){M[e.id]&&(i.start=M[e.id].start);return this.animate(i,d,R,E);};aF[a9].animateAlong=aG();aF[a9].animateAlongBack=aG(1);function aG(d){return function(E,i,e,S){var R={back:d};au.is(e,"function")?(S=e):(R.rot=e);E&&E.constructor==aF&&(E=E.attrs.path);E&&(R.along=E);return this.animate(R,i,S);};}aF[a9].onAnimation=function(d){this._run=d||0;return this;};aF[a9].animate=function(bq,bh,bg,E){if(au.is(bg,"function")||!bg){E=bg||null;}var bl={},e={},be={};for(var bi in bq){if(bq[W](bi)){if(ad[W](bi)){bl[bi]=this.attr(bi);(bl[bi]==null)&&(bl[bi]=k[bi]);e[bi]=bq[bi];switch(ad[bi]){case"along":var bo=aw(bq[bi]),bj=G(bq[bi],bo*!!bq.back),R=this.getBBox();be[bi]=bo/bh;be.tx=R.x;be.ty=R.y;be.sx=bj.x;be.sy=bj.y;e.rot=bq.rot;e.back=bq.back;e.len=bo;bq.rot&&(be.r=aa(this.rotate())||0);break;case"number":be[bi]=(e[bi]-bl[bi])/bh;break;case"colour":bl[bi]=au.getRGB(bl[bi]);var bk=au.getRGB(e[bi]);be[bi]={r:(bk.r-bl[bi].r)/bh,g:(bk.g-bl[bi].g)/bh,b:(bk.b-bl[bi].b)/bh};break;case"path":var S=L(bl[bi],e[bi]);bl[bi]=S[0];var bf=S[1];be[bi]=[];for(var bn=0,bd=bl[bi][n];bn"); docum.close(); bod = docum.body; } catch(e) { - bod = createPopup().document.body; + bod = win.createPopup().document.body; } var range = bod.createTextRange(); try { @@ -121,6 +121,12 @@ Raphael = (function () { } return toHex(color); }; + var hsbtoString = function () { + return "hsb(" + [this.h, this.s, this.b] + ")"; + }, + rgbtoString = function () { + return this.hex; + }; R.hsb2rgb = cacher(function (hue, saturation, brightness) { if (R.is(hue, "object") && "h" in hue && "s" in hue && "b" in hue) { brightness = hue.b; @@ -149,7 +155,7 @@ Raphael = (function () { red *= 255; green *= 255; blue *= 255; - var rgb = {r: red, g: green, b: blue}, + var rgb = {r: red, g: green, b: blue, toString: rgbtoString}, r = (~~red)[toString](16), g = (~~green)[toString](16), b = (~~blue)[toString](16); @@ -197,7 +203,7 @@ Raphael = (function () { hue < 0 && hue++; hue > 1 && hue--; } - return {h: hue, s: saturation, b: brightness}; + return {h: hue, s: saturation, b: brightness, toString: hsbtoString}; }, R); var p2s = /,?([achlmqrstvxz]),?/gi; R._path2string = function () { @@ -325,7 +331,7 @@ Raphael = (function () { data[push]([b][concat](params.splice(0, paramCounts[name]))); if (!paramCounts[name]) { break; - }; + } } }); } @@ -804,7 +810,7 @@ Raphael = (function () { par[2] && (dot.offset = par[2] + "%"); dots[push](dot); } - for (var i = 1, ii = dots[length] - 1; i < ii; i++) { + for (i = 1, ii = dots[length] - 1; i < ii; i++) { if (!dots[i].offset) { var start = toFloat(dots[i - 1].offset || 0), end = 0; @@ -828,49 +834,43 @@ Raphael = (function () { } return dots; }), - getContainer = function () { - var container, - x, - y, - width, - height; - if (R.is(arguments[0], "string") || R.is(arguments[0], "object")) { - if (R.is(arguments[0], "string")) { - container = doc.getElementById(arguments[0]); - } else { - container = arguments[0]; - } + getContainer = function (x, y, w, h) { + var container; + if (R.is(x, "string") || R.is(x, "object")) { + container = R.is(x, "string") ? doc.getElementById(x) : x; if (container.tagName) { - if (arguments[1] == null) { + if (y == null) { return { container: container, width: container.style.pixelWidth || container.offsetWidth, height: container.style.pixelHeight || container.offsetHeight }; } else { - return {container: container, width: arguments[1], height: arguments[2]}; + return {container: container, width: y, height: w}; } } - } else if (R.is(arguments[0], nu) && arguments[length] > 3) { - return {container: 1, x: arguments[0], y: arguments[1], width: arguments[2], height: arguments[3]}; + } else if (R.is(x, nu) && h != null) { + return {container: 1, x: x, y: y, width: w, height: h}; } }, plugins = function (con, add) { var that = this; - for (var prop in add) if (add[has](prop) && !(prop in con)) { - switch (typeof add[prop]) { - case "function": - (function (f) { - con[prop] = con === that ? f : function () { return f[apply](that, arguments); }; - })(add[prop]); - break; - case "object": - con[prop] = con[prop] || {}; - plugins.call(this, con[prop], add[prop]); - break; - default: - con[prop] = add[prop]; - break; + for (var prop in add) { + if (add[has](prop) && !(prop in con)) { + switch (typeof add[prop]) { + case "function": + (function (f) { + con[prop] = con === that ? f : function () { return f[apply](that, arguments); }; + })(add[prop]); + break; + case "object": + con[prop] = con[prop] || {}; + plugins.call(this, con[prop], add[prop]); + break; + default: + con[prop] = add[prop]; + break; + } } } }, @@ -927,31 +927,33 @@ Raphael = (function () { if (R.svg) { Paper[proto].svgns = "http://www.w3.org/2000/svg"; Paper[proto].xlink = "http://www.w3.org/1999/xlink"; - var round = function (num) { + round = function (num) { return +num + (~~num === num) * .5; - }, - roundPath = function (path) { - for (var i = 0, ii = path[length]; i < ii; i++) { - if (lowerCase.call(path[i][0]) != "a") { - for (var j = 1, jj = path[i][length]; j < jj; j++) { - path[i][j] = round(path[i][j]); - } - } else { - path[i][6] = round(path[i][6]); - path[i][7] = round(path[i][7]); + }; + var roundPath = function (path) { + for (var i = 0, ii = path[length]; i < ii; i++) { + if (lowerCase.call(path[i][0]) != "a") { + for (var j = 1, jj = path[i][length]; j < jj; j++) { + path[i][j] = round(path[i][j]); } + } else { + path[i][6] = round(path[i][6]); + path[i][7] = round(path[i][7]); } - return path; - }, - $ = function (el, attr) { - if (attr) { - for (var key in attr) if (attr[has](key)) { + } + return path; + }, + $ = function (el, attr) { + if (attr) { + for (var key in attr) { + if (attr[has](key)) { el[setAttribute](key, attr[key]); } - } else { - return doc.createElementNS(Paper[proto].svgns, el); } - }; + } else { + return doc.createElementNS(Paper[proto].svgns, el); + } + }; R[toString] = function () { return "Your browser supports SVG.\nYou are running Rapha\xebl " + this.version; }; @@ -1004,6 +1006,10 @@ Raphael = (function () { if (!dots) { return null; } + var id = o.getAttribute("fill"); + id = id.match(/^url\(#(.*)\)$/); + id && SVG.defs.removeChild(doc.getElementById(id[1])); + var el = $(type + "Gradient"); el.id = "r" + (R._id++)[toString](36); $(el, type == "radial" ? {fx: fx, fy: fy} : {x1: vector[0], y1: vector[1], x2: vector[2], y2: vector[3]}); @@ -1015,7 +1021,7 @@ Raphael = (function () { "stop-color": dots[i].color || "#fff" }); el[appendChild](stop); - }; + } $(o, { fill: "url(#" + el.id + ")", opacity: 1, @@ -1070,208 +1076,213 @@ Raphael = (function () { rotxy[2] = +rotxy[2]; } toFloat(rot) && o.rotate(0, true); - for (var att in params) if (params[has](att)) { - if (!availableAttrs[has](att)) { - continue; - } - var value = params[att]; - attrs[att] = value; - switch (att) { - case "rotation": - o.rotate(value, true); - break; - // Hyperlink - case "href": - case "title": - case "target": - var pn = node.parentNode; - if (lowerCase.call(pn.tagName) != "a") { - var hl = $("a"); - pn.insertBefore(hl, node); - hl[appendChild](node); - pn = hl; - } - pn.setAttributeNS(o.paper.xlink, att, value); - break; - case "cursor": - node.style.cursor = value; - break; - case "clip-rect": - var rect = (value + E)[split](separator); - if (rect[length] == 4) { - o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode); - var el = $("clipPath"), - rc = $("rect"); - el.id = "r" + (R._id++)[toString](36); - $(rc, { - x: rect[0], - y: rect[1], - width: rect[2], - height: rect[3] - }); - el[appendChild](rc); - o.paper.defs[appendChild](el); - $(node, {"clip-path": "url(#" + el.id + ")"}); - o.clip = rc; - } - if (!value) { - var clip = doc.getElementById(node.getAttribute("clip-path")[rp](/(^url\(#|\)$)/g, E)); - clip && clip.parentNode.removeChild(clip); - $(node, {"clip-path": E}); - delete o.clip; - } - break; - case "path": - if (o.type == "path") { - $(node, {d: value ? attrs.path = roundPath(pathToAbsolute(value)) : "M0,0"}); - } - break; - case "width": - node[setAttribute](att, value); - if (attrs.fx) { - att = "x"; - value = attrs.x; - } else { + for (var att in params) { + if (params[has](att)) { + if (!availableAttrs[has](att)) { + continue; + } + var value = params[att]; + attrs[att] = value; + switch (att) { + case "blur": + o.blur(value); break; - } - case "x": - if (attrs.fx) { - value = -attrs.x - (attrs.width || 0); - } - case "rx": - if (att == "rx" && o.type == "rect") { + case "rotation": + o.rotate(value, true); break; - } - case "cx": - rotxy && (att == "x" || att == "cx") && (rotxy[1] += value - attrs[att]); - node[setAttribute](att, round(value)); - o.pattern && updatePosition(o); - break; - case "height": - node[setAttribute](att, value); - if (attrs.fy) { - att = "y"; - value = attrs.y; - } else { + // Hyperlink + case "href": + case "title": + case "target": + var pn = node.parentNode; + if (lowerCase.call(pn.tagName) != "a") { + var hl = $("a"); + pn.insertBefore(hl, node); + hl[appendChild](node); + pn = hl; + } + pn.setAttributeNS(o.paper.xlink, att, value); break; - } - case "y": - if (attrs.fy) { - value = -attrs.y - (attrs.height || 0); - } - case "ry": - if (att == "ry" && o.type == "rect") { + case "cursor": + node.style.cursor = value; break; - } - case "cy": - rotxy && (att == "y" || att == "cy") && (rotxy[2] += value - attrs[att]); - node[setAttribute](att, round(value)); - o.pattern && updatePosition(o); + case "clip-rect": + var rect = (value + E)[split](separator); + if (rect[length] == 4) { + o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode); + var el = $("clipPath"), + rc = $("rect"); + el.id = "r" + (R._id++)[toString](36); + $(rc, { + x: rect[0], + y: rect[1], + width: rect[2], + height: rect[3] + }); + el[appendChild](rc); + o.paper.defs[appendChild](el); + $(node, {"clip-path": "url(#" + el.id + ")"}); + o.clip = rc; + } + if (!value) { + var clip = doc.getElementById(node.getAttribute("clip-path")[rp](/(^url\(#|\)$)/g, E)); + clip && clip.parentNode.removeChild(clip); + $(node, {"clip-path": E}); + delete o.clip; + } break; - case "r": - if (o.type == "rect") { - $(node, {rx: value, ry: value}); - } else { + case "path": + if (o.type == "path") { + $(node, {d: value ? attrs.path = roundPath(pathToAbsolute(value)) : "M0,0"}); + } + break; + case "width": node[setAttribute](att, value); - } - break; - case "src": - if (o.type == "image") { - node.setAttributeNS(o.paper.xlink, "href", value); - } - break; - case "stroke-width": - node.style.strokeWidth = value; - // Need following line for Firefox - node[setAttribute](att, value); - if (attrs["stroke-dasharray"]) { - addDashes(o, attrs["stroke-dasharray"]); - } - break; - case "stroke-dasharray": - addDashes(o, value); - break; - case "translation": - var xy = (value + E)[split](separator); - xy[0] = +xy[0] || 0; - xy[1] = +xy[1] || 0; - if (rotxy) { - rotxy[1] += xy[0]; - rotxy[2] += xy[1]; - } - translate.call(o, xy[0], xy[1]); - break; - case "scale": - var xy = (value + E)[split](separator); - o.scale(+xy[0] || 1, +xy[1] || +xy[0] || 1, +xy[2] || null, +xy[3] || null); - break; - case "fill": - var isURL = (value + E).match(ISURL); - if (isURL) { - var el = $("pattern"), - ig = $("image"); - el.id = "r" + (R._id++)[toString](36); - $(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse", height: 1, width: 1}); - $(ig, {x: 0, y: 0}); - ig.setAttributeNS(o.paper.xlink, "href", isURL[1]); - el[appendChild](ig); - - var img = doc.createElement("img"); - img.style.cssText = "position:absolute;left:-9999em;top-9999em"; - img.onload = function () { - $(el, {width: this.offsetWidth, height: this.offsetHeight}); - $(ig, {width: this.offsetWidth, height: this.offsetHeight}); - doc.body.removeChild(this); - o.paper.safari(); - }; - doc.body[appendChild](img); - img.src = isURL[1]; - o.paper.defs[appendChild](el); - node.style.fill = "url(#" + el.id + ")"; - $(node, {fill: "url(#" + el.id + ")"}); - o.pattern = el; + if (attrs.fx) { + att = "x"; + value = attrs.x; + } else { + break; + } + case "x": + if (attrs.fx) { + value = -attrs.x - (attrs.width || 0); + } + case "rx": + if (att == "rx" && o.type == "rect") { + break; + } + case "cx": + rotxy && (att == "x" || att == "cx") && (rotxy[1] += value - attrs[att]); + node[setAttribute](att, round(value)); o.pattern && updatePosition(o); break; - } - if (!R.getRGB(value).error) { - delete params.gradient; - delete attrs.gradient; - !R.is(attrs.opacity, "undefined") && - R.is(params.opacity, "undefined") && - $(node, {opacity: attrs.opacity}); - !R.is(attrs["fill-opacity"], "undefined") && - R.is(params["fill-opacity"], "undefined") && - $(node, {"fill-opacity": attrs["fill-opacity"]}); - } else if ((({circle: 1, ellipse: 1})[has](o.type) || (value + E).charAt() != "r") && addGradientFill(node, value, o.paper)) { - attrs.gradient = value; - attrs.fill = "none"; + case "height": + node[setAttribute](att, value); + if (attrs.fy) { + att = "y"; + value = attrs.y; + } else { + break; + } + case "y": + if (attrs.fy) { + value = -attrs.y - (attrs.height || 0); + } + case "ry": + if (att == "ry" && o.type == "rect") { + break; + } + case "cy": + rotxy && (att == "y" || att == "cy") && (rotxy[2] += value - attrs[att]); + node[setAttribute](att, round(value)); + o.pattern && updatePosition(o); break; - } - case "stroke": - node[setAttribute](att, R.getRGB(value).hex); - break; - case "gradient": - (({circle: 1, ellipse: 1})[has](o.type) || (value + E).charAt() != "r") && addGradientFill(node, value, o.paper); - break; - case "opacity": - case "fill-opacity": - if (attrs.gradient) { - var gradient = doc.getElementById(node.getAttribute("fill")[rp](/^url\(#|\)$/g, E)); - if (gradient) { - var stops = gradient.getElementsByTagName("stop"); - stops[stops[length] - 1][setAttribute]("stop-opacity", value); + case "r": + if (o.type == "rect") { + $(node, {rx: value, ry: value}); + } else { + node[setAttribute](att, value); } break; - } - default: - att == "font-size" && (value = toInt(value, 10) + "px"); - var cssrule = att[rp](/(\-.)/g, function (w) { - return upperCase.call(w.substring(1)); - }); - node.style[cssrule] = value; - // Need following line for Firefox - node[setAttribute](att, value); - break; + case "src": + if (o.type == "image") { + node.setAttributeNS(o.paper.xlink, "href", value); + } + break; + case "stroke-width": + node.style.strokeWidth = value; + // Need following line for Firefox + node[setAttribute](att, value); + if (attrs["stroke-dasharray"]) { + addDashes(o, attrs["stroke-dasharray"]); + } + break; + case "stroke-dasharray": + addDashes(o, value); + break; + case "translation": + var xy = (value + E)[split](separator); + xy[0] = +xy[0] || 0; + xy[1] = +xy[1] || 0; + if (rotxy) { + rotxy[1] += xy[0]; + rotxy[2] += xy[1]; + } + translate.call(o, xy[0], xy[1]); + break; + case "scale": + xy = (value + E)[split](separator); + o.scale(+xy[0] || 1, +xy[1] || +xy[0] || 1, isNaN(toFloat(xy[2])) ? null : +xy[2], isNaN(toFloat(xy[3])) ? null : +xy[3]); + break; + case "fill": + var isURL = (value + E).match(ISURL); + if (isURL) { + el = $("pattern"); + var ig = $("image"); + el.id = "r" + (R._id++)[toString](36); + $(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse", height: 1, width: 1}); + $(ig, {x: 0, y: 0}); + ig.setAttributeNS(o.paper.xlink, "href", isURL[1]); + el[appendChild](ig); + + var img = doc.createElement("img"); + img.style.cssText = "position:absolute;left:-9999em;top-9999em"; + img.onload = function () { + $(el, {width: this.offsetWidth, height: this.offsetHeight}); + $(ig, {width: this.offsetWidth, height: this.offsetHeight}); + doc.body.removeChild(this); + o.paper.safari(); + }; + doc.body[appendChild](img); + img.src = isURL[1]; + o.paper.defs[appendChild](el); + node.style.fill = "url(#" + el.id + ")"; + $(node, {fill: "url(#" + el.id + ")"}); + o.pattern = el; + o.pattern && updatePosition(o); + break; + } + if (!R.getRGB(value).error) { + delete params.gradient; + delete attrs.gradient; + !R.is(attrs.opacity, "undefined") && + R.is(params.opacity, "undefined") && + $(node, {opacity: attrs.opacity}); + !R.is(attrs["fill-opacity"], "undefined") && + R.is(params["fill-opacity"], "undefined") && + $(node, {"fill-opacity": attrs["fill-opacity"]}); + } else if ((({circle: 1, ellipse: 1})[has](o.type) || (value + E).charAt() != "r") && addGradientFill(node, value, o.paper)) { + attrs.gradient = value; + attrs.fill = "none"; + break; + } + case "stroke": + node[setAttribute](att, R.getRGB(value).hex); + break; + case "gradient": + (({circle: 1, ellipse: 1})[has](o.type) || (value + E).charAt() != "r") && addGradientFill(node, value, o.paper); + break; + case "opacity": + case "fill-opacity": + if (attrs.gradient) { + var gradient = doc.getElementById(node.getAttribute("fill")[rp](/^url\(#|\)$/g, E)); + if (gradient) { + var stops = gradient.getElementsByTagName("stop"); + stops[stops[length] - 1][setAttribute]("stop-opacity", value); + } + break; + } + default: + att == "font-size" && (value = toInt(value, 10) + "px"); + var cssrule = att[rp](/(\-.)/g, function (w) { + return upperCase.call(w.substring(1)); + }); + node.style[cssrule] = value; + // Need following line for Firefox + node[setAttribute](att, value); + break; + } } } @@ -1282,8 +1293,8 @@ Raphael = (function () { toFloat(rot) && o.rotate(rot, true); } }; - var leading = 1.2; - var tuneText = function (el, params) { + var leading = 1.2, + tuneText = function (el, params) { if (el.type != "text" || !(params[has]("text") || params[has]("font") || params[has]("font-size") || params[has]("x") || params[has]("y"))) { return; } @@ -1304,8 +1315,8 @@ Raphael = (function () { node[appendChild](tspan); } } else { - var texts = node.getElementsByTagName("tspan"); - for (var i = 0, ii = texts[length]; i < ii; i++) { + texts = node.getElementsByTagName("tspan"); + for (i = 0, ii = texts[length]; i < ii; i++) { i && $(texts[i], {dy: fontSize * leading, x: a.x}); } } @@ -1313,8 +1324,8 @@ Raphael = (function () { var bb = el.getBBox(), dif = a.y - (bb.y + bb.height / 2); dif && isFinite(dif) && $(node, {y: a.y + dif}); - }; - var Element = function (node, svg) { + }, + Element = function (node, svg) { var X = 0, Y = 0; this[0] = node; @@ -1424,11 +1435,11 @@ Raphael = (function () { hide && this.hide(); return bbox; }; - Element[proto].attr = function () { + Element[proto].attr = function (name, value) { if (this.removed) { return this; } - if (arguments[length] == 0) { + if (name == null) { var res = {}; for (var i in this.attrs) if (this.attrs[has](i)) { res[i] = this.attrs[i]; @@ -1438,34 +1449,34 @@ Raphael = (function () { res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient; return res; } - if (arguments[length] == 1 && R.is(arguments[0], "string")) { - if (arguments[0] == "translation") { + if (value == null && R.is(name, "string")) { + if (name == "translation") { return translate.call(this); } - if (arguments[0] == "rotation") { + if (name == "rotation") { return this.rotate(); } - if (arguments[0] == "scale") { + if (name == "scale") { return this.scale(); } - if (arguments[0] == "fill" && this.attrs.fill == "none" && this.attrs.gradient) { + if (name == "fill" && this.attrs.fill == "none" && this.attrs.gradient) { return this.attrs.gradient; } - return this.attrs[arguments[0]]; + return this.attrs[name]; } - if (arguments[length] == 1 && R.is(arguments[0], "array")) { + if (value == null && R.is(name, "array")) { var values = {}; - for (var j in arguments[0]) if (arguments[0][has](j)) { - values[arguments[0][j]] = this.attrs[arguments[0][j]]; + for (var j = 0, jj = name.length; j < jj; j++) { + values[name[j]] = this.attr(name[j]); } return values; } - if (arguments[length] == 2) { + if (value != null) { var params = {}; - params[arguments[0]] = arguments[1]; + params[name] = value; setFillAndStroke(this, params); - } else if (arguments[length] == 1 && R.is(arguments[0], "object")) { - setFillAndStroke(this, arguments[0]); + } else if (name != null && R.is(name, "object")) { + setFillAndStroke(this, name); } return this; }; @@ -1511,6 +1522,28 @@ Raphael = (function () { insertbefore(this, element, this.paper); return this; }; + Element[proto].blur = function (size) { + // Experimental. No Safari support. Use it on your own risk. + var t = this; + if (+size !== 0) { + var fltr = $("filter"), + blur = $("feGaussianBlur"); + t.attrs.blur = size; + fltr.id = "r" + (R._id++)[toString](36); + $(blur, {stdDeviation: +size || 1.5}); + fltr.appendChild(blur); + t.paper.defs.appendChild(fltr); + t._blur = fltr; + $(t.node, {filter: "url(#" + fltr.id + ")"}); + } else { + if (t._blur) { + t._blur.parentNode.removeChild(t._blur); + delete t._blur; + delete t.attrs.blur; + } + t.node.removeAttribute("filter"); + } + }; var theCircle = function (svg, x, y, r) { x = round(x); y = round(y); @@ -1572,7 +1605,7 @@ Raphael = (function () { return this; }; var create = function () { - var con = getContainer[apply](null, arguments), + var con = getContainer[apply](0, arguments), container = con && con.container, x = con.x, y = con.y, @@ -1625,12 +1658,14 @@ Raphael = (function () { } }; } - + // VML if (R.vml) { var map = {M: "m", L: "l", C: "c", Z: "x", m: "t", l: "r", c: "v", z: "x"}, bites = /([clmz]),?([^clmz]*)/gi, val = /-?[^,\s-]+/g, + coordsize = 1e3 + S + 1e3, + zoom = 10, path2vml = function (path) { var total = /[ahqstv]/ig, command = pathToAbsolute; @@ -1646,19 +1681,20 @@ Raphael = (function () { res += vals + map[command == "m" ? "l" : "L"]; vals = []; } - vals[push](round(value)); + vals[push](round(value * zoom)); }); return res + vals; }); return res; } - var pa = command(path), p, res = [], r; + var pa = command(path), p, r; + res = []; for (var i = 0, ii = pa[length]; i < ii; i++) { p = pa[i]; r = lowerCase.call(pa[i][0]); r == "z" && (r = "x"); for (var j = 1, jj = p[length]; j < jj; j++) { - r += round(p[j]) + (j != jj - 1 ? "," : E); + r += round(p[j] * zoom) + (j != jj - 1 ? "," : E); } res[push](r); } @@ -1668,18 +1704,18 @@ Raphael = (function () { R[toString] = function () { return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version; }; - var thePath = function (pathString, VML) { + thePath = function (pathString, vml) { var g = createNode("group"); - g.style.cssText = "position:absolute;left:0;top:0;width:" + VML.width + "px;height:" + VML.height + "px"; - g.coordsize = VML.coordsize; - g.coordorigin = VML.coordorigin; + g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; + g.coordsize = vml.coordsize; + g.coordorigin = vml.coordorigin; var el = createNode("shape"), ol = el.style; - ol.width = VML.width + "px"; - ol.height = VML.height + "px"; - el.coordsize = this.coordsize; - el.coordorigin = this.coordorigin; + ol.width = vml.width + "px"; + ol.height = vml.height + "px"; + el.coordsize = coordsize; + el.coordorigin = vml.coordorigin; g[appendChild](el); - var p = new Element(el, g, VML), + var p = new Element(el, g, vml), attr = {fill: "none", stroke: "#000"}; pathString && (attr.path = pathString); p.isAbsolute = true; @@ -1687,10 +1723,10 @@ Raphael = (function () { p.path = []; p.Path = E; setFillAndStroke(p, attr); - VML.canvas[appendChild](g); + vml.canvas[appendChild](g); return p; }; - var setFillAndStroke = function (o, params) { + setFillAndStroke = function (o, params) { o.attrs = o.attrs || {}; var node = o.node, a = o.attrs, @@ -1704,6 +1740,7 @@ Raphael = (function () { params.title && (node.title = params.title); params.target && (node.target = params.target); params.cursor && (s.cursor = params.cursor); + "blur" in params && o.blur(params.blur); if (params.path && o.type == "path") { a.path = params.path; node.path = path2vml(a.path); @@ -1815,8 +1852,8 @@ Raphael = (function () { } (params.stroke == "none" || stroke.on == null || params.stroke == 0 || params["stroke-width"] == 0) && (stroke.on = false); stroke.on && params.stroke && (stroke.color = R.getRGB(params.stroke).hex); - var opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1), - width = (toFloat(params["stroke-width"]) || 1) * .75; + opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1); + var width = (toFloat(params["stroke-width"]) || 1) * .75; opacity < 0 && (opacity = 0); opacity > 1 && (opacity = 1); params["stroke-width"] == null && (width = a["stroke-width"]); @@ -1845,7 +1882,7 @@ Raphael = (function () { newstroke && node[appendChild](stroke); } if (res.type == "text") { - var s = res.paper.span.style; + s = res.paper.span.style; a.font && (s.font = a.font); a["font-family"] && (s.fontFamily = a["font-family"]); a["font-size"] && (s.fontSize = a["font-size"]); @@ -1873,7 +1910,7 @@ Raphael = (function () { } } }; - var addGradientFill = function (o, gradient) { + addGradientFill = function (o, gradient) { o.attrs = o.attrs || {}; var attrs = o.attrs, fill = o.node.getElementsByTagName("fill"), @@ -1925,7 +1962,7 @@ Raphael = (function () { } return 1; }; - var Element = function (node, group, vml) { + Element = function (node, group, vml) { var Rotation = 0, RotX = 0, RotY = 0, @@ -2052,43 +2089,40 @@ Raphael = (function () { cx = (cx == null) ? x + w / 2 : cx; cy = (cy == null) ? y + h / 2 : cy; var left = cx - this.paper.width / 2, - top = cy - this.paper.height / 2; - if (this.type == "path" || this.type == "text") { - (gs.left != left + "px") && (gs.left = left + "px"); - (gs.top != top + "px") && (gs.top = top + "px"); - this.X = this.type == "text" ? x : -left; - this.Y = this.type == "text" ? y : -top; - this.W = w; - this.H = h; - (os.left != -left + "px") && (os.left = -left + "px"); - (os.top != -top + "px") && (os.top = -top + "px"); + top = cy - this.paper.height / 2, t; + gs.left != (t = left + "px") && (gs.left = t); + gs.top != (t = top + "px") && (gs.top = t); + this.X = this.type == "path" ? -left : x; + this.Y = this.type == "path" ? -top : y; + this.W = w; + this.H = h; + if (this.type == "path") { + os.left != (t = -left * zoom + "px") && (os.left = t); + os.top != (t = -top * zoom + "px") && (os.top = t); + } else if (this.type == "text") { + os.left != (t = -left + "px") && (os.left = t); + os.top != (t = -top + "px") && (os.top = t); } else { - (gs.left != left + "px") && (gs.left = left + "px"); - (gs.top != top + "px") && (gs.top = top + "px"); - this.X = x; - this.Y = y; - this.W = w; - this.H = h; - (gs.width != this.paper.width + "px") && (gs.width = this.paper.width + "px"); - (gs.height != this.paper.height + "px") && (gs.height = this.paper.height + "px"); - (os.left != x - left + "px") && (os.left = x - left + "px"); - (os.top != y - top + "px") && (os.top = y - top + "px"); - (os.width != w + "px") && (os.width = w + "px"); - (os.height != h + "px") && (os.height = h + "px"); + gs.width != (t = this.paper.width + "px") && (gs.width = t); + gs.height != (t = this.paper.height + "px") && (gs.height = t); + os.left != (t = x - left + "px") && (os.left = t); + os.top != (t = y - top + "px") && (os.top = t); + os.width != (t = w + "px") && (os.width = t); + os.height != (t = h + "px") && (os.height = t); var arcsize = (+params.r || 0) / mmin(w, h); if (this.type == "rect" && this.arcsize.toFixed(4) != arcsize.toFixed(4) && (arcsize || this.arcsize)) { // We should replace element with the new one var o = createNode("roundrect"), a = {}, - i = 0, ii = this.events && this.events[length]; + i = 0; o.arcsize = arcsize; o.raphael = this; this.Group[appendChild](o); this.Group.removeChild(this.node); this[0] = this.node = o; this.arcsize = arcsize; - for (var i in attr) { + for (i in attr) { a[i] = attr[i]; } delete a.scale; @@ -2134,11 +2168,11 @@ Raphael = (function () { } this.removed = true; }; - Element[proto].attr = function () { + Element[proto].attr = function (name, value) { if (this.removed) { return this; } - if (arguments[length] == 0) { + if (name == null) { var res = {}; for (var i in this.attrs) if (this.attrs[has](i)) { res[i] = this.attrs[i]; @@ -2148,34 +2182,34 @@ Raphael = (function () { res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient; return res; } - if (arguments[length] == 1 && R.is(arguments[0], "string")) { - if (arguments[0] == "translation") { + if (value == null && R.is(name, "string")) { + if (name == "translation") { return translate.call(this); } - if (arguments[0] == "rotation") { + if (name == "rotation") { return this.rotate(); } - if (arguments[0] == "scale") { + if (name == "scale") { return this.scale(); } - if (arguments[0] == "fill" && this.attrs.fill == "none" && this.attrs.gradient) { + if (name == "fill" && this.attrs.fill == "none" && this.attrs.gradient) { return this.attrs.gradient; } - return this.attrs[arguments[0]]; + return this.attrs[name]; } - if (this.attrs && arguments[length] == 1 && R.is(arguments[0], "array")) { - var values = {}; - for (var i = 0, ii = arguments[0][length]; i < ii; i++) { - values[arguments[0][i]] = this.attrs[arguments[0][i]]; - }; + if (this.attrs && value == null && R.is(name, "array")) { + var ii, values = {}; + for (i = 0, ii = name[length]; i < ii; i++) { + values[name[i]] = this.attr(name[i]); + } return values; } var params; - if (arguments[length] == 2) { + if (value != null) { params = {}; - params[arguments[0]] = arguments[1]; + params[name] = value; } - arguments[length] == 1 && R.is(arguments[0], "object") && (params = arguments[0]); + value == null && R.is(name, "object") && (params = name); if (params) { if (params.text && this.type == "text") { this.node.string = params.text; @@ -2223,13 +2257,28 @@ Raphael = (function () { insertbefore(this, element, this.paper); return this; }; + var blurregexp = / progid:\S+Blur\([^\)]+\)/g; + Element[proto].blur = function (size) { + var s = this.node.style, + f = s.filter; + f = f.replace(blurregexp, ""); + if (+size !== 0) { + this.attrs.blur = size; + s.filter = f + " progid:DXImageTransform.Microsoft.Blur(pixelradius=" + (+size || 1.5) + ")"; + s.margin = Raphael.format("-{0}px 0 0 -{0}px", Math.round(+size || 1.5)); + } else { + s.filter = f; + s.margin = 0; + delete this.attrs.blur; + } + }; - var theCircle = function (vml, x, y, r) { + theCircle = function (vml, x, y, r) { var g = createNode("group"), o = createNode("oval"), ol = o.style; g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; - g.coordsize = vml.coordsize; + g.coordsize = coordsize; g.coordorigin = vml.coordorigin; g[appendChild](o); var res = new Element(o, g, vml); @@ -2241,13 +2290,13 @@ Raphael = (function () { res.setBox({x: x - r, y: y - r, width: r * 2, height: r * 2}); vml.canvas[appendChild](g); return res; - }, + }; theRect = function (vml, x, y, w, h, r) { var g = createNode("group"), o = createNode("roundrect"), arcsize = (+r || 0) / (mmin(w, h)); g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; - g.coordsize = vml.coordsize; + g.coordsize = coordsize; g.coordorigin = vml.coordorigin; g[appendChild](o); o.arcsize = arcsize; @@ -2258,13 +2307,13 @@ Raphael = (function () { res.setBox({x: x, y: y, width: w, height: h, r: r}); vml.canvas[appendChild](g); return res; - }, + }; theEllipse = function (vml, x, y, rx, ry) { var g = createNode("group"), o = createNode("oval"), ol = o.style; g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; - g.coordsize = vml.coordsize; + g.coordsize = coordsize; g.coordorigin = vml.coordorigin; g[appendChild](o); var res = new Element(o, g, vml); @@ -2277,13 +2326,13 @@ Raphael = (function () { res.setBox({x: x - rx, y: y - ry, width: rx * 2, height: ry * 2}); vml.canvas[appendChild](g); return res; - }, + }; theImage = function (vml, src, x, y, w, h) { var g = createNode("group"), o = createNode("image"), ol = o.style; g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; - g.coordsize = vml.coordsize; + g.coordsize = coordsize; g.coordorigin = vml.coordorigin; o.src = src; g[appendChild](o); @@ -2297,7 +2346,7 @@ Raphael = (function () { res.setBox({x: x, y: y, width: w, height: h}); vml.canvas[appendChild](g); return res; - }, + }; theText = function (vml, x, y, text) { var g = createNode("group"), el = createNode("shape"), @@ -2306,9 +2355,9 @@ Raphael = (function () { ps = path.style, o = createNode("textpath"); g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; - g.coordsize = vml.coordsize; + g.coordsize = coordsize; g.coordorigin = vml.coordorigin; - path.v = R.format("m{0},{1}l{2},{1}", round(x), round(y), round(x) + 1); + path.v = R.format("m{0},{1}l{2},{1}", round(x * 10), round(y * 10), round(x * 10) + 1); path.textpathok = true; ol.width = vml.width; ol.height = vml.height; @@ -2330,7 +2379,7 @@ Raphael = (function () { res.setBox(); vml.canvas[appendChild](g); return res; - }, + }; setSize = function (width, height) { var cs = this.canvas.style; width == +width && (width += "px"); @@ -2339,8 +2388,8 @@ Raphael = (function () { cs.height = height; cs.clip = "rect(0 " + width + " " + height + " 0)"; return this; - }, - createNode; + }; + var createNode; doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)"); try { !doc.namespaces.rvml && doc.namespaces.add("rvml", "urn:schemas-microsoft-com:vml"); @@ -2352,8 +2401,8 @@ Raphael = (function () { return doc.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">'); }; } - var create = function () { - var con = getContainer[apply](null, arguments), + create = function () { + var con = getContainer[apply](0, arguments), container = con.container, height = con.height, s, @@ -2372,7 +2421,7 @@ Raphael = (function () { height == +height && (height += "px"); res.width = 1e3; res.height = 1e3; - res.coordsize = "1000 1000"; + res.coordsize = zoom * 1e3 + S + zoom * 1e3; res.coordorigin = "0 0"; res.span = doc.createElement("span"); res.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;"; @@ -2406,15 +2455,16 @@ Raphael = (function () { for (var i in this) { this[i] = removed(i); } + return true; }; } // rest // Safari or Chrome (WebKit) rendering bug workaround method - if ((/^Apple|^Google/).test(navigator.vendor) && !(navigator.userAgent.indexOf("Version/4.0") + 1)) { + if ((/^Apple|^Google/).test(win.navigator.vendor) && !(win.navigator.userAgent.indexOf("Version/4.0") + 1)) { Paper[proto].safari = function () { var rect = this.rect(-99, -99, this.width + 99, this.height + 99); - setTimeout(function () {rect.remove();}); + win.setTimeout(function () {rect.remove();}); }; } else { Paper[proto].safari = function () {}; @@ -2503,7 +2553,7 @@ Raphael = (function () { Paper[proto].raphael = R; function x_y() { return this.x + S + this.y; - }; + } Element[proto].scale = function (x, y, cx, cy) { if (x == null && y == null) { return { @@ -2560,7 +2610,6 @@ Raphael = (function () { skip = true; for (var i = 0, ii = path[length]; i < ii; i++) { var p = path[i], - j, P0 = upperCase.call(p[0]); if (P0 == "M" && skip) { continue; @@ -2572,9 +2621,9 @@ Raphael = (function () { p[path[i][length] - 1] *= ky; p[1] *= dirx * kx; p[2] *= diry * ky; - p[5] = +(dirx + diry ? !!+p[5] : !+p[5]); + p[5] = +!(dirx + diry ? !+p[5] : +p[5]); } else if (P0 == "H") { - for (j = 1, jj = p[length]; j < jj; j++) { + for (var j = 1, jj = p[length]; j < jj; j++) { p[j] *= kx; } } else if (P0 == "V") { @@ -2587,9 +2636,9 @@ Raphael = (function () { } } } - var dim2 = pathDimensions(path), - dx = ncx - dim2.x - dim2.width / 2, - dy = ncy - dim2.y - dim2.height / 2; + var dim2 = pathDimensions(path); + dx = ncx - dim2.x - dim2.width / 2; + dy = ncy - dim2.y - dim2.height / 2; path[0][1] += dx; path[0][2] += dy; this.attr({path: path}); @@ -2633,7 +2682,19 @@ Raphael = (function () { delete attr.translation; return this.paper[this.type]().attr(attr); }; - var getLengthFactory = function (istotal, subpath) { + var getPointAtSegmentLength = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) { + var len = 0, + old; + for (var i = 0; i < 1.001; i+=.001) { + var dot = R.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, i); + i && (len += pow(pow(old.x - dot.x, 2) + pow(old.y - dot.y, 2), .5)); + if (len >= length) { + return dot; + } + old = dot; + } + }), + getLengthFactory = function (istotal, subpath) { return function (path, length, onlystart) { path = path2curve(path); var x, y, p, l, sp = "", subpaths = {}, point, @@ -2647,9 +2708,9 @@ Raphael = (function () { l = segmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]); if (len + l > length) { if (subpath && !subpaths.start) { - point = R.findDotsAtSegment(x, y, p[1], p[2], p[3], p[4], p[5], p[6], (length - len) / l); + point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len); sp += ["C", point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y]; - if (onlystart) return sp; + if (onlystart) {return sp;} subpaths.start = sp; sp = ["M", point.x, point.y + "C", point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]][join](); len += l; @@ -2658,7 +2719,7 @@ Raphael = (function () { continue; } if (!istotal && !subpath) { - point = R.findDotsAtSegment(x, y, p[1], p[2], p[3], p[4], p[5], p[6], (length - len) / l); + point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len); return {x: point.x, y: point.y, alpha: point.alpha}; } } @@ -2679,7 +2740,7 @@ Raphael = (function () { len = 0; for (var i = 0; i < 1.01; i+=.01) { var dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, i); - i && (len += math.sqrt(pow(old.x - dot.x, 2) + pow(old.y - dot.y, 2))); + i && (len += pow(pow(old.x - dot.x, 2) + pow(old.y - dot.y, 2), .5)); old = dot; } return len; @@ -2688,15 +2749,15 @@ Raphael = (function () { getPointAtLength = getLengthFactory(), getSubpathsAtLength = getLengthFactory(0, 1); Element[proto].getTotalLength = function () { - if (this.type != "path") return; + if (this.type != "path") {return;} return getTotalLength(this.attrs.path); }; Element[proto].getPointAtLength = function (length) { - if (this.type != "path") return; + if (this.type != "path") {return;} return getPointAtLength(this.attrs.path, length); }; Element[proto].getSubpath = function (from, to) { - if (this.type != "path") return; + if (this.type != "path") {return;} if (math.abs(this.getTotalLength() - to) < 1e-6) { return getSubpathsAtLength(this.attrs.path, from).end; } @@ -2839,7 +2900,7 @@ Raphael = (function () { break; case "clip-rect": now = []; - var i = 4; + i = 4; while (i--) { now[i] = +from[attr][i] + pos * ms * diff[attr][i]; } @@ -2853,7 +2914,7 @@ Raphael = (function () { that._run && that._run.call(that); } else { if (to.along) { - var point = getPointAtLength(to.along, to.len * !to.back); + point = getPointAtLength(to.along, to.len * !to.back); that.translate(diff.sx - (diff.x || 0) + point.x - diff.sx, diff.sy - (diff.y || 0) + point.y - diff.sy); to.rot && that.rotate(diff.r + point.alpha, point.x, point.y); } @@ -2868,7 +2929,7 @@ Raphael = (function () { e.prev = time; } R.svg && that && that.paper.safari(); - animationElements[length] && setTimeout(animation); + animationElements[length] && win.setTimeout(animation); }, upto255 = function (color) { return color > 255 ? 255 : (color < 0 ? 0 : color); @@ -2988,7 +3049,7 @@ Raphael = (function () { case "clip-rect": from[attr] = (from[attr] + E)[split](separator); diff[attr] = []; - var i = 4; + i = 4; while (i--) { diff[attr][i] = (values[i] - from[attr][i]) / ms; } @@ -3074,7 +3135,7 @@ Raphael = (function () { } } else { for (var i = 0, ii = this.items[length]; i < ii; i++) { - this.items[i].attr[apply](this.items[i], arguments); + this.items[i].attr(name, value); } } return this; @@ -3217,11 +3278,11 @@ Raphael = (function () { } return out; }; - - R.format = function (token) { - var args = R.is(arguments[1], "array") ? [0][concat](arguments[1]) : arguments, - rg = /\{(\d+)\}/g; - token && R.is(token, "string") && args[length] - 1 && (token = token[rp](rg, function (str, i) { + + var formatrg = /\{(\d+)\}/g; + R.format = function (token, array) { + var args = R.is(array, "array") ? [0][concat](array) : arguments; + token && R.is(token, "string") && args[length] - 1 && (token = token[rp](formatrg, function (str, i) { return args[++i] == null ? E : args[i]; })); return token || E;