From 9a6968ea5e8c3690be5f0e898e3726c89069ff6b Mon Sep 17 00:00:00 2001 From: Dmitry Baranovskiy Date: Mon, 26 Oct 2009 17:15:59 +1100 Subject: [PATCH] 1.2 Replaced colour map to Dean Edwards solution Speed up IE rendering a bit Rewamp animation Fixed some bugs with gradients in IE --- raphael-min.js | 4 +- raphael.js | 467 +++++++++++++++++++++++++++++-------------------- 2 files changed, 282 insertions(+), 189 deletions(-) diff --git a/raphael-min.js b/raphael-min.js index 66fde4a..58af3bd 100644 --- a/raphael-min.js +++ b/raphael-min.js @@ -1,7 +1,7 @@ /* - * Raphael 1.1 - JavaScript Vector Library + * Raphael 1.2 - JavaScript Vector Library * * Copyright (c) 2008 - 2009 Dmitry Baranovskiy (http://raphaeljs.com) * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. */ -window.Raphael=(function(){var at=/[, ]+/,m=document,ad=window,aj={was:"Raphael" in ad,is:ad.Raphael},l=function(){if(l.is(arguments[0],"array")){var e=arguments[0],E=q[ao](l,e.splice(0,3+l.is(e[0],ah))),av=E.set();for(var au=0,aw=e[z];au1||ax>1||aD>1){az/=255;ax/=255;aD/=255;}var aw=~~(az*6),aA=(az*6)-aw,R=aD*(1-ax),E=aD*(1-(ax*aA)),aF=aD*(1-(ax*(1-aA)));au=[aD,E,R,R,aF,aD,aD][aw];av=[aF,aD,aD,E,R,R,aF][aw];aE=[R,R,aF,aD,aD,E,R][aw];au*=255;av*=255;aE*=255;var aB={r:au,g:av,b:aE},e=(~~au)[j](16),ay=(~~av)[j](16),aC=(~~aE)[j](16);e=e[Q](Y,"0");ay=ay[Q](Y,"0");aC=aC[Q](Y,"0");aB.hex="#"+e+ay+aC;return aB;},l);l.rgb2hsb=ar(function(e,i,ax){if(l.is(e,"object")&&"r" in e&&"g" in e&&"b" in e){ax=e.b;i=e.g;e=e.r;}if(l.is(e,"string")){var az=l.getRGB(e);e=az.r;i=az.g;ax=az.b;}if(e>1||i>1||ax>1){e/=255;i/=255;ax/=255;}var aw=r(e,i,ax),E=V(e,i,ax),au,R,av=aw;if(E==aw){return{h:0,s:0,b:aw};}else{var ay=(aw-E);R=ay/aw;if(e==aw){au=(i-ax)/ay;}else{if(i==aw){au=2+((ax-e)/ay);}else{au=4+((e-i)/ay);}}au/=6;if(au<0){au+=1;}if(au>1){au-=1;}}return{h:au,s:R,b:av};},l);l._path2string=function(){var R=w,aw;for(var E=0,au=this[z];E=1000){delete E.cache[E.count.shift()];}E.count[ae](av);E.cache[av]=R[ao](i,au);return e?e(E.cache[av]):E.cache[av];}return E;}l.getRGB=ar(function(e){var az={none:"none",aliceblue:"#f0f8ff",amethyst:"#96c",antiquewhite:"#faebd7",aqua:"#0ff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000",blanchedalmond:"#ffebcd",blue:"#00f",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#0ff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#f0f",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#789",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#0f0",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#f0f",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#f00",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#fff",whitesmoke:"#f5f5f5",yellow:"#ff0",yellowgreen:"#9acd32"},av;e=az[(e+w).toLowerCase()]||e;if(!e){return{r:-1,g:-1,b:-1,hex:"none",error:1};}if(e=="none"){return{r:-1,g:-1,b:-1,hex:"none"};}var E,R,ay,aw=(e+w).match(/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgb\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|rgb\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\)|hs[bl]\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|hs[bl]\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\))\s*$/i);if(aw){if(aw[2]){ay=u(aw[2].substring(5),16);R=u(aw[2].substring(3,5),16);E=u(aw[2].substring(1,3),16);}if(aw[3]){ay=u(aw[3].substring(3)+aw[3].substring(3),16);R=u(aw[3].substring(2,3)+aw[3].substring(2,3),16);E=u(aw[3].substring(1,2)+aw[3].substring(1,2),16);}if(aw[4]){aw=aw[4][H](/\s*,\s*/);E=b(aw[0]);R=b(aw[1]);ay=b(aw[2]);}if(aw[5]){aw=aw[5][H](/\s*,\s*/);E=b(aw[0])*2.55;R=b(aw[1])*2.55;ay=b(aw[2])*2.55;}if(aw[6]){aw=aw[6][H](/\s*,\s*/);E=b(aw[0]);R=b(aw[1]);ay=b(aw[2]);return l.hsb2rgb(E,R,ay);}if(aw[7]){aw=aw[7][H](/\s*,\s*/);E=b(aw[0])*2.55;R=b(aw[1])*2.55;ay=b(aw[2])*2.55;return l.hsb2rgb(E,R,ay);}aw={r:E,g:R,b:ay};var i=(~~E)[j](16),au=(~~R)[j](16),ax=(~~ay)[j](16);i=i[Q](Y,"0");au=au[Q](Y,"0");ax=ax[Q](Y,"0");aw.hex="#"+i+au+ax;av=aw;}else{av={r:-1,g:-1,b:-1,hex:"none",error:1};}return av;},l);l.getColor=function(i){var E=this.getColor.start=this.getColor.start||{h:0,s:1,b:i||0.75},e=this.hsb2rgb(E.h,E.s,E.b);E.h+=0.075;if(E.h>1){E.h=0;E.s-=0.2;if(E.s<=0){this.getColor.start={h:0,s:1,b:E.b};}}return e.hex;};l.getColor.reset=function(){delete this.start;};l.parsePathString=ar(function(e){if(!e){return null;}var E={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},i=[];if(l.is(e,"array")&&l.is(e[0],"array")){i=D(e);}if(!i[z]){(e+w)[Q](/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,function(au,R,ax){var aw=[],av=R.toLowerCase();ax[Q](/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig,function(az,ay){ay&&aw[ae](+ay);});while(aw[z]>=E[av]){i[ae]([R][J](aw.splice(0,E[av])));if(!E[av]){break;}}});}i[j]=l._path2string;return i;});var T=ar(function(aA){if(!aA){return{x:0,y:0,width:0,height:0};}aA=ag(aA);var ax=0,aw=0,R=[],E=[];for(var au=0,az=aA[z];auay){az=az-au*2;}if(!av&&ay>az){ay=ay-au*2;}}else{az=aH[0];ay=aH[1];aJ=aH[2];aI=aH[3];}var aD=ay-az;if(Math.abs(aD)>aL){var aK=ay,aN=aE,aB=a8;ay=az+aL*(av&&ay>az?1:-1);aE=aJ+aO*Math.cos(ay);a8=aI+aM*Math.sin(ay);aS=B(aE,a8,aO,aM,aG,0,av,aN,aB,[ay,aK,aJ,aI]);}aD=ay-az;var ax=Math.cos(az),a7=Math.sin(az),aw=Math.cos(ay),a6=Math.sin(ay),aV=Math.tan(aD/4),aY=4/3*aO*aV,aW=4/3*aM*aV,a4=[aF,a9],a3=[aF+aY*a7,a9-aW*ax],a2=[aE+aY*a6,a8-aW*aw],a0=[aE,a8];a3[0]=2*a4[0]-a3[0];a3[1]=2*a4[1]-a3[1];if(aH){return[a3,a2,a0][J](aS);}else{aS=[a3,a2,a0][J](aS)[t](",")[H](",");var aQ=[];for(var a1=0,aR=aS[z];a10&&aw<1?aw:0),av=O(i,e,R,E,aG,aF,aC,az,au>0&&au<1?au:0);aD=aD[J](ax.x,av.x);aA=aA[J](ax.y,av.y);aE=(aF-2*E+e)-(az-2*aF+E);aB=2*(E-e)-2*(aF-E);ay=e-E;aw=(-aB+Math.sqrt(aB*aB-4*aE*ay))/2/aE;au=(-aB-Math.sqrt(aB*aB-4*aE*ay))/2/aE;ax=O(i,e,R,E,aG,aF,aC,az,aw>0&&aw<1?aw:0);av=O(i,e,R,E,aG,aF,aC,az,au>0&&au<1?au:0);aD=aD[J](ax.x,av.x);aA=aA[J](ax.y,av.y);return{min:{x:V[ao](0,aD),y:V[ao](0,aA)},max:{x:r[ao](0,aD),y:r[ao](0,aA)}};}),ag=ar(function(aF,aA){var au=I(aF),aB=aA&&I(aA),aC={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},e={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},aw=function(aG,aH){var i,aI;if(!aG){return["C",aH.x,aH.y,aH.x,aH.y,aH.x,aH.y];}!(aG[0] in {T:1,Q:1})&&(aH.qx=aH.qy=null);switch(aG[0]){case"M":aH.X=aG[1];aH.Y=aG[2];break;case"A":aG=["C"][J](B[ao](0,[aH.x,aH.y][J](aG.slice(1))));break;case"S":i=aH.x+(aH.x-(aH.bx||aH.x));aI=aH.y+(aH.y-(aH.by||aH.y));aG=["C",i,aI][J](aG.slice(1));break;case"T":aH.qx=aH.x+(aH.x-(aH.qx||aH.x));aH.qy=aH.y+(aH.y-(aH.qy||aH.y));aG=["C"][J](K(aH.x,aH.y,aH.qx,aH.qy,aG[1],aG[2]));break;case"Q":aH.qx=aG[1];aH.qy=aG[2];aG=["C"][J](K(aH.x,aH.y,aG[1],aG[2],aG[3],aG[4]));break;case"L":aG=["C"][J](k(aH.x,aH.y,aG[1],aG[2]));break;case"H":aG=["C"][J](k(aH.x,aH.y,aG[1],aH.y));break;case"V":aG=["C"][J](k(aH.x,aH.y,aH.x,aG[1]));break;case"Z":aG=["C"][J](k(aH.x,aH.y,aH.X,aH.Y));break;}return aG;},E=function(aG,aH){if(aG[aH][z]>7){aG[aH].shift();var aI=aG[aH];while(aI[z]){aG.splice(aH++,0,["C"][J](aI.splice(0,6)));}aG.splice(aH,1);aD=r(au[z],aB&&aB[z]||0);}},R=function(aK,aJ,aH,aG,aI){if(aK&&aJ&&aK[aI][0]=="M"&&aJ[aI][0]!="M"){aJ.splice(aI,0,["M",aG.x,aG.y]);aH.bx=0;aH.by=0;aH.x=aK[aI][1];aH.y=aK[aI][2];aD=r(au[z],aB&&aB[z]||0);}};for(var ay=0,aD=r(au[z],aB&&aB[z]||0);ay3){return{container:1,x:arguments[0],y:arguments[1],width:arguments[2],height:arguments[3]};}}},a=function(e,E){var i=this;for(var R in E){if(E[h](R)&&!(R in e)){switch(typeof E[R]){case"function":(function(au){e[R]=e===i?au:function(){return au[ao](i,arguments);};})(E[R]);break;case"object":e[R]=e[R]||{};a.call(this,e[R],E[R]);break;default:e[R]=E[R];break;}}}};if(l.svg){d.svgns="http://www.w3.org/2000/svg";d.xlink="http://www.w3.org/1999/xlink";var ai=function(e){return +e+(~~e===e)*0.5;};var N=function(av){for(var E=0,R=av[z];E0.25){av=Math.sqrt(0.25-L(ax-0.5,2))+0.5;}}return w;});aD=aD[H](/\s*\-\s*/);if(aA=="linear"){var aw=aD.shift();aw=-b(aw);if(isNaN(aw)){return null;}var au=[0,0,Math.cos(aw*Math.PI/180),Math.sin(aw*Math.PI/180)],aC=1/(r(Math.abs(au[2]),Math.abs(au[3]))||1);au[2]*=aC;au[3]*=aC;if(au[2]<0){au[0]=-au[2];au[2]=0;}if(au[3]<0){au[1]=-au[3];au[3]=0;}}var az=x(aD);if(!az){return null;}var E=P(aA+"Gradient");E.id="r"+(l.idGenerator++)[j](36);aA=="radial"?P(E,{fx:ax,fy:av}):P(E,{x1:au[0],y1:au[1],x2:au[2],y2:au[3]});e.defs[c](E);for(var ay=0,aE=az[z];ayax.height)&&(ax.height=aw.y+aw.height-ax.y);(aw.x+aw.width-ax.x>ax.width)&&(ax.width=aw.x+aw.width-ax.x);}}R&&this.hide();return ax;};s[v].attr=function(){if(arguments[z]==1&&l.is(arguments[0],"string")){if(arguments[0]=="translation"){return this.translate();}if(arguments[0]=="rotation"){return this.rotate();}if(arguments[0]=="scale"){return this.scale();}return this.attrs[arguments[0]];}if(arguments[z]==1&&l.is(arguments[0],"array")){var e={};for(var i in arguments[0]){if(arguments[0][h](i)){e[arguments[0][i]]=this.attrs[arguments[0][i]];}}return e;}if(arguments[z]==2){var E={};E[arguments[0]]=arguments[1];W(this,E);}else{if(arguments[z]==1&&l.is(arguments[0],"object")){W(this,arguments[0]);}}return this;};s[v].toFront=function(){this.node.parentNode[c](this.node);return this;};s[v].toBack=function(){if(this.node.parentNode.firstChild!=this.node){this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild);}return this;};s[v].insertAfter=function(e){if(e.node.nextSibling){e.node.parentNode.insertBefore(this.node,e.node.nextSibling);}else{e.node.parentNode[c](this.node);}return this;};s[v].insertBefore=function(e){var i=e.node;i.parentNode.insertBefore(this.node,i);return this;};var S=function(i,e,av,au){e=ai(e);av=ai(av);var R=P("circle");i.canvas&&i.canvas[c](R);var E=new s(R,i);E.attrs={cx:e,cy:av,r:au,fill:"none",stroke:"#000"};E.type="circle";P(R,E.attrs);return E;};var aa=function(E,e,ax,i,av,aw){e=ai(e);ax=ai(ax);var au=P("rect");E.canvas&&E.canvas[c](au);var R=new s(au,E);R.attrs={x:e,y:ax,width:i,height:av,r:aw||0,rx:aw||0,ry:aw||0,fill:"none",stroke:"#000"};R.type="rect";P(au,R.attrs);return R;};var n=function(i,e,aw,av,au){e=ai(e);aw=ai(aw);var R=P("ellipse");i.canvas&&i.canvas[c](R);var E=new s(R,i);E.attrs={cx:e,cy:aw,rx:av,ry:au,fill:"none",stroke:"#000"};E.type="ellipse";P(R,E.attrs);return E;};var y=function(E,aw,e,ax,i,av){var au=P("image");P(au,{x:e,y:ax,width:i,height:av,preserveAspectRatio:"none"});au.setAttributeNS(E.xlink,"href",aw);E.canvas&&E.canvas[c](au);var R=new s(au,E);R.attrs={x:e,y:ax,width:i,height:av,src:aw};R.type="image";return R;};var Z=function(i,e,av,au){var R=P("text");P(R,{x:e,y:av,"text-anchor":"middle"});i.canvas&&i.canvas[c](R);var E=new s(R,i);E.attrs={x:e,y:av,"text-anchor":"middle",text:au,font:A.font,stroke:"none",fill:"#000"};E.type="text";W(E,E.attrs);return E;};var U=function(i,e){this.width=i||this.width;this.height=e||this.height;this.canvas[f]("width",this.width);this.canvas[f]("height",this.height);return this;};var q=function(){var R=X[ao](null,arguments),E=R&&R.container,i=R.x,ax=R.y,au=R.width,e=R.height;if(!E){throw new Error("SVG container not found.");}d.canvas=P("svg");var aw=d.canvas;d.width=au||512;d.height=e||342;aw[f]("width",d.width);aw[f]("height",d.height);if(E==1){aw.style.cssText="position:absolute;left:"+i+"px;top:"+ax+"px";m.body[c](aw);}else{if(E.firstChild){E.insertBefore(aw,E.firstChild);}else{E[c](aw);}}E={canvas:aw};for(var av in d){if(d[h](av)){E[av]=d[av];}}a.call(E,E,l.fn);E.clear();E.raphael=l;return E;};d.clear=function(){var e=this.canvas;while(e.firstChild){e.removeChild(e.firstChild);}(this.desc=P("desc"))[c](m.createTextNode("Created with Rapha\u00ebl"));e[c](this.desc);e[c](this.defs=P("defs"));};d.remove=function(){this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas);for(var e in this){delete this[e];}};}if(l.vml){var M=function(aE){var aB=/[ahqtv]/ig,aw=I;(aE+w).match(aB)&&(aw=ag);aB=/[clmz]/g;if(aw==I&&!(aE+w).match(aB)){var E={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},au=/([clmz]),?([^clmz]*)/gi,av=/-?[^,\s-]+/g;var aA=(aE+w)[Q](au,function(aF,aH,i){var aG=[];i[Q](av,function(aI){aG[ae](ai(aI));});return E[aH]+aG;});return aA;}var aC=aw(aE),R,aA=[],e;for(var ay=0,aD=aC[z];ay1&&(i=1);aC.opacity=i;}aD.fill&&(aC.on=true);if(aC.on==null||aD.fill=="none"){aC.on=false;}if(aC.on&&aD.fill){var E=aD.fill.match(/^url\(([^\)]+)\)$/i);if(E){aC.src=E[1];aC.type="tile";}else{aC.color=l.getRGB(aD.fill).hex;aC.src=w;aC.type="solid";if(l.getRGB(aD.fill).error&&(aI.type in {circle:1,ellipse:1}||(aD.fill+w).charAt(0)!="r")&&af(aI,aD.fill)){aE.fill="none";aE.gradient=aD.fill;}}}aF&&aB[c](aC);var au=(aB.getElementsByTagName("stroke")&&aB.getElementsByTagName("stroke")[0]),aG=false;!au&&(aG=au=ap("stroke"));if((aD.stroke&&aD.stroke!="none")||aD["stroke-width"]||aD["stroke-opacity"]!=null||aD["stroke-dasharray"]||aD["stroke-miterlimit"]||aD["stroke-linejoin"]||aD["stroke-linecap"]){au.on=true;}(aD.stroke=="none"||au.on==null||aD.stroke==0||aD["stroke-width"]==0)&&(au.on=false);au.on&&aD.stroke&&(au.color=l.getRGB(aD.stroke).hex);var i=((+aE["stroke-opacity"]+1||2)-1)*((+aE.opacity+1||2)-1);i<0&&(i=0);i>1&&(i=1);au.opacity=i;aD["stroke-linejoin"]&&(au.joinstyle=aD["stroke-linejoin"]||"miter");au.miterlimit=aD["stroke-miterlimit"]||8;aD["stroke-linecap"]&&(au.endcap={butt:"flat",square:"square",round:"round"}[aD["stroke-linecap"]]||"miter");aD["stroke-width"]&&(au.weight=(b(aD["stroke-width"])||1)*12/16);if(aD["stroke-dasharray"]){var aA={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};au.dashstyle=aA[aD["stroke-dasharray"]]||w;}aG&&aB[c](au);}if(aI.type=="text"){var aw=aI.paper.span.style;aE.font&&(aw.font=aE.font);aE["font-family"]&&(aw.fontFamily=aE["font-family"]);aE["font-size"]&&(aw.fontSize=aE["font-size"]);aE["font-weight"]&&(aw.fontWeight=aE["font-weight"]);aE["font-style"]&&(aw.fontStyle=aE["font-style"]);aI.node.string&&(aI.paper.span.innerHTML=(aI.node.string+w)[Q](/"));aI.W=aE.w=aI.paper.span.offsetWidth;aI.H=aE.h=aI.paper.span.offsetHeight;aI.X=aE.x;aI.Y=aE.y+ai(aI.H/2);switch(aE["text-anchor"]){case"start":aI.node.style["v-text-align"]="left";aI.bbx=ai(aI.W/2);break;case"end":aI.node.style["v-text-align"]="right";aI.bbx=-ai(aI.W/2);break;default:aI.node.style["v-text-align"]="center";break;}}};var af=function(e,ax){e.attrs=e.attrs||{};var ay=e.attrs,aA=e.node.getElementsByTagName("fill"),av="linear",aw=".5 .5";e.attrs.gradient=ax;ax=(ax+w)[Q](/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,function(aC,aD,i){av="radial";if(aD&&i){aD=b(aD);i=b(i);if(L(aD-0.5,2)+L(i-0.5,2)>0.25){i=Math.sqrt(0.25-L(aD-0.5,2))+0.5;}aw=aD+" "+i;}return w;});ax=ax[H](/\s*\-\s*/);if(av=="linear"){var E=ax.shift();E=-b(E);if(isNaN(E)){return null;}}var au=x(ax);if(!au){return null;}e=e.shape||e.node;aA=aA[0]||ap("fill");if(au[z]){aA.on=true;aA.method="none";aA.type=(av=="radial")?"gradientradial":"gradient";aA.color=au[0].color;aA.color2=au[au[z]-1].color;var aB=[];for(var R=0,az=au[z];R');};}catch(an){var ap=function(e){return m.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');};}var q=function(){var R=X[ao](null,arguments),i=R.container,az=R.height,aA,E=R.width,ay=R.x,ax=R.y;if(!i){throw new Error("VML container not found.");}var av={},aw=av.canvas=m.createElement("div"),au=aw.style;E=b(E)||512;az=b(az)||342;av.width=E;av.height=az;av.coordsize=E+" "+az;av.coordorigin="0 0";av.span=m.createElement("span");av.span.style.cssText="position:absolute;left:-9999px;top:-9999px;padding:0;margin:0;line-height:1;display:inline;";aw[c](av.span);au.cssText=l.format("width:{0}px;height:{1}px;position:absolute;clip:rect(0 {0}px {1}px 0)",E,az);if(i==1){m.body[c](aw);au.left=ay+"px";au.top=ax+"px";i={style:{width:E,height:az}};}else{i.style.width=E;i.style.height=az;if(i.firstChild){i.insertBefore(aw,i.firstChild);}else{i[c](aw);}}for(var e in d){if(d[h](e)){av[e]=d[e];}}a.call(av,av,l.fn);av.clear=function(){while(aw.firstChild){aw.removeChild(aw.firstChild);}};av.raphael=l;return av;};d.remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var e in this){delete this[e];}};}if({"Apple Computer, Inc.":1,"Google Inc.":1}[navigator.vendor]){d.safari=function(){var e=this.rect(-99,-99,this.width+99,this.height+99);setTimeout(function(){e.remove();});};}else{d.safari=function(){};}var o=(function(){if(m.addEventListener){return function(au,E,i,e){var R=function(av){return i.call(e,av);};au.addEventListener(E,R,false);return function(){au.removeEventListener(E,R,false);return true;};};}else{if(m.attachEvent){return function(av,R,E,i){var au=function(aw){return E.call(i,aw||ad.event);};av.attachEvent("on"+R,au);var e=function(){av.detachEvent("on"+R,au);return true;};if(R=="mouseover"){av.attachEvent("onmouseenter",au);return function(){av.detachEvent("onmouseenter",au);return e();};}else{if(R=="mouseout"){av.attachEvent("onmouseleave",au);return function(){av.detachEvent("onmouseleave",au);return e();};}}return e;};}}})();for(var ak=G[z];ak--;){(function(e){s[v][e]=function(i){if(l.is(i,"function")){this.events=this.events||{};this.events[e]=this.events[e]||{};this.events[e][i]=this.events[e][i]||[];this.events[e][i][ae](o(this.shape||this.node,e,i,this));}return this;};s[v]["un"+e]=function(i){this.events&&this.events[e]&&this.events[e][i]&&this.events[e][i][z]&&this.events[e][i].shift()()&&!this.events[e][i][z]&&delete this.events[e][i];};})(G[ak]);}d.circle=function(e,E,i){return S(this,e||0,E||0,i||0);};d.rect=function(e,au,i,E,R){return aa(this,e||0,au||0,i||0,E||0,R||0);};d.ellipse=function(e,R,E,i){return n(this,e||0,R||0,E||0,i||0);};d.path=function(e){e&&!l.is(e,"string")&&!l.is(e[0],"array")&&(e+=w);return aq(l.format[ao](l,arguments),this);};d.image=function(R,e,au,i,E){return y(this,R||"about:blank",e||0,au||0,i||0,E||0);};d.text=function(e,E,i){return Z(this,e||0,E||0,i||w);};d.set=function(e){arguments[z]>1&&(e=Array[v].splice.call(arguments,0,arguments[z]));return new p(e);};d.setSize=U;s[v].stop=function(){clearTimeout(this.animation_in_progress);return this;};s[v].scale=function(aE,aD,R,E){if(aE==null&&aD==null){return{x:this._.sx,y:this._.sy,toString:function(){return this.x+" "+this.y;}};}aD=aD||aE;!+aD&&(aD=aE);var aI,aG,aH,aF,aU=this.attrs;if(aE!=0){var aB=this.getBBox(),ay=aB.x+aB.width/2,av=aB.y+aB.height/2,aT=aE/this._.sx,aS=aD/this._.sy;R=(+R||R==0)?R:ay;E=(+E||E==0)?E:av;var aA=~~(aE/Math.abs(aE)),ax=~~(aD/Math.abs(aD)),aL=this.node.style,aW=R+(ay-R)*aA*aT,aV=E+(av-E)*ax*aS;switch(this.type){case"rect":case"image":var az=aU.width*aA*aT,aK=aU.height*ax*aS,aC=aU.r*V(aT,aS),aw=aW-az/2,au=aV-aK/2;this.attr({width:az,height:aK,x:aw,y:au,r:aC});break;case"circle":case"ellipse":this.attr({rx:aU.rx*aT,ry:aU.ry*aS,r:aU.r*V(aT,aS),cx:aW,cy:aV});break;case"path":var aN=g(aU.path),aO=true;for(var aQ=0,aJ=aN[z];aQ":function(e){return L(e-1,3)+1;},"<>":function(e){e=e*2;if(e<1){return L(e,3)/2;}e-=2;return(L(e,3)+2)/2;},backIn:function(i){var e=1.70158;return i*i*((e+1)*i-e);},backOut:function(i){i=i-1;var e=1.70158;return i*i*((e+1)*i+e)+1;},elastic:function(E){if(E==0||E==1){return E;}var i=0.3,e=i/4;return L(2,-10*E)*Math.sin((E-e)*(2*Math.PI)/i)+1;},bounce:function(R){var i=7.5625,E=2.75,e;if(R<(1/E)){e=i*R*R;}else{if(R<(2/E)){R-=(1.5/E);e=i*R*R+0.75;}else{if(R<(2.5/E)){R-=(2.25/E);e=i*R*R+0.9375;}else{R-=(2.625/E);e=i*R*R+0.984375;}}}return e;}};s[v].animate=function(aM,aD,aC,au){clearTimeout(this.animation_in_progress);if(l.is(aC,"function")||!aC){au=aC||null;}var aG={},E={},aA={},az={x:0,y:0};for(var aE in aM){if(aM[h](aE)){if(aE in F){aG[aE]=this.attr(aE);(aG[aE]==null)&&(aG[aE]=A[aE]);E[aE]=aM[aE];switch(F[aE]){case"number":aA[aE]=(E[aE]-aG[aE])/aD;break;case"colour":aG[aE]=l.getRGB(aG[aE]);var aF=l.getRGB(E[aE]);aA[aE]={r:(aF.r-aG[aE].r)/aD,g:(aF.g-aG[aE].g)/aD,b:(aF.b-aG[aE].b)/aD};break;case"path":var av=ag(aG[aE],E[aE]);aG[aE]=av[0];E[aE]=av[1];aA[aE]=[];for(var aI=0,ay=aG[aE][z];aI255?255:i;},aw=this;(function aJ(){var aO=new Date-R,aW={},aN;if(aO");i.close();aA=i.body;}catch(aC){aA=createPopup().document.body;}var R=aA.createTextRange();aA.style.color=S;var aB=R.queryCommandValue("ForeColor");aB=((aB&255)<<16)|(aB&65280)|((aB&16711680)>>>16);return"#"+("000000"+aB[af](16)).slice(-6);});}else{var E=z.createElement("i");E.className="Rapha\u00ebl colour picker";E.style.cssText="display:none";z.body[ao](E);ah=V(function(i){E.style.color=i;return z.defaultView.getComputedStyle(E,aa).getPropertyValue("color");});}return ah(e);};Y.hsb2rgb=V(function(aE,aC,aI){if(Y.is(aE,"object")&&"h" in aE&&"s" in aE&&"b" in aE){aI=aE.b;aC=aE.s;aE=aE.h;}var S,aA,aJ;if(aI==0){return{r:0,g:0,b:0,hex:"#000"};}if(aE>1||aC>1||aI>1){aE/=255;aC/=255;aI/=255;}var aB=~~(aE*6),aF=(aE*6)-aB,R=aI*(1-aC),E=aI*(1-(aC*aF)),aK=aI*(1-(aC*(1-aF)));S=[aI,E,R,R,aK,aI,aI][aB];aA=[aK,aI,aI,E,R,R,aK][aB];aJ=[R,R,aK,aI,aI,E,R][aB];S*=255;aA*=255;aJ*=255;var aG={r:S,g:aA,b:aJ},e=(~~S)[af](16),aD=(~~aA)[af](16),aH=(~~aJ)[af](16);e=e[aq](av,"0");aD=aD[aq](av,"0");aH=aH[aq](av,"0");aG.hex="#"+e+aD+aH;return aG;},Y);Y.rgb2hsb=V(function(e,i,aC){if(Y.is(e,"object")&&"r" in e&&"g" in e&&"b" in e){aC=e.b;i=e.g;e=e.r;}if(Y.is(e,"string")){var aE=Y.getRGB(e);e=aE.r;i=aE.g;aC=aE.b;}if(e>1||i>1||aC>1){e/=255;i/=255;aC/=255;}var aB=d(e,i,aC),E=al(e,i,aC),S,R,aA=aB;if(E==aB){return{h:0,s:0,b:aB};}else{var aD=(aB-E);R=aD/aB;if(e==aB){S=(i-aC)/aD;}else{if(i==aB){S=2+((aC-e)/aD);}else{S=4+((e-i)/aD);}}S/=6;S<0&&S++;S>1&&S--;}return{h:S,s:R,b:aA};},Y);Y._path2string=function(){var R=aa,aB;for(var E=0,S=this[j];E=1000&&delete aA[aC.shift()];aC[c](aB);aA[aB]=R[ax](i,S);return e?e(aA[aB]):aA[aB];}return E;}Y.getRGB=V(function(e){if(!e||!!((e+aa).indexOf("-")+1)){return{r:-1,g:-1,b:-1,hex:"none",error:1};}e=e+aa;if(e=="none"){return{r:-1,g:-1,b:-1,hex:"none"};}!(({hs:1,rg:1}[F](e.substring(0,2))))&&(e=ah(e));var aA,E,R,aD,aB=e.match(/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgb\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|rgb\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\)|hs[bl]\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|hs[bl]\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\))\s*$/i);if(aB){if(aB[2]){aD=v(aB[2].substring(5),16);R=v(aB[2].substring(3,5),16);E=v(aB[2].substring(1,3),16);}if(aB[3]){aD=v(aB[3].substring(3)+aB[3].substring(3),16);R=v(aB[3].substring(2,3)+aB[3].substring(2,3),16);E=v(aB[3].substring(1,2)+aB[3].substring(1,2),16);}if(aB[4]){aB=aB[4][r](/\s*,\s*/);E=J(aB[0]);R=J(aB[1]);aD=J(aB[2]);}if(aB[5]){aB=aB[5][r](/\s*,\s*/);E=J(aB[0])*2.55;R=J(aB[1])*2.55;aD=J(aB[2])*2.55;}if(aB[6]){aB=aB[6][r](/\s*,\s*/);E=J(aB[0]);R=J(aB[1]);aD=J(aB[2]);return Y.hsb2rgb(E,R,aD);}if(aB[7]){aB=aB[7][r](/\s*,\s*/);E=J(aB[0])*2.55;R=J(aB[1])*2.55;aD=J(aB[2])*2.55;return Y.hsb2rgb(E,R,aD);}aB={r:E,g:R,b:aD};var i=(~~E)[af](16),S=(~~R)[af](16),aC=(~~aD)[af](16);i=i[aq](av,"0");S=S[aq](av,"0");aC=aC[aq](av,"0");aB.hex="#"+i+S+aC;return aB;}return{r:-1,g:-1,b:-1,hex:"none",error:1};},Y);Y.getColor=function(i){var E=this.getColor.start=this.getColor.start||{h:0,s:1,b:i||0.75},e=this.hsb2rgb(E.h,E.s,E.b);E.h+=0.075;if(E.h>1){E.h=0;E.s-=0.2;E.s<=0&&(this.getColor.start={h:0,s:1,b:E.b});}return e.hex;};Y.getColor.reset=function(){delete this.start;};Y.parsePathString=V(function(e){if(!e){return null;}var E={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},i=[];if(Y.is(e,"array")&&Y.is(e[0],"array")){i=ac(e);}if(!i[j]){(e+aa)[aq](/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,function(S,R,aC){var aB=[],aA=R.toLowerCase();aC[aq](/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig,function(aE,aD){aD&&aB[c](+aD);});while(aB[j]>=E[aA]){i[c]([R][au](aB.splice(0,E[aA])));if(!E[aA]){break;}}});}i[af]=Y._path2string;return i;});var H=V(function(aF){if(!aF){return{x:0,y:0,width:0,height:0};}aF=w(aF);var aC=0,aB=0,R=[],E=[];for(var S=0,aE=aF[j];SaD){aE=aE-S*2;}if(!aA&&aD>aE){aD=aD-S*2;}}else{aE=aM[0];aD=aM[1];aO=aM[2];aN=aM[3];}var aI=aD-aE;if(Math.abs(aI)>aQ){var aP=aD,aS=aJ,aG=bd;aD=aE+aQ*(aA&&aD>aE?1:-1);aJ=aO+aT*Math.cos(aD);bd=aN+aR*Math.sin(aD);aX=y(aJ,bd,aT,aR,aL,0,aA,aS,aG,[aD,aP,aO,aN]);}aI=aD-aE;var aC=Math.cos(aE),bc=Math.sin(aE),aB=Math.cos(aD),bb=Math.sin(aD),a0=Math.tan(aI/4),a3=4/3*aT*a0,a1=4/3*aR*a0,a9=[aK,be],a8=[aK+a3*bc,be-a1*aC],a7=[aJ+a3*bb,bd-a1*aB],a5=[aJ,bd];a8[0]=2*a9[0]-a8[0];a8[1]=2*a9[1]-a8[1];if(aM){return[a8,a7,a5][au](aX);}else{aX=[a8,a7,a5][au](aX)[ae](",")[r](",");var aV=[];for(var a6=0,aW=aX[j];a60&&aB<1?aB:0),aA=A(i,e,R,E,aL,aK,aH,aE,S>0&&S<1?S:0);aI=aI[au](aC.x,aA.x);aF=aF[au](aC.y,aA.y);aJ=(aK-2*E+e)-(aE-2*aK+E);aG=2*(E-e)-2*(aK-E);aD=e-E;aB=(-aG+Math.sqrt(aG*aG-4*aJ*aD))/2/aJ;S=(-aG-Math.sqrt(aG*aG-4*aJ*aD))/2/aJ;aC=A(i,e,R,E,aL,aK,aH,aE,aB>0&&aB<1?aB:0);aA=A(i,e,R,E,aL,aK,aH,aE,S>0&&S<1?S:0);aI=aI[au](aC.x,aA.x);aF=aF[au](aC.y,aA.y);return{min:{x:al[ax](0,aI),y:al[ax](0,aF)},max:{x:d[ax](0,aI),y:d[ax](0,aF)}};}),w=V(function(aK,aF){var S=n(aK),aG=aF&&n(aF),aH={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},e={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},aB=function(aL,aM){var i,aN;if(!aL){return["C",aM.x,aM.y,aM.x,aM.y,aM.x,aM.y];}!(aL[0] in {T:1,Q:1})&&(aM.qx=aM.qy=null);switch(aL[0]){case"M":aM.X=aL[1];aM.Y=aL[2];break;case"A":aL=["C"][au](y[ax](0,[aM.x,aM.y][au](aL.slice(1))));break;case"S":i=aM.x+(aM.x-(aM.bx||aM.x));aN=aM.y+(aM.y-(aM.by||aM.y));aL=["C",i,aN][au](aL.slice(1));break;case"T":aM.qx=aM.x+(aM.x-(aM.qx||aM.x));aM.qy=aM.y+(aM.y-(aM.qy||aM.y));aL=["C"][au](an(aM.x,aM.y,aM.qx,aM.qy,aL[1],aL[2]));break;case"Q":aM.qx=aL[1];aM.qy=aL[2];aL=["C"][au](an(aM.x,aM.y,aL[1],aL[2],aL[3],aL[4]));break;case"L":aL=["C"][au](ay(aM.x,aM.y,aL[1],aL[2]));break;case"H":aL=["C"][au](ay(aM.x,aM.y,aL[1],aM.y));break;case"V":aL=["C"][au](ay(aM.x,aM.y,aM.x,aL[1]));break;case"Z":aL=["C"][au](ay(aM.x,aM.y,aM.X,aM.Y));break;}return aL;},E=function(aL,aM){if(aL[aM][j]>7){aL[aM].shift();var aN=aL[aM];while(aN[j]){aL.splice(aM++,0,["C"][au](aN.splice(0,6)));}aL.splice(aM,1);aI=d(S[j],aG&&aG[j]||0);}},R=function(aP,aO,aM,aL,aN){if(aP&&aO&&aP[aN][0]=="M"&&aO[aN][0]!="M"){aO.splice(aN,0,["M",aL.x,aL.y]);aM.bx=0;aM.by=0;aM.x=aP[aN][1];aM.y=aP[aN][2];aI=d(S[j],aG&&aG[j]||0);}};for(var aD=0,aI=d(S[j],aG&&aG[j]||0);aD3){return{container:1,x:arguments[0],y:arguments[1],width:arguments[2],height:arguments[3]};}}},aj=function(e,E){var i=this;for(var R in E){if(E[F](R)&&!(R in e)){switch(typeof E[R]){case"function":(function(S){e[R]=e===i?S:function(){return S[ax](i,arguments);};})(E[R]);break;case"object":e[R]=e[R]||{};aj.call(this,e[R],E[R]);break;default:e[R]=E[R];break;}}}};if(Y.svg){ar.svgns="http://www.w3.org/2000/svg";ar.xlink="http://www.w3.org/1999/xlink";var C=function(e){return +e+(~~e===e)*0.5;};var I=function(aA){for(var E=0,R=aA[j];E0.25){aA=Math.sqrt(0.25-ap(aC-0.5,2))+0.5;}}return aa;});aI=aI[r](/\s*\-\s*/);if(aF=="linear"){var aB=aI.shift();aB=-J(aB);if(isNaN(aB)){return null;}var S=[0,0,Math.cos(aB*Math.PI/180),Math.sin(aB*Math.PI/180)],aH=1/(d(Math.abs(S[2]),Math.abs(S[3]))||1);S[2]*=aH;S[3]*=aH;if(S[2]<0){S[0]=-S[2];S[2]=0;}if(S[3]<0){S[1]=-S[3];S[3]=0;}}var aE=l(aI);if(!aE){return null;}var E=am(aF+"Gradient");E.id="r"+(Y._id++)[af](36);aF=="radial"?am(E,{fx:aC,fy:aA}):am(E,{x1:S[0],y1:S[1],x2:S[2],y2:S[3]});e.defs[ao](E);for(var aD=0,aJ=aE[j];aDaC.height)&&(aC.height=aB.y+aB.height-aC.y);(aB.x+aB.width-aC.x>aC.width)&&(aC.width=aB.x+aB.width-aC.x);}}R&&this.hide();return aC;};ad[az].attr=function(){if(this.removed){return this;}if(arguments[j]==1&&Y.is(arguments[0],"string")){if(arguments[0]=="translation"){return this.translate();}if(arguments[0]=="rotation"){return this.rotate();}if(arguments[0]=="scale"){return this.scale();}return this.attrs[arguments[0]];}if(arguments[j]==1&&Y.is(arguments[0],"array")){var e={};for(var i in arguments[0]){if(arguments[0][F](i)){e[arguments[0][i]]=this.attrs[arguments[0][i]];}}return e;}if(arguments[j]==2){var E={};E[arguments[0]]=arguments[1];M(this,E);}else{if(arguments[j]==1&&Y.is(arguments[0],"object")){M(this,arguments[0]);}}return this;};ad[az].toFront=function(){!this.removed&&this.node.parentNode[ao](this.node);return this;};ad[az].toBack=function(){if(this.removed){return this;}if(this.node.parentNode.firstChild!=this.node){this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild);}return this;};ad[az].insertAfter=function(e){if(this.removed){return this;}if(e.node.nextSibling){e.node.parentNode.insertBefore(this.node,e.node.nextSibling);}else{e.node.parentNode[ao](this.node);}return this;};ad[az].insertBefore=function(e){if(this.removed){return this;}var i=e.node;i.parentNode.insertBefore(this.node,i);return this;};var D=function(i,e,aA,S){e=C(e);aA=C(aA);var R=am("circle");i.canvas&&i.canvas[ao](R);var E=new ad(R,i);E.attrs={cx:e,cy:aA,r:S,fill:"none",stroke:"#000"};E.type="circle";am(R,E.attrs);return E;};var ai=function(E,e,aC,i,aA,aB){e=C(e);aC=C(aC);var S=am("rect");E.canvas&&E.canvas[ao](S);var R=new ad(S,E);R.attrs={x:e,y:aC,width:i,height:aA,r:aB||0,rx:aB||0,ry:aB||0,fill:"none",stroke:"#000"};R.type="rect";am(S,R.attrs);return R;};var U=function(i,e,aB,aA,S){e=C(e);aB=C(aB);var R=am("ellipse");i.canvas&&i.canvas[ao](R);var E=new ad(R,i);E.attrs={cx:e,cy:aB,rx:aA,ry:S,fill:"none",stroke:"#000"};E.type="ellipse";am(R,E.attrs);return E;};var k=function(E,aB,e,aC,i,aA){var S=am("image");am(S,{x:e,y:aC,width:i,height:aA,preserveAspectRatio:"none"});S.setAttributeNS(E.xlink,"href",aB);E.canvas&&E.canvas[ao](S);var R=new ad(S,E);R.attrs={x:e,y:aC,width:i,height:aA,src:aB};R.type="image";return R;};var K=function(i,e,aA,S){var R=am("text");am(R,{x:e,y:aA,"text-anchor":"middle"});i.canvas&&i.canvas[ao](R);var E=new ad(R,i);E.attrs={x:e,y:aA,"text-anchor":"middle",text:S,font:g.font,stroke:"none",fill:"#000"};E.type="text";M(E,E.attrs);return E;};var aw=function(i,e){this.width=i||this.width;this.height=e||this.height;this.canvas[o]("width",this.width);this.canvas[o]("height",this.height);return this;};var p=function(){var R=Z[ax](null,arguments),E=R&&R.container,i=R.x,aC=R.y,S=R.width,e=R.height;if(!E){throw new Error("SVG container not found.");}ar.canvas=am("svg");var aB=ar.canvas;ar.width=S||512;ar.height=e||342;aB[o]("width",ar.width);aB[o]("height",ar.height);if(E==1){aB.style.cssText="position:absolute;left:"+i+"px;top:"+aC+"px";z.body[ao](aB);}else{if(E.firstChild){E.insertBefore(aB,E.firstChild);}else{E[ao](aB);}}E={canvas:aB};for(var aA in ar){if(ar[F](aA)){E[aA]=ar[aA];}}aj.call(E,E,Y.fn);E.clear();E.raphael=Y;return E;};ar.clear=function(){var e=this.canvas;while(e.firstChild){e.removeChild(e.firstChild);}(this.desc=am("desc"))[ao](z.createTextNode("Created with Rapha\u00ebl"));e[ao](this.desc);e[ao](this.defs=am("defs"));};ar.remove=function(){this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas);for(var e in this){delete this[e];}};}if(Y.vml){var ak=function(aJ){var aG=/[ahqtv]/ig,aB=n;(aJ+aa).match(aG)&&(aB=w);aG=/[clmz]/g;if(aB==n&&!(aJ+aa).match(aG)){var E={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},S=/([clmz]),?([^clmz]*)/gi,aA=/-?[^,\s-]+/g;var aF=(aJ+aa)[aq](S,function(aK,aM,i){var aL=[];i[aq](aA,function(aN){aL[c](C(aN));});return E[aM]+aL;});return aF;}var aH=aB(aJ),R,aF=[],e;for(var aD=0,aI=aH[j];aD1&&(i=1);aH.opacity=i;}aI.fill&&(aH.on=true);if(aH.on==null||aI.fill=="none"){aH.on=false;}if(aH.on&&aI.fill){var E=aI.fill.match(/^url\(([^\)]+)\)$/i);if(E){aH.src=E[1];aH.type="tile";}else{aH.color=Y.getRGB(aI.fill).hex;aH.src=aa;aH.type="solid";if(Y.getRGB(aI.fill).error&&(aN.type in {circle:1,ellipse:1}||(aI.fill+aa).charAt(0)!="r")&&b(aN,aI.fill)){aJ.fill="none";aJ.gradient=aI.fill;}}}aK&&aG[ao](aH);var S=(aG.getElementsByTagName("stroke")&&aG.getElementsByTagName("stroke")[0]),aL=false;!S&&(aL=S=T("stroke"));if((aI.stroke&&aI.stroke!="none")||aI["stroke-width"]||aI["stroke-opacity"]!=null||aI["stroke-dasharray"]||aI["stroke-miterlimit"]||aI["stroke-linejoin"]||aI["stroke-linecap"]){S.on=true;}(aI.stroke=="none"||S.on==null||aI.stroke==0||aI["stroke-width"]==0)&&(S.on=false);S.on&&aI.stroke&&(S.color=Y.getRGB(aI.stroke).hex);var i=((+aJ["stroke-opacity"]+1||2)-1)*((+aJ.opacity+1||2)-1);i<0&&(i=0);i>1&&(i=1);S.opacity=i;aI["stroke-linejoin"]&&(S.joinstyle=aI["stroke-linejoin"]||"miter");S.miterlimit=aI["stroke-miterlimit"]||8;aI["stroke-linecap"]&&(S.endcap={butt:"flat",square:"square",round:"round"}[aI["stroke-linecap"]]||"miter");aI["stroke-width"]&&(S.weight=(J(aI["stroke-width"])||1)*12/16);if(aI["stroke-dasharray"]){var aF={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};S.dashstyle=aF[aI["stroke-dasharray"]]||aa;}aL&&aG[ao](S);}if(aN.type=="text"){var aB=aN.paper.span.style;aJ.font&&(aB.font=aJ.font);aJ["font-family"]&&(aB.fontFamily=aJ["font-family"]);aJ["font-size"]&&(aB.fontSize=aJ["font-size"]);aJ["font-weight"]&&(aB.fontWeight=aJ["font-weight"]);aJ["font-style"]&&(aB.fontStyle=aJ["font-style"]);aN.node.string&&(aN.paper.span.innerHTML=(aN.node.string+aa)[aq](/"));aN.W=aJ.w=aN.paper.span.offsetWidth;aN.H=aJ.h=aN.paper.span.offsetHeight;aN.X=aJ.x;aN.Y=aJ.y+C(aN.H/2);switch(aJ["text-anchor"]){case"start":aN.node.style["v-text-align"]="left";aN.bbx=C(aN.W/2);break;case"end":aN.node.style["v-text-align"]="right";aN.bbx=-C(aN.W/2);break;default:aN.node.style["v-text-align"]="center";break;}}};var b=function(e,aC){e.attrs=e.attrs||{};var aD=e.attrs,aF=e.node.getElementsByTagName("fill"),aA="linear",aB=".5 .5";e.attrs.gradient=aC;aC=(aC+aa)[aq](/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,function(aH,aI,i){aA="radial";if(aI&&i){aI=J(aI);i=J(i);if(ap(aI-0.5,2)+ap(i-0.5,2)>0.25){i=Math.sqrt(0.25-ap(aI-0.5,2))+0.5;}aB=aI+X+i;}return aa;});aC=aC[r](/\s*\-\s*/);if(aA=="linear"){var E=aC.shift();E=-J(E);if(isNaN(E)){return null;}}var S=l(aC);if(!S){return null;}e=e.shape||e.node;aF=aF[0]||T("fill");if(S[j]){aF.on=true;aF.method="none";aF.type=(aA=="radial")?"gradientradial":"gradient";aF.color=S[0].color;aF.color2=S[S[j]-1].color;var aG=[];for(var R=0,aE=S[j];R');};}catch(P){var T=function(e){return z.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');};}var p=function(){var R=Z[ax](null,arguments),i=R.container,aE=R.height,aF,E=R.width,aD=R.x,aC=R.y;if(!i){throw new Error("VML container not found.");}var aA={},aB=aA.canvas=z.createElement("div"),S=aB.style;E=J(E)||512;aE=J(aE)||342;aA.width=E;aA.height=aE;aA.coordsize=E+X+aE;aA.coordorigin="0 0";aA.span=z.createElement("span");aA.span.style.cssText="position:absolute;left:-9999px;top:-9999px;padding:0;margin:0;line-height:1;display:inline;";aB[ao](aA.span);S.cssText=Y.format("width:{0}px;height:{1}px;position:absolute;clip:rect(0 {0}px {1}px 0)",E,aE);if(i==1){z.body[ao](aB);S.left=aD+"px";S.top=aC+"px";i={style:{width:E,height:aE}};}else{i.style.width=E;i.style.height=aE;if(i.firstChild){i.insertBefore(aB,i.firstChild);}else{i[ao](aB);}}for(var e in ar){if(ar[F](e)){aA[e]=ar[e];}}aj.call(aA,aA,Y.fn);aA.clear=function(){aB.innerHTML=aa;};aA.raphael=Y;return aA;};ar.remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var e in this){delete this[e];}};}if({"Apple Computer, Inc.":1,"Google Inc.":1}[navigator.vendor]){ar.safari=function(){var e=this.rect(-99,-99,this.width+99,this.height+99);setTimeout(function(){e.remove();});};}else{ar.safari=function(){};}var Q=(function(){if(z.addEventListener){return function(S,E,i,e){var R=function(aA){return i.call(e,aA);};S.addEventListener(E,R,false);return function(){S.removeEventListener(E,R,false);return true;};};}else{if(z.attachEvent){return function(aA,R,E,i){var S=function(aB){return E.call(i,aB||ab.event);};aA.attachEvent("on"+R,S);var e=function(){aA.detachEvent("on"+R,S);return true;};if(R=="mouseover"){aA.attachEvent("onmouseenter",S);return function(){aA.detachEvent("onmouseenter",S);return e();};}else{if(R=="mouseout"){aA.attachEvent("onmouseleave",S);return function(){aA.detachEvent("onmouseleave",S);return e();};}}return e;};}}})();for(var N=u[j];N--;){(function(e){ad[az][e]=function(i){if(Y.is(i,"function")){this.events=this.events||{};this.events[e]=this.events[e]||{};this.events[e][i]=this.events[e][i]||[];this.events[e][i][c](Q(this.shape||this.node,e,i,this));}return this;};ad[az]["un"+e]=function(i){var E=this.events;E&&E[e]&&E[e][i]&&E[e][i][j]&&E[e][i].shift()()&&!E[e][i][j]&&delete E[e][i];return this;};})(u[N]);}ad[az].hover=function(i,e){return this.mouseover(i).mouseout(e);};ar.circle=function(e,E,i){return D(this,e||0,E||0,i||0);};ar.rect=function(e,S,i,E,R){return ai(this,e||0,S||0,i||0,E||0,R||0);};ar.ellipse=function(e,R,E,i){return U(this,e||0,R||0,E||0,i||0);};ar.path=function(e){e&&!Y.is(e,"string")&&!Y.is(e[0],"array")&&(e+=aa);return m(Y.format[ax](Y,arguments),this);};ar.image=function(R,e,S,i,E){return k(this,R||"about:blank",e||0,S||0,i||0,E||0);};ar.text=function(e,E,i){return K(this,e||0,E||0,i||aa);};ar.set=function(e){arguments[j]>1&&(e=Array[az].splice.call(arguments,0,arguments[j]));return new G(e);};ar.setSize=aw;ad[az].scale=function(aJ,aI,R,E){if(aJ==null&&aI==null){return{x:this._.sx,y:this._.sy,toString:function(){return this.x+X+this.y;}};}aI=aI||aJ;!+aI&&(aI=aJ);var aN,aL,aM,aK,aZ=this.attrs;if(aJ!=0){var aG=this.getBBox(),aD=aG.x+aG.width/2,aA=aG.y+aG.height/2,aY=aJ/this._.sx,aX=aI/this._.sy;R=(+R||R==0)?R:aD;E=(+E||E==0)?E:aA;var aF=~~(aJ/Math.abs(aJ)),aC=~~(aI/Math.abs(aI)),aQ=this.node.style,a1=R+(aD-R)*aF*aY,a0=E+(aA-E)*aC*aX;switch(this.type){case"rect":case"image":var aE=aZ.width*aF*aY,aP=aZ.height*aC*aX,aH=aZ.r*al(aY,aX),aB=a1-aE/2,S=a0-aP/2;this.attr({width:aE,height:aP,x:aB,y:S,r:aH});break;case"circle":case"ellipse":this.attr({rx:aZ.rx*aY,ry:aZ.ry*aX,r:aZ.r*al(aY,aX),cx:a1,cy:a0});break;case"path":var aS=O(aZ.path),aT=true;for(var aV=0,aO=aS[j];aV":function(e){return ap(e-1,3)+1;},"<>":function(e){e=e*2;if(e<1){return ap(e,3)/2;}e-=2;return(ap(e,3)+2)/2;},backIn:function(i){var e=1.70158;return i*i*((e+1)*i-e);},backOut:function(i){i=i-1;var e=1.70158;return i*i*((e+1)*i+e)+1;},elastic:function(E){if(E==0||E==1){return E;}var i=0.3,e=i/4;return ap(2,-10*E)*Math.sin((E-e)*(2*Math.PI)/i)+1;},bounce:function(R){var i=7.5625,E=2.75,e;if(R<(1/E)){e=i*R*R;}else{if(R<(2/E)){R-=(1.5/E);e=i*R*R+0.75;}else{if(R<(2.5/E)){R-=(2.25/E);e=i*R*R+0.9375;}else{R-=(2.625/E);e=i*R*R+0.984375;}}}return e;}};var x={length:0},at=function(){var aD=+new Date;for(var aO in x){if(aO!="length"&&x[F](aO)){var aT=x[aO];if(aT.stop){delete x[aO];x[j]--;continue;}var aB=aD-aT.start,aM=aT.ms,aL=aT.easing,aP=aT.from,aI=aT.diff,R=aT.to,aH=aT.t,aK=aT.prev||0,aC=aT.el,S=aT.callback,aJ={},E;if(aB255?255:(e<0?0:e);};ad[az].animateWith=function(i,E,e,S,R){x[i.in_animation]&&(E.start=x[i.in_animation].start);return this.animate(E,e,S,R);};ad[az].onAnimation=function(e){this._run=e||null;return this;};ad[az].animate=function(R,e,aF,aL){if(Y.is(aF,"function")||!aF){aL=aF||null;}var aG={},aH={},aI={};for(var aE in R){if(R[F](aE)){if(L[F](aE)){aG[aE]=this.attr(aE);(aG[aE]==null)&&(aG[aE]=g[aE]);aH[aE]=R[aE];switch(L[aE]){case"number":aI[aE]=(aH[aE]-aG[aE])/e;break;case"colour":aG[aE]=Y.getRGB(aG[aE]);var aC=Y.getRGB(aH[aE]);aI[aE]={r:(aC.r-aG[aE].r)/e,g:(aC.g-aG[aE].g)/e,b:(aC.b-aG[aE].b)/e};break;case"path":var E=w(aG[aE],aH[aE]);aG[aE]=E[0];aH[aE]=E[1];aI[aE]=[];for(var aB=0,aK=aG[aE][j];aB"); + document.close(); + bod = document.body; + } catch(e) { + bod = createPopup().document.body; + } + var range = bod.createTextRange(); + bod.style.color = color; + var value = range.queryCommandValue("ForeColor"); + value = ((value & 255) << 16) | (value & 65280) | ((value & 16711680) >>> 16); + return "#" + ("000000" + value[toString](16)).slice(-6); + }); + } else { + var i = doc.createElement("i"); + i.className = "Rapha\u00ebl colour picker"; + i.style.cssText = "display:none"; + doc.body[appendChild](i); + toHex = cacher(function (color) { + i.style.color = color; + return doc.defaultView.getComputedStyle(i, E).getPropertyValue("color"); + }); + } + return toHex(color); + }; R.hsb2rgb = cacher(function (hue, saturation, brightness) { if (R.is(hue, "object") && "h" in hue && "s" in hue && "b" in hue) { brightness = hue.b; @@ -145,12 +172,8 @@ window.Raphael = (function () { hue = 4 + ((red - green) / delta); } hue /= 6; - if (hue < 0) { - hue += 1; - } - if (hue > 1) { - hue -= 1; - } + hue < 0 && hue++; + hue > 1 && hue--; } return {h: hue, s: saturation, b: brightness}; }, R); @@ -162,43 +185,41 @@ window.Raphael = (function () { res += this[i][j]; j && j != jj - 1 && (res += ","); } - i != ii - 1 && (res += " "); + i != ii - 1 && (res += S); } return res[rp](/,(?=-)/g, E); }; function cacher(f, scope, postprocessor) { function newf() { var arg = Array[proto].splice.call(arguments, 0, arguments[length]), - args = arg[join]("\u25ba"); - newf.cache = newf.cache || {}; - newf.count = newf.count || []; - if (args in newf.cache) { - return postprocessor ? postprocessor(newf.cache[args]) : newf.cache[args]; - } - if (newf.count[length] >= 1e3) { - delete newf.cache[newf.count.shift()]; - } - newf.count[push](args); - newf.cache[args] = f[apply](scope, arg); - return postprocessor ? postprocessor(newf.cache[args]) : newf.cache[args]; + args = arg[join]("\u25ba"), + cache = newf.cache = newf.cache || {}, + count = newf.count = newf.count || []; + if (cache[has](args)) { + return postprocessor ? postprocessor(cache[args]) : cache[args]; + } + count[length] >= 1e3 && delete cache[count.shift()]; + count[push](args); + cache[args] = f[apply](scope, arg); + return postprocessor ? postprocessor(cache[args]) : cache[args]; } return newf; } R.getRGB = cacher(function (colour) { - var htmlcolors = {none: "none", aliceblue: "#f0f8ff", amethyst: "#96c", antiquewhite: "#faebd7", aqua: "#0ff", aquamarine: "#7fffd4", azure: "#f0ffff", beige: "#f5f5dc", bisque: "#ffe4c4", black: "#000", blanchedalmond: "#ffebcd", blue: "#00f", blueviolet: "#8a2be2", brown: "#a52a2a", burlywood: "#deb887", cadetblue: "#5f9ea0", chartreuse: "#7fff00", chocolate: "#d2691e", coral: "#ff7f50", cornflowerblue: "#6495ed", cornsilk: "#fff8dc", crimson: "#dc143c", cyan: "#0ff", darkblue: "#00008b", darkcyan: "#008b8b", darkgoldenrod: "#b8860b", darkgray: "#a9a9a9", darkgreen: "#006400", darkkhaki: "#bdb76b", darkmagenta: "#8b008b", darkolivegreen: "#556b2f", darkorange: "#ff8c00", darkorchid: "#9932cc", darkred: "#8b0000", darksalmon: "#e9967a", darkseagreen: "#8fbc8f", darkslateblue: "#483d8b", darkslategray: "#2f4f4f", darkturquoise: "#00ced1", darkviolet: "#9400d3", deeppink: "#ff1493", deepskyblue: "#00bfff", dimgray: "#696969", dodgerblue: "#1e90ff", firebrick: "#b22222", floralwhite: "#fffaf0", forestgreen: "#228b22", fuchsia: "#f0f", gainsboro: "#dcdcdc", ghostwhite: "#f8f8ff", gold: "#ffd700", goldenrod: "#daa520", gray: "#808080", green: "#008000", greenyellow: "#adff2f", honeydew: "#f0fff0", hotpink: "#ff69b4", indianred: "#cd5c5c", indigo: "#4b0082", ivory: "#fffff0", khaki: "#f0e68c", lavender: "#e6e6fa", lavenderblush: "#fff0f5", lawngreen: "#7cfc00", lemonchiffon: "#fffacd", lightblue: "#add8e6", lightcoral: "#f08080", lightcyan: "#e0ffff", lightgoldenrodyellow: "#fafad2", lightgreen: "#90ee90", lightgrey: "#d3d3d3", lightpink: "#ffb6c1", lightsalmon: "#ffa07a", lightsalmon: "#ffa07a", lightseagreen: "#20b2aa", lightskyblue: "#87cefa", lightslategray: "#789", lightsteelblue: "#b0c4de", lightyellow: "#ffffe0", lime: "#0f0", limegreen: "#32cd32", linen: "#faf0e6", magenta: "#f0f", maroon: "#800000", mediumaquamarine: "#66cdaa", mediumblue: "#0000cd", mediumorchid: "#ba55d3", mediumpurple: "#9370db", mediumseagreen: "#3cb371", mediumslateblue: "#7b68ee", mediumslateblue: "#7b68ee", mediumspringgreen: "#00fa9a", mediumturquoise: "#48d1cc", mediumvioletred: "#c71585", midnightblue: "#191970", mintcream: "#f5fffa", mistyrose: "#ffe4e1", moccasin: "#ffe4b5", navajowhite: "#ffdead", navy: "#000080", oldlace: "#fdf5e6", olive: "#808000", olivedrab: "#6b8e23", orange: "#ffa500", orangered: "#ff4500", orchid: "#da70d6", palegoldenrod: "#eee8aa", palegreen: "#98fb98", paleturquoise: "#afeeee", palevioletred: "#db7093", papayawhip: "#ffefd5", peachpuff: "#ffdab9", peru: "#cd853f", pink: "#ffc0cb", plum: "#dda0dd", powderblue: "#b0e0e6", purple: "#800080", red: "#f00", rosybrown: "#bc8f8f", royalblue: "#4169e1", saddlebrown: "#8b4513", salmon: "#fa8072", sandybrown: "#f4a460", seagreen: "#2e8b57", seashell: "#fff5ee", sienna: "#a0522d", silver: "#c0c0c0", skyblue: "#87ceeb", slateblue: "#6a5acd", slategray: "#708090", snow: "#fffafa", springgreen: "#00ff7f", steelblue: "#4682b4", tan: "#d2b48c", teal: "#008080", thistle: "#d8bfd8", tomato: "#ff6347", turquoise: "#40e0d0", violet: "#ee82ee", wheat: "#f5deb3", white: "#fff", whitesmoke: "#f5f5f5", yellow: "#ff0", yellowgreen: "#9acd32"}, - res; - colour = htmlcolors[(colour + E).toLowerCase()] || colour; - if (!colour) { + if (!colour || !!((colour + E).indexOf("-") + 1)) { return {r: -1, g: -1, b: -1, hex: "none", error: 1}; } + colour = colour + E; if (colour == "none") { return {r: -1, g: -1, b: -1, hex: "none"}; } - var red, + !(({hs: 1, rg: 1}[has](colour.substring(0, 2)))) && (colour = toHex(colour)); + var res, + red, green, blue, - rgb = (colour + E).match(/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgb\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|rgb\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\)|hs[bl]\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|hs[bl]\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\))\s*$/i); + rgb = colour.match(/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgb\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|rgb\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\)|hs[bl]\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|hs[bl]\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\))\s*$/i); if (rgb) { if (rgb[2]) { blue = toInt(rgb[2].substring(5), 16); @@ -244,11 +265,9 @@ window.Raphael = (function () { g = g[rp](rg, "0"); b = b[rp](rg, "0"); rgb.hex = "#" + r + g + b; - res = rgb; - } else { - res = {r: -1, g: -1, b: -1, hex: "none", error: 1}; + return rgb; } - return res; + return {r: -1, g: -1, b: -1, hex: "none", error: 1}; }, R); R.getColor = function (value) { var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75}, @@ -257,9 +276,7 @@ window.Raphael = (function () { if (start.h > 1) { start.h = 0; start.s -= .2; - if (start.s <= 0) { - this.getColor.start = {h: 0, s: 1, b: start.b}; - } + start.s <= 0 && (this.getColor.start = {h: 0, s: 1, b: start.b}); } return rgb.hex; }; @@ -879,7 +896,7 @@ window.Raphael = (function () { return null; } var el = $(type + "Gradient"); - el.id = "r" + (R.idGenerator++)[toString](36); + el.id = "r" + (R._id++)[toString](36); type == "radial" ? $(el, {fx: fx, fy: fy}) : $(el, {x1: vector[0], y1: vector[1], x2: vector[2], y2: vector[3]}); SVG.defs[appendChild](el); for (var i = 0, ii = dots[length]; i < ii; i++) { @@ -921,7 +938,7 @@ window.Raphael = (function () { }, node = o.node, attrs = o.attrs, - rot = o.attr("rotation"), + rot = o.rotate(), addDashes = function (o, value) { value = dasharray[(value + E).toLowerCase()]; if (value) { @@ -962,7 +979,7 @@ window.Raphael = (function () { o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode); var el = $("clipPath"), rc = $("rect"); - el.id = "r" + (R.idGenerator++)[toString](36); + el.id = "r" + (R._id++)[toString](36); $(rc, { x: rect[0], y: rect[1], @@ -1004,7 +1021,7 @@ window.Raphael = (function () { break; } case "cx": - node[setAttribute](att, value); + node[setAttribute](att, round(value)); o.pattern && updatePosition(o); break; case "height": @@ -1024,7 +1041,7 @@ window.Raphael = (function () { break; } case "cy": - node[setAttribute](att, value); + node[setAttribute](att, round(value)); o.pattern && updatePosition(o); break; case "r": @@ -1067,7 +1084,7 @@ window.Raphael = (function () { if (isURL) { var el = $("pattern"), ig = $("image"); - el.id = "r" + (R.idGenerator++)[toString](36); + el.id = "r" + (R._id++)[toString](36); $(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse"}); $(ig, {x: 0, y:0}); ig.setAttributeNS(o.paper.xlink, "href", isURL[1]); @@ -1139,7 +1156,7 @@ window.Raphael = (function () { } tuneText(o, params); - toInt(rot, 10) && o.rotate(rot, true); + toFloat(rot) && o.rotate(rot, true); }; var leading = 1.2; var tuneText = function (el, params) { @@ -1170,12 +1187,13 @@ window.Raphael = (function () { $(node, {y: a.y}); var bb = el.getBBox(), dif = a.y - (bb.y + bb.height / 2); - dif && $(node, {y: a.y + dif}); + dif && isFinite(dif) && $(node, {y: a.y + dif}); }; var Element = function (node, svg) { var X = 0, Y = 0; this[0] = node; + this.id = R._oid++; this.node = node; node.raphael = this; this.paper = svg; @@ -1190,9 +1208,12 @@ window.Raphael = (function () { }; }; Element[proto].rotate = function (deg, cx, cy) { + if (this.removed) { + return this; + } if (deg == null) { if (this._.rt.cx) { - return [this._.rt.deg, this._.rt.cx, this._.rt.cy][join](" "); + return [this._.rt.deg, this._.rt.cx, this._.rt.cy][join](S); } return this._.rt.deg; } @@ -1220,15 +1241,15 @@ window.Raphael = (function () { this.transformations[0] = E; this.clip && $(this.clip, {transform: E}); } - $(this.node, {transform: this.transformations[join](" ")}); + $(this.node, {transform: this.transformations[join](S)}); return this; }; Element[proto].hide = function () { - this.node.style.display = "none"; + !this.removed && (this.node.style.display = "none"); return this; }; Element[proto].show = function () { - this.node.style.display = "block"; + !this.removed && (this.node.style.display = ""); return this; }; Element[proto].remove = function () { @@ -1236,8 +1257,12 @@ window.Raphael = (function () { for (var i in this) { delete this[i]; } + this.removed = true; }; Element[proto].getBBox = function () { + if (this.removed) { + return this; + } if (this.type == "path") { return pathDimensions(this.attrs.path); } @@ -1266,6 +1291,9 @@ window.Raphael = (function () { return bbox; }; Element[proto].attr = function () { + if (this.removed) { + return this; + } if (arguments[length] == 1 && R.is(arguments[0], "string")) { if (arguments[0] == "translation") { return this.translate(); @@ -1295,16 +1323,22 @@ window.Raphael = (function () { return this; }; Element[proto].toFront = function () { - this.node.parentNode[appendChild](this.node); + !this.removed && this.node.parentNode[appendChild](this.node); return this; }; Element[proto].toBack = function () { + if (this.removed) { + return this; + } if (this.node.parentNode.firstChild != this.node) { this.node.parentNode.insertBefore(this.node, this.node.parentNode.firstChild); } return this; }; Element[proto].insertAfter = function (element) { + if (this.removed) { + return this; + } if (element.node.nextSibling) { element.node.parentNode.insertBefore(this.node, element.node.nextSibling); } else { @@ -1313,6 +1347,9 @@ window.Raphael = (function () { return this; }; Element[proto].insertBefore = function (element) { + if (this.removed) { + return this; + } var node = element.node; node.parentNode.insertBefore(this.node, node); return this; @@ -1460,7 +1497,7 @@ window.Raphael = (function () { } res[push](r); } - return res[join](" "); + return res[join](S); }; R[toString] = function () { @@ -1500,7 +1537,6 @@ window.Raphael = (function () { params.title && (node.title = params.title); params.target && (node.target = params.target); if (params.path && o.type == "path") { - // a.path = R.parsePathString(params.path); a.path = params.path; node.path = path2vml(a.path); } @@ -1675,7 +1711,7 @@ window.Raphael = (function () { if (pow(fx - .5, 2) + pow(fy - .5, 2) > .25) { fy = Math.sqrt(.25 - pow(fx - .5, 2)) + .5; } - fxfy = fx + " " + fy; + fxfy = fx + S + fy; } return E; }); @@ -1701,13 +1737,9 @@ window.Raphael = (function () { fill.color2 = dots[dots[length] - 1].color; var clrs = []; for (var i = 0, ii = dots[length]; i < ii; i++) { - dots[i].offset && clrs[push](dots[i].offset + " " + dots[i].color); - } - if (clrs[length] && fill.colors) { - fill.colors.value = clrs[join](","); - } else { - fill.colors.value = "0% " + fill.color; + dots[i].offset && clrs[push](dots[i].offset + S + dots[i].color); } + fill.colors.value = clrs[length] ? clrs[join](",") : "0% " + fill.color; if (type == "radial") { fill.focus = "100%"; fill.focussize = fxfy; @@ -1724,6 +1756,7 @@ window.Raphael = (function () { RotY = 0, Scale = 1; this[0] = node; + this.id = R._oid++; this.node = node; node.raphael = this; this.X = 0; @@ -1740,9 +1773,12 @@ window.Raphael = (function () { }; }; Element[proto].rotate = function (deg, cx, cy) { + if (this.removed) { + return this; + } if (deg == null) { if (this._.rt.cx) { - return [this._.rt.deg, this._.rt.cx, this._.rt.cy][join](" "); + return [this._.rt.deg, this._.rt.cx, this._.rt.cy][join](S); } return this._.rt.deg; } @@ -1770,6 +1806,9 @@ window.Raphael = (function () { return this; }; Element[proto].setBox = function (params, cx, cy) { + if (this.removed) { + return this; + } var gs = this.Group.style, os = (this.shape && this.shape.style) || this.node.style; params = params || {}; @@ -1865,20 +1904,22 @@ window.Raphael = (function () { this.node.parentNode.removeChild(this.node); this.node = o; this.arcsize = arcsize; - setFillAndStroke(this, this.attrs); - this.setBox(this.attrs); + this.attr(this.attrs); } } }; Element[proto].hide = function () { - this.Group.style.display = "none"; + !this.removed && (this.Group.style.display = "none"); return this; }; Element[proto].show = function () { - this.Group.style.display = "block"; + !this.removed && (this.Group.style.display = "block"); return this; }; Element[proto].getBBox = function () { + if (this.removed) { + return this; + } if (this.type == "path") { return pathDimensions(this.attrs.path); } @@ -1896,8 +1937,12 @@ window.Raphael = (function () { for (var i in this) { delete this[i]; } + this.removed = true; }; Element[proto].attr = function () { + if (this.removed) { + return this; + } if (arguments[length] == 1 && R.is(arguments[0], "string")) { if (arguments[0] == "translation") { return this.translate(); @@ -1922,32 +1967,36 @@ window.Raphael = (function () { params = {}; params[arguments[0]] = arguments[1]; } - if (arguments[length] == 1 && R.is(arguments[0], "object")) { - params = arguments[0]; - } + arguments[length] == 1 && R.is(arguments[0], "object") && (params = arguments[0]); if (params) { - if (params.gradient && (this.type in {circle: 1, ellipse: 1} || (params.gradient + E).charAt(0) != "r")) { - addGradientFill(this, params.gradient); - } if (params.text && this.type == "text") { this.node.string = params.text; } setFillAndStroke(this, params); + if (params.gradient && ({circle: 1, ellipse: 1}[has](this.type) || (params.gradient + E).charAt(0) != "r")) { + addGradientFill(this, params.gradient); + } this.setBox(this.attrs); } return this; }; Element[proto].toFront = function () { - this.Group.parentNode[appendChild](this.Group); + !this.removed && this.Group.parentNode[appendChild](this.Group); return this; }; Element[proto].toBack = function () { + if (this.removed) { + return this; + } if (this.Group.parentNode.firstChild != this.Group) { this.Group.parentNode.insertBefore(this.Group, this.Group.parentNode.firstChild); } return this; }; Element[proto].insertAfter = function (element) { + if (this.removed) { + return this; + } if (element.Group.nextSibling) { element.Group.parentNode.insertBefore(this.Group, element.Group.nextSibling); } else { @@ -1956,7 +2005,7 @@ window.Raphael = (function () { return this; }; Element[proto].insertBefore = function (element) { - element.Group.parentNode.insertBefore(this.Group, element.Group); + !this.removed && element.Group.parentNode.insertBefore(this.Group, element.Group); return this; }; @@ -2048,7 +2097,7 @@ window.Raphael = (function () { path.textpathok = true; ol.width = vml.width; ol.height = vml.height; - o.string = text; + o.string = text + E; o.on = true; el[appendChild](o); el[appendChild](path); @@ -2074,7 +2123,7 @@ window.Raphael = (function () { cs.width = this.width + "px"; cs.height = this.height + "px"; cs.clip = "rect(0 " + this.width + "px " + this.height + "px 0)"; - this.coordsize = this.width + " " + this.height; + this.coordsize = this.width + S + this.height; return this; }; doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)"); @@ -2106,7 +2155,7 @@ window.Raphael = (function () { height = toFloat(height) || 342; res.width = width; res.height = height; - res.coordsize = width + " " + height; + res.coordsize = width + S + height; res.coordorigin = "0 0"; res.span = doc.createElement("span"); res.span.style.cssText = "position:absolute;left:-9999px;top:-9999px;padding:0;margin:0;line-height:1;display:inline;"; @@ -2136,9 +2185,7 @@ window.Raphael = (function () { } plugins.call(res, res, R.fn); res.clear = function () { - while (c.firstChild) { - c.removeChild(c.firstChild); - } + c.innerHTML = E; }; res.raphael = R; return res; @@ -2214,17 +2261,22 @@ window.Raphael = (function () { return this; }; Element[proto]["un" + eventName] = function (fn) { - this.events && - this.events[eventName] && - this.events[eventName][fn] && - this.events[eventName][fn][length] && - this.events[eventName][fn].shift()() && - !this.events[eventName][fn][length] && - delete this.events[eventName][fn]; + var e = this.events; + e && + e[eventName] && + e[eventName][fn] && + e[eventName][fn][length] && + e[eventName][fn].shift()() && + !e[eventName][fn][length] && + delete e[eventName][fn]; + return this; }; })(events[i]); } + Element[proto].hover = function (f_in, f_out) { + return this.mouseover(f_in).mouseout(f_out); + }; paper.circle = function (x, y, r) { return theCircle(this, x || 0, y || 0, r || 0); }; @@ -2249,13 +2301,9 @@ window.Raphael = (function () { return new Set(itemsArray); }; paper.setSize = setSize; - Element[proto].stop = function () { - clearTimeout(this.animation_in_progress); - return this; - }; Element[proto].scale = function (x, y, cx, cy) { if (x == null && y == null) { - return {x: this._.sx, y: this._.sy, toString: function () { return this.x + " " + this.y; }}; + return {x: this._.sx, y: this._.sy, toString: function () { return this.x + S + this.y; }}; } y = y || x; !+y && (y = x); @@ -2337,7 +2385,7 @@ window.Raphael = (function () { if (this.type in {text: 1, image:1} && (dirx != 1 || diry != 1)) { if (this.transformations) { this.transformations[2] = "scale("[concat](dirx, ",", diry, ")"); - this.node[setAttribute]("transform", this.transformations[join](" ")); + this.node[setAttribute]("transform", this.transformations[join](S)); dx = (dirx == -1) ? -a.x - (neww || 0) : a.x; dy = (diry == -1) ? -a.y - (newh || 0) : a.y; this.attr({x: dx, y: dy}); @@ -2352,7 +2400,7 @@ window.Raphael = (function () { } else { if (this.transformations) { this.transformations[2] = E; - this.node[setAttribute]("transform", this.transformations[join](" ")); + this.node[setAttribute]("transform", this.transformations[join](S)); a.fx = 0; a.fy = 0; } else { @@ -2360,7 +2408,7 @@ window.Raphael = (function () { s.filter = (this.node.filterMatrix || E) + (this.node.filterOpacity || E); } } - a.scale = [x, y, cx, cy][join](" "); + a.scale = [x, y, cx, cy][join](S); this._.sx = x; this._.sy = y; } @@ -2427,17 +2475,118 @@ window.Raphael = (function () { } }; + var animationElements = {length : 0}, + animation = function () { + var Now = +new Date; + for (var l in animationElements) if (l != "length" && animationElements[has](l)) { + var e = animationElements[l]; + if (e.stop) { + delete animationElements[l]; + animationElements[length]--; + continue; + } + var time = Now - e.start, + ms = e.ms, + easing = e.easing, + from = e.from, + diff = e.diff, + to = e.to, + t = e.t, + prev = e.prev || 0, + that = e.el, + callback = e.callback, + set = {}, + now; + if (time < ms) { + var pos = R.easing_formulas[easing] ? R.easing_formulas[easing](time / ms) : time / ms; + for (var attr in from) if (from[has](attr)) { + switch (availableAnimAttrs[attr]) { + case "number": + now = +from[attr] + pos * ms * diff[attr]; + break; + case "colour": + now = "rgb(" + [ + upto255(round(from[attr].r + pos * ms * diff[attr].r)), + upto255(round(from[attr].g + pos * ms * diff[attr].g)), + upto255(round(from[attr].b + pos * ms * diff[attr].b)) + ][join](",") + ")"; + break; + case "path": + now = []; + for (var i = 0, ii = from[attr][length]; i < ii; i++) { + now[i] = [from[attr][i][0]]; + for (var j = 1, jj = from[attr][i][length]; j < jj; j++) { + now[i][j] = +from[attr][i][j] + pos * ms * diff[attr][i][j]; + } + now[i] = now[i][join](S); + } + now = now[join](S); + break; + case "csv": + switch (attr) { + case "translation": + var x = diff[attr][0] * (time - prev), + y = diff[attr][1] * (time - prev); + t.x += x; + t.y += y; + now = x + S + y; + break; + case "rotation": + now = +from[attr][0] + pos * ms * diff[attr][0]; + from[attr][1] && (now += "," + from[attr][1] + "," + from[attr][2]); + break; + case "scale": + now = [+from[attr][0] + pos * ms * diff[attr][0], +from[attr][1] + pos * ms * diff[attr][1], (2 in to[attr] ? to[attr][2] : E), (3 in to[attr] ? to[attr][3] : E)][join](S); + break; + case "clip-rect": + now = []; + var i = 4; + while (i--) { + now[i] = +from[attr][i] + pos * ms * diff[attr][i]; + } + break; + } + break; + } + set[attr] = now; + } + that.attr(set); + that._run && that._run.call(that); + } else { + (t.x || t.y) && that.translate(-t.x, -t.y); + to.scale && (to.scale = to.scale + E); + that.attr(to); + R.is(callback, "function") && callback.call(that); + delete animationElements[l]; + animationElements[length]--; + that.in_animation = null; + } + e.prev = time; + } + R.svg && paper.safari(); + animationElements[length] && setTimeout(animation); + }, + upto255 = function (color) { + return color > 255 ? 255 : (color < 0 ? 0 : color); + }; + + Element[proto].animateWith = function (element, params, ms, easing, callback) { + animationElements[element.in_animation] && (params.start = animationElements[element.in_animation].start); + return this.animate(params, ms, easing, callback); + }; + Element[proto].onAnimation = function (f) { + this._run = f || null; + return this; + }; Element[proto].animate = function (params, ms, easing, callback) { - clearTimeout(this.animation_in_progress); if (R.is(easing, "function") || !easing) { callback = easing || null; } var from = {}, to = {}, - diff = {}, - t = {x: 0, y: 0}; + diff = {}; for (var attr in params) if (params[has](attr)) { - if (attr in availableAnimAttrs) { + if (availableAnimAttrs[has](attr)) { from[attr] = this.attr(attr); (from[attr] == null) && (from[attr] = availableAttrs[attr]); to[attr] = params[attr]; @@ -2496,82 +2645,25 @@ window.Raphael = (function () { } } } - var start = +new Date, - prev = 0, - upto255 = function (color) { - return color > 255 ? 255 : color; - }, - that = this; - (function tick() { - var time = new Date - start, - set = {}, - now; - if (time < ms) { - var pos = R.easing_formulas[easing] ? R.easing_formulas[easing](time / ms) : time / ms; - for (var attr in from) if (from[has](attr)) { - switch (availableAnimAttrs[attr]) { - case "number": - now = +from[attr] + pos * ms * diff[attr]; - break; - case "colour": - now = "rgb(" + [ - upto255(round(from[attr].r + pos * ms * diff[attr].r)), - upto255(round(from[attr].g + pos * ms * diff[attr].g)), - upto255(round(from[attr].b + pos * ms * diff[attr].b)) - ][join](",") + ")"; - break; - case "path": - now = []; - for (var i = 0, ii = from[attr][length]; i < ii; i++) { - now[i] = [from[attr][i][0]]; - for (var j = 1, jj = from[attr][i][length]; j < jj; j++) { - now[i][j] = +from[attr][i][j] + pos * ms * diff[attr][i][j]; - } - now[i] = now[i][join](" "); - } - now = now[join](" "); - break; - case "csv": - switch (attr) { - case "translation": - var x = diff[attr][0] * (time - prev), - y = diff[attr][1] * (time - prev); - t.x += x; - t.y += y; - now = x + " " + y; - break; - case "rotation": - now = +from[attr][0] + pos * ms * diff[attr][0]; - from[attr][1] && (now += "," + from[attr][1] + "," + from[attr][2]); - break; - case "scale": - now = [+from[attr][0] + pos * ms * diff[attr][0], +from[attr][1] + pos * ms * diff[attr][1], (2 in params[attr] ? params[attr][2] : E), (3 in params[attr] ? params[attr][3] : E)][join](" "); - break; - case "clip-rect": - now = []; - var i = 4; - while (i--) { - now[i] = +from[attr][i] + pos * ms * diff[attr][i]; - } - break; - } - break; - } - set[attr] = now + E; - } - that.attr(set); - that.animation_in_progress = setTimeout(tick); - R.svg && paper.safari(); - } else { - (t.x || t.y) && that.translate(-t.x, -t.y); - params.scale && (params.scale = params.scale + E); - that.attr(params); - clearTimeout(that.animation_in_progress); - R.svg && paper.safari(); - (R.is(callback, "function")) && callback.call(that); - } - prev = time; - })(); + this.stop(); + this.in_animation = 1; + animationElements[this.id] = { + start: params.start || +new Date, + ms: ms, + easing: easing, + from: from, + diff: diff, + to: to, + el: this, + callback: callback, + t: {x: 0, y: 0} + }; + ++animationElements[length] == 1 && animation(); + return this; + }; + Element[proto].stop = function () { + delete animationElements[this.id]; + this.in_animation = 0; return this; }; Element[proto].translate = function (x, y) { @@ -2602,7 +2694,7 @@ window.Raphael = (function () { Element[proto][toString] = function () { return "Rapha\u00ebl\u2019s object"; }; - + R.ae = animationElements; // Set var Set = function (items) { @@ -2657,9 +2749,7 @@ window.Raphael = (function () { return this; }; Set[proto].animate = function (params, ms, easing, callback) { - if (R.is(easing, "function") || !easing) { - callback = easing || null; - } + (R.is(easing, "function") || !easing) && (callback = easing || null); var len = this.items[length], i = len, set = this; @@ -2667,12 +2757,14 @@ window.Raphael = (function () { var collector = function () { !--len && callback.call(set); }; + this.items[--i].animate(params, ms, easing || collector, collector); while (i--) { - this.items[i].animate(params, ms, easing || collector, collector); + this.items[i].animateWith(this.items[len - 1], params, ms, easing || collector, collector); } } else { + this.items[--i].animate(params, ms, easing); while (i--) { - this.items[i].animate(params, ms, easing); + this.items[i].animateWith(this.items[len - 1], params, ms, easing); } } return this; @@ -2785,8 +2877,9 @@ window.Raphael = (function () { }; R.format = function (token) { - var args = R.is(arguments[1], "array") ? [0][concat](arguments[1]) : arguments; - token && R.is(token, "string") && args[length] - 1 && (token = token[rp](/\{(\d+)\}/g, function (str, i) { + 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) { return args[++i] == null ? E : args[i]; })); return token || E; -- 2.39.2