From 2b2be3434bd8527580cf377f426c92b54661eb4f Mon Sep 17 00:00:00 2001 From: Dmitry Baranovskiy Date: Tue, 17 Aug 2010 13:18:08 +1000 Subject: [PATCH] =?utf8?q?1.5.0=20=E2=80=A2=20fixed=20IE8=20issue=20with?= =?utf8?q?=20the=20HTML=20element=20named=20Raphael=20=E2=80=A2=20fixed=20?= =?utf8?q?precision=20for=20arcs=20in=20IE=20=E2=80=A2=20added=20caching?= =?utf8?q?=20to=20getPointAtSegmentLength=20function=20=E2=80=A2=20added?= =?utf8?q?=20ability=20to=20do=20more=20than=20one=20animation=20of=20an?= =?utf8?q?=20element=20at=20the=20same=20time=20=E2=80=A2=20added=20"cubic?= =?utf8?q?-bezier()"=20as=20an=20easing=20method=20=E2=80=A2=20added=20new?= =?utf8?q?=20syntax=20for=20animation=20(keyframes)=20=E2=80=A2=20hsl2rgb?= =?utf8?q?=20now=20accept=20h=20as=20degree=20(0..360),=20s=20and=20b=20as?= =?utf8?q?=20%=20(0..100)=20=E2=80=A2=20show=3D"new"=20instead=20of=20targ?= =?utf8?q?et=3D"blank"=20for=20SVG=20=E2=80=A2=20added=20angle=20method=20?= =?utf8?q?=E2=80=A2=20added=20snapTo=20method=20=E2=80=A2=20cached=20popup?= =?utf8?q?=20||=20activeX=20for=20IE=20=E2=80=A2=20fixed=20insertAfter=20?= =?utf8?q?=E2=80=A2=20fixed=20timeouts=20for=20animation=20=E2=80=A2=20add?= =?utf8?q?ed=20customAttributes?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- raphael-min.js | 113 +--------- raphael.js | 564 ++++++++++++++++++++++++++++++++----------------- reference.html | 69 +++++- 3 files changed, 438 insertions(+), 308 deletions(-) diff --git a/raphael-min.js b/raphael-min.js index 33e620e..89d6acb 100644 --- a/raphael-min.js +++ b/raphael-min.js @@ -1,116 +1,7 @@ /* - * Raphael 1.4.7 - JavaScript Vector Library + * Raphael 1.5.0 - JavaScript Vector Library * * Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com) * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. */ -Raphael=function(){function l(){if(l.is(arguments[0],U)){for(var a=arguments[0],b=Ca[K](l,a.splice(0,3+l.is(a[0],P))),c=b.set(),d=0,f=a[o];d';da=da.firstChild;da.style.behavior="url(#default#VML)";if(!(da&&typeof da.adj=="object"))return l.type=null;da=null}l.svg=!(l.vml=l.type=="VML");H[p]=l[p];l._id=0;l._oid=0;l.fn={};l.is=function(a,b){b=fa.call(b);return b=="object"&&a===Object(a)||b=="undefined"&&typeof a==b||b=="null"&&a==null||b=="array"&&Array.isArray&&Array.isArray(a)||fa.call(tb.call(a).slice(8,-1))==b};l.setWindow=function(a){aa= -a;C=aa.document};function ua(a){if(l.vml){var b=/^\s+|\s+$/g;ua=Z(function(d){var f;d=D(d)[I](b,A);try{var e=new aa.ActiveXObject("htmlfile");e.write("");e.close();f=e.body}catch(g){f=aa.createPopup().document.body}e=f.createTextRange();try{f.style.color=d;var h=e.queryCommandValue("ForeColor");h=(h&255)<<16|h&65280|(h&16711680)>>>16;return"#"+("000000"+h[O](16)).slice(-6)}catch(i){return"none"}})}else{var c=C.createElement("i");c.title="Rapha\u00ebl Colour Picker";c.style.display="none";C.body[x](c); -ua=Z(function(d){c.style.color=d;return C.defaultView.getComputedStyle(c,A).getPropertyValue("color")})}return ua(a)}function Ta(){return"hsb("+[this.h,this.s,this.b]+")"}function vb(){return"hsl("+[this.h,this.s,this.l]+")"}function wb(){return this.hex}l.hsb2rgb=function(a,b,c){if(l.is(a,"object")&&"h"in a&&"s"in a&&"b"in a){c=a.b;b=a.s;a=a.h}return l.hsl2rgb(a,b,c/2)};l.hsl2rgb=function(a,b,c){if(l.is(a,"object")&&"h"in a&&"s"in a&&"l"in a){c=a.l;b=a.s;a=a.h}if(a>1||b>1||c>1){a/=255;b/=255;c/= -255}var d={},f=["r","g","b"],e;if(b){b=c<0.5?c*(1+b):c+b-c*b;c=2*c-b;for(var g=0,h=f.length;g1&&e--;d[f[g]]=e*6<1?c+(b-c)*6*e:e*2<1?b:e*3<2?c+(b-c)*(2/3-e)*6:c}}else d={r:c,g:c,b:c};d.r*=255;d.g*=255;d.b*=255;a=(~~d.r)[O](16);f=(~~d.g)[O](16);b=(~~d.b)[O](16);a=a[I](ja,"0");f=f[I](ja,"0");b=b[I](ja,"0");d.hex="#"+a+f+b;d.toString=wb;return d};l.rgb2hsb=function(a,b,c){if(b==null&&l.is(a,"object")&&"r"in a&&"g"in a&&"b"in a){c=a.b;b=a.g;a=a.r}if(b==null&&l.is(a,ga)){var d= -l.getRGB(a);a=d.r;b=d.g;c=d.b}if(a>1||b>1||c>1){a/=255;b/=255;c/=255}var f=Y(a,b,c),e=ba(a,b,c);d=f;if(e==f)return{h:0,s:0,b:f,toString:Ta};else{var g=f-e;e=g/f;a=a==f?(b-c)/g:b==f?2+(c-a)/g:4+(a-b)/g;a/=6;a<0&&a++;a>1&&a--}return{h:a,s:e,b:d,toString:Ta}};l.rgb2hsl=function(a,b,c){if(b==null&&l.is(a,"object")&&"r"in a&&"g"in a&&"b"in a){c=a.b;b=a.g;a=a.r}if(b==null&&l.is(a,ga)){var d=l.getRGB(a);a=d.r;b=d.g;c=d.b}if(a>1||b>1||c>1){a/=255;b/=255;c/=255}var f=Y(a,b,c),e=ba(a,b,c);d=(f+e)/2;if(e==f)a= -{h:0,s:0,l:d};else{var g=f-e;e=d<0.5?g/(f+e):g/(2-f-e);a=a==f?(b-c)/g:b==f?2+(c-a)/g:4+(a-b)/g;a/=6;a<0&&a++;a>1&&a--;a={h:a,s:e,l:d}}a.toString=vb;return a};var xb=/,?([achlmqrstvxz]),?/gi,ka=/\s*,\s*/,yb={hs:1,rg:1};l._path2string=function(){return this.join(",")[I](xb,"$1")};function Z(a,b,c){function d(){var f=Array[p].slice.call(arguments,0),e=f[R]("\u25ba"),g=d.cache=d.cache||{},h=d.count=d.count||[];if(g[z](e))return c?c(g[e]):g[e];h[o]>=1000&&delete g[h.shift()];h[F](e);g[e]=a[K](b,f);return c? -c(g[e]):g[e]}return d}l.getRGB=Z(function(a){if(!a||(a=D(a)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1};if(a=="none")return{r:-1,g:-1,b:-1,hex:"none"};!(yb[z](a.substring(0,2))||a.charAt()=="#")&&(a=ua(a));var b,c,d,f,e;if(a=a.match(ub)){if(a[2]){d=ha(a[2].substring(5),16);c=ha(a[2].substring(3,5),16);b=ha(a[2].substring(1,3),16)}if(a[3]){d=ha((e=a[3].charAt(3))+e,16);c=ha((e=a[3].charAt(2))+e,16);b=ha((e=a[3].charAt(1))+e,16)}if(a[4]){a=a[4][G](ka);b=y(a[0]);c=y(a[1]);d=y(a[2]);f=y(a[3])}if(a[5]){a= -a[5][G](ka);b=y(a[0])*2.55;c=y(a[1])*2.55;d=y(a[2])*2.55;f=y(a[3])}if(a[6]){a=a[6][G](ka);b=y(a[0]);c=y(a[1]);d=y(a[2]);(a[0].slice(-3)=="deg"||a[0].slice(-1)=="\u00b0")&&(b/=360);return l.hsb2rgb(b,c,d)}if(a[7]){a=a[7][G](ka);b=y(a[0])*2.55;c=y(a[1])*2.55;d=y(a[2])*2.55;(a[0].slice(-3)=="deg"||a[0].slice(-1)=="\u00b0")&&(b/=360*2.55);return l.hsb2rgb(b,c,d)}if(a[8]){a=a[8][G](ka);b=y(a[0]);c=y(a[1]);d=y(a[2]);(a[0].slice(-3)=="deg"||a[0].slice(-1)=="\u00b0")&&(b/=360);return l.hsl2rgb(b,c,d)}if(a[9]){a= -a[9][G](ka);b=y(a[0])*2.55;c=y(a[1])*2.55;d=y(a[2])*2.55;(a[0].slice(-3)=="deg"||a[0].slice(-1)=="\u00b0")&&(b/=360*2.55);return l.hsl2rgb(b,c,d)}a={r:b,g:c,b:d};b=(~~b)[O](16);c=(~~c)[O](16);d=(~~d)[O](16);b=b[I](ja,"0");c=c[I](ja,"0");d=d[I](ja,"0");a.hex="#"+b+c+d;isFinite(y(f))&&(a.o=f);return a}return{r:-1,g:-1,b:-1,hex:"none",error:1}},l);l.getColor=function(a){a=this.getColor.start=this.getColor.start||{h:0,s:1,b:a||0.75};var b=this.hsb2rgb(a.h,a.s,a.b);a.h+=0.075;if(a.h>1){a.h=0;a.s-=0.2; -a.s<=0&&(this.getColor.start={h:0,s:1,b:a.b})}return b.hex};l.getColor.reset=function(){delete this.start};var zb=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,Ab=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig;l.parsePathString=Z(function(a){if(!a)return null;var b={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},c=[];if(l.is(a,U)&&l.is(a[0],U))c=va(a);c[o]||D(a)[I](zb,function(d,f,e){var g=[];d=fa.call(f);e[I](Ab,function(h,i){i&&g[F](+i)});if(d=="m"&&g[o]>2){c[F]([f][M](g.splice(0,2)));d="l"; -f=f=="m"?"l":"L"}for(;g[o]>=b[d];){c[F]([f][M](g.splice(0,b[d])));if(!b[d])break}});c[O]=l._path2string;return c});l.findDotsAtSegment=function(a,b,c,d,f,e,g,h,i){var j=1-i,m=E(j,3)*a+E(j,2)*3*i*c+j*3*i*i*f+E(i,3)*g;j=E(j,3)*b+E(j,2)*3*i*d+j*3*i*i*e+E(i,3)*h;var n=a+2*i*(c-a)+i*i*(f-2*c+a),r=b+2*i*(d-b)+i*i*(e-2*d+b),q=c+2*i*(f-c)+i*i*(g-2*f+c),k=d+2*i*(e-d)+i*i*(h-2*e+d);a=(1-i)*a+i*c;b=(1-i)*b+i*d;f=(1-i)*f+i*g;e=(1-i)*e+i*h;h=90-v.atan((n-q)/(r-k))*180/v.PI;(n>q||r1){B=v.sqrt(B);c=B*c;d=B*d}B=c*c;var L=d*d;B=(e==g?-1:1)*v.sqrt(v.abs((B*L-B*w*w-L*k*k)/(B*w*w+L*k*k)));e=B*c*w/d+(a+h)/2;var B=B*-d*k/c+(b+i)/2,w=v.asin(((b-B)/d).toFixed(7));k=v.asin(((i-B)/d).toFixed(7));w=ak)w-=m*2;if(!g&&k>w)k-=m*2}m=k-w;if(v.abs(m)>n){q=k;m=h;L=i;k=w+n*(g&&k>w?1:-1);h=e+c*v.cos(k);i=B+d*v.sin(k);q=Va(h,i,c,d,f,0,g,m, -L,[k,q,e,B])}m=k-w;f=v.cos(w);e=v.sin(w);g=v.cos(k);k=v.sin(k);m=v.tan(m/4);c=4/3*c*m;m=4/3*d*m;d=[a,b];a=[a+c*e,b-m*f];b=[h+c*k,i-m*g];h=[h,i];a[0]=2*d[0]-a[0];a[1]=2*d[1]-a[1];if(j)return[a,b,h][M](q);else{q=[a,b,h][M](q)[R]()[G](",");j=[];h=0;for(i=q[o];h1000000000000&&(n=0.5);v.abs(i)>1000000000000&&(i=0.5);if(n>0&&n<1){n=la(a,b,c,d,f,e,g,h,n);q[F](n.x);r[F](n.y)}if(i>0&&i<1){n=la(a,b,c,d,f,e,g,h,i);q[F](n.x);r[F](n.y)}i=e-2*d+b-(h-2*e+d);j=2*(d-b)-2*(e-d);m=b-d;n=(-j+v.sqrt(j*j-4*i*m))/2/i;i=(-j-v.sqrt(j*j-4*i*m))/2/i;v.abs(n)>1000000000000&&(n=0.5);v.abs(i)>1000000000000&&(i=0.5);if(n>0&&n<1){n=la(a,b,c,d,f,e,g,h,n);q[F](n.x); -r[F](n.y)}if(i>0&&i<1){n=la(a,b,c,d,f,e,g,h,i);q[F](n.x);r[F](n.y)}return{min:{x:ba[K](0,q),y:ba[K](0,r)},max:{x:Y[K](0,q),y:Y[K](0,r)}}}),wa=Z(function(a,b){var c=oa(a),d=b&&oa(b);a={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};b={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};function f(q,k){var t;if(!q)return["C",k.x,k.y,k.x,k.y,k.x,k.y];!(q[0]in{T:1,Q:1})&&(k.qx=k.qy=null);switch(q[0]){case "M":k.X=q[1];k.Y=q[2];break;case "A":q=["C"][M](Va[K](0,[k.x,k.y][M](q.slice(1))));break;case "S":t=k.x+(k.x- -(k.bx||k.x));k=k.y+(k.y-(k.by||k.y));q=["C",t,k][M](q.slice(1));break;case "T":k.qx=k.x+(k.x-(k.qx||k.x));k.qy=k.y+(k.y-(k.qy||k.y));q=["C"][M](Ua(k.x,k.y,k.qx,k.qy,q[1],q[2]));break;case "Q":k.qx=q[1];k.qy=q[2];q=["C"][M](Ua(k.x,k.y,q[1],q[2],q[3],q[4]));break;case "L":q=["C"][M](ya(k.x,k.y,q[1],q[2]));break;case "H":q=["C"][M](ya(k.x,k.y,q[1],k.y));break;case "V":q=["C"][M](ya(k.x,k.y,k.x,q[1]));break;case "Z":q=["C"][M](ya(k.x,k.y,k.X,k.Y));break}return q}function e(q,k){if(q[k][o]>7){q[k].shift(); -for(var t=q[k];t[o];)q.splice(k++,0,["C"][M](t.splice(0,6)));q.splice(k,1);i=Y(c[o],d&&d[o]||0)}}function g(q,k,t,L,B){if(q&&k&&q[B][0]=="M"&&k[B][0]!="M"){k.splice(B,0,["M",L.x,L.y]);t.bx=0;t.by=0;t.x=q[B][1];t.y=q[B][2];i=Y(c[o],d&&d[o]||0)}}for(var h=0,i=Y(c[o],d&&d[o]||0);h0.5)*2-1;E(f-0.5,2)+E(e-0.5,2)>0.25&&(e=v.sqrt(0.25-E(f-0.5,2))*m+0.5)&&e!=0.5&&(e=e.toFixed(5)-1.0E-5*m)}return A});b=b[G](/\s*\-\s*/); -if(d=="linear"){var h=b.shift();h=-y(h);if(isNaN(h))return null;h=[0,0,v.cos(h*v.PI/180),v.sin(h*v.PI/180)];var i=1/(Y(v.abs(h[2]),v.abs(h[3]))||1);h[2]*=i;h[3]*=i;if(h[2]<0){h[0]=-h[2];h[2]=0}if(h[3]<0){h[1]=-h[3];h[3]=0}}b=Wa(b);if(!b)return null;i=a.getAttribute(ca);(i=i.match(/^url\(#(.*)\)$/))&&c.defs.removeChild(C.getElementById(i[1]));i=u(d+"Gradient");i.id="r"+(l._id++)[O](36);u(i,d=="radial"?{fx:f,fy:e}:{x1:h[0],y1:h[1],x2:h[2],y2:h[3]});c.defs[x](i);c=0;for(h=b[o];c1?m.o/100:m.o});case "stroke":m=l.getRGB(j);d[W](i,m.hex);i=="stroke"&&m[z]("o")&&u(d,{"stroke-opacity":m.o>1?m.o/100:m.o});break;case "gradient":(({circle:1,ellipse:1})[z](a.type)||D(j).charAt()!="r")&&pa(d,j,a.paper);break;case "opacity":case "fill-opacity":if(f.gradient){if(m=C.getElementById(d.getAttribute(ca)[I](/^url\(#|\)$/g,A))){m=m.getElementsByTagName("stop");m[m[o]- -1][W]("stop-opacity",j)}break}default:i=="font-size"&&(j=ha(j,10)+"px");m=i[I](/(\-.)/g,function(k){return sa.call(k.substring(1))});d.style[m]=j;d[W](i,j);break}}Db(a,b);if(h)a.rotate(h.join(N));else y(e)&&a.rotate(e,true)},eb=1.2,Db=function(a,b){if(!(a.type!="text"||!(b[z]("text")||b[z]("font")||b[z]("font-size")||b[z]("x")||b[z]("y")))){var c=a.attrs,d=a.node,f=d.firstChild?ha(C.defaultView.getComputedStyle(d.firstChild,A).getPropertyValue("font-size"),10):10;if(b[z]("text")){for(c.text=b.text;d.firstChild;)d.removeChild(d.firstChild); -b=D(b.text)[G]("\n");for(var e=0,g=b[o];eb.height&&(b.height=e.y+e.height-b.y);e.x+e.width- -b.x>b.width&&(b.width=e.x+e.width-b.x)}}a&&this.hide();return b};s[p].attr=function(a,b){if(this.removed)return this;if(a==null){a={};for(var c in this.attrs)if(this.attrs[z](c))a[c]=this.attrs[c];this._.rt.deg&&(a.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(a.scale=this.scale());a.gradient&&a.fill=="none"&&(a.fill=a.gradient)&&delete a.gradient;return a}if(b==null&&l.is(a,ga)){if(a=="translation")return Aa.call(this);if(a=="rotation")return this.rotate();if(a=="scale")return this.scale(); -if(a==ca&&this.attrs.fill=="none"&&this.attrs.gradient)return this.attrs.gradient;return this.attrs[a]}if(b==null&&l.is(a,U)){b={};c=0;for(var d=a.length;c1&&(a=1);f.opacity=a}b.fill&&(f.on=true);if(f.on==null||b.fill=="none")f.on=false;if(f.on&&b.fill)if(a=b.fill.match(Sa)){f.src=a[1];f.type="tile"}else{f.color=l.getRGB(b.fill).hex;f.src=A;f.type="solid";if(l.getRGB(b.fill).error&&(g.type in{circle:1,ellipse:1}||D(b.fill).charAt()!="r")&&pa(g,b.fill)){d.fill="none";d.gradient=b.fill}}e&&c[x](f);f=c.getElementsByTagName("stroke")&&c.getElementsByTagName("stroke")[0];e=false;!f&&(e=f=S("stroke"));if(b.stroke&&b.stroke!="none"|| -b["stroke-width"]||b["stroke-opacity"]!=null||b["stroke-dasharray"]||b["stroke-miterlimit"]||b["stroke-linejoin"]||b["stroke-linecap"])f.on=true;(b.stroke=="none"||f.on==null||b.stroke==0||b["stroke-width"]==0)&&(f.on=false);a=l.getRGB(b.stroke);f.on&&b.stroke&&(f.color=a.hex);a=((+d["stroke-opacity"]+1||2)-1)*((+d.opacity+1||2)-1)*((+a.o+1||2)-1);h=(y(b["stroke-width"])||1)*0.75;a<0&&(a=0);a>1&&(a=1);b["stroke-width"]==null&&(h=d["stroke-width"]);b["stroke-width"]&&(f.weight=h);h&&h<1&&(a*=h)&&(f.weight= -1);f.opacity=a;b["stroke-linejoin"]&&(f.joinstyle=b["stroke-linejoin"]||"miter");f.miterlimit=b["stroke-miterlimit"]||8;b["stroke-linecap"]&&(f.endcap=b["stroke-linecap"]=="butt"?"flat":b["stroke-linecap"]=="square"?"square":"round");if(b["stroke-dasharray"]){a={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};f.dashstyle=a[z](b["stroke-dasharray"])?a[b["stroke-dasharray"]]: -A}e&&c[x](f)}if(g.type=="text"){f=g.paper.span.style;d.font&&(f.font=d.font);d["font-family"]&&(f.fontFamily=d["font-family"]);d["font-size"]&&(f.fontSize=d["font-size"]);d["font-weight"]&&(f.fontWeight=d["font-weight"]);d["font-style"]&&(f.fontStyle=d["font-style"]);g.node.string&&(g.paper.span.innerHTML=D(g.node.string)[I](/"));g.W=d.w=g.paper.span.offsetWidth;g.H=d.h=g.paper.span.offsetHeight;g.X=d.x;g.Y=d.y+Q(g.H/2);switch(d["text-anchor"]){case "start":g.node.style["v-text-align"]= -"left";g.bbx=Q(g.W/2);break;case "end":g.node.style["v-text-align"]="right";g.bbx=-Q(g.W/2);break;default:g.node.style["v-text-align"]="center";break}}};pa=function(a,b){a.attrs=a.attrs||{};var c="linear",d=".5 .5";a.attrs.gradient=b;b=D(b)[I](cb,function(i,j,m){c="radial";if(j&&m){j=y(j);m=y(m);E(j-0.5,2)+E(m-0.5,2)>0.25&&(m=v.sqrt(0.25-E(j-0.5,2))*((m>0.5)*2-1)+0.5);d=j+N+m}return A});b=b[G](/\s*\-\s*/);if(c=="linear"){var f=b.shift();f=-y(f);if(isNaN(f))return null}var e=Wa(b);if(!e)return null; -a=a.shape||a.node;b=a.getElementsByTagName(ca)[0]||S(ca);!b.parentNode&&a.appendChild(b);if(e[o]){b.on=true;b.method="none";b.color=e[0].color;b.color2=e[e[o]-1].color;a=[];for(var g=0,h=e[o];g')}}catch(Pb){S=function(a){return C.createElement("<"+a+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}Ca= -function(){var a=Xa[K](0,arguments),b=a.container,c=a.height,d=a.width,f=a.x;a=a.y;if(!b)throw new Error("VML container not found.");var e=new H,g=e.canvas=C.createElement("div"),h=g.style;f=f||0;a=a||0;d=d||512;c=c||342;d==+d&&(d+="px");c==+c&&(c+="px");e.width=1000;e.height=1000;e.coordsize=na*1000+N+na*1000;e.coordorigin="0 0";e.span=C.createElement("span");e.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";g[x](e.span);h.cssText= -l.format("width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",d,c);if(b==1){C.body[x](g);h.left=f+"px";h.top=a+"px";h.position="absolute"}else b.firstChild?b.insertBefore(g,b.firstChild):b[x](g);Ia.call(e,e,l.fn);return e};H[p].clear=function(){this.canvas.innerHTML=A;this.span=C.createElement("span");this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";this.canvas[x](this.span);this.bottom= -this.top=null};H[p].remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var a in this)this[a]=bb(a);return true}}H[p].safari=navigator.vendor=="Apple Computer, Inc."&&(navigator.userAgent.match(/Version\/(.*?)\s/)[1]<4||aa.navigator.platform.slice(0,2)=="iP")?function(){var a=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});aa.setTimeout(function(){a.remove()})}:function(){};function Ib(){this.returnValue=false}function Jb(){return this.originalEvent.preventDefault()} -function Kb(){this.cancelBubble=true}function Lb(){return this.originalEvent.stopPropagation()}var Mb=function(){if(C.addEventListener)return function(a,b,c,d){var f=Da&&Ea[b]?Ea[b]:b;function e(g){if(Da&&Ea[z](b))for(var h=0,i=g.targetTouches&&g.targetTouches.length;h1&&(a=Array[p].splice.call(arguments,0,arguments[o]));return new X(a)};H[p].setSize=kb;H[p].top=H[p].bottom=null;H[p].raphael=l;function nb(){return this.x+N+this.y}s[p].resetScale=function(){if(this.removed)return this;this._.sx=1;this._.sy=1;this.attrs.scale="1 1"};s[p].scale=function(a,b,c,d){if(this.removed)return this;if(a==null&&b==null)return{x:this._.sx, -y:this._.sy,toString:nb};b=b||a;!+b&&(b=a);var f,e,g=this.attrs;if(a!=0){var h=this.getBBox(),i=h.x+h.width/2,j=h.y+h.height/2;f=a/this._.sx;e=b/this._.sy;c=+c||c==0?c:i;d=+d||d==0?d:j;h=~~(a/v.abs(a));var m=~~(b/v.abs(b)),n=this.node.style,r=c+(i-c)*f;j=d+(j-d)*e;switch(this.type){case "rect":case "image":var q=g.width*h*f,k=g.height*m*e;this.attr({height:k,r:g.r*ba(h*f,m*e),width:q,x:r-q/2,y:j-k/2});break;case "circle":case "ellipse":this.attr({rx:g.rx*h*f,ry:g.ry*m*e,r:g.r*ba(h*f,m*e),cx:r,cy:j}); -break;case "text":this.attr({x:r,y:j});break;case "path":i=Ha(g.path);for(var t=true,L=0,B=i[o];L=i)return r;m=r}});function Ma(a,b){return function(c,d,f){c=wa(c);for(var e,g,h,i,j="",m={},n=0,r=0,q=c.length;rd){if(b&&!m.start){e=ob(e,g,h[1],h[2],h[3],h[4],h[5],h[6],d-n);j+=["C",e.start.x,e.start.y,e.m.x,e.m.y,e.x,e.y];if(f)return j;m.start=j;j=["M",e.x,e.y+"C",e.n.x,e.n.y,e.end.x,e.end.y,h[5],h[6]][R]();n+=i;e=+h[5];g=+h[6];continue}if(!a&&!b){e=ob(e,g,h[1],h[2],h[3],h[4],h[5],h[6], -d-n);return{x:e.x,y:e.y,alpha:e.alpha}}}n+=i;e=+h[5];g=+h[6]}j+=h}m.end=j;e=a?n:b?m:l.findDotsAtSegment(e,g,h[1],h[2],h[3],h[4],h[5],h[6],1);e.alpha&&(e={x:e.x,y:e.y,alpha:e.alpha});return e}}var Nb=Z(function(a,b,c,d,f,e,g,h){for(var i={x:0,y:0},j=0,m=0;m<1.01;m+=0.01){var n=la(a,b,c,d,f,e,g,h,m);m&&(j+=E(E(i.x-n.x,2)+E(i.y-n.y,2),0.5));i=n}return j}),pb=Ma(1),Ba=Ma(),Na=Ma(0,1);s[p].getTotalLength=function(){if(this.type=="path"){if(this.node.getTotalLength)return this.node.getTotalLength();return pb(this.attrs.path)}}; -s[p].getPointAtLength=function(a){if(this.type=="path"){if(this.node.getPointAtLength)return this.node.getPointAtLength(a);return Ba(this.attrs.path,a)}};s[p].getSubpath=function(a,b){if(this.type=="path"){if(v.abs(this.getTotalLength()-b)<1.0E-6)return Na(this.attrs.path,a).end;b=Na(this.attrs.path,b,1);return a?Na(b,a).end:b}};l.easing_formulas={linear:function(a){return a},"<":function(a){return E(a,3)},">":function(a){return E(a-1,3)+1},"<>":function(a){a*=2;if(a<1)return E(a,3)/2;a-=2;return(E(a, -3)+2)/2},backIn:function(a){var b=1.70158;return a*a*((b+1)*a-b)},backOut:function(a){a-=1;var b=1.70158;return a*a*((b+1)*a+b)+1},elastic:function(a){if(a==0||a==1)return a;var b=0.3,c=b/4;return E(2,-10*a)*v.sin((a-c)*2*v.PI/b)+1},bounce:function(a){var b=7.5625,c=2.75;if(a<1/c)a=b*a*a;else if(a<2/c){a-=1.5/c;a=b*a*a+0.75}else if(a<2.5/c){a-=2.25/c;a=b*a*a+0.9375}else{a-=2.625/c;a=b*a*a+0.984375}return a}};var T={length:0};function qb(){var a=+new Date;for(var b in T)if(b!="length"&&T[z](b)){var c= -T[b];if(c.stop||c.el.removed){delete T[b];T[o]--}else{var d=a-c.start,f=c.ms,e=c.easing,g=c.from,h=c.diff,i=c.to,j=c.t,m=c.prev||0,n=c.el,r=c.callback,q={},k;if(d';az=av.firstChild;az.style.behavior="url(#default#VML)";if(!(az&&typeof az.adj=="object")){return aG.type=null}av=null}aG.svg=!(aG.vml=aG.type=="VML");bw[bC]=aG[bC];aW=bw[bC];aG._id=0;aG._oid=0;aG.fn={};aG.is=function(d,b){b=bE.call(b);if(b=="finite"){return !ao.test(+d)}return(b=="null"&&d===null)||(b==typeof d)||(b=="object"&&d===Object(d))||(b=="array"&&Array.isArray&&Array.isArray(d))||aQ.call(d).slice(8,-1).toLowerCase()==b};aG.angle=function(E,S,e,R,d,i){if(d==null){var b=E-e,bF=S-R;if(!b&&!bF){return 0}return((b<0)*180+an.atan(-bF/-b)*180/an.PI+360)%360}else{return aG.angle(E,S,d,i)-aG.angle(e,R,d,i)}};aG.snapTo=function(d,E,b){b=b||10;d=[][bt](d);var e=d.length;while(e--){if(an.abs(d[e]-E)<=b){return d[e]}}return E};aG.setWindow=function(b){aN=b;Z=aN.document};var a6=function(E){if(aG.vml){var b=/^\s+|\s+$/g;var S;try{var bF=new ActiveXObject("htmlfile");bF.write("");bF.close();S=bF.body}catch(bG){S=createPopup().document.body}var d=S.createTextRange();a6=ay(function(i){try{S.style.color=bA(i)[bp](b,aM);var bH=d.queryCommandValue("ForeColor");bH=((bH&255)<<16)|(bH&65280)|((bH&16711680)>>>16);return"#"+("000000"+bH[aX](16)).slice(-6)}catch(bI){return"none"}})}else{var R=Z.createElement("i");R.title="Rapha\xebl Colour Picker";R.style.display="none";Z.body[bh](R);a6=ay(function(e){R.style.color=e;return Z.defaultView.getComputedStyle(R,aM).getPropertyValue("color")})}return a6(E)},aA=function(){return"hsb("+[this.h,this.s,this.b]+")"},L=function(){return"hsl("+[this.h,this.s,this.l]+")"},A=function(){return this.hex};aG.hsb2rgb=function(i,e,d){if(aG.is(i,"object")&&"h" in i&&"s" in i&&"b" in i){d=i.b;e=i.s;i=i.h}return aG.hsl2rgb(i,e,d/2)};aG.hsl2rgb=function(S,bM,e){if(aG.is(S,"object")&&"h" in S&&"s" in S&&"l" in S){e=S.l;bM=S.s;S=S.h}if(S>1||bM>1||e>1){S/=360;bM/=100;e/=100}var bJ={},bG=["r","g","b"],bF,bI,R,d,bH,bK;if(!bM){bJ={r:e,g:e,b:e}}else{if(e<0.5){bF=e*(1+bM)}else{bF=e+bM-e*bM}bI=2*e-bF;for(var E=0,bL=bG.length;E1&&R--;if(R*6<1){bJ[bG[E]]=bI+(bF-bI)*6*R}else{if(R*2<1){bJ[bG[E]]=bF}else{if(R*3<2){bJ[bG[E]]=bI+(bF-bI)*(2/3-R)*6}else{bJ[bG[E]]=bI}}}}}bJ.r*=255;bJ.g*=255;bJ.b*=255;d=(~~bJ.r)[aX](16);bH=(~~bJ.g)[aX](16);bK=(~~bJ.b)[aX](16);d=d[bp](bx,"0");bH=bH[bp](bx,"0");bK=bK[bp](bx,"0");bJ.hex="#"+d+bH+bK;bJ.toString=A;return bJ};aG.rgb2hsb=function(b,d,bF){if(d==null&&aG.is(b,"object")&&"r" in b&&"g" in b&&"b" in b){bF=b.b;d=b.g;b=b.r}if(d==null&&aG.is(b,ae)){var bH=aG.getRGB(b);b=bH.r;d=bH.g;bF=bH.b}if(b>1||d>1||bF>1){b/=255;d/=255;bF/=255}var S=l(b,d,bF),e=bf(b,d,bF),E,i,R=S;if(e==S){return{h:0,s:0,b:S,toString:aA}}else{var bG=(S-e);i=bG/S;if(b==S){E=(d-bF)/bG}else{if(d==S){E=2+((bF-b)/bG)}else{E=4+((b-d)/bG)}}E/=6;E<0&&E++;E>1&&E--}return{h:E,s:i,b:R,toString:aA}};aG.rgb2hsl=function(d,e,S){if(e==null&&aG.is(d,"object")&&"r" in d&&"g" in d&&"b" in d){S=d.b;e=d.g;d=d.r}if(e==null&&aG.is(d,ae)){var bI=aG.getRGB(d);d=bI.r;e=bI.g;S=bI.b}if(d>1||e>1||S>1){d/=255;e/=255;S/=255}var R=l(d,e,S),i=bf(d,e,S),E,bH,b=(R+i)/2,bG;if(i==R){bG={h:0,s:0,l:b}}else{var bF=R-i;bH=b<0.5?bF/(R+i):bF/(2-R-i);if(d==R){E=(e-S)/bF}else{if(e==R){E=2+(S-d)/bF}else{E=4+(d-e)/bF}}E/=6;E<0&&E++;E>1&&E--;bG={h:E,s:bH,l:b}}bG.toString=L;return bG};aG._path2string=function(){return this.join(",")[bp](a7,"$1")};function ay(i,d,b){function e(){var E=Array[bC].slice.call(arguments,0),S=E[aT]("\u25ba"),R=e.cache=e.cache||{},bF=e.count=e.count||[];if(R[af](S)){return b?b(R[S]):R[S]}bF[r]>=1000&&delete R[bF.shift()];bF[j](S);R[S]=i[bz](d,E);return b?b(R[S]):R[S]}return e}aG.getRGB=ay(function(e){if(!e||!!((e=bA(e)).indexOf("-")+1)){return{r:-1,g:-1,b:-1,hex:"none",error:1}}if(e=="none"){return{r:-1,g:-1,b:-1,hex:"none"}}!(m[af](e.substring(0,2))||e.charAt()=="#")&&(e=a6(e));var bF,i,E,bI,S,bJ,bG=e.match(F);if(bG){if(bG[2]){bI=Q(bG[2].substring(5),16);E=Q(bG[2].substring(3,5),16);i=Q(bG[2].substring(1,3),16)}if(bG[3]){bI=Q((bJ=bG[3].charAt(3))+bJ,16);E=Q((bJ=bG[3].charAt(2))+bJ,16);i=Q((bJ=bG[3].charAt(1))+bJ,16)}if(bG[4]){bG=bG[4][H](ba);i=ai(bG[0]);E=ai(bG[1]);bI=ai(bG[2]);S=ai(bG[3])}if(bG[5]){bG=bG[5][H](ba);i=ai(bG[0])*2.55;E=ai(bG[1])*2.55;bI=ai(bG[2])*2.55;S=ai(bG[3])}if(bG[6]){bG=bG[6][H](ba);i=ai(bG[0]);E=ai(bG[1]);bI=ai(bG[2]);(bG[0].slice(-3)=="deg"||bG[0].slice(-1)=="\xb0")&&(i/=360);return aG.hsb2rgb(i,E,bI)}if(bG[7]){bG=bG[7][H](ba);i=ai(bG[0])*2.55;E=ai(bG[1])*2.55;bI=ai(bG[2])*2.55;(bG[0].slice(-3)=="deg"||bG[0].slice(-1)=="\xb0")&&(i/=360*2.55);return aG.hsb2rgb(i,E,bI)}if(bG[8]){bG=bG[8][H](ba);i=ai(bG[0]);E=ai(bG[1]);bI=ai(bG[2]);(bG[0].slice(-3)=="deg"||bG[0].slice(-1)=="\xb0")&&(i/=360);return aG.hsl2rgb(i,E,bI)}if(bG[9]){bG=bG[9][H](ba);i=ai(bG[0])*2.55;E=ai(bG[1])*2.55;bI=ai(bG[2])*2.55;(bG[0].slice(-3)=="deg"||bG[0].slice(-1)=="\xb0")&&(i/=360*2.55);return aG.hsl2rgb(i,E,bI)}bG={r:i,g:E,b:bI};var d=(~~i)[aX](16),R=(~~E)[aX](16),bH=(~~bI)[aX](16);d=d[bp](bx,"0");R=R[bp](bx,"0");bH=bH[bp](bx,"0");bG.hex="#"+d+R+bH;isFinite(ai(S))&&(bG.o=S);return bG}return{r:-1,g:-1,b:-1,hex:"none",error:1}},aG);aG.getColor=function(d){var e=this.getColor.start=this.getColor.start||{h:0,s:1,b:d||0.75},b=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 b.hex};aG.getColor.reset=function(){delete this.start};aG.parsePathString=ay(function(b){if(!b){return null}var e={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},d=[];if(aG.is(b,a4)&&aG.is(b[0],a4)){d=aP(b)}if(!d[r]){bA(b)[bp](aO,function(E,i,bF){var S=[],R=bE.call(i);bF[bp](aE,function(bH,bG){bG&&S[j](+bG)});if(R=="m"&&S[r]>2){d[j]([i][bt](S.splice(0,2)));R="l";i=i=="m"?"l":"L"}while(S[r]>=e[R]){d[j]([i][bt](S.splice(0,e[R])));if(!e[R]){break}}})}d[aX]=aG._path2string;return d});aG.findDotsAtSegment=function(d,b,bS,bQ,S,E,bG,bF,bM){var bK=1-bM,bJ=bi(bK,3)*d+bi(bK,2)*3*bM*bS+bK*3*bM*bM*S+bi(bM,3)*bG,bH=bi(bK,3)*b+bi(bK,2)*3*bM*bQ+bK*3*bM*bM*E+bi(bM,3)*bF,bO=d+2*bM*(bS-d)+bM*bM*(S-2*bS+d),bN=b+2*bM*(bQ-b)+bM*bM*(E-2*bQ+b),bR=bS+2*bM*(S-bS)+bM*bM*(bG-2*S+bS),bP=bQ+2*bM*(E-bQ)+bM*bM*(bF-2*E+bQ),bL=(1-bM)*d+bM*bS,bI=(1-bM)*b+bM*bQ,i=(1-bM)*S+bM*bG,e=(1-bM)*E+bM*bF,R=(90-an.atan((bO-bR)/(bN-bP))*180/an.PI);(bO>bR||bN1){cc=an.sqrt(cc);bW=cc*bW;bU=cc*bU}var e=bW*bW,b5=bU*bU,b7=(bI==R?-1:1)*an.sqrt(an.abs((e*b5-e*b1*b1-b5*b2*b2)/(e*b1*b1+b5*b2*b2))),bR=b7*bW*b1/bU+(bN+bM)/2,bQ=b7*-bU*b2/bW+(ci+ch)/2,bH=an.asin(((ci-bQ)/bU).toFixed(9)),bG=an.asin(((ch-bQ)/bU).toFixed(9));bH=bNbG){bH=bH-E*2}if(!R&&bG>bH){bG=bG-E*2}}else{bH=bP[0];bG=bP[1];bR=bP[2];bQ=bP[3]}var bL=bG-bH;if(an.abs(bL)>bT){var bS=bG,bV=bM,bJ=ch;bG=bH+bT*(R&&bG>bH?1:-1);bM=bR+bW*an.cos(bG);ch=bQ+bU*an.sin(bG);b0=Y(bM,ch,bW,bU,bO,0,R,bV,bJ,[bG,bS,bR,bQ])}bL=bG-bH;var bF=an.cos(bH),cg=an.sin(bH),S=an.cos(bG),cf=an.sin(bG),b3=an.tan(bL/4),b6=4/3*bW*b3,b4=4/3*bU*b3,cd=[bN,ci],cb=[bN+b6*cg,ci-b4*bF],ca=[bM+b6*cf,ch-b4*S],b8=[bM,ch];cb[0]=2*cd[0]-cb[0];cb[1]=2*cd[1]-cb[1];if(bP){return[cb,ca,b8][bt](b0)}else{b0=[cb,ca,b8][bt](b0)[aT]()[H](",");var bY=[];for(var b9=0,bZ=b0[r];b9"1e12"&&(bF=0.5);an.abs(S)>"1e12"&&(S=0.5);if(bF>0&&bF<1){e=ab(i,d,R,E,bO,bN,bK,bH,bF);bL[j](e.x);bI[j](e.y)}if(S>0&&S<1){e=ab(i,d,R,E,bO,bN,bK,bH,S);bL[j](e.x);bI[j](e.y)}bM=(bN-2*E+d)-(bH-2*bN+E);bJ=2*(E-d)-2*(bN-E);bG=d-E;bF=(-bJ+an.sqrt(bJ*bJ-4*bM*bG))/2/bM;S=(-bJ-an.sqrt(bJ*bJ-4*bM*bG))/2/bM;an.abs(bF)>"1e12"&&(bF=0.5);an.abs(S)>"1e12"&&(S=0.5);if(bF>0&&bF<1){e=ab(i,d,R,E,bO,bN,bK,bH,bF);bL[j](e.x);bI[j](e.y)}if(S>0&&S<1){e=ab(i,d,R,E,bO,bN,bK,bH,S);bL[j](e.x);bI[j](e.y)}return{min:{x:bf[bz](0,bL),y:bf[bz](0,bI)},max:{x:l[bz](0,bL),y:l[bz](0,bI)}}}),U=ay(function(bN,bI){var E=x(bN),bJ=bI&&x(bI),bK={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},b={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},S=function(bO,bP){var i,bQ;if(!bO){return["C",bP.x,bP.y,bP.x,bP.y,bP.x,bP.y]}!(bO[0] in {T:1,Q:1})&&(bP.qx=bP.qy=null);switch(bO[0]){case"M":bP.X=bO[1];bP.Y=bO[2];break;case"A":bO=["C"][bt](Y[bz](0,[bP.x,bP.y][bt](bO.slice(1))));break;case"S":i=bP.x+(bP.x-(bP.bx||bP.x));bQ=bP.y+(bP.y-(bP.by||bP.y));bO=["C",i,bQ][bt](bO.slice(1));break;case"T":bP.qx=bP.x+(bP.x-(bP.qx||bP.x));bP.qy=bP.y+(bP.y-(bP.qy||bP.y));bO=["C"][bt](bg(bP.x,bP.y,bP.qx,bP.qy,bO[1],bO[2]));break;case"Q":bP.qx=bO[1];bP.qy=bO[2];bO=["C"][bt](bg(bP.x,bP.y,bO[1],bO[2],bO[3],bO[4]));break;case"L":bO=["C"][bt](bB(bP.x,bP.y,bO[1],bO[2]));break;case"H":bO=["C"][bt](bB(bP.x,bP.y,bO[1],bP.y));break;case"V":bO=["C"][bt](bB(bP.x,bP.y,bP.x,bO[1]));break;case"Z":bO=["C"][bt](bB(bP.x,bP.y,bP.X,bP.Y));break}return bO},d=function(bO,bP){if(bO[bP][r]>7){bO[bP].shift();var bQ=bO[bP];while(bQ[r]){bO.splice(bP++,0,["C"][bt](bQ.splice(0,6)))}bO.splice(bP,1);bL=l(E[r],bJ&&bJ[r]||0)}},e=function(bS,bR,bP,bO,bQ){if(bS&&bR&&bS[bQ][0]=="M"&&bR[bQ][0]!="M"){bR.splice(bQ,0,["M",bO.x,bO.y]);bP.bx=0;bP.by=0;bP.x=bS[bQ][1];bP.y=bS[bQ][2];bL=l(E[r],bJ&&bJ[r]||0)}};for(var bG=0,bL=l(E[r],bJ&&bJ[r]||0);bG0.5)*2-1);bi(bG-0.5,2)+bi(S-0.5,2)>0.25&&(S=an.sqrt(0.25-bi(bG-0.5,2))*bP+0.5)&&S!=0.5&&(S=S.toFixed(5)-0.00001*bP)}return aM});bM=bM[H](/\s*\-\s*/);if(bJ=="linear"){var bF=bM.shift();bF=-ai(bF);if(isNaN(bF)){return null}var R=[0,0,an.cos(bF*an.PI/180),an.sin(bF*an.PI/180)],bL=1/(l(an.abs(R[2]),an.abs(R[3]))||1);R[2]*=bL;R[3]*=bL;if(R[2]<0){R[0]=-R[2];R[2]=0}if(R[3]<0){R[1]=-R[3];R[3]=0}}var bI=v(bM);if(!bI){return null}var d=E.getAttribute(a1);d=d.match(/^url\(#(.*)\)$/);d&&b.defs.removeChild(Z.getElementById(d[1]));var e=be(bJ+"Gradient");e.id="r"+(aG._id++)[aX](36);be(e,bJ=="radial"?{fx:bG,fy:S}:{x1:R[0],y1:R[1],x2:R[2],y2:R[3]});b.defs[bh](e);for(var bH=0,bN=bI[r];bH1?i.o/100:i.o});case"stroke":i=aG.getRGB(bN);bQ[C](bP,i.hex);bP=="stroke"&&i[af]("o")&&be(bQ,{"stroke-opacity":i.o>1?i.o/100:i.o});break;case"gradient":(({circle:1,ellipse:1})[af](bL.type)||bA(bN).charAt()!="r")&&g(bQ,bN,bL.paper);break;case"opacity":case"fill-opacity":if(bM.gradient){var b=Z.getElementById(bQ.getAttribute(a1)[bp](/^url\(#|\)$/g,aM));if(b){var bG=b.getElementsByTagName("stop");bG[bG[r]-1][C]("stop-opacity",bN)}break}default:bP=="font-size"&&(bN=Q(bN,10)+"px");var bJ=bP[bp](/(\-.)/g,function(bW){return bl.call(bW.substring(1))});bQ.style[bJ]=bN;bQ[C](bP,bN);break}}}O(bL,bU);if(bH){bL.rotate(bH.join(aF))}else{ai(bI)&&bL.rotate(bI,true)}};var n=1.2,O=function(b,E){if(b.type!="text"||!(E[af]("text")||E[af]("font")||E[af]("font-size")||E[af]("x")||E[af]("y"))){return}var bH=b.attrs,d=b.node,bJ=d.firstChild?Q(Z.defaultView.getComputedStyle(d.firstChild,aM).getPropertyValue("font-size"),10):10;if(E[af]("text")){bH.text=E.text;while(d.firstChild){d.removeChild(d.firstChild)}var e=bA(E.text)[H]("\n");for(var R=0,bI=e[r];RbF.height)&&(bF.height=S.y+S.height-bF.y);(S.x+S.width-bF.x>bF.width)&&(bF.width=S.x+S.width-bF.x)}}d&&this.hide();return bF};aR[bC].attr=function(b,bH){if(this.removed){return this}if(b==null){var bG={};for(var R in this.attrs){if(this.attrs[af](R)){bG[R]=this.attrs[R]}}this._.rt.deg&&(bG.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(bG.scale=this.scale());bG.gradient&&bG.fill=="none"&&(bG.fill=bG.gradient)&&delete bG.gradient;return bG}if(bH==null&&aG.is(b,ae)){if(b=="translation"){return z.call(this)}if(b=="rotation"){return this.rotate()}if(b=="scale"){return this.scale()}if(b==a1&&this.attrs.fill=="none"&&this.attrs.gradient){return this.attrs.gradient}return this.attrs[b]}if(bH==null&&aG.is(b,a4)){var bJ={};for(var E=0,S=b.length;E"));bT.W=bP.w=bT.paper.span.offsetWidth;bT.H=bP.h=bT.paper.span.offsetHeight;bT.X=bP.x;bT.Y=bP.y+ac(bT.H/2);switch(bP["text-anchor"]){case"start":bT.node.style["v-text-align"]="left";bT.bbx=ac(bT.W/2);break;case"end":bT.node.style["v-text-align"]="right";bT.bbx=-ac(bT.W/2);break;default:bT.node.style["v-text-align"]="center";break}}};g=function(b,bF){b.attrs=b.attrs||{};var bG=b.attrs,bI,R="linear",S=".5 .5";b.attrs.gradient=bF;bF=bA(bF)[bp](aL,function(bK,bL,i){R="radial";if(bL&&i){bL=ai(bL);i=ai(i);bi(bL-0.5,2)+bi(i-0.5,2)>0.25&&(i=an.sqrt(0.25-bi(bL-0.5,2))*((i>0.5)*2-1)+0.5);S=bL+aF+i}return aM});bF=bF[H](/\s*\-\s*/);if(R=="linear"){var d=bF.shift();d=-ai(d);if(isNaN(d)){return null}}var E=v(bF);if(!E){return null}b=b.shape||b.node;bI=b.getElementsByTagName(a1)[0]||aw(a1);!bI.parentNode&&b.appendChild(bI);if(E[r]){bI.on=true;bI.method="none";bI.color=E[0].color;bI.color2=E[E[r]-1].color;var bJ=[];for(var e=0,bH=E[r];e')}}catch(au){aw=function(b){return Z.createElement("<"+b+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}D=function(){var e=aH[bz](0,arguments),b=e.container,bG=e.height,bH,d=e.width,bF=e.x,S=e.y;if(!b){throw new Error("VML container not found.")}var E=new bw,R=E.canvas=Z.createElement("div"),i=R.style;bF=bF||0;S=S||0;d=d||512;bG=bG||342;d==+d&&(d+="px");bG==+bG&&(bG+="px");E.width=1000;E.height=1000;E.coordsize=t*1000+aF+t*1000;E.coordorigin="0 0";E.span=Z.createElement("span");E.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";R[bh](E.span);i.cssText=aG.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",d,bG);if(b==1){Z.body[bh](R);i.left=bF+"px";i.top=S+"px";i.position="absolute"}else{if(b.firstChild){b.insertBefore(R,b.firstChild)}else{b[bh](R)}}bb.call(E,E,aG.fn);return E};aW.clear=function(){this.canvas.innerHTML=aM;this.span=Z.createElement("span");this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";this.canvas[bh](this.span);this.bottom=this.top=null};aW.remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var b in this){this[b]=y(b)}return true}}var T=navigator.userAgent.match(/Version\/(.*?)\s/);if((navigator.vendor=="Apple Computer, Inc.")&&(T&&T[1]<4||navigator.platform.slice(0,2)=="iP")){aW.safari=function(){var b=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});aN.setTimeout(function(){b.remove()})}}else{aW.safari=function(){}}var N=function(){this.returnValue=false},bs=function(){return this.originalEvent.preventDefault()},a0=function(){this.cancelBubble=true},aB=function(){return this.originalEvent.stopPropagation()},at=(function(){if(Z.addEventListener){return function(R,i,e,d){var b=V&&bn[i]?bn[i]:i;var E=function(bH){if(V&&bn[af](i)){for(var bF=0,bG=bH.targetTouches&&bH.targetTouches.length;bF1&&(b=Array[bC].splice.call(arguments,0,arguments[r]));return new ag(b)};aW.setSize=by;aW.top=aW.bottom=null;aW.raphael=aG;function B(){return this.x+aF+this.y}a9.resetScale=function(){if(this.removed){return this}this._.sx=1;this._.sy=1;this.attrs.scale="1 1"};a9.scale=function(bK,bJ,e,d){if(this.removed){return this}if(bK==null&&bJ==null){return{x:this._.sx,y:this._.sy,toString:B}}bJ=bJ||bK;!+bJ&&(bJ=bK);var bO,bM,bN,bL,b0=this.attrs;if(bK!=0){var bI=this.getBBox(),bF=bI.x+bI.width/2,E=bI.y+bI.height/2,bZ=bK/this._.sx,bY=bJ/this._.sy;e=(+e||e==0)?e:bF;d=(+d||d==0)?d:E;var bH=~~(bK/an.abs(bK)),S=~~(bJ/an.abs(bJ)),bR=this.node.style,b2=e+(bF-e)*bZ,b1=d+(E-d)*bY;switch(this.type){case"rect":case"image":var bG=b0.width*bH*bZ,bQ=b0.height*S*bY;this.attr({height:bQ,r:b0.r*bf(bH*bZ,S*bY),width:bG,x:b2-bG/2,y:b1-bQ/2});break;case"circle":case"ellipse":this.attr({rx:b0.rx*bH*bZ,ry:b0.ry*S*bY,r:b0.r*bf(bH*bZ,S*bY),cx:b2,cy:b1});break;case"text":this.attr({x:b2,y:b1});break;case"path":var bT=ar(b0.path),bU=true;for(var bW=0,bP=bT[r];bWbI){e=b.data[bI*100]}else{e=aG.findDotsAtSegment(R,d,bH,bG,bN,bM,bL,bK,bI/100);b.data[bI]=e}bI&&(bJ+=bi(bi(bF.x-e.x,2)+bi(bF.y-e.y,2),0.5));if(S!=null&&bJ>=S){return e}bF=e}if(S==null){return bJ}},aY=function(b,d){return function(bN,R,S){bN=U(bN);var bJ,bI,e,bF,E="",bM={},bK,bH=0;for(var bG=0,bL=bN.length;bGR){if(d&&!bM.start){bK=k(bJ,bI,e[1],e[2],e[3],e[4],e[5],e[6],R-bH);E+=["C",bK.start.x,bK.start.y,bK.m.x,bK.m.y,bK.x,bK.y];if(S){return E}bM.start=E;E=["M",bK.x,bK.y+"C",bK.n.x,bK.n.y,bK.end.x,bK.end.y,e[5],e[6]][aT]();bH+=bF;bJ=+e[5];bI=+e[6];continue}if(!b&&!d){bK=k(bJ,bI,e[1],e[2],e[3],e[4],e[5],e[6],R-bH);return{x:bK.x,y:bK.y,alpha:bK.alpha}}}bH+=bF;bJ=+e[5];bI=+e[6]}E+=e}bM.end=E;bK=b?bH:d?bM:aG.findDotsAtSegment(bJ,bI,e[1],e[2],e[3],e[4],e[5],e[6],1);bK.alpha&&(bK={x:bK.x,y:bK.y,alpha:bK.alpha});return bK}};var aI=aY(1),K=aY(),X=aY(0,1);a9.getTotalLength=function(){if(this.type!="path"){return}if(this.node.getTotalLength){return this.node.getTotalLength()}return aI(this.attrs.path)};a9.getPointAtLength=function(b){if(this.type!="path"){return}if(this.node.getPointAtLength){return this.node.getPointAtLength(b)}return K(this.attrs.path,b)};a9.getSubpath=function(e,d){if(this.type!="path"){return}if(an.abs(this.getTotalLength()-d)<"1e-6"){return X(this.attrs.path,e).end}var b=X(this.attrs.path,d,1);return e?X(b,e).end:b};aG.easing_formulas={linear:function(b){return b},"<":function(b){return bi(b,3)},">":function(b){return bi(b-1,3)+1},"<>":function(b){b=b*2;if(b<1){return bi(b,3)/2}b-=2;return(bi(b,3)+2)/2},backIn:function(d){var b=1.70158;return d*d*((b+1)*d-b)},backOut:function(d){d=d-1;var b=1.70158;return d*d*((b+1)*d+b)+1},elastic:function(e){if(e==0||e==1){return e}var d=0.3,b=d/4;return bi(2,-10*e)*an.sin((e-b)*(2*an.PI)/d)+1},bounce:function(i){var d=7.5625,e=2.75,b;if(i<(1/e)){b=d*i*i}else{if(i<(2/e)){i-=(1.5/e);b=d*i*i+0.75}else{if(i<(2.5/e)){i-=(2.25/e);b=d*i*i+0.9375}else{i-=(2.625/e);b=d*i*i+0.984375}}}return b}};var W=[],br=function(){var bG=+new Date;for(var bR=0;bRbS){return bS}while(bTbO){bT=bQ}else{bS=bQ}bQ=(bS-bT)/2+bT}return bQ}return e(bL,1/(200*bF))}a9.onAnimation=function(b){this._run=b||0;return this};a9.animate=function(bY,bO,bN,R){var d=this;d.timeouts=d.timeouts||[];if(aG.is(bN,"function")||!bN){R=bN||null}if(d.removed){R&&R.call(d);return d}var bS={},e={},S=false,bJ={};for(var bP in bY){if(bY[af](bP)){if(al[af](bP)||d.paper.customAttributes[af](bP)){S=true;bS[bP]=d.attr(bP);(bS[bP]==null)&&(bS[bP]=p[bP]);e[bP]=bY[bP];switch(al[bP]){case"along":var bW=aI(bY[bP]);var bQ=K(bY[bP],bW*!!bY.back);var bF=d.getBBox();bJ[bP]=bW/bO;bJ.tx=bF.x;bJ.ty=bF.y;bJ.sx=bQ.x;bJ.sy=bQ.y;e.rot=bY.rot;e.back=bY.back;e.len=bW;bY.rot&&(bJ.r=ai(d.rotate())||0);break;case aD:bJ[bP]=(e[bP]-bS[bP])/bO;break;case"colour":bS[bP]=aG.getRGB(bS[bP]);var bR=aG.getRGB(e[bP]);bJ[bP]={r:(bR.r-bS[bP].r)/bO,g:(bR.g-bS[bP].g)/bO,b:(bR.b-bS[bP].b)/bO};break;case"path":var bG=U(bS[bP],e[bP]);bS[bP]=bG[0];var bL=bG[1];bJ[bP]=[];for(var bV=0,bI=bS[bP][r];bV"); + docum.close(); + bod = docum.body; + } catch(e) { + bod = createPopup().document.body; + } + var range = bod.createTextRange(); toHex = cacher(function (color) { - var bod; - color = Str(color)[rp](trim, E); try { - var docum = new win.ActiveXObject("htmlfile"); - docum.write(""); - docum.close(); - bod = docum.body; - } catch(e) { - bod = win.createPopup().document.body; - } - var range = bod.createTextRange(); - try { - bod.style.color = color; + bod.style.color = Str(color)[rp](trim, E); var value = range.queryCommandValue("ForeColor"); value = ((value & 255) << 16) | (value & 65280) | ((value & 16711680) >>> 16); return "#" + ("000000" + value[toString](16)).slice(-6); @@ -164,9 +203,9 @@ Raphael = (function () { h = h.h; } if (h > 1 || s > 1 || l > 1) { - h /= 255; - s /= 255; - l /= 255; + h /= 360; + s /= 100; + l /= 100; } var rgb = {}, channels = ["r", "g", "b"], @@ -295,9 +334,6 @@ Raphael = (function () { hsl.toString = hsltoString; return hsl; }; - var p2s = /,?([achlmqrstvxz]),?/gi, - commaSpaces = /\s*,\s*/, - hsrg = {hs: 1, rg: 1}; R._path2string = function () { return this.join(",")[rp](p2s, "$1"); }; @@ -418,8 +454,6 @@ Raphael = (function () { delete this.start; }; // path utilities - var pathCommand = /([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig, - pathValues = /(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig; R.parsePathString = cacher(function (pathString) { if (!pathString) { return null; @@ -715,8 +749,8 @@ Raphael = (function () { math.sqrt(math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))), cx = k * rx * y / ry + (x1 + x2) / 2, cy = k * -ry * x / rx + (y1 + y2) / 2, - f1 = math.asin(((y1 - cy) / ry).toFixed(7)), - f2 = math.asin(((y2 - cy) / ry).toFixed(7)); + f1 = math.asin(((y1 - cy) / ry).toFixed(9)), + f2 = math.asin(((y2 - cy) / ry).toFixed(9)); f1 = x1 < cx ? PI - f1 : f1; f2 = x2 < cx ? PI - f2 : f2; @@ -785,8 +819,8 @@ Raphael = (function () { y = [p1y, p2y], x = [p1x, p2x], dot; - math.abs(t1) > 1e12 && (t1 = .5); - math.abs(t2) > 1e12 && (t2 = .5); + math.abs(t1) > "1e12" && (t1 = .5); + math.abs(t2) > "1e12" && (t2 = .5); if (t1 > 0 && t1 < 1) { dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1); x[push](dot.x); @@ -802,8 +836,8 @@ Raphael = (function () { c = p1y - c1y; t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a; t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a; - math.abs(t1) > 1e12 && (t1 = .5); - math.abs(t2) > 1e12 && (t2 = .5); + math.abs(t1) > "1e12" && (t1 = .5); + math.abs(t2) > "1e12" && (t2 = .5); if (t1 > 0 && t1 < 1) { dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1); x[push](dot.x); @@ -1039,8 +1073,8 @@ Raphael = (function () { R.pathToRelative = pathToRelative; // SVG if (R.svg) { - Paper[proto].svgns = "http://www.w3.org/2000/svg"; - Paper[proto].xlink = "http://www.w3.org/1999/xlink"; + paperproto.svgns = "http://www.w3.org/2000/svg"; + paperproto.xlink = "http://www.w3.org/1999/xlink"; round = function (num) { return +num + (~~num === num) * .5; }; @@ -1052,7 +1086,7 @@ Raphael = (function () { } } } else { - el = doc.createElementNS(Paper[proto].svgns, el); + el = doc.createElementNS(paperproto.svgns, el); el.style.webkitTapHighlightColor = "rgba(0,0,0,0)"; return el; } @@ -1112,7 +1146,7 @@ Raphael = (function () { var id = o.getAttribute(fillString); 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]}); @@ -1203,7 +1237,11 @@ Raphael = (function () { hl[appendChild](node); pn = hl; } - pn.setAttributeNS(o.paper.xlink, att, value); + if (att == "target" && value == "blank") { + pn.setAttributeNS(o.paper.xlink, "show", "new"); + } else { + pn.setAttributeNS(o.paper.xlink, att, value); + } break; case "cursor": node.style.cursor = value; @@ -1454,6 +1492,7 @@ Raphael = (function () { svg.top = this; this.next = null; }; + var elproto = Element[proto]; Element[proto].rotate = function (deg, cx, cy) { if (this.removed) { return this; @@ -1471,7 +1510,7 @@ Raphael = (function () { cy = toFloat(deg[2]); } deg = toFloat(deg[0]); - if (cx != null) { + if (cx != null && cx !== false) { this._.rt.deg = deg; } else { this._.rt.deg += deg; @@ -1580,10 +1619,17 @@ Raphael = (function () { if (value != null) { var params = {}; params[name] = value; - setFillAndStroke(this, params); } else if (name != null && R.is(name, "object")) { - setFillAndStroke(this, name); + params = name; + } + for (var key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) { + var par = this.paper.customAttributes[key].apply(this, [][concat](params[key])); + this.attrs[key] = params[key]; + for (var subkey in par) if (par[has](subkey)) { + params[subkey] = par[subkey]; + } } + setFillAndStroke(this, params); return this; }; Element[proto].toFront = function () { @@ -1610,7 +1656,7 @@ Raphael = (function () { if (this.removed) { return this; } - var node = element.node || element[element.length].node; + var node = element.node || element[element.length - 1].node; if (node.nextSibling) { node.parentNode.insertBefore(this.node, node.nextSibling); } else { @@ -1658,8 +1704,8 @@ Raphael = (function () { res.type = "circle"; $(el, res.attrs); return res; - }; - var theRect = function (svg, x, y, w, h, r) { + }, + theRect = function (svg, x, y, w, h, r) { var el = $("rect"); svg.canvas && svg.canvas[appendChild](el); var res = new Element(el, svg); @@ -1667,8 +1713,8 @@ Raphael = (function () { res.type = "rect"; $(el, res.attrs); return res; - }; - var theEllipse = function (svg, x, y, rx, ry) { + }, + theEllipse = function (svg, x, y, rx, ry) { var el = $("ellipse"); svg.canvas && svg.canvas[appendChild](el); var res = new Element(el, svg); @@ -1676,8 +1722,8 @@ Raphael = (function () { res.type = "ellipse"; $(el, res.attrs); return res; - }; - var theImage = function (svg, src, x, y, w, h) { + }, + theImage = function (svg, src, x, y, w, h) { var el = $("image"); $(el, {x: x, y: y, width: w, height: h, preserveAspectRatio: "none"}); el.setAttributeNS(svg.xlink, "href", src); @@ -1686,8 +1732,8 @@ Raphael = (function () { res.attrs = {x: x, y: y, width: w, height: h, src: src}; res.type = "image"; return res; - }; - var theText = function (svg, x, y, text) { + }, + theText = function (svg, x, y, text) { var el = $("text"); $(el, {x: x, y: y, "text-anchor": "middle"}); svg.canvas && svg.canvas[appendChild](el); @@ -1696,15 +1742,15 @@ Raphael = (function () { res.type = "text"; setFillAndStroke(res, res.attrs); return res; - }; - var setSize = function (width, height) { + }, + setSize = function (width, height) { this.width = width || this.width; this.height = height || this.height; this.canvas[setAttribute]("width", this.width); this.canvas[setAttribute]("height", this.height); return this; - }; - var create = function () { + }, + create = function () { var con = getContainer[apply](0, arguments), container = con && con.container, x = con.x, @@ -1743,7 +1789,7 @@ Raphael = (function () { container.clear(); return container; }; - Paper[proto].clear = function () { + paperproto.clear = function () { var c = this.canvas; while (c.firstChild) { c.removeChild(c.firstChild); @@ -1753,7 +1799,7 @@ Raphael = (function () { c[appendChild](this.desc); c[appendChild](this.defs = $("defs")); }; - Paper[proto].remove = function () { + paperproto.remove = function () { this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas); for (var i in this) { this[i] = removed(i); @@ -1765,6 +1811,7 @@ Raphael = (function () { 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, + blurregexp = / progid:\S+Blur\([^\)]+\)/g, val = /-?[^,\s-]+/g, coordsize = 1e3 + S + 1e3, zoom = 10, @@ -1821,7 +1868,6 @@ Raphael = (function () { var p = new Element(el, g, vml), attr = {fill: "none", stroke: "#000"}; pathString && (attr.path = pathString); - p.isAbsolute = true; p.type = "path"; p.path = []; p.Path = E; @@ -1854,7 +1900,7 @@ Raphael = (function () { params.cursor && (s.cursor = params.cursor); "blur" in params && o.blur(params.blur); if (params.path && o.type == "path" || newpath) { - node.path = path2vml(a.path); + node.path = path2vml(a.path); } if (params.rotation != null) { o.rotate(params.rotation, true); @@ -1925,8 +1971,7 @@ Raphael = (function () { !fill && (newfill = fill = createNode(fillString)); if ("fill-opacity" in params || "opacity" in params) { var opacity = ((+a["fill-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+R.getRGB(params.fill).o + 1 || 2) - 1); - opacity < 0 && (opacity = 0); - opacity > 1 && (opacity = 1); + opacity = mmin(mmax(opacity, 0), 1); fill.opacity = opacity; } params.fill && (fill.on = true); @@ -1966,8 +2011,7 @@ Raphael = (function () { stroke.on && params.stroke && (stroke.color = strokeColor.hex); opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+strokeColor.o + 1 || 2) - 1); var width = (toFloat(params["stroke-width"]) || 1) * .75; - opacity < 0 && (opacity = 0); - opacity > 1 && (opacity = 1); + opacity = mmin(mmax(opacity, 0), 1); params["stroke-width"] == null && (width = a["stroke-width"]); params["stroke-width"] && (stroke.weight = width); width && width < 1 && (opacity *= width) && (stroke.weight = 1); @@ -2103,7 +2147,8 @@ Raphael = (function () { vml.top = this; this.next = null; }; - Element[proto].rotate = function (deg, cx, cy) { + elproto = Element[proto]; + elproto.rotate = function (deg, cx, cy) { if (this.removed) { return this; } @@ -2136,7 +2181,7 @@ Raphael = (function () { // !R.is(fill.angle, "undefined") && (fill.angle = b); return this; }; - Element[proto].setBox = function (params, cx, cy) { + elproto.setBox = function (params, cx, cy) { if (this.removed) { return this; } @@ -2225,15 +2270,15 @@ Raphael = (function () { os.height != (t = h + "px") && (os.height = t); } }; - Element[proto].hide = function () { + elproto.hide = function () { !this.removed && (this.Group.style.display = "none"); return this; }; - Element[proto].show = function () { + elproto.show = function () { !this.removed && (this.Group.style.display = "block"); return this; }; - Element[proto].getBBox = function () { + elproto.getBBox = function () { if (this.removed) { return this; } @@ -2247,7 +2292,7 @@ Raphael = (function () { height: this.H }; }; - Element[proto].remove = function () { + elproto.remove = function () { if (this.removed) { return; } @@ -2260,7 +2305,7 @@ Raphael = (function () { } this.removed = true; }; - Element[proto].attr = function (name, value) { + elproto.attr = function (name, value) { if (this.removed) { return this; } @@ -2274,7 +2319,7 @@ Raphael = (function () { res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient; return res; } - if (value == null && R.is(name, string)) { + if (value == null && R.is(name, "string")) { if (name == "translation") { return translate.call(this); } @@ -2303,6 +2348,13 @@ Raphael = (function () { } value == null && R.is(name, "object") && (params = name); if (params) { + for (var key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) { + var par = this.paper.customAttributes[key].apply(this, [][concat](params[key])); + this.attrs[key] = params[key]; + for (var subkey in par) if (par[has](subkey)) { + params[subkey] = par[subkey]; + } + } if (params.text && this.type == "text") { this.node.string = params.text; } @@ -2314,12 +2366,12 @@ Raphael = (function () { } return this; }; - Element[proto].toFront = function () { + elproto.toFront = function () { !this.removed && this.Group.parentNode[appendChild](this.Group); this.paper.top != this && tofront(this, this.paper); return this; }; - Element[proto].toBack = function () { + elproto.toBack = function () { if (this.removed) { return this; } @@ -2329,7 +2381,7 @@ Raphael = (function () { } return this; }; - Element[proto].insertAfter = function (element) { + elproto.insertAfter = function (element) { if (this.removed) { return this; } @@ -2344,7 +2396,7 @@ Raphael = (function () { insertafter(this, element, this.paper); return this; }; - Element[proto].insertBefore = function (element) { + elproto.insertBefore = function (element) { if (this.removed) { return this; } @@ -2355,8 +2407,7 @@ Raphael = (function () { insertbefore(this, element, this.paper); return this; }; - var blurregexp = / progid:\S+Blur\([^\)]+\)/g; - Element[proto].blur = function (size) { + elproto.blur = function (size) { var s = this.node.runtimeStyle, f = s.filter; f = f.replace(blurregexp, E); @@ -2430,8 +2481,7 @@ Raphael = (function () { }; theImage = function (vml, src, x, y, w, h) { var g = createNode("group"), - o = createNode("image"), - ol = o.style; + o = createNode("image"); g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; g.coordsize = coordsize; g.coordorigin = vml.coordorigin; @@ -2529,7 +2579,7 @@ Raphael = (function () { res.span = doc.createElement("span"); res.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;"; c[appendChild](res.span); - cs.cssText = R.format("width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden", width, height); + cs.cssText = R.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden", width, height); if (container == 1) { doc.body[appendChild](c); cs.left = x + "px"; @@ -2545,14 +2595,14 @@ Raphael = (function () { plugins.call(res, res, R.fn); return res; }; - Paper[proto].clear = function () { + paperproto.clear = function () { this.canvas.innerHTML = E; this.span = doc.createElement("span"); this.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;"; this.canvas[appendChild](this.span); this.bottom = this.top = null; }; - Paper[proto].remove = function () { + paperproto.remove = function () { this.canvas.parentNode.removeChild(this.canvas); for (var i in this) { this[i] = removed(i); @@ -2563,13 +2613,14 @@ Raphael = (function () { // rest // WebKit rendering bug workaround method - if ((navigator.vendor == "Apple Computer, Inc.") && (navigator.userAgent.match(/Version\/(.*?)\s/)[1] < 4 || win.navigator.platform.slice(0, 2) == "iP")) { - Paper[proto].safari = function () { + var version = navigator.userAgent.match(/Version\/(.*?)\s/); + if ((navigator.vendor == "Apple Computer, Inc.") && (version && version[1] < 4 || navigator.platform.slice(0, 2) == "iP")) { + paperproto.safari = function () { var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: "none"}); win.setTimeout(function () {rect.remove();}); }; } else { - Paper[proto].safari = function () {}; + paperproto.safari = function () {}; } // Events @@ -2631,6 +2682,8 @@ Raphael = (function () { dragMove = function (e) { var x = e.clientX, y = e.clientY, + scrollY = doc.documentElement.scrollTop || doc.body.scrollTop, + scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft, dragi, j = drag.length; while (j--) { @@ -2650,6 +2703,8 @@ Raphael = (function () { } else { e.preventDefault(); } + x += scrollX; + y += scrollY; dragi.move && dragi.move.call(dragi.el, x - dragi.el._drag.x, y - dragi.el._drag.y, x, y); } }, @@ -2686,62 +2741,64 @@ Raphael = (function () { }; })(events[i]); } - Element[proto].hover = function (f_in, f_out) { + elproto.hover = function (f_in, f_out) { return this.mouseover(f_in).mouseout(f_out); }; - Element[proto].unhover = function (f_in, f_out) { + elproto.unhover = function (f_in, f_out) { return this.unmouseover(f_in).unmouseout(f_out); }; - Element[proto].drag = function (onmove, onstart, onend) { + elproto.drag = function (onmove, onstart, onend) { this._drag = {}; this.mousedown(function (e) { (e.originalEvent || e).preventDefault(); - this._drag.x = e.clientX; - this._drag.y = e.clientY; + var scrollY = doc.documentElement.scrollTop || doc.body.scrollTop, + scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft; + this._drag.x = e.clientX + scrollX; + this._drag.y = e.clientY + scrollY; this._drag.id = e.identifier; - onstart && onstart.call(this, e.clientX, e.clientY); + onstart && onstart.call(this, e.clientX + scrollX, e.clientY + scrollY); !drag.length && R.mousemove(dragMove).mouseup(dragUp); drag.push({el: this, move: onmove, end: onend}); }); return this; }; - Element[proto].undrag = function (onmove, onstart, onend) { + elproto.undrag = function (onmove, onstart, onend) { var i = drag.length; while (i--) { drag[i].el == this && (drag[i].move == onmove && drag[i].end == onend) && drag.splice(i, 1); !drag.length && R.unmousemove(dragMove).unmouseup(dragUp); } }; - Paper[proto].circle = function (x, y, r) { + paperproto.circle = function (x, y, r) { return theCircle(this, x || 0, y || 0, r || 0); }; - Paper[proto].rect = function (x, y, w, h, r) { + paperproto.rect = function (x, y, w, h, r) { return theRect(this, x || 0, y || 0, w || 0, h || 0, r || 0); }; - Paper[proto].ellipse = function (x, y, rx, ry) { + paperproto.ellipse = function (x, y, rx, ry) { return theEllipse(this, x || 0, y || 0, rx || 0, ry || 0); }; - Paper[proto].path = function (pathString) { + paperproto.path = function (pathString) { pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E); return thePath(R.format[apply](R, arguments), this); }; - Paper[proto].image = function (src, x, y, w, h) { + paperproto.image = function (src, x, y, w, h) { return theImage(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0); }; - Paper[proto].text = function (x, y, text) { - return theText(this, x || 0, y || 0, text || E); + paperproto.text = function (x, y, text) { + return theText(this, x || 0, y || 0, Str(text)); }; - Paper[proto].set = function (itemsArray) { + paperproto.set = function (itemsArray) { arguments[length] > 1 && (itemsArray = Array[proto].splice.call(arguments, 0, arguments[length])); return new Set(itemsArray); }; - Paper[proto].setSize = setSize; - Paper[proto].top = Paper[proto].bottom = null; - Paper[proto].raphael = R; + paperproto.setSize = setSize; + paperproto.top = paperproto.bottom = null; + paperproto.raphael = R; function x_y() { return this.x + S + this.y; } - Element[proto].resetScale = function () { + elproto.resetScale = function () { if (this.removed) { return this; } @@ -2749,7 +2806,7 @@ Raphael = (function () { this._.sy = 1; this.attrs.scale = "1 1"; }; - Element[proto].scale = function (x, y, cx, cy) { + elproto.scale = function (x, y, cx, cy) { if (this.removed) { return this; } @@ -2880,7 +2937,7 @@ Raphael = (function () { } return this; }; - Element[proto].clone = function () { + elproto.clone = function () { if (this.removed) { return null; } @@ -2889,18 +2946,32 @@ Raphael = (function () { delete attr.translation; return this.paper[this.type]().attr(attr); }; - var getPointAtSegmentLength = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) { + var curveslengths = {}, + getPointAtSegmentLength = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) { var len = 0, - old; - for (var i = 0; i < 1.01; i+=.01) { - var dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, i); + name = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y].join(), + cache = curveslengths[name], + old, dot; + !cache && (curveslengths[name] = cache = {data: []}); + cache.timer && clearTimeout(cache.timer); + cache.timer = setTimeout(function () {delete curveslengths[name];}, 2000); + for (var i = 0; i < 101; i++) { + if (cache.data[length] > i) { + dot = cache.data[i * 100]; + } else { + dot = R.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, i / 100); + cache.data[i] = dot; + } i && (len += pow(pow(old.x - dot.x, 2) + pow(old.y - dot.y, 2), .5)); - if (len >= length) { + if (length != null && len >= length) { return dot; } old = dot; } - }), + if (length == null) { + return len; + } + }, getLengthFactory = function (istotal, subpath) { return function (path, length, onlystart) { path = path2curve(path); @@ -2912,7 +2983,7 @@ Raphael = (function () { x = +p[1]; y = +p[2]; } else { - l = segmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]); + l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]); if (len + l > length) { if (subpath && !subpaths.start) { point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len); @@ -2941,37 +3012,27 @@ Raphael = (function () { point.alpha && (point = {x: point.x, y: point.y, alpha: point.alpha}); return point; }; - }, - segmentLength = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { - var old = {x: 0, y: 0}, - 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 += pow(pow(old.x - dot.x, 2) + pow(old.y - dot.y, 2), .5)); - old = dot; - } - return len; - }); + }; var getTotalLength = getLengthFactory(1), getPointAtLength = getLengthFactory(), getSubpathsAtLength = getLengthFactory(0, 1); - Element[proto].getTotalLength = function () { + elproto.getTotalLength = function () { if (this.type != "path") {return;} if (this.node.getTotalLength) { return this.node.getTotalLength(); } return getTotalLength(this.attrs.path); }; - Element[proto].getPointAtLength = function (length) { + elproto.getPointAtLength = function (length) { if (this.type != "path") {return;} if (this.node.getPointAtLength) { return this.node.getPointAtLength(length); } return getPointAtLength(this.attrs.path, length); }; - Element[proto].getSubpath = function (from, to) { + elproto.getSubpath = function (from, to) { if (this.type != "path") {return;} - if (math.abs(this.getTotalLength() - to) < 1e-6) { + if (math.abs(this.getTotalLength() - to) < "1e-6") { return getSubpathsAtLength(this.attrs.path, from).end; } var a = getSubpathsAtLength(this.attrs.path, to, 1); @@ -3038,14 +3099,12 @@ Raphael = (function () { } }; - var animationElements = {length : 0}, + var animationElements = [], animation = function () { var Now = +new Date; - for (var l in animationElements) if (l != "length" && animationElements[has](l)) { + for (var l = 0; l < animationElements[length]; l++) { var e = animationElements[l]; if (e.stop || e.el.removed) { - delete animationElements[l]; - animationElements[length]--; continue; } var time = Now - e.start, @@ -3055,13 +3114,11 @@ Raphael = (function () { 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; + var pos = easing(time / ms); for (var attr in from) if (from[has](attr)) { switch (availableAnimAttrs[attr]) { case "along": @@ -3098,8 +3155,8 @@ Raphael = (function () { case "csv": switch (attr) { case "translation": - var x = diff[attr][0] * (time - prev), - y = diff[attr][1] * (time - prev); + var x = pos * ms * diff[attr][0] - t.x, + y = pos * ms * diff[attr][1] - t.y; t.x += x; t.y += y; now = x + S + y; @@ -3120,6 +3177,14 @@ Raphael = (function () { break; } break; + default: + var from2 = [].concat(from[attr]); + now = []; + i = that.paper.customAttributes[attr].length; + while (i--) { + now[i] = +from2[i] + pos * ms * diff[attr][i]; + } + break; } set[attr] = now; } @@ -3134,15 +3199,18 @@ Raphael = (function () { (t.x || t.y) && that.translate(-t.x, -t.y); to.scale && (to.scale += E); that.attr(to); - delete animationElements[l]; - animationElements[length]--; - that.in_animation = null; - R.is(callback, "function") && callback.call(that); + animationElements.splice(l--, 1); } - e.prev = time; } R.svg && that && that.paper && that.paper.safari(); - animationElements[length] && win.setTimeout(animation); + animationElements[length] && setTimeout(animation); + }, + keyframesRun = function (attr, element, time, prev, prevcallback) { + var dif = time - prev; + element.timeouts.push(setTimeout(function () { + R.is(prevcallback, "function") && prevcallback.call(element); + element.animate(attr, dif, attr.easing); + }, prev)); }, upto255 = function (color) { return mmax(mmin(color, 255), 0); @@ -3172,12 +3240,16 @@ Raphael = (function () { } return this; }; - Element[proto].animateWith = function (element, params, ms, easing, callback) { - animationElements[element.id] && (params.start = animationElements[element.id].start); + elproto.animateWith = function (element, params, ms, easing, callback) { + for (var i = 0, ii = animationElements.length; i < ii; i++) { + if (animationElements[i].el.id == element.id) { + params.start = animationElements[i].start; + } + } return this.animate(params, ms, easing, callback); }; - Element[proto].animateAlong = along(); - Element[proto].animateAlongBack = along(1); + elproto.animateAlong = along(); + elproto.animateAlongBack = along(1); function along(isBack) { return function (path, ms, rotate, callback) { var params = {back: isBack}; @@ -3187,27 +3259,87 @@ Raphael = (function () { return this.animate(params, ms, callback); }; } - Element[proto].onAnimation = function (f) { + function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) { + var cx = 3 * p1x, + bx = 3 * (p2x - p1x) - cx, + ax = 1 - cx - bx, + cy = 3 * p1y, + by = 3 * (p2y - p1y) - cy, + ay = 1 - cy - by; + function sampleCurveX(t) { + return ((ax * t + bx) * t + cx) * t; + } + function solve(x, epsilon) { + var t = solveCurveX(x, epsilon); + return ((ay * t + by) * t + cy) * t; + } + function solveCurveX(x, epsilon) { + var t0, t1, t2, x2, d2, i; + for(t2 = x, i = 0; i < 8; i++) { + x2 = sampleCurveX(t2) - x; + if (math.abs(x2) < epsilon) { + return t2; + } + d2 = (3 * ax * t2 + 2 * bx) * t2 + cx; + if (math.abs(d2) < 1e-6) { + break; + } + t2 = t2 - x2 / d2; + } + t0 = 0; + t1 = 1; + t2 = x; + if (t2 < t0) { + return t0; + } + if (t2 > t1) { + return t1; + } + while (t0 < t1) { + x2 = sampleCurveX(t2); + if (math.abs(x2 - x) < epsilon) { + return t2; + } + if (x > x2) { + t0 = t2; + } else { + t1 = t2; + } + t2 = (t1 - t0) / 2 + t0; + } + return t2; + } + return solve(t, 1 / (200 * duration)); + } + elproto.onAnimation = function (f) { this._run = f || 0; return this; }; - Element[proto].animate = function (params, ms, easing, callback) { + elproto.animate = function (params, ms, easing, callback) { + var element = this; + element.timeouts = element.timeouts || []; if (R.is(easing, "function") || !easing) { callback = easing || null; } + if (element.removed) { + callback && callback.call(element); + return element; + } var from = {}, to = {}, + animateable = false, diff = {}; for (var attr in params) if (params[has](attr)) { - if (availableAnimAttrs[has](attr)) { - from[attr] = this.attr(attr); + if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) { + animateable = true; + from[attr] = element.attr(attr); (from[attr] == null) && (from[attr] = availableAttrs[attr]); to[attr] = params[attr]; switch (availableAnimAttrs[attr]) { case "along": var len = getTotalLength(params[attr]); var point = getPointAtLength(params[attr], len * !!params.back); - var bb = this.getBBox(); + var bb = element.getBBox(); diff[attr] = len / ms; diff.tx = bb.x; diff.ty = bb.y; @@ -3216,7 +3348,7 @@ Raphael = (function () { to.rot = params.rot; to.back = params.back; to.len = len; - params.rot && (diff.r = toFloat(this.rotate()) || 0); + params.rot && (diff.r = toFloat(element.rotate()) || 0); break; case nu: diff[attr] = (to[attr] - from[attr]) / ms; @@ -3269,34 +3401,88 @@ Raphael = (function () { break; } to[attr] = values; + break; + default: + values = [].concat(params[attr]); + from2 = [].concat(from[attr]); + diff[attr] = []; + i = element.paper.customAttributes[attr][length]; + while (i--) { + diff[attr][i] = ((values[i] || 0) - (from2[i] || 0)) / ms; + } + break; } } } - 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(); + if (!animateable) { + var attrs = [], + lastcall; + for (var key in params) if (params[has](key) && animKeyFrames.test(key)) { + attr = {value: params[key]}; + key == "from" && (key = 0); + key == "to" && (key = 100); + attr.key = toInt(key, 10); + attrs.push(attr); + } + attrs.sort(sortByKey); + if (attrs[0].key) { + attrs.unshift({key: 0, value: element.attrs}); + } + for (i = 0, ii = attrs[length]; i < ii; i++) { + keyframesRun(attrs[i].value, element, ms / 100 * attrs[i].key, ms / 100 * (attrs[i - 1] && attrs[i - 1].key || 0), attrs[i - 1] && attrs[i - 1].value.callback); + } + lastcall = attrs[attrs[length] - 1].value.callback; + if (lastcall) { + element.timeouts.push(setTimeout(function () {lastcall.call(element);}, ms)); + } + } else { + var easyeasy = R.easing_formulas[easing]; + if (!easyeasy) { + easyeasy = Str(easing).match(bezierrg); + if (easyeasy && easyeasy[length] == 5) { + var curve = easyeasy; + easyeasy = function (t) { + return CubicBezierAtTime(t, +curve[1], +curve[2], +curve[3], +curve[4], ms); + }; + } else { + easyeasy = function (t) { + return t; + }; + } + } + animationElements.push({ + start: params.start || +new Date, + ms: ms, + easing: easyeasy, + from: from, + diff: diff, + to: to, + el: element, + t: {x: 0, y: 0} + }); + R.is(callback, "function") && (element._ac = setTimeout(function () { + callback.call(element); + }, ms)); + animationElements[length] == 1 && setTimeout(animation); + } return this; }; - Element[proto].stop = function () { - animationElements[this.id] && animationElements[length]--; - delete animationElements[this.id]; + elproto.stop = function () { + for (var i = 0; i < animationElements.length; i++) { + animationElements[i].el.id == this.id && animationElements.splice(i--, 1); + } + for (i = 0, ii = this.timeouts && this.timeouts.length; i < ii; i++) { + clearTimeout(this.timeouts[i]); + } + this.timeouts = []; + clearTimeout(this._ac); + delete this._ac; return this; }; - Element[proto].translate = function (x, y) { + elproto.translate = function (x, y) { return this.attr({translation: x + " " + y}); }; - Element[proto][toString] = function () { + elproto[toString] = function () { return "Rapha\xebl\u2019s object"; }; R.ae = animationElements; @@ -3332,7 +3518,7 @@ Raphael = (function () { delete this[this[length]--]; return this.items.pop(); }; - for (var method in Element[proto]) if (Element[proto][has](method)) { + for (var method in elproto) if (elproto[has](method)) { Set[proto][method] = (function (methodname) { return function () { for (var i = 0, ii = this.items[length]; i < ii; i++) { @@ -3367,7 +3553,7 @@ Raphael = (function () { easing = R.is(easing, string) ? easing : collector; item = this.items[--i].animate(params, ms, easing, collector); while (i--) { - this.items[i].animateWith(item, params, ms, easing, collector); + this.items[i] && !this.items[i].removed && this.items[i].animateWith(item, params, ms, easing, collector); } return this; }; @@ -3446,7 +3632,7 @@ Raphael = (function () { } return font; }; - Paper[proto].getFont = function (family, weight, style, stretch) { + paperproto.getFont = function (family, weight, style, stretch) { stretch = stretch || "normal"; style = style || "normal"; weight = +weight || {normal: 400, bold: 700, lighter: 300, bolder: 800}[weight] || 400; @@ -3474,8 +3660,9 @@ Raphael = (function () { } return thefont; }; - Paper[proto].print = function (x, y, string, font, size, origin) { + paperproto.print = function (x, y, string, font, size, origin, letter_spacing) { origin = origin || "middle"; // baseline|middle + letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1); var out = this.set(), letters = Str(string)[split](E), shift = 0, @@ -3490,7 +3677,7 @@ Raphael = (function () { for (var i = 0, ii = letters[length]; i < ii; i++) { var prev = i && font.glyphs[letters[i - 1]] || {}, curr = font.glyphs[letters[i]]; - shift += i ? (prev.w || font.w) + (prev.k && prev.k[letters[i]] || 0) : 0; + shift += i ? (prev.w || font.w) + (prev.k && prev.k[letters[i]] || 0) + (font.w * letter_spacing) : 0; curr && curr.d && out[push](this.path(curr.d).attr({fill: "#000", stroke: "none", translation: [shift, 0]})); } out.scale(scale, scale, top, height).translate(x - top, y - height); @@ -3498,7 +3685,6 @@ Raphael = (function () { return out; }; - var formatrg = /\{(\d+)\}/g; R.format = function (token, params) { var args = R.is(params, array) ? [0][concat](params) : arguments; token && R.is(token, string) && args[length] - 1 && (token = token[rp](formatrg, function (str, i) { @@ -3507,9 +3693,11 @@ Raphael = (function () { return token || E; }; R.ninja = function () { - oldRaphael.was ? (Raphael = oldRaphael.is) : delete Raphael; + oldRaphael.was ? (win.Raphael = oldRaphael.is) : delete Raphael; return R; }; - R.el = Element[proto]; - return R; + R.el = elproto; + R.st = Set[proto]; + + oldRaphael.was ? (win.Raphael = R) : (Raphael = R); })(); \ No newline at end of file diff --git a/reference.html b/reference.html index 3474e44..1c70e53 100644 --- a/reference.html +++ b/reference.html @@ -1,8 +1,9 @@ - + + Raphaël Reference - + @@ -20,7 +21,7 @@
 

Main Function

-

+

Raphael

@@ -392,9 +393,15 @@ c.attr({

  1. newAttrs object A parameters object of the animation results. (Not all attributes can be animated.)
  2. ms number The duration of the animation, given in milliseconds.
  3. -
  4. easing string [“>”, “<”, “<>”, “backIn”, “backOut”, “bounce”, “elastic”] or function [optional]
  5. +
  6. easing string [“>”, “<”, “<>”, “backIn”, “backOut”, “bounce”, “elastic”, “cubic-bezier(p1, p2, p3, p4)”] or function [optional], see explanation re cubic-bezier syntax
  7. callback function [optional]
+

or

+
    +
  1. keyFrames object Key-value map, where key represents keyframe timing: [“from”, “20%”, “to”, “35%”, etc] and value is the same as newAttrs from above, except it could also have easing and callback properties
  2. +
  3. ms number The duration of the animation, given in milliseconds.
  4. +
+

Look at the example of keyframes usage

Attributes that can be animated

The newAttrs parameter accepts an object whose properties are the attributes to animate. However, not all attributes listed in the attr method reference can be animated. The following is a list of those properties that can be animated:

    @@ -425,9 +432,14 @@ c.attr({ For easing use built in functions or add your own by adding new functions to Raphael.easing_formulas object. Look at the example of easing usage.

    Usage

    -
    var c = paper.circle(10, 10, 10);
    -c.animate({cx: 20, r: 20}, 2000);
    -c.animate({cx: 20, r: 20}, 2000, "bounce");
    +
    var c = paper.circle(10, 10, 10);
    +c.animate({cx: 20, r: 20}, 2000);
    +c.animate({cx: 20, r: 20}, 2000, "bounce");
    +c.animate({
    +    "20%": {cx: 20, r: 20, easing: ">"},
    +    "50%": {cx: 70, r: 120, callback: function () {…}},
    +    "100%": {cx: 10, r: 10}
    +}, 2000);

    animateWith

    @@ -753,10 +765,13 @@ paper.circle(100, 100, 20).red();
  • #•••••• — full length HTML colour: (“#000000”, “#bd2300”)
  • rgb(•••, •••, •••) — red, green and blue channels’ values: (“rgb(200, 100, 0)”)
  • rgb(•••%, •••%, •••%) — same as above, but in %: (“rgb(100%, 175%, 0%)”)
  • +
  • rgba(•••, •••, •••, •••) — red, green and blue channels’ values: (“rgb(200, 100, 0, .5)”)
  • +
  • rgba(•••%, •••%, •••%, •••%) — same as above, but in %: (“rgb(100%, 175%, 0%, 50%)”)
  • hsb(•••, •••, •••) — hue, saturation and brightness values: (“hsb(0.5, 0.25, 1)”)
  • hsb(•••%, •••%, •••%) — same as above, but in %
  • -
  • hsl(•••, •••, •••) — same as hsb
  • -
  • hsl(•••%, •••%, •••%) — same as hsb
  • +
  • hsl(•••, •••, •••) — almost the same as hsb, see Wikipedia page
  • +
  • hsl(•••%, •••%, •••%) — almost the same as hsb
  • +
  • Optionally for hsb and hsl you could specify hue as a degree: “hsl(240deg, 1, .5)” or, if you want to go fancy, “hsl(240°, 1, .5)”

Usage

paper.circle(100, 100, 20).attr({
@@ -819,6 +834,42 @@ element.hover(function (event) {
                         

To unbind events use the same method names with “un” prefix, i.e. element.unclick(f);

+

+ Drag ’n’ Drop +

+

+ To make element “draggable” you need to call method drag on element. +

+

Parameters

+
    +
  1. onmove function event handler for moving
  2. +
  3. onstart function event handler for start
  4. +
  5. onend function event handler for end of the drag
  6. +
+

Usage

+
var c = R.circle(100, 100, 50).attr({
+    fill: "hsb(.8, 1, 1)",
+    stroke: "none",
+    opacity: .5
+});
+var start = function () {
+    // storing original coordinates
+    this.ox = this.attr("cx");
+    this.oy = this.attr("cy");
+    this.attr({opacity: 1});
+},
+move = function (dx, dy) {
+    // move will be called with dx and dy
+    this.attr({cx: this.ox + dx, cy: this.oy + dy});
+},
+up = function () {
+    // restoring state
+    this.attr({opacity: .5});
+};
+c.drag(move, start, up);
+

+ To unbind drag use the undrag method. +

-- 2.39.2