2 * Raphael 0.5.6b - JavaScript Vector Library
4 * Copyright (c) 2008 Dmitry Baranovskiy (raphaeljs.com)
5 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
7 var Raphael = (function (type) {
9 return r._create.apply(r, arguments);
14 function Matrix(m11, m12, m21, m22, dx, dy) {
16 [m11 || 1, m12 || 0, 0],
17 [m21 || 0, m22 || 1, 0],
18 [dx || 0, dy || 0, 1],
22 C._getX = C._getY = C._getW = C._getH = function (x) { return x; };
25 Matrix.prototype.toString = function () {
26 return "progid:DXImageTransform.Microsoft.Matrix(M11=" + this.m[0][0] +
27 ", M12=" + this.m[1][0] + ", M21=" + this.m[0][1] + ", M22=" + this.m[1][1] +
28 ", Dx=" + this.m[2][0] + ", Dy=" + this.m[2][1] + ", sizingmethod='auto expand', filtertype='bilinear')";
30 var thePath = function (params, pathString, VML) {
31 var g = document.createElement("rvml:group"), gl = g.style;
32 gl.position = "absolute";
35 gl.width = VML.width + "px";
36 gl.height = VML.height + "px";
37 var el = document.createElement("rvml:shape"), ol = el.style;
38 ol.width = VML.width + "px";
39 ol.height = VML.height + "px";
41 if (params["class"]) {
42 el.className = params["class"];
44 el.coordsize = this.coordsize;
45 el.coordorigin = this.coordorigin;
47 VML.canvas.appendChild(g);
48 var p = new Element(el, g, VML);
49 setFillAndStroke(p, params);
50 if (params.gradient) {
51 addGrdientFill(p, params.gradient);
56 p.last = {x: 0, y: 0, bx: 0, by: 0, isAbsolute: true};
58 p.absolutely = function () {
59 this.isAbsolute = true;
62 p.relatively = function () {
63 this.isAbsolute = false;
66 p.redraw = function () {
68 var oldPath = this.path;
70 for (var i = 0, ii = oldPath.length; i < ii; i++) {
71 if (oldPath[i].type != "end") {
72 this[oldPath[i].type + "To"].apply(this, oldPath[i].arg);
79 p.moveTo = function (x, y) {
80 var d = this.isAbsolute?"m":"t";
81 var _getX = this.isAbsolute ? VML._getX : VML._getW;
82 var _getY = this.isAbsolute ? VML._getY : VML._getH;
83 d += Math.round(_getX(parseFloat(x, 10))) + " " + Math.round(_getY(parseFloat(y, 10)));
84 this[0].path = this.Path += d;
85 this.last.x = (this.isAbsolute ? 0 : this.last.x) + Math.round(_getX(parseFloat(x, 10)));
86 this.last.y = (this.isAbsolute ? 0 : this.last.y) + Math.round(_getY(parseFloat(y, 10)));
87 this.last.isAbsolute = this.isAbsolute;
88 this.path.push({type: "move", arg: [].slice.call(arguments, 0), pos: this.isAbsolute});
91 p.lineTo = function (x, y) {
92 var d = this.isAbsolute?"l":"r";
93 var _getX = this.isAbsolute ? VML._getX : VML._getW;
94 var _getY = this.isAbsolute ? VML._getY : VML._getH;
95 d += Math.round(_getX(parseFloat(x, 10))) + " " + Math.round(_getY(parseFloat(y, 10)));
96 this[0].path = this.Path += d;
97 this.last.x = (this.isAbsolute ? 0 : this.last.x) + Math.round(_getX(parseFloat(x, 10)));
98 this.last.y = (this.isAbsolute ? 0 : this.last.y) + Math.round(_getY(parseFloat(y, 10)));
99 this.last.isAbsolute = this.isAbsolute;
100 this.path.push({type: "line", arg: [].slice.call(arguments, 0), pos: this.isAbsolute});
103 p.arcTo = function (rx, ry, large_arc_flag, sweep_flag, x2, y2) {
104 // for more information of where this math came from visit:
105 // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
106 x2 = (this.isAbsolute ? 0 : this.last.x) + x2;
107 y2 = (this.isAbsolute ? 0 : this.last.y) + y2;
108 var x1 = this.last.x,
112 k = (large_arc_flag == sweep_flag ? -1 : 1) *
113 Math.sqrt((rx * rx * ry * ry - rx * rx * y * y - ry * ry * x * x) / (rx * rx * y * y + ry * ry * x * x)),
114 cx = k * rx * y / ry + (x1 + x2) / 2,
115 cy = k * -ry * x / rx + (y1 + y2) / 2,
116 d = sweep_flag ? (this.isAbsolute?"wa":"wr") : (this.isAbsolute?"at":"ar"),
117 _getX = this.isAbsolute ? VML._getX : VML._getW,
118 _getY = this.isAbsolute ? VML._getY : VML._getH,
119 left = Math.round(cx - rx),
120 top = Math.round(cy - ry);
121 d += [left, top, left + rx * 2, top + ry * 2, x1, y1, Math.round(_getX(parseFloat(x2, 10))), Math.round(_getX(parseFloat(y2, 10)))].join(", ");
122 this[0].path = this.Path += d;
123 this.last.x = (this.isAbsolute ? 0 : this.last.x) + Math.round(_getX(parseFloat(x2, 10)));
124 this.last.y = (this.isAbsolute ? 0 : this.last.y) + Math.round(_getY(parseFloat(y2, 10)));
125 this.last.isAbsolute = this.isAbsolute;
126 this.path.push({type: "arc", arg: [].slice.call(arguments, 0), pos: this.isAbsolute});
129 p.cplineTo = function (x1, y1, w1) {
131 return this.lineTo(x1, y1);
134 p._getX = this.isAbsolute ? VML._getX : VML._getW;
135 p._getY = this.isAbsolute ? VML._getY : VML._getH;
136 var x = Math.round(p._getX(Math.round(parseFloat(x1, 10) * 100) / 100));
137 var y = Math.round(p._getY(Math.round(parseFloat(y1, 10) * 100) / 100));
138 var w = Math.round(VML._getW(Math.round(parseFloat(w1, 10) * 100) / 100));
139 var d = this.isAbsolute?"c":"v";
140 var attr = [this.last.x + w, this.last.y, x - w, y, x, y];
141 d += attr.join(" ") + " ";
142 this.last.x = (this.isAbsolute ? 0 : this.last.x) + attr[4];
143 this.last.y = (this.isAbsolute ? 0 : this.last.y) + attr[5];
144 this.last.bx = attr[2];
145 this.last.by = attr[3];
146 this[0].path = this.Path += d;
147 this.path.push({type: "cpline", arg: [].slice.call(arguments, 0), pos: this.isAbsolute});
151 p.curveTo = function () {
152 var d = this.isAbsolute?"c":"v";
153 var _getX = this.isAbsolute ? VML._getX : VML._getW;
154 var _getY = this.isAbsolute ? VML._getY : VML._getH;
155 if (arguments.length == 6) {
156 this.last.x = (this.isAbsolute ? 0 : this.last.x) + Math.round(_getX(parseFloat(arguments[4], 10)));
157 this.last.y = (this.isAbsolute ? 0 : this.last.y) + Math.round(_getY(parseFloat(arguments[5], 10)));
158 this.last.bx = Math.round(_getX(parseFloat(arguments[2], 10)));
159 this.last.by = Math.round(_getY(parseFloat(arguments[3], 10)));
160 d += Math.round(_getX(parseFloat(arguments[0], 10))) + " " + Math.round(_getY(parseFloat(arguments[1], 10))) + " " +
161 Math.round(_getX(parseFloat(arguments[2], 10))) + " " + Math.round(_getY(parseFloat(arguments[3], 10))) + " " +
162 Math.round(_getX(parseFloat(arguments[4], 10))) + " " + Math.round(_getY(parseFloat(arguments[5], 10))) + " ";
163 this.last.isAbsolute = this.isAbsolute;
165 this[0].path = this.Path += d;
166 this.path.push({type: "curve", arg: [].slice.call(arguments, 0), pos: this.isAbsolute});
169 p.addRoundedCorner = function (r, dir) {
170 var R = .5522 * r, rollback = this.isAbsolute, o = this;
173 rollback = function () {
177 rollback = function () {};
183 o.curveTo(-R, 0, -r, -(r - R), -r, -r);
186 o.curveTo(-R, 0, -r, r - R, -r, r);
193 o.curveTo(R, 0, r, -(r - R), r, -r);
196 o.curveTo(R, 0, r, r - R, r, r);
203 o.curveTo(0, -R, -(R - r), -r, r, -r);
206 o.curveTo(0, -R, R - r, -r, -r, -r);
213 o.curveTo(0, R, -(R - r), r, r, r);
216 o.curveTo(0, R, R - r, r, -r, r);
221 actions[dir.charAt(0)]()[dir.charAt(1)]();
225 p.andClose = function () {
226 this[0].path = (this.Path += "x e");
229 if (typeof pathString == "string") {
230 pathString = pathString.replace(/([mzlhvcsqta])/ig, ",$1,").replace(/([^,])\-/ig, "$1,-");
231 path = pathString.split(",");
232 var i = 1, ii = path.length;
236 p.absolutely().moveTo(path[++i], path[++i]);
239 p.relatively().moveTo(path[++i], path[++i]);
242 p.absolutely().curveTo(path[++i], path[++i], path[++i], path[++i], path[++i], path[++i]);
245 p.relatively().curveTo(path[++i], path[++i], path[++i], path[++i], path[++i], path[++i]);
248 p.absolutely().lineTo(path[++i], path[++i]);
251 p.relatively().lineTo(path[++i], path[++i]);
254 p.absolutely().lineTo(path[++i], 0);
257 p.relatively().lineTo(path[++i], 0);
260 p.absolutely().lineTo(0, path[++i]);
263 p.relatively().lineTo(0, path[++i]);
266 p.absolutely().arcTo(path[++i], path[++i], path[++i], path[++i], path[++i], path[++i]);
269 p.relatively().arcTo(path[++i], path[++i], path[++i], path[++i], path[++i], path[++i]);
281 var setFillAndStroke = function (o, params) {
283 o.attrs = o.attrs || {};
284 for (var par in params) {
285 o.attrs[par] = params[par];
287 params["font-family"] && (s.fontFamily = params["font-family"]);
288 params["font-size"] && (s.fontSize = params["font-size"]);
289 params["font"] && (s.font = params["font"]);
290 params["font-weight"] && (s.fontWeight = params["font-weight"]);
291 if (typeof params.opacity != "undefined" || typeof params["stroke-width"] != "undefined" || typeof params.fill != "undefined" || typeof params.stroke != "undefined") {
293 var fill = (o.getElementsByTagName("fill") && o.getElementsByTagName("fill")[0]) || document.createElement("rvml:fill");
294 if ("fill-opacity" in params || "opacity" in params) {
295 fill.opacity = ((params["fill-opacity"] + 1 || 2) - 1) * ((params.opacity + 1 || 2) - 1);
300 if (params.fill == "none") {
303 if (fill.on && params.fill) {
304 fill.color = params.fill;
307 var stroke = (o.getElementsByTagName("stroke") && o.getElementsByTagName("stroke")[0]) || document.createElement("rvml:stroke");
308 if ((params.stroke && params.stroke != "none") || params["stroke-width"] || params["stroke-opacity"] || params["stroke-dasharray"]) {
311 if (params.stroke == "none" || typeof stroke.on == "undefined") {
314 if (stroke.on && params.stroke) {
315 stroke.color = params.stroke;
317 stroke.opacity = ((params["stroke-opacity"] + 1 || 2) - 1) * ((params.opacity + 1 || 2) - 1);
318 stroke.joinstyle = params["stroke-linejoin"] || "miter";
319 stroke.miterlimit = params["stroke-miterlimit"] || 8;
320 stroke.endcap = {butt: "flat", square: "square", round: "round"}[params["stroke-linecap"] || "miter"];
321 if (params["stroke-width"]) {
322 stroke.weight = (parseFloat(params["stroke-width"], 10) || 1) * 12/16;
324 if (params["stroke-dasharray"]) {
325 var dashes = params["stroke-dasharray"].replace(" ", ",").split(","),
328 for (var i = 0, ii = dashes.length; i < ii; i++) {
329 var res = dashes[i] / str;
334 stroke.dashstyle = dashesn.join(" ");
336 o.appendChild(stroke);
339 var addGrdientFill = function (o, gradient) {
340 o.attrs = o.attrs || {};
341 o.attrs.gradient = gradient;
343 var fill = o.getElementsByTagName("fill");
347 fill = document.createElement("rvml:fill");
349 if (gradient.dots.length) {
351 fill.type = (gradient.type.toLowerCase() == "linear") ? "gradient" : "gradientradial";
352 if (typeof gradient.dots[0].color != "undefined") {
353 fill.color = gradient.dots[0].color || "#000";
355 if (typeof gradient.dots[0].opacity != "undefined") {
356 fill.opacity = gradient.dots[0].opacity;
358 if (typeof gradient.dots[gradient.dots.length - 1].opacity != "undefined") {
359 fill.opacity2 = gradient.dots[gradient.dots.length - 1].opacity;
361 if (typeof gradient.dots[gradient.dots.length - 1].color != "undefined") {
362 fill.color2 = gradient.dots[gradient.dots.length - 1].color || "#000";
365 for (var i = 1, ii = gradient.dots.length - 1; i < ii; i++) {
366 colors += gradient.dots[i].offset + " " + gradient.dots[i].color;
372 fill.colors = colors;
374 if (gradient.vector) {
375 var angle = Math.round(Math.atan((parseInt(gradient.vector[3], 10) - parseInt(gradient.vector[1], 10)) / (parseInt(gradient.vector[2], 10) - parseInt(gradient.vector[0], 10))) * 57.29) + 180;
376 fill.angle = angle + 90;
378 if (gradient.type.toLowerCase() == "radial") {
379 fill.focusposition = "0.5, 0.5";
380 fill.focussize = "0, 0";
381 fill.method = "none";
385 var Element = function (node, group, vml) {
396 this.rotate = function (deg) {
397 if (deg == undefined) {
401 this.Group.style.rotation = Rotation;
405 Element.prototype.setBox = function (params) {
406 var gs = this.Group.style,
408 for (var i in params) {
409 this.attrs[i] = params[i];
411 var attr = this.attrs, x, y, w, h;
414 x = attr.cx - attr.r;
415 y = attr.cy - attr.r;
419 x = attr.cx - attr.rx;
420 y = attr.cy - attr.ry;
432 this.textpath.v = ["m", Math.round(attr.x), ", ", Math.round(attr.y - 2), "l", Math.round(attr.x) + 1, ", ", Math.round(attr.y - 2)].join("");
437 var left = this.vml.width / 2 - w / 2,
438 top = this.vml.height / 2 - h / 2;
439 gs.position = "absolute";
440 gs.left = x - left + "px";
441 gs.top = y - top + "px";
446 gs.width = this.vml.width + "px";
447 gs.height = this.vml.height + "px";
448 os.position = "absolute";
450 os.left = left + "px";
452 os.height = h + "px";
454 Element.prototype.hide = function () {
455 this.Group.style.display = "none";
458 Element.prototype.show = function () {
459 this.Group.style.display = "block";
462 Element.prototype.translate = function (x, y) {
463 if (x == undefined && y == undefined) {
464 return {x: this.X, y: this.Y};
468 this.Group.style.left = this.X + "px";
469 this.Group.style.top = this.Y + "px";
473 Element.prototype.matrix = function (xx, xy, yx, yy, dx, dy) {
474 tMatrix = new Matrix(xx, xy, yx, yy, dx, dy);
475 this.Group.style.filter = tMatrix;
478 Element.prototype.scale = function (x, y) {
479 if (x == undefined && y == undefined) {
484 if (x != 0 && !(x == 1 && y == 1)) {
485 var dirx = Math.round(x / Math.abs(x)),
486 diry = Math.round(y / Math.abs(y)),
488 if (dirx != 1 || diry != 1) {
489 s.filter = new Matrix(dirx, 0, 0, diry, 0, 0);
491 var width = parseInt(s.width, 10) * x * dirx;
492 var height = parseInt(s.height, 10) * y * diry;
493 var left = parseInt(s.left, 10);
494 var top = parseInt(s.top, 10);
495 s.left = this.X = left + this.W / 2 - width / 2;
496 s.top = this.Y = top + this.H / 2 - height / 2;
497 s.width = this.W = width;
498 s.height = this.H = height;
502 Element.prototype.getBBox = function () {
504 x: this.Group.offsetLeft,
505 y: this.Group.offsetTop,
506 width: this.Group.offsetWidth,
507 height: this.Group.offsetHeight
510 Element.prototype.remove = function () {
511 this[0].parentNode.removeChild(this[0]);
512 this.Group.parentNode.removeChild(this.Group);
513 this.shape && this.shape.parentNode.removeChild(this.shape);
515 Element.prototype.attr = function () {
516 if (arguments.length == 1 && typeof arguments[0] == "string") {
517 return this.attrs[arguments[0]];
519 if (this.attrs && arguments.length == 1 && arguments[0] instanceof Array) {
521 for (var i = 0, ii = arguments[0].length; i < ii; i++) {
522 values[arguments[0][i]] = this.attrs[arguments[0][i]];
526 if (this[0].tagName.toLowerCase() == "group") {
527 var children = this[0].childNodes;
528 this.attrs = this.attrs || {};
529 if (arguments.length == 2) {
530 this.attrs[arguments[0]] = arguments[1];
531 } else if (arguments.length == 1 || typeof arguments[0] == "object") {
532 for (var j in arguments[0]) {
533 this.attrs[j] = arguments[0][j];
536 for (var i = 0, ii = children.length; i < ii; i++) {
537 this.attr.apply(new item(children[i], this[0], this.vml), arguments);
541 if (arguments.length == 2) {
543 params[arguments[0]] = arguments[1];
545 if (arguments.length == 1 && typeof arguments[0] == "object") {
546 params = arguments[0];
549 setFillAndStroke(this, params);
551 if (params.gradient) {
552 addGrdientFill(this, params.gradient);
554 if (params.text && this.type == "text") {
555 this[0].string = params.text;
558 this[0].id = params.id;
564 Element.prototype.toFront = function () {
565 this.Group.parentNode.appendChild(this.Group);
568 Element.prototype.toBack = function () {
569 if (this.Group.parentNode.firstChild != this.Group) {
570 this.Group.parentNode.insertBefore(this.Group, this.Group.parentNode.firstChild);
574 var theCircle = function (vml, x, y, r) {
575 var g = document.createElement("rvml:group");
576 var o = document.createElement("rvml:oval");
578 vml.canvas.appendChild(g);
579 var res = new Element(o, g, vml);
580 setFillAndStroke(res, {stroke: "#000", fill: "none"});
581 res.setBox({x: x - r, y: y - r, w: r * 2, h: r * 2});
588 var theRect = function (vml, x, y, w, h, r) {
589 var g = document.createElement("rvml:group");
590 var o = document.createElement(r ? "rvml:roundrect" : "rvml:rect");
592 o.arcsize = r / (Math.min(w, h));
595 vml.canvas.appendChild(g);
596 var res = new Element(o, g, vml);
597 setFillAndStroke(res, {stroke: "#000"});
598 res.setBox({x: x, y: y, w: w, h: h});
607 var theEllipse = function (vml, x, y, rx, ry) {
608 var g = document.createElement("rvml:group");
609 var o = document.createElement("rvml:oval");
611 vml.canvas.appendChild(g);
612 var res = new Element(o, g, vml);
613 setFillAndStroke(res, {stroke: "#000"});
614 res.setBox({x: x - rx, y: y - ry, w: rx * 2, h: ry * 2});
619 res.type = "ellipse";
622 var theImage = function (vml, src, x, y, w, h) {
623 var g = document.createElement("rvml:group");
624 var o = document.createElement("rvml:image");
627 vml.canvas.appendChild(g);
628 var res = new Element(o, g, vml);
630 res.setBox({x: x, y: y, w: w, h: h});
637 var theText = function (vml, x, y, text) {
639 var g = document.createElement("rvml:group"), gs = g.style;
640 var el = document.createElement("rvml:shape"), ol = el.style;
641 var path = document.createElement("rvml:path"), ps = path.style;
642 path.v = ["m", Math.round(x), ", ", Math.round(y - 2), "l", Math.round(x) + 1, ", ", Math.round(y - 2)].join("");
643 path.textpathok = true;
644 ol.width = vml.width;
645 ol.height = vml.height;
646 gs.position = "absolute";
649 gs.width = vml.width;
650 gs.height = vml.height;
651 var o = document.createElement("rvml:textpath");
654 o.coordsize = vml.coordsize;
655 o.coordorigin = vml.coordorigin;
657 el.appendChild(path);
659 vml.canvas.appendChild(g);
660 var res = new Element(o, g, vml);
670 var theGroup = function (vml) {
671 var el = document.createElement("rvml:group"), els = el.style;
672 els.position = "absolute";
675 els.width = vml.width;
676 els.height = vml.height;
678 vml.canvas.appendChild(el);
680 var res = new Element(el, el, vml);
682 if (f.charAt(0) != "_" && typeof vml[f] == "function") {
683 res[f] = (function (f) {
685 var e = vml[f].apply(vml, arguments);
686 el.appendChild(e[0].parentNode);
695 r._create = function () {
696 // container, width, height
697 // x, y, width, height
698 var container, width, height;
699 if (typeof arguments[0] == "string") {
700 container = document.getElementById(arguments[0]);
701 width = arguments[1];
702 height = arguments[2];
704 if (typeof arguments[0] == "object") {
705 container = arguments[0];
706 width = arguments[1];
707 height = arguments[2];
709 if (typeof arguments[0] == "number") {
713 width = arguments[2];
714 height = arguments[3];
717 throw new Error("VML container not found.");
719 if (!document.namespaces["rvml"]) {
720 document.namespaces.add("rvml","urn:schemas-microsoft-com:vml");
721 document.createStyleSheet().addRule("rvml\\:*", "behavior:url(#default#VML)");
723 var c = document.createElement("div"),
724 r = C.canvas = document.createElement("rvml:group"),
725 cs = c.style, rs = r.style;
728 width = width || "320px";
729 height = height || "200px";
730 cs.clip = "rect(0 " + width + " " + height + " 0)";
731 cs.position = "absolute";
734 r.coordsize = (width == "100%" ? width : parseFloat(width)) + " " + (height == "100%" ? height : parseFloat(height));
735 r.coordorigin = "0 0";
737 var b = document.createElement("rvml:rect"), bs = b.style;
738 bs.left = bs.top = 0;
740 bs.height = rs.height;
741 b.filled = b.stroked = "f";
745 if (container == 1) {
746 document.body.appendChild(c);
747 cs.position = "absolute";
759 cs.width = container.style.width = width;
760 cs.height = container.style.height = height;
761 if (container.firstChild) {
762 container.insertBefore(c, container.firstChild);
764 container.appendChild(c);
767 for (var prop in C) {
768 container[prop] = C[prop];
770 container.clear = function () {
772 for (var i = 0, ii = r.childNodes.length; i < ii; i++) {
773 if (r.childNodes[i] != b) {
774 todel.push(r.childNodes[i]);
777 for (i = 0, ii = todel.length; i < ii; i++) {
778 r.removeChild(todel[i]);
785 Matrix.prototype.toString = function () {
786 return "matrix(" + this.m[0][0] +
787 ", " + this.m[1][0] + ", " + this.m[0][1] + ", " + this.m[1][1] +
788 ", " + this.m[2][0] + ", " + this.m[2][1] + ")";
790 var thePath = function (params, pathString, SVG) {
791 var el = document.createElementNS(SVG.svgns, "path");
792 el.setAttribute("fill", "none");
794 for (var attr in params) {
795 if (params.gradient) {
796 addGrdientFill(el, params.gradient, SVG);
798 el.setAttribute(attr, params[attr]);
803 SVG.canvas.appendChild(el);
805 var p = new Element(el, SVG);
806 for (var attr in params) {
807 p.attrs[attr] = params[attr];
811 p.last = {x: 0, y: 0, bx: 0, by: 0};
812 p.absolutely = function () {
813 this.isAbsolute = true;
816 p.relatively = function () {
817 this.isAbsolute = false;
820 p.redraw = function () {
821 this[0].setAttribute("d", "M0 0");
822 var oldPath = this.path;
824 for (var i = 0, ii = oldPath.length; i < ii; i++) {
825 if (oldPath[i].type != "end") {
826 this[oldPath[i].type + "To"].apply(this, oldPath[i].arg);
833 p.moveTo = function (x, y) {
834 var d = this.isAbsolute?"M":"m";
835 var _getX = this.isAbsolute ? SVG._getX : SVG._getW;
836 var _getY = this.isAbsolute ? SVG._getY : SVG._getH;
837 d += _getX(parseFloat(x, 10)) + " " + _getY(parseFloat(y, 10)) + " ";
838 var oldD = this[0].getAttribute("d") || "";
839 this[0].setAttribute("d", oldD + d);
840 this.last.x = SVG._getX(parseFloat(x, 10));
841 this.last.y = SVG._getY(parseFloat(y, 10));
842 this.path.push({type: "move", arg: arguments, pos: this.isAbsolute});
845 p.lineTo = function (x, y) {
846 var d = this.isAbsolute?"L":"l";
847 var _getX = this.isAbsolute ? SVG._getX : SVG._getW;
848 var _getY = this.isAbsolute ? SVG._getY : SVG._getH;
849 d += _getX(parseFloat(x, 10)) + " " + _getY(parseFloat(y, 10)) + " ";
850 var oldD = this[0].getAttribute("d") || "";
851 this[0].setAttribute("d", oldD + d);
852 this.last.x = SVG._getX(parseFloat(x, 10));
853 this.last.y = SVG._getY(parseFloat(y, 10));
854 this.path.push({type: "line", arg: arguments, pos: this.isAbsolute});
857 p.arcTo = function (rx, ry, large_arc_flag, sweep_flag, x, y) {
858 var d = this.isAbsolute ? "A" : "a";
859 var _getX = this.isAbsolute ? SVG._getX : SVG._getW;
860 var _getY = this.isAbsolute ? SVG._getY : SVG._getH;
861 d += [SVG._getW(parseFloat(rx, 10)), SVG._getH(parseFloat(ry, 10)), 0, large_arc_flag, sweep_flag, _getX(parseFloat(x, 10)), _getY(parseFloat(y, 10))].join(" ");
862 var oldD = this[0].getAttribute("d") || "";
863 this[0].setAttribute("d", oldD + d);
864 this.last.x = SVG._getX(parseFloat(x, 10));
865 this.last.y = SVG._getY(parseFloat(y, 10));
866 this.path.push({type: "arc", arg: arguments, pos: this.isAbsolute});
869 p.cplineTo = function (x1, y1, w1) {
871 return this.lineTo(x1, y1);
874 p._getX = this.isAbsolute ? SVG._getX : SVG._getW;
875 p._getY = this.isAbsolute ? SVG._getY : SVG._getH;
876 var x = p._getX(Math.round(parseFloat(x1, 10) * 100) / 100);
877 var y = p._getY(Math.round(parseFloat(y1, 10) * 100) / 100);
878 var w = SVG._getW(Math.round(parseFloat(w1, 10) * 100) / 100);
879 var d = this.isAbsolute?"C":"c";
880 var attr = [this.last.x + w, this.last.y, x - w, y, x, y];
881 for (var i = 0, ii = attr.length; i < ii; i++) {
884 this.last.x = attr[4];
885 this.last.y = attr[5];
886 this.last.bx = attr[2];
887 this.last.by = attr[3];
888 var oldD = this[0].getAttribute("d") || "";
889 this[0].setAttribute("d", oldD + d);
890 this.path.push({type: "cpline", arg: arguments, pos: this.isAbsolute});
894 p.curveTo = function () {
896 p._getX = this.isAbsolute ? SVG._getX : SVG._getW;
897 p._getY = this.isAbsolute ? SVG._getY : SVG._getH;
898 if (arguments.length == 6) {
899 var d = this.isAbsolute?"C":"c";
900 for (var i = 0, ii = arguments.length; i < ii; i++) {
901 d += p[(i % 2 == 0) ? "_getX" : "_getY"](Math.round(parseFloat(arguments[i], 10) * 100) / 100) + " ";
903 this.last.x = p._getX((parseFloat(arguments[4], 10) * 100) / 100);
904 this.last.y = p._getY((parseFloat(arguments[5], 10) * 100) / 100);
905 this.last.bx = p._getX((parseFloat(arguments[2], 10) * 100) / 100);
906 this.last.by = p._getY((parseFloat(arguments[3], 10) * 100) / 100);
908 if (arguments.length == 4) {
909 var d = this.isAbsolute?"S":"s";
910 for (var i = 0, ii = arguments.length; i < ii; i++) {
911 d += p[i % 2 == 0 ? "_getX" : "_getY"]((parseFloat(arguments[i], 10) * 100) / 100) + " ";
914 this.last.x = p._getX((parseFloat(arguments[2], 10) * 100) / 100);
915 this.last.y = p._getY((parseFloat(arguments[3], 10) * 100) / 100);
916 this.last.bx = p._getX((parseFloat(arguments[0], 10) * 100) / 100);
917 this.last.by = p._getY((parseFloat(arguments[1], 10) * 100) / 100);
919 var oldD = this[0].getAttribute("d") || "";
920 this[0].setAttribute("d", oldD + d);
921 this.path.push({type: "curve", arg: arguments, pos: this.isAbsolute});
924 p.addRoundedCorner = function (r, dir) {
925 var R = .5522 * r, rollback = this.isAbsolute, o = this;
928 rollback = function () {
932 rollback = function () {};
938 o.curveTo(-R, 0, -r, -(r - R), -r, -r);
941 o.curveTo(-R, 0, -r, r - R, -r, r);
948 o.curveTo(R, 0, r, -(r - R), r, -r);
951 o.curveTo(R, 0, r, r - R, r, r);
958 o.curveTo(0, -R, -(R - r), -r, r, -r);
961 o.curveTo(0, -R, R - r, -r, -r, -r);
968 o.curveTo(0, R, -(R - r), r, r, r);
971 o.curveTo(0, R, R - r, r, -r, r);
976 actions[dir[0]]()[dir[1]]();
980 p.andClose = function () {
981 var oldD = this[0].getAttribute("d") || "";
982 this[0].setAttribute("d", oldD + "Z ");
983 this.path.push({type: "end"});
986 if (typeof pathString == "string") {
987 pathString = pathString.replace(/([mzlhvcsqta])/ig, ",$1,").replace(/([^,])\-/ig, "$1,-");
988 path = pathString.split(",");
989 var i = 1, ii = path.length;
993 p.absolutely().moveTo(path[++i], path[++i]);
996 p.relatively().moveTo(path[++i], path[++i]);
999 p.absolutely().curveTo(path[++i], path[++i], path[++i], path[++i], path[++i], path[++i]);
1002 p.relatively().curveTo(path[++i], path[++i], path[++i], path[++i], path[++i], path[++i]);
1005 p.relatively().curveTo(path[++i], path[++i], path[++i], path[++i]);
1008 p.absolutely().curveTo(path[++i], path[++i], path[++i], path[++i]);
1011 p.absolutely().lineTo(path[++i], path[++i]);
1014 p.relatively().lineTo(path[++i], path[++i]);
1017 p.absolutely().lineTo(path[++i], 0);
1020 p.relatively().lineTo(path[++i], 0);
1023 p.absolutely().lineTo(0, path[++i]);
1026 p.relatively().lineTo(0, path[++i]);
1029 p.absolutely().arcTo(path[++i], path[++i], path[++i], path[++i], path[++i], path[++i]);
1032 p.relatively().arcTo(path[++i], path[++i], path[++i], path[++i], path[++i], path[++i]);
1043 var addGrdientFill = function (o, gradient, SVG) {
1044 var el = document.createElementNS(SVG.svgns, gradient.type + "Gradient");
1045 el.id = "raphael-gradient-" + SVG.gradients++;
1046 if (gradient.vector && gradient.vector.length) {
1047 el.setAttribute("x1", gradient.vector[0]);
1048 el.setAttribute("y1", gradient.vector[1]);
1049 el.setAttribute("x2", gradient.vector[2]);
1050 el.setAttribute("y2", gradient.vector[3]);
1052 SVG.defs.appendChild(el);
1053 for (var i = 0, ii = gradient.dots.length; i < ii; i++) {
1054 var stop = document.createElementNS(SVG.svgns, "stop");
1055 stop.setAttribute("offset", gradient.dots[i].offset ? gradient.dots[i].offset : (i == 0) ? "0%" : "100%");
1056 stop.setAttribute("stop-color", gradient.dots[i].color || "#fff");
1057 if (typeof gradient.dots[i].opacity != "undefined") {
1058 stop.setAttribute("stop-opacity", gradient.dots[i].opacity);
1060 el.appendChild(stop);
1062 o.setAttribute("fill", "url(#" + el.id + ")");
1064 var Element = function (node, svg) {
1067 Rotation = {deg: 0, x: 0, y: 0},
1073 this.attrs = this.attrs || {};
1074 this.transformations = []; // rotate, translate, scale, matrix
1075 this.rotate = function (deg) {
1076 if (deg == undefined) {
1077 return Rotation.deg;
1079 var bbox = this.getBBox();
1080 Rotation.deg += deg;
1082 this.transformations[0] = ("rotate(" + Rotation.deg + " " + (bbox.x + bbox.width / 2) + " " + (bbox.y + bbox.height / 2) + ")");
1084 this.transformations[0] = "";
1086 this[0].setAttribute("transform", this.transformations.join(" "));
1089 this.translate = function (x, y) {
1090 if (x == undefined && y == undefined) {
1091 return {x: X, y: Y};
1096 this.transformations[1] = "translate(" + X + "," + Y + ")";
1098 this.transformations[1] = "";
1100 this[0].setAttribute("transform", this.transformations.join(" "));
1103 this.scale = function (x, y) {
1104 if (x == undefined && y == undefined) {
1105 return {x: ScaleX, y: ScaleY};
1108 if (x != 0 && !(x == 1 && y == 1)) {
1111 if (!(ScaleX == 1 && ScaleY == 1)) {
1112 var bbox = this.getBBox(),
1113 dx = bbox.x * (1 - ScaleX) + (bbox.width / 2 - bbox.width * ScaleX / 2),
1114 dy = bbox.y * (1 - ScaleY) + (bbox.height / 2 - bbox.height * ScaleY / 2);
1115 this.transformations[2] = new Matrix(ScaleX, 0, 0, ScaleY, dx, dy);
1117 this.transformations[2] = "";
1119 this[0].setAttribute("transform", this.transformations.join(" "));
1124 Element.prototype.hide = function () {
1125 this[0].style.display = "none";
1128 Element.prototype.show = function () {
1129 this[0].style.display = "block";
1133 Element.prototype.matrix = function (xx, xy, yx, yy, dx, dy) {
1134 this.transformations[3] = new Matrix(xx, xy, yx, yy, dx, dy);
1135 this[0].setAttribute("transform", this.transformations.join(" "));
1138 Element.prototype.remove = function () {
1139 this[0].parentNode.removeChild(this[0]);
1141 Element.prototype.getBBox = function () {
1142 return this[0].getBBox();
1144 Element.prototype.attr = function () {
1145 if (arguments.length == 1 && typeof arguments[0] == "string") {
1146 return this[0].getAttribute(arguments[0]);
1148 if (arguments.length == 1 && arguments[0] instanceof Array) {
1150 for (var j in arguments[0]) {
1151 values[arguments[0][j]] = this.attrs[arguments[0][j]];
1155 if (arguments.length == 2) {
1156 var att = arguments[0],
1157 value = arguments[1];
1159 this.attrs[att] = value;
1164 this[0].setAttribute(att, svg._getX(value));
1169 this[0].setAttribute(att, svg._getY(value));
1172 this[0].setAttribute(att, svg._getW(value));
1175 this[0].setAttribute(att, svg._getH(value));
1178 addGrdientFill(this[0], params.gradient, svg);
1180 case "stroke-dasharray":
1181 this[0].setAttribute(att, value.replace(" ", ","));
1184 if (this.type == "text") {
1185 this[0].removeChild(this[0].firstChild);
1186 this[0].appendChild(document.createTextNode(value));
1190 var cssrule = att.replace(/(\-.)/g, function (w) {
1191 return w.substring(1).toUpperCase();
1193 this[0].style[cssrule] = value;
1194 // Need following line for Firefox
1195 this[0].setAttribute(att, value);
1198 } else if (arguments.length == 1 && typeof arguments[0] == "object") {
1199 var params = arguments[0];
1200 for (var attr in params) {
1201 this.attrs[attr] = params[attr];
1202 if (attr == "stroke-dasharray") {
1203 this[0].setAttribute(attr, params[attr].replace(" ", ","));
1204 } else if (attr == "text" && this.type == "text") {
1205 this[0].removeChild(this[0].firstChild);
1206 this[0].appendChild(document.createTextNode(params[attr]));
1208 var cssrule = attr.replace(/(\-.)/g, function (w) {
1209 return w.substring(1).toUpperCase();
1211 this[0].style[cssrule] = params[attr];
1212 // Need following line for Firefox
1213 this[0].setAttribute(attr, params[attr]);
1216 if (params.gradient) {
1217 this.attrs.gradient = params.gradient;
1218 addGrdientFill(this[0], params.gradient, this.svg);
1223 Element.prototype.toFront = function () {
1224 this[0].parentNode.appendChild(this[0]);
1227 Element.prototype.toBack = function () {
1228 if (this[0].parentNode.firstChild != this[0]) {
1229 this[0].parentNode.insertBefore(this[0], this[0].parentNode.firstChild);
1233 var theCircle = function (svg, x, y, r) {
1234 var el = document.createElementNS(svg.svgns, "circle");
1235 el.setAttribute("cx", svg._getX(x));
1236 el.setAttribute("cy", svg._getY(y));
1237 el.setAttribute("r", r);
1238 el.setAttribute("fill", "none");
1239 el.setAttribute("stroke", "#000");
1241 svg.canvas.appendChild(el);
1243 var res = new Element(el, svg);
1244 res.attrs = res.attrs || {};
1248 res.attrs.stroke = "#000";
1249 res.type = "circle";
1252 var theRect = function (svg, x, y, w, h, r) {
1253 var el = document.createElementNS(svg.svgns, "rect");
1254 el.setAttribute("x", svg._getX(x));
1255 el.setAttribute("y", svg._getY(y));
1256 el.setAttribute("width", svg._getW(w));
1257 el.setAttribute("height", svg._getH(h));
1259 el.setAttribute("rx", r);
1260 el.setAttribute("ry", r);
1262 el.setAttribute("fill", "none");
1263 el.setAttribute("stroke", "#000");
1265 svg.canvas.appendChild(el);
1267 var res = new Element(el, svg);
1268 res.attrs = res.attrs || {};
1271 res.attrs.width = w;
1272 res.attrs.height = h;
1273 res.attrs.stroke = "#000";
1275 res.attrs.rx = res.attrs.ry = r;
1280 var theEllipse = function (svg, x, y, rx, ry) {
1281 var el = document.createElementNS(svg.svgns, "ellipse");
1282 el.setAttribute("cx", svg._getX(x));
1283 el.setAttribute("cy", svg._getY(y));
1284 el.setAttribute("rx", svg._getW(rx));
1285 el.setAttribute("ry", svg._getH(ry));
1286 el.setAttribute("fill", "none");
1287 el.setAttribute("stroke", "#000");
1289 svg.canvas.appendChild(el);
1291 var res = new Element(el, svg);
1292 res.attrs = res.attrs || {};
1297 res.attrs.stroke = "#000";
1298 res.type = "ellipse";
1301 var theImage = function (svg, src, x, y, w, h) {
1302 var el = document.createElementNS(svg.svgns, "image");
1303 el.setAttribute("x", svg._getX(x));
1304 el.setAttribute("y", svg._getY(y));
1305 el.setAttribute("width", svg._getW(w));
1306 el.setAttribute("height", svg._getH(h));
1307 el.setAttributeNS(svg.xlink, "href", src);
1309 svg.canvas.appendChild(el);
1311 var res = new Element(el, svg);
1312 res.attrs = res.attrs || {};
1315 res.attrs.width = w;
1316 res.attrs.height = h;
1320 var theText = function (svg, x, y, text) {
1321 var el = document.createElementNS(svg.svgns, "text");
1322 el.setAttribute("x", x);
1323 el.setAttribute("y", y);
1324 el.setAttribute("text-anchor", "middle");
1325 el.setAttribute("fill", "#000");
1327 el.appendChild(document.createTextNode(text));
1330 svg.canvas.appendChild(el);
1332 var res = new Element(el, svg);
1333 res.attrs = res.attrs || {};
1336 res.attrs.fill = "#000";
1340 var theGroup = function (svg) {
1341 var el = document.createElementNS(svg.svgns, "g");
1343 svg.canvas.appendChild(el);
1345 var i = new Element(el, svg);
1346 for (var f in svg) {
1347 if (f[0] != "_" && typeof svg[f] == "function") {
1348 i[f] = (function (f) {
1349 return function () {
1350 var e = svg[f].apply(svg, arguments);
1351 el.appendChild(e[0]);
1360 r._create = function () {
1361 // container, width, height
1362 // x, y, width, height
1363 if (typeof arguments[0] == "string") {
1364 var container = document.getElementById(arguments[0]);
1365 var width = arguments[1];
1366 var height = arguments[2];
1368 if (typeof arguments[0] == "object") {
1369 var container = arguments[0];
1370 var width = arguments[1];
1371 var height = arguments[2];
1373 if (typeof arguments[0] == "number") {
1377 width = arguments[2],
1378 height = arguments[3];
1381 throw new Error("SVG container not found.");
1383 C.canvas = document.createElementNS(C.svgns, "svg");
1384 C.canvas.setAttribute("width", width || 320);
1385 C.width = width || 320;
1386 C.canvas.setAttribute("height", height || 200);
1387 C.height = height || 200;
1388 if (container == 1) {
1389 document.body.appendChild(C.canvas);
1390 C.canvas.style.position = "absolute";
1391 C.canvas.style.left = x + "px";
1392 C.canvas.style.top = y + "px";
1394 if (container.firstChild) {
1395 container.insertBefore(C.canvas, container.firstChild);
1397 container.appendChild(C.canvas);
1402 clear: function () {
1403 while (this.canvas.firstChild) {
1404 this.canvas.removeChild(this.canvas.firstChild);
1406 this.defs = document.createElementNS(C.svgns, "defs");
1408 this.canvas.appendChild(this.defs);
1411 for (var prop in C) {
1412 if (prop != "create") {
1413 container[prop] = C[prop];
1419 C.svgns = "http://www.w3.org/2000/svg";
1420 C.xlink = "http://www.w3.org/1999/xlink";
1422 if (type == "VML" || type == "SVG") {
1423 C.circle = function (x, y, r) {
1424 return theCircle(this, x, y, r);
1426 C.rect = function (x, y, w, h, r) {
1427 return theRect(this, x, y, w, h, r);
1429 C.ellipse = function (x, y, rx, ry) {
1430 return theEllipse(this, x, y, rx, ry);
1432 C.path = function (params, pathString) {
1433 return thePath(params, pathString, this);
1435 C.image = function (src, x, y, w, h) {
1436 return theImage(this, src, x, y, w, h);
1438 C.text = function (x, y, text) {
1439 return theText(this, x, y, text);
1441 C.group = function () {
1442 return theGroup(this);
1444 C.linerect = function (x, y, w, h, r) {
1445 if (r && parseInt(r, 10)) {
1446 return this.path({stroke: "#000"}).moveTo(x + r, y).lineTo(x + w - r, y).addRoundedCorner(r, "rd").lineTo(x + w, y + h - r).addRoundedCorner(r, "dl").lineTo(x + r, y + h).addRoundedCorner(r, "lu").lineTo(x, y + r).addRoundedCorner(r, "ur").andClose();
1448 return this.path({stroke: "#000"}).moveTo(x, y).lineTo(x + w, y).lineTo(x + w, y + h).lineTo(x, y + h).andClose();
1450 C.drawGrid = function (x, y, w, h, wv, hv, color) {
1451 color = color || "#000";
1452 var p = this.path({stroke: color, "stroke-width": 1})
1453 .moveTo(x, y).lineTo(x + w, y).lineTo(x + w, y + h).lineTo(x, y + h).lineTo(x, y);
1454 for (var i = 1; i < hv; i++) {
1455 p.moveTo(x, y + i * Math.round(h / hv)).lineTo(x + w, y + i * Math.round(h / hv));
1457 for (var i = 1; i < wv; i++) {
1458 p.moveTo(x + i * Math.round(w / wv), y).lineTo(x + i * Math.round(w / wv), y + h);
1462 C.setGrid = function (xmin, ymin, xmax, ymax, w, h) {
1463 var xc = (xmax - xmin) / w;
1464 var yc = (ymax - ymin) / h;
1465 this._getX = function (x) {
1466 return xmin + x * xc;
1468 this._getY = function (y) {
1469 return ymin + y * yc;
1471 this._getW = function (w) {
1474 this._getH = function (h) {
1478 C.clearGrid = function () {
1479 this._getX = this._getY = this._getW = this._getH = function (x) { return x; };
1481 C.safari = function () {
1482 if (r.type == "SVG") {
1483 var rect = C.rect(-C.width, -C.height, C.width * 3, C.height * 3).attr({stroke: "none"});
1484 setTimeout(function () {rect.remove();}, 0);
1487 Element.prototype.animateTo = function (x, y, ms, callback) {
1488 clearTimeout(this.animation_in_progress);
1489 if ("cx" in this.attrs || "x" in this.attrs) {
1490 var is_round = ("cx" in this.attrs),
1491 X = this.attrs.cx || this.attrs.x,
1492 Y = this.attrs.cy || this.attrs.y;
1493 if (x == X && y == Y) {
1499 plus = Y - coeff * X,
1500 alpha = Math.atan(this.coeff);
1501 this.xs = this.step * Math.cos(alpha);
1505 var start = new Date(),
1508 var time = (new Date()).getTime() - start.getTime();
1510 var x1 = X + time * dx / ms;
1511 var y1 = x1 * coeff + plus;
1512 that.attr(is_round ? {cx: x1, cy: y1} : {x: x1, y: y1});
1513 that.animation_in_progress = setTimeout(arguments.callee, 1);
1516 that.attr(is_round ? {cx: x, cy: y} : {x: x, y: y});
1518 callback && callback.call(that);
1527 return function () {};
1529 })((!(window.SVGPreserveAspectRatio && window.SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN == 2)) ? "VML" : "SVG");
1532 Raphael.vml = !(Raphael.svg = (Raphael.type == "SVG"));
1533 if (Raphael.vml && window.CanvasRenderingContext2D) {
1534 Raphael.type = "Canvas only";
1535 Raphael.vml = Raphael.svg = false;
1537 Raphael.toString = function () {
1538 return "Your browser supports " + this.type;
1540 // generic utilities
1541 Raphael.hsb2rgb = function (hue, saturation, brightness) {
1542 if (typeof hue == "object" && "h" in hue && "s" in hue && "b" in hue) {
1550 if (brightness == 0) {
1551 return {r: 0, g: 0, b: 0, hex: "#000"};
1553 var i = Math.floor(hue * 6),
1555 p = brightness * (1 - saturation),
1556 q = brightness * (1 - (saturation * f)),
1557 t = brightness * (1 - (saturation * (1 - f)));
1559 function () {red = brightness; green = t; blue = p;},
1560 function () {red = q; green = brightness; blue = p;},
1561 function () {red = p; green = brightness; blue = t;},
1562 function () {red = p; green = q; blue = brightness;},
1563 function () {red = t; green = p; blue = brightness;},
1564 function () {red = brightness; green = p; blue = q;},
1565 function () {red = brightness; green = t; blue = p;},
1568 var rgb = {r: red, g: green, b: blue};
1572 var r = Math.round(red).toString(16);
1573 if (r.length == 1) {
1576 var g = Math.round(green).toString(16);
1577 if (g.length == 1) {
1580 var b = Math.round(blue).toString(16);
1581 if (b.length == 1) {
1584 rgb.hex = "#" + r + g + b;
1587 Raphael.rgb2hsb = function (red, green, blue) {
1588 if (typeof red == "object" && "r" in red && "g" in red && "b" in red) {
1593 if (red.charAt(0) == "#") {
1594 if (red.length == 4) {
1595 blue = parseInt(red.substring(3), 16);
1596 green = parseInt(red.substring(2, 3), 16);
1597 red = parseInt(red.substring(1, 2), 16);
1599 blue = parseInt(red.substring(5), 16);
1600 green = parseInt(red.substring(3, 5), 16);
1601 red = parseInt(red.substring(1, 3), 16);
1604 if (red > 1 || green > 1 || blue > 1) {
1609 var max = Math.max(red, green, blue),
1610 min = Math.min(red, green, blue),
1615 return {h: 0, s: 0, b: max};
1617 var delta = (max - min);
1618 saturation = delta / max;
1620 hue = (green - blue) / delta;
1621 } else if (green == max) {
1622 hue = 2 + ((blue - red) / delta);
1624 hue = 4 + ((red - green) / delta);
1634 return {h: hue, s: saturation, b: brightness};
1636 Raphael.getColor = function (value) {
1637 var start = arguments.callee.start = arguments.callee.start || {h: 0, s: 1, b: value || .75};
1638 var rgb = this.hsb2rgb(start.h, start.s, start.b);
1644 start = {h: 0, s: 1, b: start.b};
1649 Raphael.getColor.reset = function () {
1650 this.start = undefined;