raphael-rails 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/README.md +3 -0
- data/Rakefile +2 -0
- data/lib/raphael-rails.rb +6 -0
- data/lib/raphael-rails/version.rb +5 -0
- data/license.txt +21 -0
- data/vendor/assets/javascripts/plugins/colorpicker.js +259 -0
- data/vendor/assets/javascripts/plugins/colorwheel.js +212 -0
- data/vendor/assets/javascripts/plugins/jquery.colorpicker.js +16 -0
- data/vendor/assets/javascripts/plugins/jquery.colorwheel.js +9 -0
- data/vendor/assets/javascripts/plugins/raphael.blur.js +53 -0
- data/vendor/assets/javascripts/plugins/raphael.path.methods.js +60 -0
- data/vendor/assets/javascripts/plugins/raphael.primitives.js +99 -0
- data/vendor/assets/javascripts/plugins/raphael.shadow.js +52 -0
- data/vendor/assets/javascripts/raphael-min.js +7 -0
- data/vendor/assets/javascripts/raphael.js +3725 -0
- data/vendor/assets/javascripts/test/image/raphael.png +0 -0
- data/vendor/assets/javascripts/test/integration.html +101 -0
- data/vendor/assets/javascripts/test/vendor/jquery.js +3549 -0
- metadata +87 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
/*!
|
2
|
+
* Color Picker 0.1.0 - Raphael plugin
|
3
|
+
*
|
4
|
+
* Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
|
5
|
+
* Based on Color Wheel (http://jweir.github.com/colorwheel) by John Weir (http://famedriver.com)
|
6
|
+
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
|
7
|
+
*/
|
8
|
+
(function ($, R) {
|
9
|
+
$.fn.colorpicker = function (size, initcolor) {
|
10
|
+
if (R) {
|
11
|
+
var offset = this.offset();
|
12
|
+
return R.colorpicker(offset.left, offset.top, size, initcolor, this[0]);
|
13
|
+
}
|
14
|
+
return null;
|
15
|
+
};
|
16
|
+
})(window.jQuery, window.Raphael);
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/*!
|
2
|
+
* Raphael Blur Plugin 0.1
|
3
|
+
*
|
4
|
+
* Copyright (c) 2009 Dmitry Baranovskiy (http://raphaeljs.com)
|
5
|
+
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
|
6
|
+
*/
|
7
|
+
|
8
|
+
(function () {
|
9
|
+
if (Raphael.vml) {
|
10
|
+
var reg = / progid:\S+Blur\([^\)]+\)/g;
|
11
|
+
Raphael.el.blur = function (size) {
|
12
|
+
var s = this.node.style,
|
13
|
+
f = s.filter;
|
14
|
+
f = f.replace(reg, "");
|
15
|
+
if (size != "none") {
|
16
|
+
s.filter = f + " progid:DXImageTransform.Microsoft.Blur(pixelradius=" + (+size || 1.5) + ")";
|
17
|
+
s.margin = Raphael.format("-{0}px 0 0 -{0}px", Math.round(+size || 1.5));
|
18
|
+
} else {
|
19
|
+
s.filter = f;
|
20
|
+
s.margin = 0;
|
21
|
+
}
|
22
|
+
};
|
23
|
+
} else {
|
24
|
+
var $ = function (el, attr) {
|
25
|
+
if (attr) {
|
26
|
+
for (var key in attr) if (attr.hasOwnProperty(key)) {
|
27
|
+
el.setAttribute(key, attr[key]);
|
28
|
+
}
|
29
|
+
} else {
|
30
|
+
return doc.createElementNS("http://www.w3.org/2000/svg", el);
|
31
|
+
}
|
32
|
+
};
|
33
|
+
Raphael.el.blur = function (size) {
|
34
|
+
// Experimental. No WebKit support.
|
35
|
+
if (size != "none") {
|
36
|
+
var fltr = $("filter"),
|
37
|
+
blur = $("feGaussianBlur");
|
38
|
+
fltr.id = "r" + (Raphael.idGenerator++).toString(36);
|
39
|
+
$(blur, {stdDeviation: +size || 1.5});
|
40
|
+
fltr.appendChild(blur);
|
41
|
+
this.paper.defs.appendChild(fltr);
|
42
|
+
this._blur = fltr;
|
43
|
+
$(this.node, {filter: "url(#" + fltr.id + ")"});
|
44
|
+
} else {
|
45
|
+
if (this._blur) {
|
46
|
+
this._blur.parentNode.removeChild(this._blur);
|
47
|
+
delete this._blur;
|
48
|
+
}
|
49
|
+
this.node.removeAttribute("filter");
|
50
|
+
}
|
51
|
+
};
|
52
|
+
}
|
53
|
+
})();
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/*!
|
2
|
+
* Raphael Path Methods Plugin 0.2
|
3
|
+
*
|
4
|
+
* Copyright (c) 2009 Dmitry Baranovskiy (http://raphaeljs.com)
|
5
|
+
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
|
6
|
+
*/
|
7
|
+
|
8
|
+
Raphael.el.isAbsolute = true;
|
9
|
+
Raphael.el.absolutely = function () {
|
10
|
+
this.isAbsolute = 1;
|
11
|
+
return this;
|
12
|
+
};
|
13
|
+
Raphael.el.relatively = function () {
|
14
|
+
this.isAbsolute = 0;
|
15
|
+
return this;
|
16
|
+
};
|
17
|
+
Raphael.el.moveTo = function (x, y) {
|
18
|
+
this._last = {x: x, y: y};
|
19
|
+
return this.attr({path: this.attrs.path + ["m", "M"][+this.isAbsolute] + parseFloat(x) + " " + parseFloat(y)});
|
20
|
+
};
|
21
|
+
Raphael.el.lineTo = function (x, y) {
|
22
|
+
this._last = {x: x, y: y};
|
23
|
+
return this.attr({path: this.attrs.path + ["l", "L"][+this.isAbsolute] + parseFloat(x) + " " + parseFloat(y)});
|
24
|
+
};
|
25
|
+
Raphael.el.arcTo = function (rx, ry, large_arc_flag, sweep_flag, x, y, angle) {
|
26
|
+
this._last = {x: x, y: y};
|
27
|
+
return this.attr({path: this.attrs.path + ["a", "A"][+this.isAbsolute] + [parseFloat(rx), parseFloat(ry), +angle, large_arc_flag, sweep_flag, parseFloat(x), parseFloat(y)].join(" ")});
|
28
|
+
};
|
29
|
+
Raphael.el.curveTo = function () {
|
30
|
+
var args = Array.prototype.splice.call(arguments, 0, arguments.length),
|
31
|
+
d = [0, 0, 0, 0, "s", 0, "c"][args.length] || "";
|
32
|
+
this.isAbsolute && (d = d.toUpperCase());
|
33
|
+
this._last = {x: args[args.length - 2], y: args[args.length - 1]};
|
34
|
+
return this.attr({path: this.attrs.path + d + args});
|
35
|
+
};
|
36
|
+
Raphael.el.cplineTo = function (x, y, w) {
|
37
|
+
this.attr({path: this.attrs.path + ["C", this._last.x + w, this._last.y, x - w, y, x, y]});
|
38
|
+
this._last = {x: x, y: y};
|
39
|
+
return this;
|
40
|
+
};
|
41
|
+
Raphael.el.qcurveTo = function () {
|
42
|
+
var d = [0, 1, "t", 3, "q"][arguments.length],
|
43
|
+
args = Array.prototype.splice.call(arguments, 0, arguments.length);
|
44
|
+
if (this.isAbsolute) {
|
45
|
+
d = d.toUpperCase();
|
46
|
+
}
|
47
|
+
this._last = {x: args[args.length - 2], y: args[args.length - 1]};
|
48
|
+
return this.attr({path: this.attrs.path + d + args});
|
49
|
+
};
|
50
|
+
Raphael.el.addRoundedCorner = function (r, dir) {
|
51
|
+
var rollback = this.isAbsolute;
|
52
|
+
rollback && this.relatively();
|
53
|
+
this._last = {x: r * (!!(dir.indexOf("r") + 1) * 2 - 1), y: r * (!!(dir.indexOf("d") + 1) * 2 - 1)};
|
54
|
+
this.arcTo(r, r, 0, {"lu": 1, "rd": 1, "ur": 1, "dl": 1}[dir] || 0, this._last.x, this._last.y);
|
55
|
+
rollback && this.absolutely();
|
56
|
+
return this;
|
57
|
+
};
|
58
|
+
Raphael.el.andClose = function () {
|
59
|
+
return this.attr({path: this.attrs.path + "z"});
|
60
|
+
};
|
@@ -0,0 +1,99 @@
|
|
1
|
+
/*!
|
2
|
+
* Raphael Primitives Plugin 0.2
|
3
|
+
*
|
4
|
+
* Copyright (c) 2009 Dmitry Baranovskiy (http://raphaeljs.com)
|
5
|
+
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
|
6
|
+
*/
|
7
|
+
|
8
|
+
Raphael.fn.star = function (cx, cy, r, r2, rays) {
|
9
|
+
r2 = r2 || r * .382;
|
10
|
+
rays = rays || 5;
|
11
|
+
var points = ["M", cx, cy + r2, "L"],
|
12
|
+
R;
|
13
|
+
for (var i = 1; i < rays * 2; i++) {
|
14
|
+
R = i % 2 ? r : r2;
|
15
|
+
points = points.concat([(cx + R * Math.sin(i * Math.PI / rays)), (cy + R * Math.cos(i * Math.PI / rays))]);
|
16
|
+
}
|
17
|
+
points.push("z");
|
18
|
+
return this.path(points.join());
|
19
|
+
};
|
20
|
+
Raphael.fn.flower = function (cx, cy, rout, rin, n) {
|
21
|
+
rin = rin || rout * .5;
|
22
|
+
n = +n < 3 || !n ? 5 : n;
|
23
|
+
var points = ["M", cx, cy + rin, "Q"],
|
24
|
+
R;
|
25
|
+
for (var i = 1; i < n * 2 + 1; i++) {
|
26
|
+
R = i % 2 ? rout : rin;
|
27
|
+
points = points.concat([+(cx + R * Math.sin(i * Math.PI / n)).toFixed(3), +(cy + R * Math.cos(i * Math.PI / n)).toFixed(3)]);
|
28
|
+
}
|
29
|
+
points.push("z");
|
30
|
+
return this.path(points);
|
31
|
+
};
|
32
|
+
Raphael.fn.spike = function (cx, cy, rout, rin, n) {
|
33
|
+
rin = rin || rout * .5;
|
34
|
+
n = +n < 3 || !n ? 5 : n;
|
35
|
+
var points = ["M", cx, cy - rout, "Q"],
|
36
|
+
R;
|
37
|
+
for (var i = 1; i < n * 2 + 1; i++) {
|
38
|
+
R = i % 2 ? rin : rout;
|
39
|
+
points = points.concat([cx + R * Math.sin(i * Math.PI / n - Math.PI), cy + R * Math.cos(i * Math.PI / n - Math.PI)]);
|
40
|
+
}
|
41
|
+
points.push("z");
|
42
|
+
return this.path(points);
|
43
|
+
};
|
44
|
+
Raphael.fn.polyline = function () {
|
45
|
+
var points = "M".concat(arguments[0] || 0, ",", arguments[1] || 0, "L");
|
46
|
+
for (var i = 2, ii = arguments.length - 1; i < ii; i++) {
|
47
|
+
points += arguments[i] + "," + arguments[++i];
|
48
|
+
}
|
49
|
+
arguments[ii].toLowerCase() == "z" && (points += "z");
|
50
|
+
return this.path(points);
|
51
|
+
};
|
52
|
+
Raphael.fn.polygon = function (cx, cy, r, n) {
|
53
|
+
n = +n < 3 || !n ? 5 : n;
|
54
|
+
var points = ["M", cx, cy - r, "L"],
|
55
|
+
R;
|
56
|
+
for (var i = 1; i < n; i++) {
|
57
|
+
points = points.concat([cx + r * Math.sin(i * Math.PI * 2 / n - Math.PI), cy + r * Math.cos(i * Math.PI * 2 / n - Math.PI)]);
|
58
|
+
}
|
59
|
+
points.push("z");
|
60
|
+
return this.path(points);
|
61
|
+
};
|
62
|
+
Raphael.fn.line = function (x1, y1, x2, y2) {
|
63
|
+
return this.path(["M", x1, y1, "L", x2, y2]);
|
64
|
+
};
|
65
|
+
Raphael.fn.drawGrid = function (x, y, w, h, wv, hv, color) {
|
66
|
+
color = color || "#000";
|
67
|
+
var path = ["M", x, y, "L", x + w, y, x + w, y + h, x, y + h, x, y],
|
68
|
+
rowHeight = h / hv,
|
69
|
+
columnWidth = w / wv;
|
70
|
+
for (var i = 1; i < hv; i++) {
|
71
|
+
path = path.concat(["M", x, y + i * rowHeight, "L", x + w, y + i * rowHeight]);
|
72
|
+
}
|
73
|
+
for (var i = 1; i < wv; i++) {
|
74
|
+
path = path.concat(["M", x + i * columnWidth, y, "L", x + i * columnWidth, y + h]);
|
75
|
+
}
|
76
|
+
return this.path(path.join(",")).attr({stroke: color});
|
77
|
+
};
|
78
|
+
Raphael.fn.square = function (cx, cy, r) {
|
79
|
+
r = r * .7;
|
80
|
+
return this.rect(cx - r, cy - r, 2 * r, 2 * r);
|
81
|
+
};
|
82
|
+
Raphael.fn.triangle = function (cx, cy, r) {
|
83
|
+
r *= 1.75;
|
84
|
+
return this.path("M".concat(cx, ",", cy, "m0-", r * .58, "l", r * .5, ",", r * .87, "-", r, ",0z"));
|
85
|
+
};
|
86
|
+
Raphael.fn.diamond = function (cx, cy, r) {
|
87
|
+
return this.path(["M", cx, cy - r, "l", r, r, -r, r, -r, -r, r, -r, "z"]);
|
88
|
+
};
|
89
|
+
Raphael.fn.cross = function (cx, cy, r) {
|
90
|
+
r = r / 2.5;
|
91
|
+
return this.path("M".concat(cx - r, ",", cy, "l", [-r, -r, r, -r, r, r, r, -r, r, r, -r, r, r, r, -r, r, -r, -r, -r, r, -r, -r, "z"]));
|
92
|
+
};
|
93
|
+
Raphael.fn.plus = function (cx, cy, r) {
|
94
|
+
r = r / 2;
|
95
|
+
return this.path("M".concat(cx - r / 2, ",", cy - r / 2, "l", [0, -r, r, 0, 0, r, r, 0, 0, r, -r, 0, 0, r, -r, 0, 0, -r, -r, 0, 0, -r, "z"]));
|
96
|
+
};
|
97
|
+
Raphael.fn.arrow = function (cx, cy, r) {
|
98
|
+
return this.path("M".concat(cx - r * .7, ",", cy - r * .4, "l", [r * .6, 0, 0, -r * .4, r, r * .8, -r, r * .8, 0, -r * .4, -r * .6, 0], "z"));
|
99
|
+
};
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/*!
|
2
|
+
* Raphael Shadow plugin 0.3
|
3
|
+
*
|
4
|
+
* Copyright (c) 2008 - 2009 Dmitry Baranovskiy (http://raphaeljs.com)
|
5
|
+
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
|
6
|
+
*/
|
7
|
+
Raphael.shadow = function (x, y, w, h, options) {
|
8
|
+
// options format: {
|
9
|
+
// size: 0..1, shadow size
|
10
|
+
// color: "#000", placeholder colour
|
11
|
+
// stroke: "#000", placeholder stroke colour
|
12
|
+
// shadow: "#000", shadow colour
|
13
|
+
// target: "someID" | htmlElement
|
14
|
+
// r: 5, radius of placeholder rounded corners
|
15
|
+
// }
|
16
|
+
options = options || {};
|
17
|
+
var t = ~~(size * .3 + .5),
|
18
|
+
size = (options.size || 1) * 10,
|
19
|
+
color = options.color || "#fff",
|
20
|
+
stroke = options.stroke || color,
|
21
|
+
shadowColor = options.shadow || "#000",
|
22
|
+
target = options.target || null,
|
23
|
+
R = options.r == null ? 3 : options.r,
|
24
|
+
s = size,
|
25
|
+
b = size * 2,
|
26
|
+
r = b + s,
|
27
|
+
rg = this.format("r{0}-{0}", shadowColor),
|
28
|
+
rect = "rect",
|
29
|
+
none = "none",
|
30
|
+
res,
|
31
|
+
set;
|
32
|
+
|
33
|
+
if (target) {
|
34
|
+
res = this(target, w + (x = s) * 2, h + (y = t) + b);
|
35
|
+
} else {
|
36
|
+
res = this(x - s, y - t, w + (x = s) * 2, h + (y = t) + b);
|
37
|
+
}
|
38
|
+
|
39
|
+
set = res.set(
|
40
|
+
res.rect(x - s, y - t, b + s, h + y + b).attr({stroke: none, fill: this.format("180-{0}-{0}", shadowColor), opacity: 0, "clip-rect": [x - s + 1, y - t + r, b, h + y + b - r * 2 + .9]}),
|
41
|
+
res.rect(x + w - b, y - t, b + s, h + y + b).attr({stroke: none, fill: this.format("0-{0}-{0}", shadowColor), opacity: 0, "clip-rect": [x + w - s + 1, y - t + r, b, h + y + b - r * 2]}),
|
42
|
+
res.rect(x + b - 1, y + h - s, w + b, b + s).attr({stroke: none, fill: this.format("270-{0}-{0}", shadowColor), opacity: 0, "clip-rect": [x + b, y + h - s, w + b - r * 2, b + s]}),
|
43
|
+
res.rect(x + s - 1, y - t, w + b, b + s).attr({stroke: none, fill: this.format("90-{0}-{0}", shadowColor), opacity: 0, "clip-rect": [x + b, y - t, w + b - r * 2, s + t + 1]}),
|
44
|
+
res.circle(x + b, y + h - s, r).attr({stroke: none, fill: rg, opacity: 0, "clip-rect": [x - s, y + h - s + .999, r, r]}),
|
45
|
+
res.circle(x + w - b, y + h - s, r).attr({stroke: none, fill: rg, opacity: 0, "clip-rect": [x + w - b, y + h - s, r, r]}),
|
46
|
+
res.circle(x + b, y - t + r, r).attr({stroke: none, fill: rg, opacity: 0, "clip-rect": [x - s, y - t, r, r]}),
|
47
|
+
res.circle(x + w - b, y - t + r, r).attr({stroke: none, fill: rg, opacity: 0, "clip-rect": [x + w - b, y - t, r, r]}),
|
48
|
+
res.rect(x, y, w, h, R).attr({fill: color, stroke: stroke})
|
49
|
+
);
|
50
|
+
|
51
|
+
return set[0].paper;
|
52
|
+
};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* Raphael 1.5.2 - JavaScript Vector Library
|
3
|
+
*
|
4
|
+
* Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
|
5
|
+
* Licensed under the MIT (http://raphaeljs.com/license.html) license.
|
6
|
+
*/
|
7
|
+
(function(){function a(){if(a.is(arguments[0],G)){var b=arguments[0],d=bV[m](a,b.splice(0,3+a.is(b[0],E))),e=d.set();for(var g=0,h=b[w];g<h;g++){var i=b[g]||{};c[f](i.type)&&e[L](d[i.type]().attr(i))}return e}return bV[m](a,arguments)}a.version="1.5.2";var b=/[, ]+/,c={circle:1,rect:1,path:1,ellipse:1,text:1,image:1},d=/\{(\d+)\}/g,e="prototype",f="hasOwnProperty",g=document,h=window,i={was:Object[e][f].call(h,"Raphael"),is:h.Raphael},j=function(){this.customAttributes={}},k,l="appendChild",m="apply",n="concat",o="createTouch"in g,p="",q=" ",r=String,s="split",t="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend"[s](q),u={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},v="join",w="length",x=r[e].toLowerCase,y=Math,z=y.max,A=y.min,B=y.abs,C=y.pow,D=y.PI,E="number",F="string",G="array",H="toString",I="fill",J=Object[e][H],K={},L="push",M=/^url\(['"]?([^\)]+?)['"]?\)$/i,N=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,O={"NaN":1,Infinity:1,"-Infinity":1},P=/^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,Q=y.round,R="setAttribute",S=parseFloat,T=parseInt,U=" progid:DXImageTransform.Microsoft",V=r[e].toUpperCase,W={blur:0,"clip-rect":"0 0 1e9 1e9",cursor:"default",cx:0,cy:0,fill:"#fff","fill-opacity":1,font:"10px \"Arial\"","font-family":"\"Arial\"","font-size":"10","font-style":"normal","font-weight":400,gradient:0,height:0,href:"http://raphaeljs.com/",opacity:1,path:"M0,0",r:0,rotation:0,rx:0,ry:0,scale:"1 1",src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,target:"_blank","text-anchor":"middle",title:"Raphael",translation:"0 0",width:0,x:0,y:0},X={along:"along",blur:E,"clip-rect":"csv",cx:E,cy:E,fill:"colour","fill-opacity":E,"font-size":E,height:E,opacity:E,path:"path",r:E,rotation:"csv",rx:E,ry:E,scale:"csv",stroke:"colour","stroke-opacity":E,"stroke-width":E,translation:"csv",width:E,x:E,y:E},Y="replace",Z=/^(from|to|\d+%?)$/,$=/\s*,\s*/,_={hs:1,rg:1},ba=/,?([achlmqrstvxz]),?/gi,bb=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,bc=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig,bd=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,be=function(a,b){return a.key-b.key};a.type=h.SVGAngle||g.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML";if(a.type=="VML"){var bf=g.createElement("div"),bg;bf.innerHTML="<v:shape adj=\"1\"/>";bg=bf.firstChild;bg.style.behavior="url(#default#VML)";if(!(bg&&typeof bg.adj=="object"))return a.type=null;bf=null}a.svg=!(a.vml=a.type=="VML");j[e]=a[e];k=j[e];a._id=0;a._oid=0;a.fn={};a.is=function(a,b){b=x.call(b);if(b=="finite")return!O[f](+a);return b=="null"&&a===null||b==typeof a||b=="object"&&a===Object(a)||b=="array"&&Array.isArray&&Array.isArray(a)||J.call(a).slice(8,-1).toLowerCase()==b};a.angle=function(b,c,d,e,f,g){{if(f==null){var h=b-d,i=c-e;if(!h&&!i)return 0;return((h<0)*180+y.atan(-i/-h)*180/D+360)%360}return a.angle(b,c,f,g)-a.angle(d,e,f,g)}};a.rad=function(a){return a%360*D/180};a.deg=function(a){return a*180/D%360};a.snapTo=function(b,c,d){d=a.is(d,"finite")?d:10;if(a.is(b,G)){var e=b.length;while(e--)if(B(b[e]-c)<=d)return b[e]}else{b=+b;var f=c%b;if(f<d)return c-f;if(f>b-d)return c-f+b}return c};function bh(){var a=[],b=0;for(;b<32;b++)a[b]=(~(~(y.random()*16)))[H](16);a[12]=4;a[16]=(a[16]&3|8)[H](16);return"r-"+a[v]("")}a.setWindow=function(a){h=a;g=h.document};var bi=function(b){if(a.vml){var c=/^\s+|\s+$/g,d;try{var e=new ActiveXObject("htmlfile");e.write("<body>");e.close();d=e.body}catch(a){d=createPopup().document.body}var f=d.createTextRange();bi=bm(function(a){try{d.style.color=r(a)[Y](c,p);var b=f.queryCommandValue("ForeColor");b=(b&255)<<16|b&65280|(b&16711680)>>>16;return"#"+("000000"+b[H](16)).slice(-6)}catch(a){return"none"}})}else{var h=g.createElement("i");h.title="Raphaël Colour Picker";h.style.display="none";g.body[l](h);bi=bm(function(a){h.style.color=a;return g.defaultView.getComputedStyle(h,p).getPropertyValue("color")})}return bi(b)},bj=function(){return"hsb("+[this.h,this.s,this.b]+")"},bk=function(){return"hsl("+[this.h,this.s,this.l]+")"},bl=function(){return this.hex};a.hsb2rgb=function(b,c,d,e){if(a.is(b,"object")&&"h"in b&&"s"in b&&"b"in b){d=b.b;c=b.s;b=b.h;e=b.o}return a.hsl2rgb(b,c,d/2,e)};a.hsl2rgb=function(b,c,d,e){if(a.is(b,"object")&&"h"in b&&"s"in b&&"l"in b){d=b.l;c=b.s;b=b.h}if(b>1||c>1||d>1){b/=360;c/=100;d/=100}var f={},g=["r","g","b"],h,i,j,k,l,m;if(c){d<0.5?h=d*(1+c):h=d+c-d*c;i=2*d-h;for(var n=0;n<3;n++){j=b+1/3*-(n-1);j<0&&j++;j>1&&j--;j*6<1?f[g[n]]=i+(h-i)*6*j:j*2<1?f[g[n]]=h:j*3<2?f[g[n]]=i+(h-i)*(2/3-j)*6:f[g[n]]=i}}else f={r:d,g:d,b:d};f.r*=255;f.g*=255;f.b*=255;f.hex="#"+(16777216|f.b|f.g<<8|f.r<<16).toString(16).slice(1);a.is(e,"finite")&&(f.opacity=e);f.toString=bl;return f};a.rgb2hsb=function(b,c,d){if(c==null&&a.is(b,"object")&&"r"in b&&"g"in b&&"b"in b){d=b.b;c=b.g;b=b.r}if(c==null&&a.is(b,F)){var e=a.getRGB(b);b=e.r;c=e.g;d=e.b}if(b>1||c>1||d>1){b/=255;c/=255;d/=255}var f=z(b,c,d),g=A(b,c,d),h,i,j=f;{if(g==f)return{h:0,s:0,b:f,toString:bj};var k=f-g;i=k/f;b==f?h=(c-d)/k:c==f?h=2+(d-b)/k:h=4+(b-c)/k;h/=6;h<0&&h++;h>1&&h--}return{h:h,s:i,b:j,toString:bj}};a.rgb2hsl=function(b,c,d){if(c==null&&a.is(b,"object")&&"r"in b&&"g"in b&&"b"in b){d=b.b;c=b.g;b=b.r}if(c==null&&a.is(b,F)){var e=a.getRGB(b);b=e.r;c=e.g;d=e.b}if(b>1||c>1||d>1){b/=255;c/=255;d/=255}var f=z(b,c,d),g=A(b,c,d),h,i,j=(f+g)/2,k;if(g==f)k={h:0,s:0,l:j};else{var l=f-g;i=j<0.5?l/(f+g):l/(2-f-g);b==f?h=(c-d)/l:c==f?h=2+(d-b)/l:h=4+(b-c)/l;h/=6;h<0&&h++;h>1&&h--;k={h:h,s:i,l:j}}k.toString=bk;return k};a._path2string=function(){return this.join(",")[Y](ba,"$1")};function bm(a,b,c){function d(){var g=Array[e].slice.call(arguments,0),h=g[v]("►"),i=d.cache=d.cache||{},j=d.count=d.count||[];if(i[f](h))return c?c(i[h]):i[h];j[w]>=1000&&delete i[j.shift()];j[L](h);i[h]=a[m](b,g);return c?c(i[h]):i[h]}return d}a.getRGB=bm(function(b){if(!b||!(!((b=r(b)).indexOf("-")+1)))return{r:-1,g:-1,b:-1,hex:"none",error:1};if(b=="none")return{r:-1,g:-1,b:-1,hex:"none"};!(_[f](b.toLowerCase().substring(0,2))||b.charAt()=="#")&&(b=bi(b));var c,d,e,g,h,i,j,k=b.match(N);if(k){if(k[2]){g=T(k[2].substring(5),16);e=T(k[2].substring(3,5),16);d=T(k[2].substring(1,3),16)}if(k[3]){g=T((i=k[3].charAt(3))+i,16);e=T((i=k[3].charAt(2))+i,16);d=T((i=k[3].charAt(1))+i,16)}if(k[4]){j=k[4][s]($);d=S(j[0]);j[0].slice(-1)=="%"&&(d*=2.55);e=S(j[1]);j[1].slice(-1)=="%"&&(e*=2.55);g=S(j[2]);j[2].slice(-1)=="%"&&(g*=2.55);k[1].toLowerCase().slice(0,4)=="rgba"&&(h=S(j[3]));j[3]&&j[3].slice(-1)=="%"&&(h/=100)}if(k[5]){j=k[5][s]($);d=S(j[0]);j[0].slice(-1)=="%"&&(d*=2.55);e=S(j[1]);j[1].slice(-1)=="%"&&(e*=2.55);g=S(j[2]);j[2].slice(-1)=="%"&&(g*=2.55);(j[0].slice(-3)=="deg"||j[0].slice(-1)=="°")&&(d/=360);k[1].toLowerCase().slice(0,4)=="hsba"&&(h=S(j[3]));j[3]&&j[3].slice(-1)=="%"&&(h/=100);return a.hsb2rgb(d,e,g,h)}if(k[6]){j=k[6][s]($);d=S(j[0]);j[0].slice(-1)=="%"&&(d*=2.55);e=S(j[1]);j[1].slice(-1)=="%"&&(e*=2.55);g=S(j[2]);j[2].slice(-1)=="%"&&(g*=2.55);(j[0].slice(-3)=="deg"||j[0].slice(-1)=="°")&&(d/=360);k[1].toLowerCase().slice(0,4)=="hsla"&&(h=S(j[3]));j[3]&&j[3].slice(-1)=="%"&&(h/=100);return a.hsl2rgb(d,e,g,h)}k={r:d,g:e,b:g};k.hex="#"+(16777216|g|e<<8|d<<16).toString(16).slice(1);a.is(h,"finite")&&(k.opacity=h);return k}return{r:-1,g:-1,b:-1,hex:"none",error:1}},a);a.getColor=function(a){var b=this.getColor.start=this.getColor.start||{h:0,s:1,b:a||0.75},c=this.hsb2rgb(b.h,b.s,b.b);b.h+=0.075;if(b.h>1){b.h=0;b.s-=0.2;b.s<=0&&(this.getColor.start={h:0,s:1,b:b.b})}return c.hex};a.getColor.reset=function(){delete this.start};a.parsePathString=bm(function(b){if(!b)return null;var c={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},d=[];a.is(b,G)&&a.is(b[0],G)&&(d=bo(b));d[w]||r(b)[Y](bb,function(a,b,e){var f=[],g=x.call(b);e[Y](bc,function(a,b){b&&f[L](+b)});if(g=="m"&&f[w]>2){d[L]([b][n](f.splice(0,2)));g="l";b=b=="m"?"l":"L"}while(f[w]>=c[g]){d[L]([b][n](f.splice(0,c[g])));if(!c[g])break}});d[H]=a._path2string;return d});a.findDotsAtSegment=function(a,b,c,d,e,f,g,h,i){var j=1-i,k=C(j,3)*a+C(j,2)*3*i*c+j*3*i*i*e+C(i,3)*g,l=C(j,3)*b+C(j,2)*3*i*d+j*3*i*i*f+C(i,3)*h,m=a+2*i*(c-a)+i*i*(e-2*c+a),n=b+2*i*(d-b)+i*i*(f-2*d+b),o=c+2*i*(e-c)+i*i*(g-2*e+c),p=d+2*i*(f-d)+i*i*(h-2*f+d),q=(1-i)*a+i*c,r=(1-i)*b+i*d,s=(1-i)*e+i*g,t=(1-i)*f+i*h,u=90-y.atan((m-o)/(n-p))*180/D;(m>o||n<p)&&(u+=180);return{x:k,y:l,m:{x:m,y:n},n:{x:o,y:p},start:{x:q,y:r},end:{x:s,y:t},alpha:u}};var bn=bm(function(a){if(!a)return{x:0,y:0,width:0,height:0};a=bw(a);var b=0,c=0,d=[],e=[],f;for(var g=0,h=a[w];g<h;g++){f=a[g];if(f[0]=="M"){b=f[1];c=f[2];d[L](b);e[L](c)}else{var i=bv(b,c,f[1],f[2],f[3],f[4],f[5],f[6]);d=d[n](i.min.x,i.max.x);e=e[n](i.min.y,i.max.y);b=f[5];c=f[6]}}var j=A[m](0,d),k=A[m](0,e);return{x:j,y:k,width:z[m](0,d)-j,height:z[m](0,e)-k}}),bo=function(b){var c=[];if(!a.is(b,G)||!a.is(b&&b[0],G))b=a.parsePathString(b);for(var d=0,e=b[w];d<e;d++){c[d]=[];for(var f=0,g=b[d][w];f<g;f++)c[d][f]=b[d][f]}c[H]=a._path2string;return c},bp=bm(function(b){if(!a.is(b,G)||!a.is(b&&b[0],G))b=a.parsePathString(b);var c=[],d=0,e=0,f=0,g=0,h=0;if(b[0][0]=="M"){d=b[0][1];e=b[0][2];f=d;g=e;h++;c[L](["M",d,e])}for(var i=h,j=b[w];i<j;i++){var k=c[i]=[],l=b[i];if(l[0]!=x.call(l[0])){k[0]=x.call(l[0]);switch(k[0]){case"a":k[1]=l[1];k[2]=l[2];k[3]=l[3];k[4]=l[4];k[5]=l[5];k[6]=+(l[6]-d).toFixed(3);k[7]=+(l[7]-e).toFixed(3);break;case"v":k[1]=+(l[1]-e).toFixed(3);break;case"m":f=l[1];g=l[2];default:for(var m=1,n=l[w];m<n;m++)k[m]=+(l[m]-(m%2?d:e)).toFixed(3)}}else{k=c[i]=[];if(l[0]=="m"){f=l[1]+d;g=l[2]+e}for(var o=0,p=l[w];o<p;o++)c[i][o]=l[o]}var q=c[i][w];switch(c[i][0]){case"z":d=f;e=g;break;case"h":d+=+c[i][q-1];break;case"v":e+=+c[i][q-1];break;default:d+=+c[i][q-2];e+=+c[i][q-1]}}c[H]=a._path2string;return c},0,bo),bq=bm(function(b){if(!a.is(b,G)||!a.is(b&&b[0],G))b=a.parsePathString(b);var c=[],d=0,e=0,f=0,g=0,h=0;if(b[0][0]=="M"){d=+b[0][1];e=+b[0][2];f=d;g=e;h++;c[0]=["M",d,e]}for(var i=h,j=b[w];i<j;i++){var k=c[i]=[],l=b[i];if(l[0]!=V.call(l[0])){k[0]=V.call(l[0]);switch(k[0]){case"A":k[1]=l[1];k[2]=l[2];k[3]=l[3];k[4]=l[4];k[5]=l[5];k[6]=+(l[6]+d);k[7]=+(l[7]+e);break;case"V":k[1]=+l[1]+e;break;case"H":k[1]=+l[1]+d;break;case"M":f=+l[1]+d;g=+l[2]+e;default:for(var m=1,n=l[w];m<n;m++)k[m]=+l[m]+(m%2?d:e)}}else for(var o=0,p=l[w];o<p;o++)c[i][o]=l[o];switch(k[0]){case"Z":d=f;e=g;break;case"H":d=k[1];break;case"V":e=k[1];break;case"M":f=c[i][c[i][w]-2];g=c[i][c[i][w]-1];default:d=c[i][c[i][w]-2];e=c[i][c[i][w]-1]}}c[H]=a._path2string;return c},null,bo),br=function(a,b,c,d){return[a,b,c,d,c,d]},bs=function(a,b,c,d,e,f){var g=1/3,h=2/3;return[g*a+h*c,g*b+h*d,g*e+h*c,g*f+h*d,e,f]},bt=function(a,b,c,d,e,f,g,h,i,j){var k=D*120/180,l=D/180*(+e||0),m=[],o,p=bm(function(a,b,c){var d=a*y.cos(c)-b*y.sin(c),e=a*y.sin(c)+b*y.cos(c);return{x:d,y:e}});if(j){G=j[0];H=j[1];E=j[2];F=j[3]}else{o=p(a,b,-l);a=o.x;b=o.y;o=p(h,i,-l);h=o.x;i=o.y;var q=y.cos(D/180*e),r=y.sin(D/180*e),t=(a-h)/2,u=(b-i)/2,x=t*t/(c*c)+u*u/(d*d);if(x>1){x=y.sqrt(x);c=x*c;d=x*d}var z=c*c,A=d*d,C=(f==g?-1:1)*y.sqrt(B((z*A-z*u*u-A*t*t)/(z*u*u+A*t*t))),E=C*c*u/d+(a+h)/2,F=C*-d*t/c+(b+i)/2,G=y.asin(((b-F)/d).toFixed(9)),H=y.asin(((i-F)/d).toFixed(9));G=a<E?D-G:G;H=h<E?D-H:H;G<0&&(G=D*2+G);H<0&&(H=D*2+H);g&&G>H&&(G=G-D*2);!g&&H>G&&(H=H-D*2)}var I=H-G;if(B(I)>k){var J=H,K=h,L=i;H=G+k*(g&&H>G?1:-1);h=E+c*y.cos(H);i=F+d*y.sin(H);m=bt(h,i,c,d,e,0,g,K,L,[H,J,E,F])}I=H-G;var M=y.cos(G),N=y.sin(G),O=y.cos(H),P=y.sin(H),Q=y.tan(I/4),R=4/3*c*Q,S=4/3*d*Q,T=[a,b],U=[a+R*N,b-S*M],V=[h+R*P,i-S*O],W=[h,i];U[0]=2*T[0]-U[0];U[1]=2*T[1]-U[1];{if(j)return[U,V,W][n](m);m=[U,V,W][n](m)[v]()[s](",");var X=[];for(var Y=0,Z=m[w];Y<Z;Y++)X[Y]=Y%2?p(m[Y-1],m[Y],l).y:p(m[Y],m[Y+1],l).x;return X}},bu=function(a,b,c,d,e,f,g,h,i){var j=1-i;return{x:C(j,3)*a+C(j,2)*3*i*c+j*3*i*i*e+C(i,3)*g,y:C(j,3)*b+C(j,2)*3*i*d+j*3*i*i*f+C(i,3)*h}},bv=bm(function(a,b,c,d,e,f,g,h){var i=e-2*c+a-(g-2*e+c),j=2*(c-a)-2*(e-c),k=a-c,l=(-j+y.sqrt(j*j-4*i*k))/2/i,n=(-j-y.sqrt(j*j-4*i*k))/2/i,o=[b,h],p=[a,g],q;B(l)>"1e12"&&(l=0.5);B(n)>"1e12"&&(n=0.5);if(l>0&&l<1){q=bu(a,b,c,d,e,f,g,h,l);p[L](q.x);o[L](q.y)}if(n>0&&n<1){q=bu(a,b,c,d,e,f,g,h,n);p[L](q.x);o[L](q.y)}i=f-2*d+b-(h-2*f+d);j=2*(d-b)-2*(f-d);k=b-d;l=(-j+y.sqrt(j*j-4*i*k))/2/i;n=(-j-y.sqrt(j*j-4*i*k))/2/i;B(l)>"1e12"&&(l=0.5);B(n)>"1e12"&&(n=0.5);if(l>0&&l<1){q=bu(a,b,c,d,e,f,g,h,l);p[L](q.x);o[L](q.y)}if(n>0&&n<1){q=bu(a,b,c,d,e,f,g,h,n);p[L](q.x);o[L](q.y)}return{min:{x:A[m](0,p),y:A[m](0,o)},max:{x:z[m](0,p),y:z[m](0,o)}}}),bw=bm(function(a,b){var c=bq(a),d=b&&bq(b),e={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},f={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},g=function(a,b){var c,d;if(!a)return["C",b.x,b.y,b.x,b.y,b.x,b.y];!(a[0]in{T:1,Q:1})&&(b.qx=b.qy=null);switch(a[0]){case"M":b.X=a[1];b.Y=a[2];break;case"A":a=["C"][n](bt[m](0,[b.x,b.y][n](a.slice(1))));break;case"S":c=b.x+(b.x-(b.bx||b.x));d=b.y+(b.y-(b.by||b.y));a=["C",c,d][n](a.slice(1));break;case"T":b.qx=b.x+(b.x-(b.qx||b.x));b.qy=b.y+(b.y-(b.qy||b.y));a=["C"][n](bs(b.x,b.y,b.qx,b.qy,a[1],a[2]));break;case"Q":b.qx=a[1];b.qy=a[2];a=["C"][n](bs(b.x,b.y,a[1],a[2],a[3],a[4]));break;case"L":a=["C"][n](br(b.x,b.y,a[1],a[2]));break;case"H":a=["C"][n](br(b.x,b.y,a[1],b.y));break;case"V":a=["C"][n](br(b.x,b.y,b.x,a[1]));break;case"Z":a=["C"][n](br(b.x,b.y,b.X,b.Y));break}return a},h=function(a,b){if(a[b][w]>7){a[b].shift();var e=a[b];while(e[w])a.splice(b++,0,["C"][n](e.splice(0,6)));a.splice(b,1);k=z(c[w],d&&d[w]||0)}},i=function(a,b,e,f,g){if(a&&b&&a[g][0]=="M"&&b[g][0]!="M"){b.splice(g,0,["M",f.x,f.y]);e.bx=0;e.by=0;e.x=a[g][1];e.y=a[g][2];k=z(c[w],d&&d[w]||0)}};for(var j=0,k=z(c[w],d&&d[w]||0);j<k;j++){c[j]=g(c[j],e);h(c,j);d&&(d[j]=g(d[j],f));d&&h(d,j);i(c,d,e,f,j);i(d,c,f,e,j);var l=c[j],o=d&&d[j],p=l[w],q=d&&o[w];e.x=l[p-2];e.y=l[p-1];e.bx=S(l[p-4])||e.x;e.by=S(l[p-3])||e.y;f.bx=d&&(S(o[q-4])||f.x);f.by=d&&(S(o[q-3])||f.y);f.x=d&&o[q-2];f.y=d&&o[q-1]}return d?[c,d]:c},null,bo),bx=bm(function(b){var c=[];for(var d=0,e=b[w];d<e;d++){var f={},g=b[d].match(/^([^:]*):?([\d\.]*)/);f.color=a.getRGB(g[1]);if(f.color.error)return null;f.color=f.color.hex;g[2]&&(f.offset=g[2]+"%");c[L](f)}for(d=1,e=c[w]-1;d<e;d++){if(!c[d].offset){var h=S(c[d-1].offset||0),i=0;for(var j=d+1;j<e;j++){if(c[j].offset){i=c[j].offset;break}}if(!i){i=100;j=e}i=S(i);var k=(i-h)/(j-d+1);for(;d<j;d++){h+=k;c[d].offset=h+"%"}}}return c}),by=function(b,c,d,e){var f;if(a.is(b,F)||a.is(b,"object")){f=a.is(b,F)?g.getElementById(b):b;if(f.tagName)return c==null?{container:f,width:f.style.pixelWidth||f.offsetWidth,height:f.style.pixelHeight||f.offsetHeight}:{container:f,width:c,height:d}}else return{container:1,x:b,y:c,width:d,height:e}},bz=function(a,b){var c=this;for(var d in b){if(b[f](d)&&!(d in a))switch(typeof b[d]){case"function":(function(b){a[d]=a===c?b:function(){return b[m](c,arguments)}})(b[d]);break;case"object":a[d]=a[d]||{};bz.call(this,a[d],b[d]);break;default:a[d]=b[d];break}}},bA=function(a,b){a==b.top&&(b.top=a.prev);a==b.bottom&&(b.bottom=a.next);a.next&&(a.next.prev=a.prev);a.prev&&(a.prev.next=a.next)},bB=function(a,b){if(b.top===a)return;bA(a,b);a.next=null;a.prev=b.top;b.top.next=a;b.top=a},bC=function(a,b){if(b.bottom===a)return;bA(a,b);a.next=b.bottom;a.prev=null;b.bottom.prev=a;b.bottom=a},bD=function(a,b,c){bA(a,c);b==c.top&&(c.top=a);b.next&&(b.next.prev=a);a.next=b.next;a.prev=b;b.next=a},bE=function(a,b,c){bA(a,c);b==c.bottom&&(c.bottom=a);b.prev&&(b.prev.next=a);a.prev=b.prev;b.prev=a;a.next=b},bF=function(a){return function(){throw new Error("Raphaël: you are calling to method “"+a+"” of removed object")}};a.pathToRelative=bp;if(a.svg){k.svgns="http://www.w3.org/2000/svg";k.xlink="http://www.w3.org/1999/xlink";Q=function(a){return+a+(~(~a)===a)*0.5};var bG=function(a,b){if(b)for(var c in b)b[f](c)&&a[R](c,r(b[c]));else{a=g.createElementNS(k.svgns,a);a.style.webkitTapHighlightColor="rgba(0,0,0,0)";return a}};a[H]=function(){return"Your browser supports SVG.\nYou are running Raphaël "+this.version};var bH=function(a,b){var c=bG("path");b.canvas&&b.canvas[l](c);var d=new bN(c,b);d.type="path";bK(d,{fill:"none",stroke:"#000",path:a});return d},bI=function(a,b,c){var d="linear",e=0.5,f=0.5,h=a.style;b=r(b)[Y](bd,function(a,b,c){d="radial";if(b&&c){e=S(b);f=S(c);var g=(f>0.5)*2-1;C(e-0.5,2)+C(f-0.5,2)>0.25&&(f=y.sqrt(0.25-C(e-0.5,2))*g+0.5)&&f!=0.5&&(f=f.toFixed(5)-0.00001*g)}return p});b=b[s](/\s*\-\s*/);if(d=="linear"){var i=b.shift();i=-S(i);if(isNaN(i))return null;var j=[0,0,y.cos(i*D/180),y.sin(i*D/180)],k=1/(z(B(j[2]),B(j[3]))||1);j[2]*=k;j[3]*=k;if(j[2]<0){j[0]=-j[2];j[2]=0}if(j[3]<0){j[1]=-j[3];j[3]=0}}var m=bx(b);if(!m)return null;var n=a.getAttribute(I);n=n.match(/^url\(#(.*)\)$/);n&&c.defs.removeChild(g.getElementById(n[1]));var o=bG(d+"Gradient");o.id=bh();bG(o,d=="radial"?{fx:e,fy:f}:{x1:j[0],y1:j[1],x2:j[2],y2:j[3]});c.defs[l](o);for(var q=0,t=m[w];q<t;q++){var u=bG("stop");bG(u,{offset:m[q].offset?m[q].offset:q?"100%":"0%","stop-color":m[q].color||"#fff"});o[l](u)}bG(a,{fill:"url(#"+o.id+")",opacity:1,"fill-opacity":1});h.fill=p;h.opacity=1;h.fillOpacity=1;return 1},bJ=function(b){var c=b.getBBox();bG(b.pattern,{patternTransform:a.format("translate({0},{1})",c.x,c.y)})},bK=function(c,d){var e={"":[0],none:[0],"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},h=c.node,i=c.attrs,j=c.rotate(),k=function(a,b){b=e[x.call(b)];if(b){var c=a.attrs["stroke-width"]||"1",f=({round:c,square:c,butt:0})[a.attrs["stroke-linecap"]||d["stroke-linecap"]]||0,g=[],i=b[w];while(i--)g[i]=b[i]*c+(i%2?1:-1)*f;bG(h,{"stroke-dasharray":g[v](",")})}};d[f]("rotation")&&(j=d.rotation);var m=r(j)[s](b);if(m.length-1){m[1]=+m[1];m[2]=+m[2]}else m=null;S(j)&&c.rotate(0,true);for(var n in d){if(d[f](n)){if(!W[f](n))continue;var o=d[n];i[n]=o;switch(n){case"blur":c.blur(o);break;case"rotation":c.rotate(o,true);break;case"href":case"title":case"target":var t=h.parentNode;if(x.call(t.tagName)!="a"){var u=bG("a");t.insertBefore(u,h);u[l](h);t=u}n=="target"&&o=="blank"?t.setAttributeNS(c.paper.xlink,"show","new"):t.setAttributeNS(c.paper.xlink,n,o);break;case"cursor":h.style.cursor=o;break;case"clip-rect":var y=r(o)[s](b);if(y[w]==4){c.clip&&c.clip.parentNode.parentNode.removeChild(c.clip.parentNode);var z=bG("clipPath"),A=bG("rect");z.id=bh();bG(A,{x:y[0],y:y[1],width:y[2],height:y[3]});z[l](A);c.paper.defs[l](z);bG(h,{"clip-path":"url(#"+z.id+")"});c.clip=A}if(!o){var B=g.getElementById(h.getAttribute("clip-path")[Y](/(^url\(#|\)$)/g,p));B&&B.parentNode.removeChild(B);bG(h,{"clip-path":p});delete c.clip}break;case"path":c.type=="path"&&bG(h,{d:o?i.path=bq(o):"M0,0"});break;case"width":h[R](n,o);if(i.fx){n="x";o=i.x}else break;case"x":i.fx&&(o=-i.x-(i.width||0));case"rx":if(n=="rx"&&c.type=="rect")break;case"cx":m&&(n=="x"||n=="cx")&&(m[1]+=o-i[n]);h[R](n,o);c.pattern&&bJ(c);break;case"height":h[R](n,o);if(i.fy){n="y";o=i.y}else break;case"y":i.fy&&(o=-i.y-(i.height||0));case"ry":if(n=="ry"&&c.type=="rect")break;case"cy":m&&(n=="y"||n=="cy")&&(m[2]+=o-i[n]);h[R](n,o);c.pattern&&bJ(c);break;case"r":c.type=="rect"?bG(h,{rx:o,ry:o}):h[R](n,o);break;case"src":c.type=="image"&&h.setAttributeNS(c.paper.xlink,"href",o);break;case"stroke-width":h.style.strokeWidth=o;h[R](n,o);i["stroke-dasharray"]&&k(c,i["stroke-dasharray"]);break;case"stroke-dasharray":k(c,o);break;case"translation":var C=r(o)[s](b);C[0]=+C[0]||0;C[1]=+C[1]||0;if(m){m[1]+=C[0];m[2]+=C[1]}cz.call(c,C[0],C[1]);break;case"scale":C=r(o)[s](b);c.scale(+C[0]||1,+C[1]||+C[0]||1,isNaN(S(C[2]))?null:+C[2],isNaN(S(C[3]))?null:+C[3]);break;case I:var D=r(o).match(M);if(D){z=bG("pattern");var E=bG("image");z.id=bh();bG(z,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1});bG(E,{x:0,y:0});E.setAttributeNS(c.paper.xlink,"href",D[1]);z[l](E);var F=g.createElement("img");F.style.cssText="position:absolute;left:-9999em;top-9999em";F.onload=function(){bG(z,{width:this.offsetWidth,height:this.offsetHeight});bG(E,{width:this.offsetWidth,height:this.offsetHeight});g.body.removeChild(this);c.paper.safari()};g.body[l](F);F.src=D[1];c.paper.defs[l](z);h.style.fill="url(#"+z.id+")";bG(h,{fill:"url(#"+z.id+")"});c.pattern=z;c.pattern&&bJ(c);break}var G=a.getRGB(o);if(G.error)if((({circle:1,ellipse:1})[f](c.type)||r(o).charAt()!="r")&&bI(h,o,c.paper)){i.gradient=o;i.fill="none";break}else{delete d.gradient;delete i.gradient;!a.is(i.opacity,"undefined")&&a.is(d.opacity,"undefined")&&bG(h,{opacity:i.opacity});!a.is(i["fill-opacity"],"undefined")&&a.is(d["fill-opacity"],"undefined")&&bG(h,{"fill-opacity":i["fill-opacity"]})}G[f]("opacity")&&bG(h,{"fill-opacity":G.opacity>1?G.opacity/100:G.opacity});case"stroke":G=a.getRGB(o);h[R](n,G.hex);n=="stroke"&&G[f]("opacity")&&bG(h,{"stroke-opacity":G.opacity>1?G.opacity/100:G.opacity});break;case"gradient":(({circle:1,ellipse:1})[f](c.type)||r(o).charAt()!="r")&&bI(h,o,c.paper);break;case"opacity":i.gradient&&!i[f]("stroke-opacity")&&bG(h,{"stroke-opacity":o>1?o/100:o});case"fill-opacity":if(i.gradient){var H=g.getElementById(h.getAttribute(I)[Y](/^url\(#|\)$/g,p));if(H){var J=H.getElementsByTagName("stop");J[J[w]-1][R]("stop-opacity",o)}break}default:n=="font-size"&&(o=T(o,10)+"px");var K=n[Y](/(\-.)/g,function(a){return V.call(a.substring(1))});h.style[K]=o;h[R](n,o);break}}}bM(c,d);m?c.rotate(m.join(q)):S(j)&&c.rotate(j,true)},bL=1.2,bM=function(b,c){if(b.type!="text"||!(c[f]("text")||c[f]("font")||c[f]("font-size")||c[f]("x")||c[f]("y")))return;var d=b.attrs,e=b.node,h=e.firstChild?T(g.defaultView.getComputedStyle(e.firstChild,p).getPropertyValue("font-size"),10):10;if(c[f]("text")){d.text=c.text;while(e.firstChild)e.removeChild(e.firstChild);var i=r(c.text)[s]("\n");for(var j=0,k=i[w];j<k;j++)if(i[j]){var m=bG("tspan");j&&bG(m,{dy:h*bL,x:d.x});m[l](g.createTextNode(i[j]));e[l](m)}}else{i=e.getElementsByTagName("tspan");for(j=0,k=i[w];j<k;j++)j&&bG(i[j],{dy:h*bL,x:d.x})}bG(e,{y:d.y});var n=b.getBBox(),o=d.y-(n.y+n.height/2);o&&a.is(o,"finite")&&bG(e,{y:d.y+o})},bN=function(b,c){var d=0,e=0;this[0]=b;this.id=a._oid++;this.node=b;b.raphael=this;this.paper=c;this.attrs=this.attrs||{};this.transformations=[];this._={tx:0,ty:0,rt:{deg:0,cx:0,cy:0},sx:1,sy:1};!c.bottom&&(c.bottom=this);this.prev=c.top;c.top&&(c.top.next=this);c.top=this;this.next=null},bO=bN[e];bN[e].rotate=function(c,d,e){if(this.removed)return this;if(c==null){if(this._.rt.cx)return[this._.rt.deg,this._.rt.cx,this._.rt.cy][v](q);return this._.rt.deg}var f=this.getBBox();c=r(c)[s](b);if(c[w]-1){d=S(c[1]);e=S(c[2])}c=S(c[0]);d!=null&&d!==false?this._.rt.deg=c:this._.rt.deg+=c;e==null&&(d=null);this._.rt.cx=d;this._.rt.cy=e;d=d==null?f.x+f.width/2:d;e=e==null?f.y+f.height/2:e;if(this._.rt.deg){this.transformations[0]=a.format("rotate({0} {1} {2})",this._.rt.deg,d,e);this.clip&&bG(this.clip,{transform:a.format("rotate({0} {1} {2})",-this._.rt.deg,d,e)})}else{this.transformations[0]=p;this.clip&&bG(this.clip,{transform:p})}bG(this.node,{transform:this.transformations[v](q)});return this};bN[e].hide=function(){!this.removed&&(this.node.style.display="none");return this};bN[e].show=function(){!this.removed&&(this.node.style.display="");return this};bN[e].remove=function(){if(this.removed)return;bA(this,this.paper);this.node.parentNode.removeChild(this.node);for(var a in this)delete this[a];this.removed=true};bN[e].getBBox=function(){if(this.removed)return this;if(this.type=="path")return bn(this.attrs.path);if(this.node.style.display=="none"){this.show();var a=true}var b={};try{b=this.node.getBBox()}catch(a){}finally{b=b||{}}if(this.type=="text"){b={x:b.x,y:Infinity,width:0,height:0};for(var c=0,d=this.node.getNumberOfChars();c<d;c++){var e=this.node.getExtentOfChar(c);e.y<b.y&&(b.y=e.y);e.y+e.height-b.y>b.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};bN[e].attr=function(b,c){if(this.removed)return this;if(b==null){var d={};for(var e in this.attrs)this.attrs[f](e)&&(d[e]=this.attrs[e]);this._.rt.deg&&(d.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(d.scale=this.scale());d.gradient&&d.fill=="none"&&(d.fill=d.gradient)&&delete d.gradient;return d}if(c==null&&a.is(b,F)){if(b=="translation")return cz.call(this);if(b=="rotation")return this.rotate();if(b=="scale")return this.scale();if(b==I&&this.attrs.fill=="none"&&this.attrs.gradient)return this.attrs.gradient;return this.attrs[b]}if(c==null&&a.is(b,G)){var g={};for(var h=0,i=b.length;h<i;h++)g[b[h]]=this.attr(b[h]);return g}if(c!=null){var j={};j[b]=c}else b!=null&&a.is(b,"object")&&(j=b);for(var k in this.paper.customAttributes)if(this.paper.customAttributes[f](k)&&j[f](k)&&a.is(this.paper.customAttributes[k],"function")){var l=this.paper.customAttributes[k].apply(this,[][n](j[k]));this.attrs[k]=j[k];for(var m in l)l[f](m)&&(j[m]=l[m])}bK(this,j);return this};bN[e].toFront=function(){if(this.removed)return this;this.node.parentNode[l](this.node);var a=this.paper;a.top!=this&&bB(this,a);return this};bN[e].toBack=function(){if(this.removed)return this;if(this.node.parentNode.firstChild!=this.node){this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild);bC(this,this.paper);var a=this.paper}return this};bN[e].insertAfter=function(a){if(this.removed)return this;var b=a.node||a[a.length-1].node;b.nextSibling?b.parentNode.insertBefore(this.node,b.nextSibling):b.parentNode[l](this.node);bD(this,a,this.paper);return this};bN[e].insertBefore=function(a){if(this.removed)return this;var b=a.node||a[0].node;b.parentNode.insertBefore(this.node,b);bE(this,a,this.paper);return this};bN[e].blur=function(a){var b=this;if(+a!==0){var c=bG("filter"),d=bG("feGaussianBlur");b.attrs.blur=a;c.id=bh();bG(d,{stdDeviation:+a||1.5});c.appendChild(d);b.paper.defs.appendChild(c);b._blur=c;bG(b.node,{filter:"url(#"+c.id+")"})}else{if(b._blur){b._blur.parentNode.removeChild(b._blur);delete b._blur;delete b.attrs.blur}b.node.removeAttribute("filter")}};var bP=function(a,b,c,d){var e=bG("circle");a.canvas&&a.canvas[l](e);var f=new bN(e,a);f.attrs={cx:b,cy:c,r:d,fill:"none",stroke:"#000"};f.type="circle";bG(e,f.attrs);return f},bQ=function(a,b,c,d,e,f){var g=bG("rect");a.canvas&&a.canvas[l](g);var h=new bN(g,a);h.attrs={x:b,y:c,width:d,height:e,r:f||0,rx:f||0,ry:f||0,fill:"none",stroke:"#000"};h.type="rect";bG(g,h.attrs);return h},bR=function(a,b,c,d,e){var f=bG("ellipse");a.canvas&&a.canvas[l](f);var g=new bN(f,a);g.attrs={cx:b,cy:c,rx:d,ry:e,fill:"none",stroke:"#000"};g.type="ellipse";bG(f,g.attrs);return g},bS=function(a,b,c,d,e,f){var g=bG("image");bG(g,{x:c,y:d,width:e,height:f,preserveAspectRatio:"none"});g.setAttributeNS(a.xlink,"href",b);a.canvas&&a.canvas[l](g);var h=new bN(g,a);h.attrs={x:c,y:d,width:e,height:f,src:b};h.type="image";return h},bT=function(a,b,c,d){var e=bG("text");bG(e,{x:b,y:c,"text-anchor":"middle"});a.canvas&&a.canvas[l](e);var f=new bN(e,a);f.attrs={x:b,y:c,"text-anchor":"middle",text:d,font:W.font,stroke:"none",fill:"#000"};f.type="text";bK(f,f.attrs);return f},bU=function(a,b){this.width=a||this.width;this.height=b||this.height;this.canvas[R]("width",this.width);this.canvas[R]("height",this.height);return this},bV=function(){var b=by[m](0,arguments),c=b&&b.container,d=b.x,e=b.y,f=b.width,h=b.height;if(!c)throw new Error("SVG container not found.");var i=bG("svg");d=d||0;e=e||0;f=f||512;h=h||342;bG(i,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:f,height:h});if(c==1){i.style.cssText="position:absolute;left:"+d+"px;top:"+e+"px";g.body[l](i)}else c.firstChild?c.insertBefore(i,c.firstChild):c[l](i);c=new j;c.width=f;c.height=h;c.canvas=i;bz.call(c,c,a.fn);c.clear();return c};k.clear=function(){var a=this.canvas;while(a.firstChild)a.removeChild(a.firstChild);this.bottom=this.top=null;(this.desc=bG("desc"))[l](g.createTextNode("Created with Raphaël"));a[l](this.desc);a[l](this.defs=bG("defs"))};k.remove=function(){this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas);for(var a in this)this[a]=bF(a)}}if(a.vml){var bW={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},bX=/([clmz]),?([^clmz]*)/gi,bY=/ progid:\S+Blur\([^\)]+\)/g,bZ=/-?[^,\s-]+/g,b$=1000+q+1000,b_=10,ca={path:1,rect:1},cb=function(a){var b=/[ahqstv]/ig,c=bq;r(a).match(b)&&(c=bw);b=/[clmz]/g;if(c==bq&&!r(a).match(b)){var d=r(a)[Y](bX,function(a,b,c){var d=[],e=x.call(b)=="m",f=bW[b];c[Y](bZ,function(a){if(e&&d[w]==2){f+=d+bW[b=="m"?"l":"L"];d=[]}d[L](Q(a*b_))});return f+d});return d}var e=c(a),f,g;d=[];for(var h=0,i=e[w];h<i;h++){f=e[h];g=x.call(e[h][0]);g=="z"&&(g="x");for(var j=1,k=f[w];j<k;j++)g+=Q(f[j]*b_)+(j!=k-1?",":p);d[L](g)}return d[v](q)};a[H]=function(){return"Your browser doesn’t support SVG. Falling down to VML.\nYou are running Raphaël "+this.version};bH=function(a,b){var c=cd("group");c.style.cssText="position:absolute;left:0;top:0;width:"+b.width+"px;height:"+b.height+"px";c.coordsize=b.coordsize;c.coordorigin=b.coordorigin;var d=cd("shape"),e=d.style;e.width=b.width+"px";e.height=b.height+"px";d.coordsize=b$;d.coordorigin=b.coordorigin;c[l](d);var f=new bN(d,c,b),g={fill:"none",stroke:"#000"};a&&(g.path=a);f.type="path";f.path=[];f.Path=p;bK(f,g);b.canvas[l](c);return f};bK=function(c,d){c.attrs=c.attrs||{};var e=c.node,h=c.attrs,i=e.style,j,k=(d.x!=h.x||d.y!=h.y||d.width!=h.width||d.height!=h.height||d.r!=h.r)&&c.type=="rect",m=c;for(var n in d)d[f](n)&&(h[n]=d[n]);if(k){h.path=cc(h.x,h.y,h.width,h.height,h.r);c.X=h.x;c.Y=h.y;c.W=h.width;c.H=h.height}d.href&&(e.href=d.href);d.title&&(e.title=d.title);d.target&&(e.target=d.target);d.cursor&&(i.cursor=d.cursor);"blur"in d&&c.blur(d.blur);if(d.path&&c.type=="path"||k)e.path=cb(h.path);d.rotation!=null&&c.rotate(d.rotation,true);if(d.translation){j=r(d.translation)[s](b);cz.call(c,j[0],j[1]);if(c._.rt.cx!=null){c._.rt.cx+=+j[0];c._.rt.cy+=+j[1];c.setBox(c.attrs,j[0],j[1])}}if(d.scale){j=r(d.scale)[s](b);c.scale(+j[0]||1,+j[1]||+j[0]||1,+j[2]||null,+j[3]||null)}if("clip-rect"in d){var o=r(d["clip-rect"])[s](b);if(o[w]==4){o[2]=+o[2]+ +o[0];o[3]=+o[3]+ +o[1];var q=e.clipRect||g.createElement("div"),t=q.style,u=e.parentNode;t.clip=a.format("rect({1}px {2}px {3}px {0}px)",o);if(!e.clipRect){t.position="absolute";t.top=0;t.left=0;t.width=c.paper.width+"px";t.height=c.paper.height+"px";u.parentNode.insertBefore(q,u);q[l](u);e.clipRect=q}}d["clip-rect"]||e.clipRect&&(e.clipRect.style.clip=p)}c.type=="image"&&d.src&&(e.src=d.src);if(c.type=="image"&&d.opacity){e.filterOpacity=U+".Alpha(opacity="+d.opacity*100+")";i.filter=(e.filterMatrix||p)+(e.filterOpacity||p)}d.font&&(i.font=d.font);d["font-family"]&&(i.fontFamily="\""+d["font-family"][s](",")[0][Y](/^['"]+|['"]+$/g,p)+"\"");d["font-size"]&&(i.fontSize=d["font-size"]);d["font-weight"]&&(i.fontWeight=d["font-weight"]);d["font-style"]&&(i.fontStyle=d["font-style"]);if(d.opacity!=null||d["stroke-width"]!=null||d.fill!=null||d.stroke!=null||d["stroke-width"]!=null||d["stroke-opacity"]!=null||d["fill-opacity"]!=null||d["stroke-dasharray"]!=null||d["stroke-miterlimit"]!=null||d["stroke-linejoin"]!=null||d["stroke-linecap"]!=null){e=c.shape||e;var v=e.getElementsByTagName(I)&&e.getElementsByTagName(I)[0],x=false;!v&&(x=v=cd(I));if("fill-opacity"in d||"opacity"in d){var y=((+h["fill-opacity"]+1||2)-1)*((+h.opacity+1||2)-1)*((+a.getRGB(d.fill).o+1||2)-1);y=A(z(y,0),1);v.opacity=y}d.fill&&(v.on=true);if(v.on==null||d.fill=="none")v.on=false;if(v.on&&d.fill){var B=d.fill.match(M);if(B){v.src=B[1];v.type="tile"}else{v.color=a.getRGB(d.fill).hex;v.src=p;v.type="solid";if(a.getRGB(d.fill).error&&(m.type in{circle:1,ellipse:1}||r(d.fill).charAt()!="r")&&bI(m,d.fill)){h.fill="none";h.gradient=d.fill}}}x&&e[l](v);var C=e.getElementsByTagName("stroke")&&e.getElementsByTagName("stroke")[0],D=false;!C&&(D=C=cd("stroke"));if(d.stroke&&d.stroke!="none"||d["stroke-width"]||d["stroke-opacity"]!=null||d["stroke-dasharray"]||d["stroke-miterlimit"]||d["stroke-linejoin"]||d["stroke-linecap"])C.on=true;(d.stroke=="none"||C.on==null||d.stroke==0||d["stroke-width"]==0)&&(C.on=false);var E=a.getRGB(d.stroke);C.on&&d.stroke&&(C.color=E.hex);y=((+h["stroke-opacity"]+1||2)-1)*((+h.opacity+1||2)-1)*((+E.o+1||2)-1);var F=(S(d["stroke-width"])||1)*0.75;y=A(z(y,0),1);d["stroke-width"]==null&&(F=h["stroke-width"]);d["stroke-width"]&&(C.weight=F);F&&F<1&&(y*=F)&&(C.weight=1);C.opacity=y;d["stroke-linejoin"]&&(C.joinstyle=d["stroke-linejoin"]||"miter");C.miterlimit=d["stroke-miterlimit"]||8;d["stroke-linecap"]&&(C.endcap=d["stroke-linecap"]=="butt"?"flat":d["stroke-linecap"]=="square"?"square":"round");if(d["stroke-dasharray"]){var G={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};C.dashstyle=G[f](d["stroke-dasharray"])?G[d["stroke-dasharray"]]:p}D&&e[l](C)}if(m.type=="text"){i=m.paper.span.style;h.font&&(i.font=h.font);h["font-family"]&&(i.fontFamily=h["font-family"]);h["font-size"]&&(i.fontSize=h["font-size"]);h["font-weight"]&&(i.fontWeight=h["font-weight"]);h["font-style"]&&(i.fontStyle=h["font-style"]);m.node.string&&(m.paper.span.innerHTML=r(m.node.string)[Y](/</g,"<")[Y](/&/g,"&")[Y](/\n/g,"<br>"));m.W=h.w=m.paper.span.offsetWidth;m.H=h.h=m.paper.span.offsetHeight;m.X=h.x;m.Y=h.y+Q(m.H/2);switch(h["text-anchor"]){case"start":m.node.style["v-text-align"]="left";m.bbx=Q(m.W/2);break;case"end":m.node.style["v-text-align"]="right";m.bbx=-Q(m.W/2);break;default:m.node.style["v-text-align"]="center";break}}};bI=function(a,b){a.attrs=a.attrs||{};var c=a.attrs,d,e="linear",f=".5 .5";a.attrs.gradient=b;b=r(b)[Y](bd,function(a,b,c){e="radial";if(b&&c){b=S(b);c=S(c);C(b-0.5,2)+C(c-0.5,2)>0.25&&(c=y.sqrt(0.25-C(b-0.5,2))*((c>0.5)*2-1)+0.5);f=b+q+c}return p});b=b[s](/\s*\-\s*/);if(e=="linear"){var g=b.shift();g=-S(g);if(isNaN(g))return null}var h=bx(b);if(!h)return null;a=a.shape||a.node;d=a.getElementsByTagName(I)[0]||cd(I);!d.parentNode&&a.appendChild(d);if(h[w]){d.on=true;d.method="none";d.color=h[0].color;d.color2=h[h[w]-1].color;var i=[];for(var j=0,k=h[w];j<k;j++)h[j].offset&&i[L](h[j].offset+q+h[j].color);d.colors&&(d.colors.value=i[w]?i[v]():"0% "+d.color);if(e=="radial"){d.type="gradientradial";d.focus="100%";d.focussize=f;d.focusposition=f}else{d.type="gradient";d.angle=(270-g)%360}}return 1};bN=function(b,c,d){var e=0,f=0,g=0,h=1;this[0]=b;this.id=a._oid++;this.node=b;b.raphael=this;this.X=0;this.Y=0;this.attrs={};this.Group=c;this.paper=d;this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1};!d.bottom&&(d.bottom=this);this.prev=d.top;d.top&&(d.top.next=this);d.top=this;this.next=null};bO=bN[e];bO.rotate=function(a,c,d){if(this.removed)return this;if(a==null){if(this._.rt.cx)return[this._.rt.deg,this._.rt.cx,this._.rt.cy][v](q);return this._.rt.deg}a=r(a)[s](b);if(a[w]-1){c=S(a[1]);d=S(a[2])}a=S(a[0]);c!=null?this._.rt.deg=a:this._.rt.deg+=a;d==null&&(c=null);this._.rt.cx=c;this._.rt.cy=d;this.setBox(this.attrs,c,d);this.Group.style.rotation=this._.rt.deg;return this};bO.setBox=function(a,b,c){if(this.removed)return this;var d=this.Group.style,e=this.shape&&this.shape.style||this.node.style;a=a||{};for(var g in a)a[f](g)&&(this.attrs[g]=a[g]);b=b||this._.rt.cx;c=c||this._.rt.cy;var h=this.attrs,i,j,k,l;switch(this.type){case"circle":i=h.cx-h.r;j=h.cy-h.r;k=l=h.r*2;break;case"ellipse":i=h.cx-h.rx;j=h.cy-h.ry;k=h.rx*2;l=h.ry*2;break;case"image":i=+h.x;j=+h.y;k=h.width||0;l=h.height||0;break;case"text":this.textpath.v=["m",Q(h.x),", ",Q(h.y-2),"l",Q(h.x)+1,", ",Q(h.y-2)][v](p);i=h.x-Q(this.W/2);j=h.y-this.H/2;k=this.W;l=this.H;break;case"rect":case"path":if(this.attrs.path){var m=bn(this.attrs.path);i=m.x;j=m.y;k=m.width;l=m.height}else{i=0;j=0;k=this.paper.width;l=this.paper.height}break;default:i=0;j=0;k=this.paper.width;l=this.paper.height;break}b=b==null?i+k/2:b;c=c==null?j+l/2:c;var n=b-this.paper.width/2,o=c-this.paper.height/2,q;d.left!=(q=n+"px")&&(d.left=q);d.top!=(q=o+"px")&&(d.top=q);this.X=ca[f](this.type)?-n:i;this.Y=ca[f](this.type)?-o:j;this.W=k;this.H=l;if(ca[f](this.type)){e.left!=(q=-n*b_+"px")&&(e.left=q);e.top!=(q=-o*b_+"px")&&(e.top=q)}else if(this.type=="text"){e.left!=(q=-n+"px")&&(e.left=q);e.top!=(q=-o+"px")&&(e.top=q)}else{d.width!=(q=this.paper.width+"px")&&(d.width=q);d.height!=(q=this.paper.height+"px")&&(d.height=q);e.left!=(q=i-n+"px")&&(e.left=q);e.top!=(q=j-o+"px")&&(e.top=q);e.width!=(q=k+"px")&&(e.width=q);e.height!=(q=l+"px")&&(e.height=q)}};bO.hide=function(){!this.removed&&(this.Group.style.display="none");return this};bO.show=function(){!this.removed&&(this.Group.style.display="block");return this};bO.getBBox=function(){if(this.removed)return this;if(ca[f](this.type))return bn(this.attrs.path);return{x:this.X+(this.bbx||0),y:this.Y,width:this.W,height:this.H}};bO.remove=function(){if(this.removed)return;bA(this,this.paper);this.node.parentNode.removeChild(this.node);this.Group.parentNode.removeChild(this.Group);this.shape&&this.shape.parentNode.removeChild(this.shape);for(var a in this)delete this[a];this.removed=true};bO.attr=function(b,c){if(this.removed)return this;if(b==null){var d={};for(var e in this.attrs)this.attrs[f](e)&&(d[e]=this.attrs[e]);this._.rt.deg&&(d.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(d.scale=this.scale());d.gradient&&d.fill=="none"&&(d.fill=d.gradient)&&delete d.gradient;return d}if(c==null&&a.is(b,"string")){if(b=="translation")return cz.call(this);if(b=="rotation")return this.rotate();if(b=="scale")return this.scale();if(b==I&&this.attrs.fill=="none"&&this.attrs.gradient)return this.attrs.gradient;return this.attrs[b]}if(this.attrs&&c==null&&a.is(b,G)){var g,h={};for(e=0,g=b[w];e<g;e++)h[b[e]]=this.attr(b[e]);return h}var i;if(c!=null){i={};i[b]=c}c==null&&a.is(b,"object")&&(i=b);if(i){for(var j in this.paper.customAttributes)if(this.paper.customAttributes[f](j)&&i[f](j)&&a.is(this.paper.customAttributes[j],"function")){var k=this.paper.customAttributes[j].apply(this,[][n](i[j]));this.attrs[j]=i[j];for(var l in k)k[f](l)&&(i[l]=k[l])}i.text&&this.type=="text"&&(this.node.string=i.text);bK(this,i);i.gradient&&(({circle:1,ellipse:1})[f](this.type)||r(i.gradient).charAt()!="r")&&bI(this,i.gradient);(!ca[f](this.type)||this._.rt.deg)&&this.setBox(this.attrs)}return this};bO.toFront=function(){!this.removed&&this.Group.parentNode[l](this.Group);this.paper.top!=this&&bB(this,this.paper);return this};bO.toBack=function(){if(this.removed)return this;if(this.Group.parentNode.firstChild!=this.Group){this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild);bC(this,this.paper)}return this};bO.insertAfter=function(a){if(this.removed)return this;a.constructor==cC&&(a=a[a.length-1]);a.Group.nextSibling?a.Group.parentNode.insertBefore(this.Group,a.Group.nextSibling):a.Group.parentNode[l](this.Group);bD(this,a,this.paper);return this};bO.insertBefore=function(a){if(this.removed)return this;a.constructor==cC&&(a=a[0]);a.Group.parentNode.insertBefore(this.Group,a.Group);bE(this,a,this.paper);return this};bO.blur=function(b){var c=this.node.runtimeStyle,d=c.filter;d=d.replace(bY,p);if(+b!==0){this.attrs.blur=b;c.filter=d+q+U+".Blur(pixelradius="+(+b||1.5)+")";c.margin=a.format("-{0}px 0 0 -{0}px",Q(+b||1.5))}else{c.filter=d;c.margin=0;delete this.attrs.blur}};bP=function(a,b,c,d){var e=cd("group"),f=cd("oval"),g=f.style;e.style.cssText="position:absolute;left:0;top:0;width:"+a.width+"px;height:"+a.height+"px";e.coordsize=b$;e.coordorigin=a.coordorigin;e[l](f);var h=new bN(f,e,a);h.type="circle";bK(h,{stroke:"#000",fill:"none"});h.attrs.cx=b;h.attrs.cy=c;h.attrs.r=d;h.setBox({x:b-d,y:c-d,width:d*2,height:d*2});a.canvas[l](e);return h};function cc(b,c,d,e,f){return f?a.format("M{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},{4}l0,{7}a{3},{3},0,0,1,{3},{4}z",b+f,c,d-f*2,f,-f,e-f*2,f*2-d,f*2-e):a.format("M{0},{1}l{2},0,0,{3},{4},0z",b,c,d,e,-d)}bQ=function(a,b,c,d,e,f){var g=cc(b,c,d,e,f),h=a.path(g),i=h.attrs;h.X=i.x=b;h.Y=i.y=c;h.W=i.width=d;h.H=i.height=e;i.r=f;i.path=g;h.type="rect";return h};bR=function(a,b,c,d,e){var f=cd("group"),g=cd("oval"),h=g.style;f.style.cssText="position:absolute;left:0;top:0;width:"+a.width+"px;height:"+a.height+"px";f.coordsize=b$;f.coordorigin=a.coordorigin;f[l](g);var i=new bN(g,f,a);i.type="ellipse";bK(i,{stroke:"#000"});i.attrs.cx=b;i.attrs.cy=c;i.attrs.rx=d;i.attrs.ry=e;i.setBox({x:b-d,y:c-e,width:d*2,height:e*2});a.canvas[l](f);return i};bS=function(a,b,c,d,e,f){var g=cd("group"),h=cd("image");g.style.cssText="position:absolute;left:0;top:0;width:"+a.width+"px;height:"+a.height+"px";g.coordsize=b$;g.coordorigin=a.coordorigin;h.src=b;g[l](h);var i=new bN(h,g,a);i.type="image";i.attrs.src=b;i.attrs.x=c;i.attrs.y=d;i.attrs.w=e;i.attrs.h=f;i.setBox({x:c,y:d,width:e,height:f});a.canvas[l](g);return i};bT=function(b,c,d,e){var f=cd("group"),g=cd("shape"),h=g.style,i=cd("path"),j=i.style,k=cd("textpath");f.style.cssText="position:absolute;left:0;top:0;width:"+b.width+"px;height:"+b.height+"px";f.coordsize=b$;f.coordorigin=b.coordorigin;i.v=a.format("m{0},{1}l{2},{1}",Q(c*10),Q(d*10),Q(c*10)+1);i.textpathok=true;h.width=b.width;h.height=b.height;k.string=r(e);k.on=true;g[l](k);g[l](i);f[l](g);var m=new bN(k,f,b);m.shape=g;m.textpath=i;m.type="text";m.attrs.text=e;m.attrs.x=c;m.attrs.y=d;m.attrs.w=1;m.attrs.h=1;bK(m,{font:W.font,stroke:"none",fill:"#000"});m.setBox();b.canvas[l](f);return m};bU=function(a,b){var c=this.canvas.style;a==+a&&(a+="px");b==+b&&(b+="px");c.width=a;c.height=b;c.clip="rect(0 "+a+" "+b+" 0)";return this};var cd;g.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");try{!g.namespaces.rvml&&g.namespaces.add("rvml","urn:schemas-microsoft-com:vml");cd=function(a){return g.createElement("<rvml:"+a+" class=\"rvml\">")}}catch(a){cd=function(a){return g.createElement("<"+a+" xmlns=\"urn:schemas-microsoft.com:vml\" class=\"rvml\">")}}bV=function(){var b=by[m](0,arguments),c=b.container,d=b.height,e,f=b.width,h=b.x,i=b.y;if(!c)throw new Error("VML container not found.");var k=new j,n=k.canvas=g.createElement("div"),o=n.style;h=h||0;i=i||0;f=f||512;d=d||342;f==+f&&(f+="px");d==+d&&(d+="px");k.width=1000;k.height=1000;k.coordsize=b_*1000+q+b_*1000;k.coordorigin="0 0";k.span=g.createElement("span");k.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";n[l](k.span);o.cssText=a.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",f,d);if(c==1){g.body[l](n);o.left=h+"px";o.top=i+"px";o.position="absolute"}else c.firstChild?c.insertBefore(n,c.firstChild):c[l](n);bz.call(k,k,a.fn);return k};k.clear=function(){this.canvas.innerHTML=p;this.span=g.createElement("span");this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";this.canvas[l](this.span);this.bottom=this.top=null};k.remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var a in this)this[a]=bF(a);return true}}var ce=navigator.userAgent.match(/Version\\x2f(.*?)\s/);navigator.vendor=="Apple Computer, Inc."&&(ce&&ce[1]<4||navigator.platform.slice(0,2)=="iP")?k.safari=function(){var a=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});h.setTimeout(function(){a.remove()})}:k.safari=function(){};var cf=function(){this.returnValue=false},cg=function(){return this.originalEvent.preventDefault()},ch=function(){this.cancelBubble=true},ci=function(){return this.originalEvent.stopPropagation()},cj=(function(){{if(g.addEventListener)return function(a,b,c,d){var e=o&&u[b]?u[b]:b,g=function(e){if(o&&u[f](b))for(var g=0,h=e.targetTouches&&e.targetTouches.length;g<h;g++){if(e.targetTouches[g].target==a){var i=e;e=e.targetTouches[g];e.originalEvent=i;e.preventDefault=cg;e.stopPropagation=ci;break}}return c.call(d,e)};a.addEventListener(e,g,false);return function(){a.removeEventListener(e,g,false);return true}};if(g.attachEvent)return function(a,b,c,d){var e=function(a){a=a||h.event;a.preventDefault=a.preventDefault||cf;a.stopPropagation=a.stopPropagation||ch;return c.call(d,a)};a.attachEvent("on"+b,e);var f=function(){a.detachEvent("on"+b,e);return true};return f}}})(),ck=[],cl=function(a){var b=a.clientX,c=a.clientY,d=g.documentElement.scrollTop||g.body.scrollTop,e=g.documentElement.scrollLeft||g.body.scrollLeft,f,h=ck.length;while(h--){f=ck[h];if(o){var i=a.touches.length,j;while(i--){j=a.touches[i];if(j.identifier==f.el._drag.id){b=j.clientX;c=j.clientY;(a.originalEvent?a.originalEvent:a).preventDefault();break}}}else a.preventDefault();b+=e;c+=d;f.move&&f.move.call(f.move_scope||f.el,b-f.el._drag.x,c-f.el._drag.y,b,c,a)}},cm=function(b){a.unmousemove(cl).unmouseup(cm);var c=ck.length,d;while(c--){d=ck[c];d.el._drag={};d.end&&d.end.call(d.end_scope||d.start_scope||d.move_scope||d.el,b)}ck=[]};for(var cn=t[w];cn--;)(function(b){a[b]=bN[e][b]=function(c,d){if(a.is(c,"function")){this.events=this.events||[];this.events.push({name:b,f:c,unbind:cj(this.shape||this.node||g,b,c,d||this)})}return this};a["un"+b]=bN[e]["un"+b]=function(a){var c=this.events,d=c[w];while(d--)if(c[d].name==b&&c[d].f==a){c[d].unbind();c.splice(d,1);!c.length&&delete this.events;return this}return this}})(t[cn]);bO.hover=function(a,b,c,d){return this.mouseover(a,c).mouseout(b,d||c)};bO.unhover=function(a,b){return this.unmouseover(a).unmouseout(b)};bO.drag=function(b,c,d,e,f,h){this._drag={};this.mousedown(function(i){(i.originalEvent||i).preventDefault();var j=g.documentElement.scrollTop||g.body.scrollTop,k=g.documentElement.scrollLeft||g.body.scrollLeft;this._drag.x=i.clientX+k;this._drag.y=i.clientY+j;this._drag.id=i.identifier;c&&c.call(f||e||this,i.clientX+k,i.clientY+j,i);!ck.length&&a.mousemove(cl).mouseup(cm);ck.push({el:this,move:b,end:d,move_scope:e,start_scope:f,end_scope:h})});return this};bO.undrag=function(b,c,d){var e=ck.length;while(e--)ck[e].el==this&&(ck[e].move==b&&ck[e].end==d)&&ck.splice(e++,1);!ck.length&&a.unmousemove(cl).unmouseup(cm)};k.circle=function(a,b,c){return bP(this,a||0,b||0,c||0)};k.rect=function(a,b,c,d,e){return bQ(this,a||0,b||0,c||0,d||0,e||0)};k.ellipse=function(a,b,c,d){return bR(this,a||0,b||0,c||0,d||0)};k.path=function(b){b&&!a.is(b,F)&&!a.is(b[0],G)&&(b+=p);return bH(a.format[m](a,arguments),this)};k.image=function(a,b,c,d,e){return bS(this,a||"about:blank",b||0,c||0,d||0,e||0)};k.text=function(a,b,c){return bT(this,a||0,b||0,r(c))};k.set=function(a){arguments[w]>1&&(a=Array[e].splice.call(arguments,0,arguments[w]));return new cC(a)};k.setSize=bU;k.top=k.bottom=null;k.raphael=a;function co(){return this.x+q+this.y}bO.resetScale=function(){if(this.removed)return this;this._.sx=1;this._.sy=1;this.attrs.scale="1 1"};bO.scale=function(a,b,c,d){if(this.removed)return this;if(a==null&&b==null)return{x:this._.sx,y:this._.sy,toString:co};b=b||a;!(+b)&&(b=a);var e,f,g,h,i=this.attrs;if(a!=0){var j=this.getBBox(),k=j.x+j.width/2,l=j.y+j.height/2,m=B(a/this._.sx),o=B(b/this._.sy);c=+c||c==0?c:k;d=+d||d==0?d:l;var r=this._.sx>0,s=this._.sy>0,t=~(~(a/B(a))),u=~(~(b/B(b))),x=m*t,y=o*u,z=this.node.style,A=c+B(k-c)*x*(k>c==r?1:-1),C=d+B(l-d)*y*(l>d==s?1:-1),D=a*t>b*u?o:m;switch(this.type){case"rect":case"image":var E=i.width*m,F=i.height*o;this.attr({height:F,r:i.r*D,width:E,x:A-E/2,y:C-F/2});break;case"circle":case"ellipse":this.attr({rx:i.rx*m,ry:i.ry*o,r:i.r*D,cx:A,cy:C});break;case"text":this.attr({x:A,y:C});break;case"path":var G=bp(i.path),H=true,I=r?x:m,J=s?y:o;for(var K=0,L=G[w];K<L;K++){var M=G[K],N=V.call(M[0]);{if(N=="M"&&H)continue;H=false}if(N=="A"){M[G[K][w]-2]*=I;M[G[K][w]-1]*=J;M[1]*=m;M[2]*=o;M[5]=+(t+u?!(!(+M[5])):!(+M[5]))}else if(N=="H")for(var O=1,P=M[w];O<P;O++)M[O]*=I;else if(N=="V")for(O=1,P=M[w];O<P;O++)M[O]*=J;else for(O=1,P=M[w];O<P;O++)M[O]*=O%2?I:J}var Q=bn(G);e=A-Q.x-Q.width/2;f=C-Q.y-Q.height/2;G[0][1]+=e;G[0][2]+=f;this.attr({path:G});break}if(this.type in{text:1,image:1}&&(t!=1||u!=1))if(this.transformations){this.transformations[2]="scale("[n](t,",",u,")");this.node[R]("transform",this.transformations[v](q));e=t==-1?-i.x-(E||0):i.x;f=u==-1?-i.y-(F||0):i.y;this.attr({x:e,y:f});i.fx=t-1;i.fy=u-1}else{this.node.filterMatrix=U+".Matrix(M11="[n](t,", M12=0, M21=0, M22=",u,", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')");z.filter=(this.node.filterMatrix||p)+(this.node.filterOpacity||p)}else if(this.transformations){this.transformations[2]=p;this.node[R]("transform",this.transformations[v](q));i.fx=0;i.fy=0}else{this.node.filterMatrix=p;z.filter=(this.node.filterMatrix||p)+(this.node.filterOpacity||p)}i.scale=[a,b,c,d][v](q);this._.sx=a;this._.sy=b}return this};bO.clone=function(){if(this.removed)return null;var a=this.attr();delete a.scale;delete a.translation;return this.paper[this.type]().attr(a)};var cp={},cq=function(b,c,d,e,f,g,h,i,j){var k=0,l=100,m=[b,c,d,e,f,g,h,i].join(),n=cp[m],o,p;!n&&(cp[m]=n={data:[]});n.timer&&clearTimeout(n.timer);n.timer=setTimeout(function(){delete cp[m]},2000);if(j!=null){var q=cq(b,c,d,e,f,g,h,i);l=~(~q)*10}for(var r=0;r<l+1;r++){if(n.data[j]>r)p=n.data[r*l];else{p=a.findDotsAtSegment(b,c,d,e,f,g,h,i,r/l);n.data[r]=p}r&&(k+=C(C(o.x-p.x,2)+C(o.y-p.y,2),0.5));if(j!=null&&k>=j)return p;o=p}if(j==null)return k},cr=function(b,c){return function(d,e,f){d=bw(d);var g,h,i,j,k="",l={},m,n=0;for(var o=0,p=d.length;o<p;o++){i=d[o];if(i[0]=="M"){g=+i[1];h=+i[2]}else{j=cq(g,h,i[1],i[2],i[3],i[4],i[5],i[6]);if(n+j>e){if(c&&!l.start){m=cq(g,h,i[1],i[2],i[3],i[4],i[5],i[6],e-n);k+=["C",m.start.x,m.start.y,m.m.x,m.m.y,m.x,m.y];if(f)return k;l.start=k;k=["M",m.x,m.y+"C",m.n.x,m.n.y,m.end.x,m.end.y,i[5],i[6]][v]();n+=j;g=+i[5];h=+i[6];continue}if(!b&&!c){m=cq(g,h,i[1],i[2],i[3],i[4],i[5],i[6],e-n);return{x:m.x,y:m.y,alpha:m.alpha}}}n+=j;g=+i[5];h=+i[6]}k+=i}l.end=k;m=b?n:c?l:a.findDotsAtSegment(g,h,i[1],i[2],i[3],i[4],i[5],i[6],1);m.alpha&&(m={x:m.x,y:m.y,alpha:m.alpha});return m}},cs=cr(1),ct=cr(),cu=cr(0,1);bO.getTotalLength=function(){if(this.type!="path")return;if(this.node.getTotalLength)return this.node.getTotalLength();return cs(this.attrs.path)};bO.getPointAtLength=function(a){if(this.type!="path")return;return ct(this.attrs.path,a)};bO.getSubpath=function(a,b){if(this.type!="path")return;if(B(this.getTotalLength()-b)<"1e-6")return cu(this.attrs.path,a).end;var c=cu(this.attrs.path,b,1);return a?cu(c,a).end:c};a.easing_formulas={linear:function(a){return a},"<":function(a){return C(a,3)},">":function(a){return C(a-1,3)+1},"<>":function(a){a=a*2;if(a<1)return C(a,3)/2;a-=2;return(C(a,3)+2)/2},backIn:function(a){var b=1.70158;return a*a*((b+1)*a-b)},backOut:function(a){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 C(2,-10*a)*y.sin((a-c)*(2*D)/b)+1},bounce:function(a){var b=7.5625,c=2.75,d;if(a<1/c)d=b*a*a;else if(a<2/c){a-=1.5/c;d=b*a*a+0.75}else if(a<2.5/c){a-=2.25/c;d=b*a*a+0.9375}else{a-=2.625/c;d=b*a*a+0.984375}return d}};var cv=[],cw=function(){var b=+(new Date);for(var c=0;c<cv[w];c++){var d=cv[c];if(d.stop||d.el.removed)continue;var e=b-d.start,g=d.ms,h=d.easing,i=d.from,j=d.diff,k=d.to,l=d.t,m=d.el,n={},o;if(e<g){var r=h(e/g);for(var s in i)if(i[f](s)){switch(X[s]){case"along":o=r*g*j[s];k.back&&(o=k.len-o);var t=ct(k[s],o);m.translate(j.sx-j.x||0,j.sy-j.y||0);j.x=t.x;j.y=t.y;m.translate(t.x-j.sx,t.y-j.sy);k.rot&&m.rotate(j.r+t.alpha,t.x,t.y);break;case E:o=+i[s]+r*g*j[s];break;case"colour":o="rgb("+[cy(Q(i[s].r+r*g*j[s].r)),cy(Q(i[s].g+r*g*j[s].g)),cy(Q(i[s].b+r*g*j[s].b))][v](",")+")";break;case"path":o=[];for(var u=0,x=i[s][w];u<x;u++){o[u]=[i[s][u][0]];for(var y=1,z=i[s][u][w];y<z;y++)o[u][y]=+i[s][u][y]+r*g*j[s][u][y];o[u]=o[u][v](q)}o=o[v](q);break;case"csv":switch(s){case"translation":var A=r*g*j[s][0]-l.x,B=r*g*j[s][1]-l.y;l.x+=A;l.y+=B;o=A+q+B;break;case"rotation":o=+i[s][0]+r*g*j[s][0];i[s][1]&&(o+=","+i[s][1]+","+i[s][2]);break;case"scale":o=[+i[s][0]+r*g*j[s][0],+i[s][1]+r*g*j[s][1],2 in k[s]?k[s][2]:p,3 in k[s]?k[s][3]:p][v](q);break;case"clip-rect":o=[];u=4;while(u--)o[u]=+i[s][u]+r*g*j[s][u];break}break;default:var C=[].concat(i[s]);o=[];u=m.paper.customAttributes[s].length;while(u--)o[u]=+C[u]+r*g*j[s][u];break}n[s]=o}m.attr(n);m._run&&m._run.call(m)}else{if(k.along){t=ct(k.along,k.len*!k.back);m.translate(j.sx-(j.x||0)+t.x-j.sx,j.sy-(j.y||0)+t.y-j.sy);k.rot&&m.rotate(j.r+t.alpha,t.x,t.y)}(l.x||l.y)&&m.translate(-l.x,-l.y);k.scale&&(k.scale+=p);m.attr(k);cv.splice(c--,1)}}a.svg&&m&&m.paper&&m.paper.safari();cv[w]&&setTimeout(cw)},cx=function(b,c,d,e,f){var g=d-e;c.timeouts.push(setTimeout(function(){a.is(f,"function")&&f.call(c);c.animate(b,g,b.easing)},e))},cy=function(a){return z(A(a,255),0)},cz=function(a,b){if(a==null)return{x:this._.tx,y:this._.ty,toString:co};this._.tx+=+a;this._.ty+=+b;switch(this.type){case"circle":case"ellipse":this.attr({cx:+a+this.attrs.cx,cy:+b+this.attrs.cy});break;case"rect":case"image":case"text":this.attr({x:+a+this.attrs.x,y:+b+this.attrs.y});break;case"path":var c=bp(this.attrs.path);c[0][1]+=+a;c[0][2]+=+b;this.attr({path:c});break}return this};bO.animateWith=function(a,b,c,d,e){for(var f=0,g=cv.length;f<g;f++)cv[f].el.id==a.id&&(b.start=cv[f].start);return this.animate(b,c,d,e)};bO.animateAlong=cA();bO.animateAlongBack=cA(1);function cA(b){return function(c,d,e,f){var g={back:b};a.is(e,"function")?f=e:g.rot=e;c&&c.constructor==bN&&(c=c.attrs.path);c&&(g.along=c);return this.animate(g,d,f)}}function cB(a,b,c,d,e,f){var g=3*b,h=3*(d-b)-g,i=1-g-h,j=3*c,k=3*(e-c)-j,l=1-j-k;function m(a){return((i*a+h)*a+g)*a}function n(a,b){var c=o(a,b);return((l*c+k)*c+j)*c}function o(a,b){var c,d,e,f,j,k;for(e=a,k=0;k<8;k++){f=m(e)-a;if(B(f)<b)return e;j=(3*i*e+2*h)*e+g;if(B(j)<0.000001)break;e=e-f/j}c=0;d=1;e=a;if(e<c)return c;if(e>d)return d;while(c<d){f=m(e);if(B(f-a)<b)return e;a>f?c=e:d=e;e=(d-c)/2+c}return e}return n(a,1/(200*f))}bO.onAnimation=function(a){this._run=a||0;return this};bO.animate=function(c,d,e,g){var h=this;h.timeouts=h.timeouts||[];if(a.is(e,"function")||!e)g=e||null;if(h.removed){g&&g.call(h);return h}var i={},j={},k=false,l={};for(var m in c)if(c[f](m)){if(X[f](m)||h.paper.customAttributes[f](m)){k=true;i[m]=h.attr(m);i[m]==null&&(i[m]=W[m]);j[m]=c[m];switch(X[m]){case"along":var n=cs(c[m]),o=ct(c[m],n*!(!c.back)),p=h.getBBox();l[m]=n/d;l.tx=p.x;l.ty=p.y;l.sx=o.x;l.sy=o.y;j.rot=c.rot;j.back=c.back;j.len=n;c.rot&&(l.r=S(h.rotate())||0);break;case E:l[m]=(j[m]-i[m])/d;break;case"colour":i[m]=a.getRGB(i[m]);var q=a.getRGB(j[m]);l[m]={r:(q.r-i[m].r)/d,g:(q.g-i[m].g)/d,b:(q.b-i[m].b)/d};break;case"path":var t=bw(i[m],j[m]);i[m]=t[0];var u=t[1];l[m]=[];for(var v=0,x=i[m][w];v<x;v++){l[m][v]=[0];for(var y=1,z=i[m][v][w];y<z;y++)l[m][v][y]=(u[v][y]-i[m][v][y])/d}break;case"csv":var A=r(c[m])[s](b),B=r(i[m])[s](b);switch(m){case"translation":i[m]=[0,0];l[m]=[A[0]/d,A[1]/d];break;case"rotation":i[m]=B[1]==A[1]&&B[2]==A[2]?B:[0,A[1],A[2]];l[m]=[(A[0]-i[m][0])/d,0,0];break;case"scale":c[m]=A;i[m]=r(i[m])[s](b);l[m]=[(A[0]-i[m][0])/d,(A[1]-i[m][1])/d,0,0];break;case"clip-rect":i[m]=r(i[m])[s](b);l[m]=[];v=4;while(v--)l[m][v]=(A[v]-i[m][v])/d;break}j[m]=A;break;default:A=[].concat(c[m]);B=[].concat(i[m]);l[m]=[];v=h.paper.customAttributes[m][w];while(v--)l[m][v]=((A[v]||0)-(B[v]||0))/d;break}}}if(k){var G=a.easing_formulas[e];if(!G){G=r(e).match(P);if(G&&G[w]==5){var H=G;G=function(a){return cB(a,+H[1],+H[2],+H[3],+H[4],d)}}else G=function(a){return a}}cv.push({start:c.start||+(new Date),ms:d,easing:G,from:i,diff:l,to:j,el:h,t:{x:0,y:0}});a.is(g,"function")&&(h._ac=setTimeout(function(){g.call(h)},d));cv[w]==1&&setTimeout(cw)}else{var C=[],D;for(var F in c)if(c[f](F)&&Z.test(F)){m={value:c[F]};F=="from"&&(F=0);F=="to"&&(F=100);m.key=T(F,10);C.push(m)}C.sort(be);C[0].key&&C.unshift({key:0,value:h.attrs});for(v=0,x=C[w];v<x;v++)cx(C[v].value,h,d/100*C[v].key,d/100*(C[v-1]&&C[v-1].key||0),C[v-1]&&C[v-1].value.callback);D=C[C[w]-1].value.callback;D&&h.timeouts.push(setTimeout(function(){D.call(h)},d))}return this};bO.stop=function(){for(var a=0;a<cv.length;a++)cv[a].el.id==this.id&&cv.splice(a--,1);for(a=0,ii=this.timeouts&&this.timeouts.length;a<ii;a++)clearTimeout(this.timeouts[a]);this.timeouts=[];clearTimeout(this._ac);delete this._ac;return this};bO.translate=function(a,b){return this.attr({translation:a+" "+b})};bO[H]=function(){return"Raphaël’s object"};a.ae=cv;var cC=function(a){this.items=[];this[w]=0;this.type="set";if(a)for(var b=0,c=a[w];b<c;b++){if(a[b]&&(a[b].constructor==bN||a[b].constructor==cC)){this[this.items[w]]=this.items[this.items[w]]=a[b];this[w]++}}};cC[e][L]=function(){var a,b;for(var c=0,d=arguments[w];c<d;c++){a=arguments[c];if(a&&(a.constructor==bN||a.constructor==cC)){b=this.items[w];this[b]=this.items[b]=a;this[w]++}}return this};cC[e].pop=function(){delete this[this[w]--];return this.items.pop()};for(var cD in bO)bO[f](cD)&&(cC[e][cD]=(function(a){return function(){for(var b=0,c=this.items[w];b<c;b++)this.items[b][a][m](this.items[b],arguments);return this}})(cD));cC[e].attr=function(b,c){if(b&&a.is(b,G)&&a.is(b[0],"object"))for(var d=0,e=b[w];d<e;d++)this.items[d].attr(b[d]);else for(var f=0,g=this.items[w];f<g;f++)this.items[f].attr(b,c);return this};cC[e].animate=function(b,c,d,e){(a.is(d,"function")||!d)&&(e=d||null);var f=this.items[w],g=f,h,i=this,j;e&&(j=function(){!(--f)&&e.call(i)});d=a.is(d,F)?d:j;h=this.items[--g].animate(b,c,d,j);while(g--)this.items[g]&&!this.items[g].removed&&this.items[g].animateWith(h,b,c,d,j);return this};cC[e].insertAfter=function(a){var b=this.items[w];while(b--)this.items[b].insertAfter(a);return this};cC[e].getBBox=function(){var a=[],b=[],c=[],d=[];for(var e=this.items[w];e--;){var f=this.items[e].getBBox();a[L](f.x);b[L](f.y);c[L](f.x+f.width);d[L](f.y+f.height)}a=A[m](0,a);b=A[m](0,b);return{x:a,y:b,width:z[m](0,c)-a,height:z[m](0,d)-b}};cC[e].clone=function(a){a=new cC;for(var b=0,c=this.items[w];b<c;b++)a[L](this.items[b].clone());return a};a.registerFont=function(a){if(!a.face)return a;this.fonts=this.fonts||{};var b={w:a.w,face:{},glyphs:{}},c=a.face["font-family"];for(var d in a.face)a.face[f](d)&&(b.face[d]=a.face[d]);this.fonts[c]?this.fonts[c][L](b):this.fonts[c]=[b];if(!a.svg){b.face["units-per-em"]=T(a.face["units-per-em"],10);for(var e in a.glyphs)if(a.glyphs[f](e)){var g=a.glyphs[e];b.glyphs[e]={w:g.w,k:{},d:g.d&&"M"+g.d[Y](/[mlcxtrv]/g,function(a){return({l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"})[a]||"M"})+"z"};if(g.k)for(var h in g.k)g[f](h)&&(b.glyphs[e].k[h]=g.k[h])}}return a};k.getFont=function(b,c,d,e){e=e||"normal";d=d||"normal";c=+c||({normal:400,bold:700,lighter:300,bolder:800})[c]||400;if(!a.fonts)return;var g=a.fonts[b];if(!g){var h=new RegExp("(^|\\s)"+b[Y](/[^\w\d\s+!~.:_-]/g,p)+"(\\s|$)","i");for(var i in a.fonts)if(a.fonts[f](i)){if(h.test(i)){g=a.fonts[i];break}}}var j;if(g)for(var k=0,l=g[w];k<l;k++){j=g[k];if(j.face["font-weight"]==c&&(j.face["font-style"]==d||!j.face["font-style"])&&j.face["font-stretch"]==e)break}return j};k.print=function(c,d,e,f,g,h,i){h=h||"middle";i=z(A(i||0,1),-1);var j=this.set(),k=r(e)[s](p),l=0,m=p,n;a.is(f,e)&&(f=this.getFont(f));if(f){n=(g||16)/f.face["units-per-em"];var o=f.face.bbox.split(b),q=+o[0],t=+o[1]+(h=="baseline"?o[3]-o[1]+ +f.face.descent:(o[3]-o[1])/2);for(var u=0,v=k[w];u<v;u++){var x=u&&f.glyphs[k[u-1]]||{},y=f.glyphs[k[u]];l+=u?(x.w||f.w)+(x.k&&x.k[k[u]]||0)+f.w*i:0;y&&y.d&&j[L](this.path(y.d).attr({fill:"#000",stroke:"none",translation:[l,0]}))}j.scale(n,n,q,t).translate(c-q,d-t)}return j};a.format=function(b,c){var e=a.is(c,G)?[0][n](c):arguments;b&&a.is(b,F)&&e[w]-1&&(b=b[Y](d,function(a,b){return e[++b]==null?p:e[b]}));return b||p};a.ninja=function(){i.was?h.Raphael=i.is:delete Raphael;return a};a.el=bO;a.st=cC[e];i.was?h.Raphael=a:Raphael=a})()
|
@@ -0,0 +1,3725 @@
|
|
1
|
+
/*!
|
2
|
+
* Raphael 1.5.2 - JavaScript Vector Library
|
3
|
+
*
|
4
|
+
* Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
|
5
|
+
* Licensed under the MIT (http://raphaeljs.com/license.html) license.
|
6
|
+
*/
|
7
|
+
(function () {
|
8
|
+
function R() {
|
9
|
+
if (R.is(arguments[0], array)) {
|
10
|
+
var a = arguments[0],
|
11
|
+
cnv = create[apply](R, a.splice(0, 3 + R.is(a[0], nu))),
|
12
|
+
res = cnv.set();
|
13
|
+
for (var i = 0, ii = a[length]; i < ii; i++) {
|
14
|
+
var j = a[i] || {};
|
15
|
+
elements[has](j.type) && res[push](cnv[j.type]().attr(j));
|
16
|
+
}
|
17
|
+
return res;
|
18
|
+
}
|
19
|
+
return create[apply](R, arguments);
|
20
|
+
}
|
21
|
+
R.version = "1.5.2";
|
22
|
+
var separator = /[, ]+/,
|
23
|
+
elements = {circle: 1, rect: 1, path: 1, ellipse: 1, text: 1, image: 1},
|
24
|
+
formatrg = /\{(\d+)\}/g,
|
25
|
+
proto = "prototype",
|
26
|
+
has = "hasOwnProperty",
|
27
|
+
doc = document,
|
28
|
+
win = window,
|
29
|
+
oldRaphael = {
|
30
|
+
was: Object[proto][has].call(win, "Raphael"),
|
31
|
+
is: win.Raphael
|
32
|
+
},
|
33
|
+
Paper = function () {
|
34
|
+
this.customAttributes = {};
|
35
|
+
},
|
36
|
+
paperproto,
|
37
|
+
appendChild = "appendChild",
|
38
|
+
apply = "apply",
|
39
|
+
concat = "concat",
|
40
|
+
supportsTouch = "createTouch" in doc,
|
41
|
+
E = "",
|
42
|
+
S = " ",
|
43
|
+
Str = String,
|
44
|
+
split = "split",
|
45
|
+
events = "click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend"[split](S),
|
46
|
+
touchMap = {
|
47
|
+
mousedown: "touchstart",
|
48
|
+
mousemove: "touchmove",
|
49
|
+
mouseup: "touchend"
|
50
|
+
},
|
51
|
+
join = "join",
|
52
|
+
length = "length",
|
53
|
+
lowerCase = Str[proto].toLowerCase,
|
54
|
+
math = Math,
|
55
|
+
mmax = math.max,
|
56
|
+
mmin = math.min,
|
57
|
+
abs = math.abs,
|
58
|
+
pow = math.pow,
|
59
|
+
PI = math.PI,
|
60
|
+
nu = "number",
|
61
|
+
string = "string",
|
62
|
+
array = "array",
|
63
|
+
toString = "toString",
|
64
|
+
fillString = "fill",
|
65
|
+
objectToString = Object[proto][toString],
|
66
|
+
paper = {},
|
67
|
+
push = "push",
|
68
|
+
ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i,
|
69
|
+
colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,
|
70
|
+
isnan = {"NaN": 1, "Infinity": 1, "-Infinity": 1},
|
71
|
+
bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,
|
72
|
+
round = math.round,
|
73
|
+
setAttribute = "setAttribute",
|
74
|
+
toFloat = parseFloat,
|
75
|
+
toInt = parseInt,
|
76
|
+
ms = " progid:DXImageTransform.Microsoft",
|
77
|
+
upperCase = Str[proto].toUpperCase,
|
78
|
+
availableAttrs = {blur: 0, "clip-rect": "0 0 1e9 1e9", cursor: "default", cx: 0, cy: 0, fill: "#fff", "fill-opacity": 1, font: '10px "Arial"', "font-family": '"Arial"', "font-size": "10", "font-style": "normal", "font-weight": 400, gradient: 0, height: 0, href: "http://raphaeljs.com/", opacity: 1, path: "M0,0", r: 0, rotation: 0, rx: 0, ry: 0, scale: "1 1", src: "", stroke: "#000", "stroke-dasharray": "", "stroke-linecap": "butt", "stroke-linejoin": "butt", "stroke-miterlimit": 0, "stroke-opacity": 1, "stroke-width": 1, target: "_blank", "text-anchor": "middle", title: "Raphael", translation: "0 0", width: 0, x: 0, y: 0},
|
79
|
+
availableAnimAttrs = {along: "along", blur: nu, "clip-rect": "csv", cx: nu, cy: nu, fill: "colour", "fill-opacity": nu, "font-size": nu, height: nu, opacity: nu, path: "path", r: nu, rotation: "csv", rx: nu, ry: nu, scale: "csv", stroke: "colour", "stroke-opacity": nu, "stroke-width": nu, translation: "csv", width: nu, x: nu, y: nu},
|
80
|
+
rp = "replace",
|
81
|
+
animKeyFrames= /^(from|to|\d+%?)$/,
|
82
|
+
commaSpaces = /\s*,\s*/,
|
83
|
+
hsrg = {hs: 1, rg: 1},
|
84
|
+
p2s = /,?([achlmqrstvxz]),?/gi,
|
85
|
+
pathCommand = /([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,
|
86
|
+
pathValues = /(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig,
|
87
|
+
radial_gradient = /^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,
|
88
|
+
sortByKey = function (a, b) {
|
89
|
+
return a.key - b.key;
|
90
|
+
};
|
91
|
+
|
92
|
+
R.type = (win.SVGAngle || doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML");
|
93
|
+
if (R.type == "VML") {
|
94
|
+
var d = doc.createElement("div"),
|
95
|
+
b;
|
96
|
+
d.innerHTML = '<v:shape adj="1"/>';
|
97
|
+
b = d.firstChild;
|
98
|
+
b.style.behavior = "url(#default#VML)";
|
99
|
+
if (!(b && typeof b.adj == "object")) {
|
100
|
+
return R.type = null;
|
101
|
+
}
|
102
|
+
d = null;
|
103
|
+
}
|
104
|
+
R.svg = !(R.vml = R.type == "VML");
|
105
|
+
Paper[proto] = R[proto];
|
106
|
+
paperproto = Paper[proto];
|
107
|
+
R._id = 0;
|
108
|
+
R._oid = 0;
|
109
|
+
R.fn = {};
|
110
|
+
R.is = function (o, type) {
|
111
|
+
type = lowerCase.call(type);
|
112
|
+
if (type == "finite") {
|
113
|
+
return !isnan[has](+o);
|
114
|
+
}
|
115
|
+
return (type == "null" && o === null) ||
|
116
|
+
(type == typeof o) ||
|
117
|
+
(type == "object" && o === Object(o)) ||
|
118
|
+
(type == "array" && Array.isArray && Array.isArray(o)) ||
|
119
|
+
objectToString.call(o).slice(8, -1).toLowerCase() == type;
|
120
|
+
};
|
121
|
+
R.angle = function (x1, y1, x2, y2, x3, y3) {
|
122
|
+
if (x3 == null) {
|
123
|
+
var x = x1 - x2,
|
124
|
+
y = y1 - y2;
|
125
|
+
if (!x && !y) {
|
126
|
+
return 0;
|
127
|
+
}
|
128
|
+
return ((x < 0) * 180 + math.atan(-y / -x) * 180 / PI + 360) % 360;
|
129
|
+
} else {
|
130
|
+
return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3);
|
131
|
+
}
|
132
|
+
};
|
133
|
+
R.rad = function (deg) {
|
134
|
+
return deg % 360 * PI / 180;
|
135
|
+
};
|
136
|
+
R.deg = function (rad) {
|
137
|
+
return rad * 180 / PI % 360;
|
138
|
+
};
|
139
|
+
R.snapTo = function (values, value, tolerance) {
|
140
|
+
tolerance = R.is(tolerance, "finite") ? tolerance : 10;
|
141
|
+
if (R.is(values, array)) {
|
142
|
+
var i = values.length;
|
143
|
+
while (i--) if (abs(values[i] - value) <= tolerance) {
|
144
|
+
return values[i];
|
145
|
+
}
|
146
|
+
} else {
|
147
|
+
values = +values;
|
148
|
+
var rem = value % values;
|
149
|
+
if (rem < tolerance) {
|
150
|
+
return value - rem;
|
151
|
+
}
|
152
|
+
if (rem > values - tolerance) {
|
153
|
+
return value - rem + values;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
return value;
|
157
|
+
};
|
158
|
+
function createUUID() {
|
159
|
+
// http://www.ietf.org/rfc/rfc4122.txt
|
160
|
+
var s = [],
|
161
|
+
i = 0;
|
162
|
+
for (; i < 32; i++) {
|
163
|
+
s[i] = (~~(math.random() * 16))[toString](16);
|
164
|
+
}
|
165
|
+
s[12] = 4; // bits 12-15 of the time_hi_and_version field to 0010
|
166
|
+
s[16] = ((s[16] & 3) | 8)[toString](16); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
167
|
+
return "r-" + s[join]("");
|
168
|
+
}
|
169
|
+
|
170
|
+
R.setWindow = function (newwin) {
|
171
|
+
win = newwin;
|
172
|
+
doc = win.document;
|
173
|
+
};
|
174
|
+
// colour utilities
|
175
|
+
var toHex = function (color) {
|
176
|
+
if (R.vml) {
|
177
|
+
// http://dean.edwards.name/weblog/2009/10/convert-any-colour-value-to-hex-in-msie/
|
178
|
+
var trim = /^\s+|\s+$/g;
|
179
|
+
var bod;
|
180
|
+
try {
|
181
|
+
var docum = new ActiveXObject("htmlfile");
|
182
|
+
docum.write("<body>");
|
183
|
+
docum.close();
|
184
|
+
bod = docum.body;
|
185
|
+
} catch(e) {
|
186
|
+
bod = createPopup().document.body;
|
187
|
+
}
|
188
|
+
var range = bod.createTextRange();
|
189
|
+
toHex = cacher(function (color) {
|
190
|
+
try {
|
191
|
+
bod.style.color = Str(color)[rp](trim, E);
|
192
|
+
var value = range.queryCommandValue("ForeColor");
|
193
|
+
value = ((value & 255) << 16) | (value & 65280) | ((value & 16711680) >>> 16);
|
194
|
+
return "#" + ("000000" + value[toString](16)).slice(-6);
|
195
|
+
} catch(e) {
|
196
|
+
return "none";
|
197
|
+
}
|
198
|
+
});
|
199
|
+
} else {
|
200
|
+
var i = doc.createElement("i");
|
201
|
+
i.title = "Rapha\xebl Colour Picker";
|
202
|
+
i.style.display = "none";
|
203
|
+
doc.body[appendChild](i);
|
204
|
+
toHex = cacher(function (color) {
|
205
|
+
i.style.color = color;
|
206
|
+
return doc.defaultView.getComputedStyle(i, E).getPropertyValue("color");
|
207
|
+
});
|
208
|
+
}
|
209
|
+
return toHex(color);
|
210
|
+
},
|
211
|
+
hsbtoString = function () {
|
212
|
+
return "hsb(" + [this.h, this.s, this.b] + ")";
|
213
|
+
},
|
214
|
+
hsltoString = function () {
|
215
|
+
return "hsl(" + [this.h, this.s, this.l] + ")";
|
216
|
+
},
|
217
|
+
rgbtoString = function () {
|
218
|
+
return this.hex;
|
219
|
+
};
|
220
|
+
R.hsb2rgb = function (h, s, b, o) {
|
221
|
+
if (R.is(h, "object") && "h" in h && "s" in h && "b" in h) {
|
222
|
+
b = h.b;
|
223
|
+
s = h.s;
|
224
|
+
h = h.h;
|
225
|
+
o = h.o;
|
226
|
+
}
|
227
|
+
return R.hsl2rgb(h, s, b / 2, o);
|
228
|
+
};
|
229
|
+
R.hsl2rgb = function (h, s, l, o) {
|
230
|
+
if (R.is(h, "object") && "h" in h && "s" in h && "l" in h) {
|
231
|
+
l = h.l;
|
232
|
+
s = h.s;
|
233
|
+
h = h.h;
|
234
|
+
}
|
235
|
+
if (h > 1 || s > 1 || l > 1) {
|
236
|
+
h /= 360;
|
237
|
+
s /= 100;
|
238
|
+
l /= 100;
|
239
|
+
}
|
240
|
+
var rgb = {},
|
241
|
+
channels = ["r", "g", "b"],
|
242
|
+
t2, t1, t3, r, g, b;
|
243
|
+
if (!s) {
|
244
|
+
rgb = {
|
245
|
+
r: l,
|
246
|
+
g: l,
|
247
|
+
b: l
|
248
|
+
};
|
249
|
+
} else {
|
250
|
+
if (l < .5) {
|
251
|
+
t2 = l * (1 + s);
|
252
|
+
} else {
|
253
|
+
t2 = l + s - l * s;
|
254
|
+
}
|
255
|
+
t1 = 2 * l - t2;
|
256
|
+
for (var i = 0; i < 3; i++) {
|
257
|
+
t3 = h + 1 / 3 * -(i - 1);
|
258
|
+
t3 < 0 && t3++;
|
259
|
+
t3 > 1 && t3--;
|
260
|
+
if (t3 * 6 < 1) {
|
261
|
+
rgb[channels[i]] = t1 + (t2 - t1) * 6 * t3;
|
262
|
+
} else if (t3 * 2 < 1) {
|
263
|
+
rgb[channels[i]] = t2;
|
264
|
+
} else if (t3 * 3 < 2) {
|
265
|
+
rgb[channels[i]] = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
266
|
+
} else {
|
267
|
+
rgb[channels[i]] = t1;
|
268
|
+
}
|
269
|
+
}
|
270
|
+
}
|
271
|
+
rgb.r *= 255;
|
272
|
+
rgb.g *= 255;
|
273
|
+
rgb.b *= 255;
|
274
|
+
rgb.hex = "#" + (16777216 | rgb.b | (rgb.g << 8) | (rgb.r << 16)).toString(16).slice(1);
|
275
|
+
R.is(o, "finite") && (rgb.opacity = o);
|
276
|
+
rgb.toString = rgbtoString;
|
277
|
+
return rgb;
|
278
|
+
};
|
279
|
+
R.rgb2hsb = function (red, green, blue) {
|
280
|
+
if (green == null && R.is(red, "object") && "r" in red && "g" in red && "b" in red) {
|
281
|
+
blue = red.b;
|
282
|
+
green = red.g;
|
283
|
+
red = red.r;
|
284
|
+
}
|
285
|
+
if (green == null && R.is(red, string)) {
|
286
|
+
var clr = R.getRGB(red);
|
287
|
+
red = clr.r;
|
288
|
+
green = clr.g;
|
289
|
+
blue = clr.b;
|
290
|
+
}
|
291
|
+
if (red > 1 || green > 1 || blue > 1) {
|
292
|
+
red /= 255;
|
293
|
+
green /= 255;
|
294
|
+
blue /= 255;
|
295
|
+
}
|
296
|
+
var max = mmax(red, green, blue),
|
297
|
+
min = mmin(red, green, blue),
|
298
|
+
hue,
|
299
|
+
saturation,
|
300
|
+
brightness = max;
|
301
|
+
if (min == max) {
|
302
|
+
return {h: 0, s: 0, b: max, toString: hsbtoString};
|
303
|
+
} else {
|
304
|
+
var delta = (max - min);
|
305
|
+
saturation = delta / max;
|
306
|
+
if (red == max) {
|
307
|
+
hue = (green - blue) / delta;
|
308
|
+
} else if (green == max) {
|
309
|
+
hue = 2 + ((blue - red) / delta);
|
310
|
+
} else {
|
311
|
+
hue = 4 + ((red - green) / delta);
|
312
|
+
}
|
313
|
+
hue /= 6;
|
314
|
+
hue < 0 && hue++;
|
315
|
+
hue > 1 && hue--;
|
316
|
+
}
|
317
|
+
return {h: hue, s: saturation, b: brightness, toString: hsbtoString};
|
318
|
+
};
|
319
|
+
R.rgb2hsl = function (red, green, blue) {
|
320
|
+
if (green == null && R.is(red, "object") && "r" in red && "g" in red && "b" in red) {
|
321
|
+
blue = red.b;
|
322
|
+
green = red.g;
|
323
|
+
red = red.r;
|
324
|
+
}
|
325
|
+
if (green == null && R.is(red, string)) {
|
326
|
+
var clr = R.getRGB(red);
|
327
|
+
red = clr.r;
|
328
|
+
green = clr.g;
|
329
|
+
blue = clr.b;
|
330
|
+
}
|
331
|
+
if (red > 1 || green > 1 || blue > 1) {
|
332
|
+
red /= 255;
|
333
|
+
green /= 255;
|
334
|
+
blue /= 255;
|
335
|
+
}
|
336
|
+
var max = mmax(red, green, blue),
|
337
|
+
min = mmin(red, green, blue),
|
338
|
+
h,
|
339
|
+
s,
|
340
|
+
l = (max + min) / 2,
|
341
|
+
hsl;
|
342
|
+
if (min == max) {
|
343
|
+
hsl = {h: 0, s: 0, l: l};
|
344
|
+
} else {
|
345
|
+
var delta = max - min;
|
346
|
+
s = l < .5 ? delta / (max + min) : delta / (2 - max - min);
|
347
|
+
if (red == max) {
|
348
|
+
h = (green - blue) / delta;
|
349
|
+
} else if (green == max) {
|
350
|
+
h = 2 + (blue - red) / delta;
|
351
|
+
} else {
|
352
|
+
h = 4 + (red - green) / delta;
|
353
|
+
}
|
354
|
+
h /= 6;
|
355
|
+
h < 0 && h++;
|
356
|
+
h > 1 && h--;
|
357
|
+
hsl = {h: h, s: s, l: l};
|
358
|
+
}
|
359
|
+
hsl.toString = hsltoString;
|
360
|
+
return hsl;
|
361
|
+
};
|
362
|
+
R._path2string = function () {
|
363
|
+
return this.join(",")[rp](p2s, "$1");
|
364
|
+
};
|
365
|
+
function cacher(f, scope, postprocessor) {
|
366
|
+
function newf() {
|
367
|
+
var arg = Array[proto].slice.call(arguments, 0),
|
368
|
+
args = arg[join]("\u25ba"),
|
369
|
+
cache = newf.cache = newf.cache || {},
|
370
|
+
count = newf.count = newf.count || [];
|
371
|
+
if (cache[has](args)) {
|
372
|
+
return postprocessor ? postprocessor(cache[args]) : cache[args];
|
373
|
+
}
|
374
|
+
count[length] >= 1e3 && delete cache[count.shift()];
|
375
|
+
count[push](args);
|
376
|
+
cache[args] = f[apply](scope, arg);
|
377
|
+
return postprocessor ? postprocessor(cache[args]) : cache[args];
|
378
|
+
}
|
379
|
+
return newf;
|
380
|
+
}
|
381
|
+
|
382
|
+
R.getRGB = cacher(function (colour) {
|
383
|
+
if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) {
|
384
|
+
return {r: -1, g: -1, b: -1, hex: "none", error: 1};
|
385
|
+
}
|
386
|
+
if (colour == "none") {
|
387
|
+
return {r: -1, g: -1, b: -1, hex: "none"};
|
388
|
+
}
|
389
|
+
!(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() == "#") && (colour = toHex(colour));
|
390
|
+
var res,
|
391
|
+
red,
|
392
|
+
green,
|
393
|
+
blue,
|
394
|
+
opacity,
|
395
|
+
t,
|
396
|
+
values,
|
397
|
+
rgb = colour.match(colourRegExp);
|
398
|
+
if (rgb) {
|
399
|
+
if (rgb[2]) {
|
400
|
+
blue = toInt(rgb[2].substring(5), 16);
|
401
|
+
green = toInt(rgb[2].substring(3, 5), 16);
|
402
|
+
red = toInt(rgb[2].substring(1, 3), 16);
|
403
|
+
}
|
404
|
+
if (rgb[3]) {
|
405
|
+
blue = toInt((t = rgb[3].charAt(3)) + t, 16);
|
406
|
+
green = toInt((t = rgb[3].charAt(2)) + t, 16);
|
407
|
+
red = toInt((t = rgb[3].charAt(1)) + t, 16);
|
408
|
+
}
|
409
|
+
if (rgb[4]) {
|
410
|
+
values = rgb[4][split](commaSpaces);
|
411
|
+
red = toFloat(values[0]);
|
412
|
+
values[0].slice(-1) == "%" && (red *= 2.55);
|
413
|
+
green = toFloat(values[1]);
|
414
|
+
values[1].slice(-1) == "%" && (green *= 2.55);
|
415
|
+
blue = toFloat(values[2]);
|
416
|
+
values[2].slice(-1) == "%" && (blue *= 2.55);
|
417
|
+
rgb[1].toLowerCase().slice(0, 4) == "rgba" && (opacity = toFloat(values[3]));
|
418
|
+
values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
|
419
|
+
}
|
420
|
+
if (rgb[5]) {
|
421
|
+
values = rgb[5][split](commaSpaces);
|
422
|
+
red = toFloat(values[0]);
|
423
|
+
values[0].slice(-1) == "%" && (red *= 2.55);
|
424
|
+
green = toFloat(values[1]);
|
425
|
+
values[1].slice(-1) == "%" && (green *= 2.55);
|
426
|
+
blue = toFloat(values[2]);
|
427
|
+
values[2].slice(-1) == "%" && (blue *= 2.55);
|
428
|
+
(values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
|
429
|
+
rgb[1].toLowerCase().slice(0, 4) == "hsba" && (opacity = toFloat(values[3]));
|
430
|
+
values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
|
431
|
+
return R.hsb2rgb(red, green, blue, opacity);
|
432
|
+
}
|
433
|
+
if (rgb[6]) {
|
434
|
+
values = rgb[6][split](commaSpaces);
|
435
|
+
red = toFloat(values[0]);
|
436
|
+
values[0].slice(-1) == "%" && (red *= 2.55);
|
437
|
+
green = toFloat(values[1]);
|
438
|
+
values[1].slice(-1) == "%" && (green *= 2.55);
|
439
|
+
blue = toFloat(values[2]);
|
440
|
+
values[2].slice(-1) == "%" && (blue *= 2.55);
|
441
|
+
(values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
|
442
|
+
rgb[1].toLowerCase().slice(0, 4) == "hsla" && (opacity = toFloat(values[3]));
|
443
|
+
values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
|
444
|
+
return R.hsl2rgb(red, green, blue, opacity);
|
445
|
+
}
|
446
|
+
rgb = {r: red, g: green, b: blue};
|
447
|
+
rgb.hex = "#" + (16777216 | blue | (green << 8) | (red << 16)).toString(16).slice(1);
|
448
|
+
R.is(opacity, "finite") && (rgb.opacity = opacity);
|
449
|
+
return rgb;
|
450
|
+
}
|
451
|
+
return {r: -1, g: -1, b: -1, hex: "none", error: 1};
|
452
|
+
}, R);
|
453
|
+
R.getColor = function (value) {
|
454
|
+
var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75},
|
455
|
+
rgb = this.hsb2rgb(start.h, start.s, start.b);
|
456
|
+
start.h += .075;
|
457
|
+
if (start.h > 1) {
|
458
|
+
start.h = 0;
|
459
|
+
start.s -= .2;
|
460
|
+
start.s <= 0 && (this.getColor.start = {h: 0, s: 1, b: start.b});
|
461
|
+
}
|
462
|
+
return rgb.hex;
|
463
|
+
};
|
464
|
+
R.getColor.reset = function () {
|
465
|
+
delete this.start;
|
466
|
+
};
|
467
|
+
// path utilities
|
468
|
+
R.parsePathString = cacher(function (pathString) {
|
469
|
+
if (!pathString) {
|
470
|
+
return null;
|
471
|
+
}
|
472
|
+
var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0},
|
473
|
+
data = [];
|
474
|
+
if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption
|
475
|
+
data = pathClone(pathString);
|
476
|
+
}
|
477
|
+
if (!data[length]) {
|
478
|
+
Str(pathString)[rp](pathCommand, function (a, b, c) {
|
479
|
+
var params = [],
|
480
|
+
name = lowerCase.call(b);
|
481
|
+
c[rp](pathValues, function (a, b) {
|
482
|
+
b && params[push](+b);
|
483
|
+
});
|
484
|
+
if (name == "m" && params[length] > 2) {
|
485
|
+
data[push]([b][concat](params.splice(0, 2)));
|
486
|
+
name = "l";
|
487
|
+
b = b == "m" ? "l" : "L";
|
488
|
+
}
|
489
|
+
while (params[length] >= paramCounts[name]) {
|
490
|
+
data[push]([b][concat](params.splice(0, paramCounts[name])));
|
491
|
+
if (!paramCounts[name]) {
|
492
|
+
break;
|
493
|
+
}
|
494
|
+
}
|
495
|
+
});
|
496
|
+
}
|
497
|
+
data[toString] = R._path2string;
|
498
|
+
return data;
|
499
|
+
});
|
500
|
+
R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
|
501
|
+
var t1 = 1 - t,
|
502
|
+
x = pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x,
|
503
|
+
y = pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y,
|
504
|
+
mx = p1x + 2 * t * (c1x - p1x) + t * t * (c2x - 2 * c1x + p1x),
|
505
|
+
my = p1y + 2 * t * (c1y - p1y) + t * t * (c2y - 2 * c1y + p1y),
|
506
|
+
nx = c1x + 2 * t * (c2x - c1x) + t * t * (p2x - 2 * c2x + c1x),
|
507
|
+
ny = c1y + 2 * t * (c2y - c1y) + t * t * (p2y - 2 * c2y + c1y),
|
508
|
+
ax = (1 - t) * p1x + t * c1x,
|
509
|
+
ay = (1 - t) * p1y + t * c1y,
|
510
|
+
cx = (1 - t) * c2x + t * p2x,
|
511
|
+
cy = (1 - t) * c2y + t * p2y,
|
512
|
+
alpha = (90 - math.atan((mx - nx) / (my - ny)) * 180 / PI);
|
513
|
+
(mx > nx || my < ny) && (alpha += 180);
|
514
|
+
return {x: x, y: y, m: {x: mx, y: my}, n: {x: nx, y: ny}, start: {x: ax, y: ay}, end: {x: cx, y: cy}, alpha: alpha};
|
515
|
+
};
|
516
|
+
var pathDimensions = cacher(function (path) {
|
517
|
+
if (!path) {
|
518
|
+
return {x: 0, y: 0, width: 0, height: 0};
|
519
|
+
}
|
520
|
+
path = path2curve(path);
|
521
|
+
var x = 0,
|
522
|
+
y = 0,
|
523
|
+
X = [],
|
524
|
+
Y = [],
|
525
|
+
p;
|
526
|
+
for (var i = 0, ii = path[length]; i < ii; i++) {
|
527
|
+
p = path[i];
|
528
|
+
if (p[0] == "M") {
|
529
|
+
x = p[1];
|
530
|
+
y = p[2];
|
531
|
+
X[push](x);
|
532
|
+
Y[push](y);
|
533
|
+
} else {
|
534
|
+
var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
|
535
|
+
X = X[concat](dim.min.x, dim.max.x);
|
536
|
+
Y = Y[concat](dim.min.y, dim.max.y);
|
537
|
+
x = p[5];
|
538
|
+
y = p[6];
|
539
|
+
}
|
540
|
+
}
|
541
|
+
var xmin = mmin[apply](0, X),
|
542
|
+
ymin = mmin[apply](0, Y);
|
543
|
+
return {
|
544
|
+
x: xmin,
|
545
|
+
y: ymin,
|
546
|
+
width: mmax[apply](0, X) - xmin,
|
547
|
+
height: mmax[apply](0, Y) - ymin
|
548
|
+
};
|
549
|
+
}),
|
550
|
+
pathClone = function (pathArray) {
|
551
|
+
var res = [];
|
552
|
+
if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption
|
553
|
+
pathArray = R.parsePathString(pathArray);
|
554
|
+
}
|
555
|
+
for (var i = 0, ii = pathArray[length]; i < ii; i++) {
|
556
|
+
res[i] = [];
|
557
|
+
for (var j = 0, jj = pathArray[i][length]; j < jj; j++) {
|
558
|
+
res[i][j] = pathArray[i][j];
|
559
|
+
}
|
560
|
+
}
|
561
|
+
res[toString] = R._path2string;
|
562
|
+
return res;
|
563
|
+
},
|
564
|
+
pathToRelative = cacher(function (pathArray) {
|
565
|
+
if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption
|
566
|
+
pathArray = R.parsePathString(pathArray);
|
567
|
+
}
|
568
|
+
var res = [],
|
569
|
+
x = 0,
|
570
|
+
y = 0,
|
571
|
+
mx = 0,
|
572
|
+
my = 0,
|
573
|
+
start = 0;
|
574
|
+
if (pathArray[0][0] == "M") {
|
575
|
+
x = pathArray[0][1];
|
576
|
+
y = pathArray[0][2];
|
577
|
+
mx = x;
|
578
|
+
my = y;
|
579
|
+
start++;
|
580
|
+
res[push](["M", x, y]);
|
581
|
+
}
|
582
|
+
for (var i = start, ii = pathArray[length]; i < ii; i++) {
|
583
|
+
var r = res[i] = [],
|
584
|
+
pa = pathArray[i];
|
585
|
+
if (pa[0] != lowerCase.call(pa[0])) {
|
586
|
+
r[0] = lowerCase.call(pa[0]);
|
587
|
+
switch (r[0]) {
|
588
|
+
case "a":
|
589
|
+
r[1] = pa[1];
|
590
|
+
r[2] = pa[2];
|
591
|
+
r[3] = pa[3];
|
592
|
+
r[4] = pa[4];
|
593
|
+
r[5] = pa[5];
|
594
|
+
r[6] = +(pa[6] - x).toFixed(3);
|
595
|
+
r[7] = +(pa[7] - y).toFixed(3);
|
596
|
+
break;
|
597
|
+
case "v":
|
598
|
+
r[1] = +(pa[1] - y).toFixed(3);
|
599
|
+
break;
|
600
|
+
case "m":
|
601
|
+
mx = pa[1];
|
602
|
+
my = pa[2];
|
603
|
+
default:
|
604
|
+
for (var j = 1, jj = pa[length]; j < jj; j++) {
|
605
|
+
r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3);
|
606
|
+
}
|
607
|
+
}
|
608
|
+
} else {
|
609
|
+
r = res[i] = [];
|
610
|
+
if (pa[0] == "m") {
|
611
|
+
mx = pa[1] + x;
|
612
|
+
my = pa[2] + y;
|
613
|
+
}
|
614
|
+
for (var k = 0, kk = pa[length]; k < kk; k++) {
|
615
|
+
res[i][k] = pa[k];
|
616
|
+
}
|
617
|
+
}
|
618
|
+
var len = res[i][length];
|
619
|
+
switch (res[i][0]) {
|
620
|
+
case "z":
|
621
|
+
x = mx;
|
622
|
+
y = my;
|
623
|
+
break;
|
624
|
+
case "h":
|
625
|
+
x += +res[i][len - 1];
|
626
|
+
break;
|
627
|
+
case "v":
|
628
|
+
y += +res[i][len - 1];
|
629
|
+
break;
|
630
|
+
default:
|
631
|
+
x += +res[i][len - 2];
|
632
|
+
y += +res[i][len - 1];
|
633
|
+
}
|
634
|
+
}
|
635
|
+
res[toString] = R._path2string;
|
636
|
+
return res;
|
637
|
+
}, 0, pathClone),
|
638
|
+
pathToAbsolute = cacher(function (pathArray) {
|
639
|
+
if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption
|
640
|
+
pathArray = R.parsePathString(pathArray);
|
641
|
+
}
|
642
|
+
var res = [],
|
643
|
+
x = 0,
|
644
|
+
y = 0,
|
645
|
+
mx = 0,
|
646
|
+
my = 0,
|
647
|
+
start = 0;
|
648
|
+
if (pathArray[0][0] == "M") {
|
649
|
+
x = +pathArray[0][1];
|
650
|
+
y = +pathArray[0][2];
|
651
|
+
mx = x;
|
652
|
+
my = y;
|
653
|
+
start++;
|
654
|
+
res[0] = ["M", x, y];
|
655
|
+
}
|
656
|
+
for (var i = start, ii = pathArray[length]; i < ii; i++) {
|
657
|
+
var r = res[i] = [],
|
658
|
+
pa = pathArray[i];
|
659
|
+
if (pa[0] != upperCase.call(pa[0])) {
|
660
|
+
r[0] = upperCase.call(pa[0]);
|
661
|
+
switch (r[0]) {
|
662
|
+
case "A":
|
663
|
+
r[1] = pa[1];
|
664
|
+
r[2] = pa[2];
|
665
|
+
r[3] = pa[3];
|
666
|
+
r[4] = pa[4];
|
667
|
+
r[5] = pa[5];
|
668
|
+
r[6] = +(pa[6] + x);
|
669
|
+
r[7] = +(pa[7] + y);
|
670
|
+
break;
|
671
|
+
case "V":
|
672
|
+
r[1] = +pa[1] + y;
|
673
|
+
break;
|
674
|
+
case "H":
|
675
|
+
r[1] = +pa[1] + x;
|
676
|
+
break;
|
677
|
+
case "M":
|
678
|
+
mx = +pa[1] + x;
|
679
|
+
my = +pa[2] + y;
|
680
|
+
default:
|
681
|
+
for (var j = 1, jj = pa[length]; j < jj; j++) {
|
682
|
+
r[j] = +pa[j] + ((j % 2) ? x : y);
|
683
|
+
}
|
684
|
+
}
|
685
|
+
} else {
|
686
|
+
for (var k = 0, kk = pa[length]; k < kk; k++) {
|
687
|
+
res[i][k] = pa[k];
|
688
|
+
}
|
689
|
+
}
|
690
|
+
switch (r[0]) {
|
691
|
+
case "Z":
|
692
|
+
x = mx;
|
693
|
+
y = my;
|
694
|
+
break;
|
695
|
+
case "H":
|
696
|
+
x = r[1];
|
697
|
+
break;
|
698
|
+
case "V":
|
699
|
+
y = r[1];
|
700
|
+
break;
|
701
|
+
case "M":
|
702
|
+
mx = res[i][res[i][length] - 2];
|
703
|
+
my = res[i][res[i][length] - 1];
|
704
|
+
default:
|
705
|
+
x = res[i][res[i][length] - 2];
|
706
|
+
y = res[i][res[i][length] - 1];
|
707
|
+
}
|
708
|
+
}
|
709
|
+
res[toString] = R._path2string;
|
710
|
+
return res;
|
711
|
+
}, null, pathClone),
|
712
|
+
l2c = function (x1, y1, x2, y2) {
|
713
|
+
return [x1, y1, x2, y2, x2, y2];
|
714
|
+
},
|
715
|
+
q2c = function (x1, y1, ax, ay, x2, y2) {
|
716
|
+
var _13 = 1 / 3,
|
717
|
+
_23 = 2 / 3;
|
718
|
+
return [
|
719
|
+
_13 * x1 + _23 * ax,
|
720
|
+
_13 * y1 + _23 * ay,
|
721
|
+
_13 * x2 + _23 * ax,
|
722
|
+
_13 * y2 + _23 * ay,
|
723
|
+
x2,
|
724
|
+
y2
|
725
|
+
];
|
726
|
+
},
|
727
|
+
a2c = function (x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
|
728
|
+
// for more information of where this math came from visit:
|
729
|
+
// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
|
730
|
+
var _120 = PI * 120 / 180,
|
731
|
+
rad = PI / 180 * (+angle || 0),
|
732
|
+
res = [],
|
733
|
+
xy,
|
734
|
+
rotate = cacher(function (x, y, rad) {
|
735
|
+
var X = x * math.cos(rad) - y * math.sin(rad),
|
736
|
+
Y = x * math.sin(rad) + y * math.cos(rad);
|
737
|
+
return {x: X, y: Y};
|
738
|
+
});
|
739
|
+
if (!recursive) {
|
740
|
+
xy = rotate(x1, y1, -rad);
|
741
|
+
x1 = xy.x;
|
742
|
+
y1 = xy.y;
|
743
|
+
xy = rotate(x2, y2, -rad);
|
744
|
+
x2 = xy.x;
|
745
|
+
y2 = xy.y;
|
746
|
+
var cos = math.cos(PI / 180 * angle),
|
747
|
+
sin = math.sin(PI / 180 * angle),
|
748
|
+
x = (x1 - x2) / 2,
|
749
|
+
y = (y1 - y2) / 2;
|
750
|
+
var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
|
751
|
+
if (h > 1) {
|
752
|
+
h = math.sqrt(h);
|
753
|
+
rx = h * rx;
|
754
|
+
ry = h * ry;
|
755
|
+
}
|
756
|
+
var rx2 = rx * rx,
|
757
|
+
ry2 = ry * ry,
|
758
|
+
k = (large_arc_flag == sweep_flag ? -1 : 1) *
|
759
|
+
math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))),
|
760
|
+
cx = k * rx * y / ry + (x1 + x2) / 2,
|
761
|
+
cy = k * -ry * x / rx + (y1 + y2) / 2,
|
762
|
+
f1 = math.asin(((y1 - cy) / ry).toFixed(9)),
|
763
|
+
f2 = math.asin(((y2 - cy) / ry).toFixed(9));
|
764
|
+
|
765
|
+
f1 = x1 < cx ? PI - f1 : f1;
|
766
|
+
f2 = x2 < cx ? PI - f2 : f2;
|
767
|
+
f1 < 0 && (f1 = PI * 2 + f1);
|
768
|
+
f2 < 0 && (f2 = PI * 2 + f2);
|
769
|
+
if (sweep_flag && f1 > f2) {
|
770
|
+
f1 = f1 - PI * 2;
|
771
|
+
}
|
772
|
+
if (!sweep_flag && f2 > f1) {
|
773
|
+
f2 = f2 - PI * 2;
|
774
|
+
}
|
775
|
+
} else {
|
776
|
+
f1 = recursive[0];
|
777
|
+
f2 = recursive[1];
|
778
|
+
cx = recursive[2];
|
779
|
+
cy = recursive[3];
|
780
|
+
}
|
781
|
+
var df = f2 - f1;
|
782
|
+
if (abs(df) > _120) {
|
783
|
+
var f2old = f2,
|
784
|
+
x2old = x2,
|
785
|
+
y2old = y2;
|
786
|
+
f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
|
787
|
+
x2 = cx + rx * math.cos(f2);
|
788
|
+
y2 = cy + ry * math.sin(f2);
|
789
|
+
res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
|
790
|
+
}
|
791
|
+
df = f2 - f1;
|
792
|
+
var c1 = math.cos(f1),
|
793
|
+
s1 = math.sin(f1),
|
794
|
+
c2 = math.cos(f2),
|
795
|
+
s2 = math.sin(f2),
|
796
|
+
t = math.tan(df / 4),
|
797
|
+
hx = 4 / 3 * rx * t,
|
798
|
+
hy = 4 / 3 * ry * t,
|
799
|
+
m1 = [x1, y1],
|
800
|
+
m2 = [x1 + hx * s1, y1 - hy * c1],
|
801
|
+
m3 = [x2 + hx * s2, y2 - hy * c2],
|
802
|
+
m4 = [x2, y2];
|
803
|
+
m2[0] = 2 * m1[0] - m2[0];
|
804
|
+
m2[1] = 2 * m1[1] - m2[1];
|
805
|
+
if (recursive) {
|
806
|
+
return [m2, m3, m4][concat](res);
|
807
|
+
} else {
|
808
|
+
res = [m2, m3, m4][concat](res)[join]()[split](",");
|
809
|
+
var newres = [];
|
810
|
+
for (var i = 0, ii = res[length]; i < ii; i++) {
|
811
|
+
newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
|
812
|
+
}
|
813
|
+
return newres;
|
814
|
+
}
|
815
|
+
},
|
816
|
+
findDotAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
|
817
|
+
var t1 = 1 - t;
|
818
|
+
return {
|
819
|
+
x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x,
|
820
|
+
y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y
|
821
|
+
};
|
822
|
+
},
|
823
|
+
curveDim = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
|
824
|
+
var a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x),
|
825
|
+
b = 2 * (c1x - p1x) - 2 * (c2x - c1x),
|
826
|
+
c = p1x - c1x,
|
827
|
+
t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a,
|
828
|
+
t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a,
|
829
|
+
y = [p1y, p2y],
|
830
|
+
x = [p1x, p2x],
|
831
|
+
dot;
|
832
|
+
abs(t1) > "1e12" && (t1 = .5);
|
833
|
+
abs(t2) > "1e12" && (t2 = .5);
|
834
|
+
if (t1 > 0 && t1 < 1) {
|
835
|
+
dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);
|
836
|
+
x[push](dot.x);
|
837
|
+
y[push](dot.y);
|
838
|
+
}
|
839
|
+
if (t2 > 0 && t2 < 1) {
|
840
|
+
dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);
|
841
|
+
x[push](dot.x);
|
842
|
+
y[push](dot.y);
|
843
|
+
}
|
844
|
+
a = (c2y - 2 * c1y + p1y) - (p2y - 2 * c2y + c1y);
|
845
|
+
b = 2 * (c1y - p1y) - 2 * (c2y - c1y);
|
846
|
+
c = p1y - c1y;
|
847
|
+
t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a;
|
848
|
+
t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a;
|
849
|
+
abs(t1) > "1e12" && (t1 = .5);
|
850
|
+
abs(t2) > "1e12" && (t2 = .5);
|
851
|
+
if (t1 > 0 && t1 < 1) {
|
852
|
+
dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);
|
853
|
+
x[push](dot.x);
|
854
|
+
y[push](dot.y);
|
855
|
+
}
|
856
|
+
if (t2 > 0 && t2 < 1) {
|
857
|
+
dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);
|
858
|
+
x[push](dot.x);
|
859
|
+
y[push](dot.y);
|
860
|
+
}
|
861
|
+
return {
|
862
|
+
min: {x: mmin[apply](0, x), y: mmin[apply](0, y)},
|
863
|
+
max: {x: mmax[apply](0, x), y: mmax[apply](0, y)}
|
864
|
+
};
|
865
|
+
}),
|
866
|
+
path2curve = cacher(function (path, path2) {
|
867
|
+
var p = pathToAbsolute(path),
|
868
|
+
p2 = path2 && pathToAbsolute(path2),
|
869
|
+
attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
|
870
|
+
attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
|
871
|
+
processPath = function (path, d) {
|
872
|
+
var nx, ny;
|
873
|
+
if (!path) {
|
874
|
+
return ["C", d.x, d.y, d.x, d.y, d.x, d.y];
|
875
|
+
}
|
876
|
+
!(path[0] in {T:1, Q:1}) && (d.qx = d.qy = null);
|
877
|
+
switch (path[0]) {
|
878
|
+
case "M":
|
879
|
+
d.X = path[1];
|
880
|
+
d.Y = path[2];
|
881
|
+
break;
|
882
|
+
case "A":
|
883
|
+
path = ["C"][concat](a2c[apply](0, [d.x, d.y][concat](path.slice(1))));
|
884
|
+
break;
|
885
|
+
case "S":
|
886
|
+
nx = d.x + (d.x - (d.bx || d.x));
|
887
|
+
ny = d.y + (d.y - (d.by || d.y));
|
888
|
+
path = ["C", nx, ny][concat](path.slice(1));
|
889
|
+
break;
|
890
|
+
case "T":
|
891
|
+
d.qx = d.x + (d.x - (d.qx || d.x));
|
892
|
+
d.qy = d.y + (d.y - (d.qy || d.y));
|
893
|
+
path = ["C"][concat](q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
|
894
|
+
break;
|
895
|
+
case "Q":
|
896
|
+
d.qx = path[1];
|
897
|
+
d.qy = path[2];
|
898
|
+
path = ["C"][concat](q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
|
899
|
+
break;
|
900
|
+
case "L":
|
901
|
+
path = ["C"][concat](l2c(d.x, d.y, path[1], path[2]));
|
902
|
+
break;
|
903
|
+
case "H":
|
904
|
+
path = ["C"][concat](l2c(d.x, d.y, path[1], d.y));
|
905
|
+
break;
|
906
|
+
case "V":
|
907
|
+
path = ["C"][concat](l2c(d.x, d.y, d.x, path[1]));
|
908
|
+
break;
|
909
|
+
case "Z":
|
910
|
+
path = ["C"][concat](l2c(d.x, d.y, d.X, d.Y));
|
911
|
+
break;
|
912
|
+
}
|
913
|
+
return path;
|
914
|
+
},
|
915
|
+
fixArc = function (pp, i) {
|
916
|
+
if (pp[i][length] > 7) {
|
917
|
+
pp[i].shift();
|
918
|
+
var pi = pp[i];
|
919
|
+
while (pi[length]) {
|
920
|
+
pp.splice(i++, 0, ["C"][concat](pi.splice(0, 6)));
|
921
|
+
}
|
922
|
+
pp.splice(i, 1);
|
923
|
+
ii = mmax(p[length], p2 && p2[length] || 0);
|
924
|
+
}
|
925
|
+
},
|
926
|
+
fixM = function (path1, path2, a1, a2, i) {
|
927
|
+
if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M") {
|
928
|
+
path2.splice(i, 0, ["M", a2.x, a2.y]);
|
929
|
+
a1.bx = 0;
|
930
|
+
a1.by = 0;
|
931
|
+
a1.x = path1[i][1];
|
932
|
+
a1.y = path1[i][2];
|
933
|
+
ii = mmax(p[length], p2 && p2[length] || 0);
|
934
|
+
}
|
935
|
+
};
|
936
|
+
for (var i = 0, ii = mmax(p[length], p2 && p2[length] || 0); i < ii; i++) {
|
937
|
+
p[i] = processPath(p[i], attrs);
|
938
|
+
fixArc(p, i);
|
939
|
+
p2 && (p2[i] = processPath(p2[i], attrs2));
|
940
|
+
p2 && fixArc(p2, i);
|
941
|
+
fixM(p, p2, attrs, attrs2, i);
|
942
|
+
fixM(p2, p, attrs2, attrs, i);
|
943
|
+
var seg = p[i],
|
944
|
+
seg2 = p2 && p2[i],
|
945
|
+
seglen = seg[length],
|
946
|
+
seg2len = p2 && seg2[length];
|
947
|
+
attrs.x = seg[seglen - 2];
|
948
|
+
attrs.y = seg[seglen - 1];
|
949
|
+
attrs.bx = toFloat(seg[seglen - 4]) || attrs.x;
|
950
|
+
attrs.by = toFloat(seg[seglen - 3]) || attrs.y;
|
951
|
+
attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x);
|
952
|
+
attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y);
|
953
|
+
attrs2.x = p2 && seg2[seg2len - 2];
|
954
|
+
attrs2.y = p2 && seg2[seg2len - 1];
|
955
|
+
}
|
956
|
+
return p2 ? [p, p2] : p;
|
957
|
+
}, null, pathClone),
|
958
|
+
parseDots = cacher(function (gradient) {
|
959
|
+
var dots = [];
|
960
|
+
for (var i = 0, ii = gradient[length]; i < ii; i++) {
|
961
|
+
var dot = {},
|
962
|
+
par = gradient[i].match(/^([^:]*):?([\d\.]*)/);
|
963
|
+
dot.color = R.getRGB(par[1]);
|
964
|
+
if (dot.color.error) {
|
965
|
+
return null;
|
966
|
+
}
|
967
|
+
dot.color = dot.color.hex;
|
968
|
+
par[2] && (dot.offset = par[2] + "%");
|
969
|
+
dots[push](dot);
|
970
|
+
}
|
971
|
+
for (i = 1, ii = dots[length] - 1; i < ii; i++) {
|
972
|
+
if (!dots[i].offset) {
|
973
|
+
var start = toFloat(dots[i - 1].offset || 0),
|
974
|
+
end = 0;
|
975
|
+
for (var j = i + 1; j < ii; j++) {
|
976
|
+
if (dots[j].offset) {
|
977
|
+
end = dots[j].offset;
|
978
|
+
break;
|
979
|
+
}
|
980
|
+
}
|
981
|
+
if (!end) {
|
982
|
+
end = 100;
|
983
|
+
j = ii;
|
984
|
+
}
|
985
|
+
end = toFloat(end);
|
986
|
+
var d = (end - start) / (j - i + 1);
|
987
|
+
for (; i < j; i++) {
|
988
|
+
start += d;
|
989
|
+
dots[i].offset = start + "%";
|
990
|
+
}
|
991
|
+
}
|
992
|
+
}
|
993
|
+
return dots;
|
994
|
+
}),
|
995
|
+
getContainer = function (x, y, w, h) {
|
996
|
+
var container;
|
997
|
+
if (R.is(x, string) || R.is(x, "object")) {
|
998
|
+
container = R.is(x, string) ? doc.getElementById(x) : x;
|
999
|
+
if (container.tagName) {
|
1000
|
+
if (y == null) {
|
1001
|
+
return {
|
1002
|
+
container: container,
|
1003
|
+
width: container.style.pixelWidth || container.offsetWidth,
|
1004
|
+
height: container.style.pixelHeight || container.offsetHeight
|
1005
|
+
};
|
1006
|
+
} else {
|
1007
|
+
return {container: container, width: y, height: w};
|
1008
|
+
}
|
1009
|
+
}
|
1010
|
+
} else {
|
1011
|
+
return {container: 1, x: x, y: y, width: w, height: h};
|
1012
|
+
}
|
1013
|
+
},
|
1014
|
+
plugins = function (con, add) {
|
1015
|
+
var that = this;
|
1016
|
+
for (var prop in add) {
|
1017
|
+
if (add[has](prop) && !(prop in con)) {
|
1018
|
+
switch (typeof add[prop]) {
|
1019
|
+
case "function":
|
1020
|
+
(function (f) {
|
1021
|
+
con[prop] = con === that ? f : function () { return f[apply](that, arguments); };
|
1022
|
+
})(add[prop]);
|
1023
|
+
break;
|
1024
|
+
case "object":
|
1025
|
+
con[prop] = con[prop] || {};
|
1026
|
+
plugins.call(this, con[prop], add[prop]);
|
1027
|
+
break;
|
1028
|
+
default:
|
1029
|
+
con[prop] = add[prop];
|
1030
|
+
break;
|
1031
|
+
}
|
1032
|
+
}
|
1033
|
+
}
|
1034
|
+
},
|
1035
|
+
tear = function (el, paper) {
|
1036
|
+
el == paper.top && (paper.top = el.prev);
|
1037
|
+
el == paper.bottom && (paper.bottom = el.next);
|
1038
|
+
el.next && (el.next.prev = el.prev);
|
1039
|
+
el.prev && (el.prev.next = el.next);
|
1040
|
+
},
|
1041
|
+
tofront = function (el, paper) {
|
1042
|
+
if (paper.top === el) {
|
1043
|
+
return;
|
1044
|
+
}
|
1045
|
+
tear(el, paper);
|
1046
|
+
el.next = null;
|
1047
|
+
el.prev = paper.top;
|
1048
|
+
paper.top.next = el;
|
1049
|
+
paper.top = el;
|
1050
|
+
},
|
1051
|
+
toback = function (el, paper) {
|
1052
|
+
if (paper.bottom === el) {
|
1053
|
+
return;
|
1054
|
+
}
|
1055
|
+
tear(el, paper);
|
1056
|
+
el.next = paper.bottom;
|
1057
|
+
el.prev = null;
|
1058
|
+
paper.bottom.prev = el;
|
1059
|
+
paper.bottom = el;
|
1060
|
+
},
|
1061
|
+
insertafter = function (el, el2, paper) {
|
1062
|
+
tear(el, paper);
|
1063
|
+
el2 == paper.top && (paper.top = el);
|
1064
|
+
el2.next && (el2.next.prev = el);
|
1065
|
+
el.next = el2.next;
|
1066
|
+
el.prev = el2;
|
1067
|
+
el2.next = el;
|
1068
|
+
},
|
1069
|
+
insertbefore = function (el, el2, paper) {
|
1070
|
+
tear(el, paper);
|
1071
|
+
el2 == paper.bottom && (paper.bottom = el);
|
1072
|
+
el2.prev && (el2.prev.next = el);
|
1073
|
+
el.prev = el2.prev;
|
1074
|
+
el2.prev = el;
|
1075
|
+
el.next = el2;
|
1076
|
+
},
|
1077
|
+
removed = function (methodname) {
|
1078
|
+
return function () {
|
1079
|
+
throw new Error("Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object");
|
1080
|
+
};
|
1081
|
+
};
|
1082
|
+
R.pathToRelative = pathToRelative;
|
1083
|
+
// SVG
|
1084
|
+
if (R.svg) {
|
1085
|
+
paperproto.svgns = "http://www.w3.org/2000/svg";
|
1086
|
+
paperproto.xlink = "http://www.w3.org/1999/xlink";
|
1087
|
+
round = function (num) {
|
1088
|
+
return +num + (~~num === num) * .5;
|
1089
|
+
};
|
1090
|
+
var $ = function (el, attr) {
|
1091
|
+
if (attr) {
|
1092
|
+
for (var key in attr) {
|
1093
|
+
if (attr[has](key)) {
|
1094
|
+
el[setAttribute](key, Str(attr[key]));
|
1095
|
+
}
|
1096
|
+
}
|
1097
|
+
} else {
|
1098
|
+
el = doc.createElementNS(paperproto.svgns, el);
|
1099
|
+
el.style.webkitTapHighlightColor = "rgba(0,0,0,0)";
|
1100
|
+
return el;
|
1101
|
+
}
|
1102
|
+
};
|
1103
|
+
R[toString] = function () {
|
1104
|
+
return "Your browser supports SVG.\nYou are running Rapha\xebl " + this.version;
|
1105
|
+
};
|
1106
|
+
var thePath = function (pathString, SVG) {
|
1107
|
+
var el = $("path");
|
1108
|
+
SVG.canvas && SVG.canvas[appendChild](el);
|
1109
|
+
var p = new Element(el, SVG);
|
1110
|
+
p.type = "path";
|
1111
|
+
setFillAndStroke(p, {fill: "none", stroke: "#000", path: pathString});
|
1112
|
+
return p;
|
1113
|
+
};
|
1114
|
+
var addGradientFill = function (o, gradient, SVG) {
|
1115
|
+
var type = "linear",
|
1116
|
+
fx = .5, fy = .5,
|
1117
|
+
s = o.style;
|
1118
|
+
gradient = Str(gradient)[rp](radial_gradient, function (all, _fx, _fy) {
|
1119
|
+
type = "radial";
|
1120
|
+
if (_fx && _fy) {
|
1121
|
+
fx = toFloat(_fx);
|
1122
|
+
fy = toFloat(_fy);
|
1123
|
+
var dir = ((fy > .5) * 2 - 1);
|
1124
|
+
pow(fx - .5, 2) + pow(fy - .5, 2) > .25 &&
|
1125
|
+
(fy = math.sqrt(.25 - pow(fx - .5, 2)) * dir + .5) &&
|
1126
|
+
fy != .5 &&
|
1127
|
+
(fy = fy.toFixed(5) - 1e-5 * dir);
|
1128
|
+
}
|
1129
|
+
return E;
|
1130
|
+
});
|
1131
|
+
gradient = gradient[split](/\s*\-\s*/);
|
1132
|
+
if (type == "linear") {
|
1133
|
+
var angle = gradient.shift();
|
1134
|
+
angle = -toFloat(angle);
|
1135
|
+
if (isNaN(angle)) {
|
1136
|
+
return null;
|
1137
|
+
}
|
1138
|
+
var vector = [0, 0, math.cos(angle * PI / 180), math.sin(angle * PI / 180)],
|
1139
|
+
max = 1 / (mmax(abs(vector[2]), abs(vector[3])) || 1);
|
1140
|
+
vector[2] *= max;
|
1141
|
+
vector[3] *= max;
|
1142
|
+
if (vector[2] < 0) {
|
1143
|
+
vector[0] = -vector[2];
|
1144
|
+
vector[2] = 0;
|
1145
|
+
}
|
1146
|
+
if (vector[3] < 0) {
|
1147
|
+
vector[1] = -vector[3];
|
1148
|
+
vector[3] = 0;
|
1149
|
+
}
|
1150
|
+
}
|
1151
|
+
var dots = parseDots(gradient);
|
1152
|
+
if (!dots) {
|
1153
|
+
return null;
|
1154
|
+
}
|
1155
|
+
var id = o.getAttribute(fillString);
|
1156
|
+
id = id.match(/^url\(#(.*)\)$/);
|
1157
|
+
id && SVG.defs.removeChild(doc.getElementById(id[1]));
|
1158
|
+
|
1159
|
+
var el = $(type + "Gradient");
|
1160
|
+
el.id = createUUID();
|
1161
|
+
$(el, type == "radial" ? {fx: fx, fy: fy} : {x1: vector[0], y1: vector[1], x2: vector[2], y2: vector[3]});
|
1162
|
+
SVG.defs[appendChild](el);
|
1163
|
+
for (var i = 0, ii = dots[length]; i < ii; i++) {
|
1164
|
+
var stop = $("stop");
|
1165
|
+
$(stop, {
|
1166
|
+
offset: dots[i].offset ? dots[i].offset : !i ? "0%" : "100%",
|
1167
|
+
"stop-color": dots[i].color || "#fff"
|
1168
|
+
});
|
1169
|
+
el[appendChild](stop);
|
1170
|
+
}
|
1171
|
+
$(o, {
|
1172
|
+
fill: "url(#" + el.id + ")",
|
1173
|
+
opacity: 1,
|
1174
|
+
"fill-opacity": 1
|
1175
|
+
});
|
1176
|
+
s.fill = E;
|
1177
|
+
s.opacity = 1;
|
1178
|
+
s.fillOpacity = 1;
|
1179
|
+
return 1;
|
1180
|
+
};
|
1181
|
+
var updatePosition = function (o) {
|
1182
|
+
var bbox = o.getBBox();
|
1183
|
+
$(o.pattern, {patternTransform: R.format("translate({0},{1})", bbox.x, bbox.y)});
|
1184
|
+
};
|
1185
|
+
var setFillAndStroke = function (o, params) {
|
1186
|
+
var dasharray = {
|
1187
|
+
"": [0],
|
1188
|
+
"none": [0],
|
1189
|
+
"-": [3, 1],
|
1190
|
+
".": [1, 1],
|
1191
|
+
"-.": [3, 1, 1, 1],
|
1192
|
+
"-..": [3, 1, 1, 1, 1, 1],
|
1193
|
+
". ": [1, 3],
|
1194
|
+
"- ": [4, 3],
|
1195
|
+
"--": [8, 3],
|
1196
|
+
"- .": [4, 3, 1, 3],
|
1197
|
+
"--.": [8, 3, 1, 3],
|
1198
|
+
"--..": [8, 3, 1, 3, 1, 3]
|
1199
|
+
},
|
1200
|
+
node = o.node,
|
1201
|
+
attrs = o.attrs,
|
1202
|
+
rot = o.rotate(),
|
1203
|
+
addDashes = function (o, value) {
|
1204
|
+
value = dasharray[lowerCase.call(value)];
|
1205
|
+
if (value) {
|
1206
|
+
var width = o.attrs["stroke-width"] || "1",
|
1207
|
+
butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0,
|
1208
|
+
dashes = [];
|
1209
|
+
var i = value[length];
|
1210
|
+
while (i--) {
|
1211
|
+
dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt;
|
1212
|
+
}
|
1213
|
+
$(node, {"stroke-dasharray": dashes[join](",")});
|
1214
|
+
}
|
1215
|
+
};
|
1216
|
+
params[has]("rotation") && (rot = params.rotation);
|
1217
|
+
var rotxy = Str(rot)[split](separator);
|
1218
|
+
if (!(rotxy.length - 1)) {
|
1219
|
+
rotxy = null;
|
1220
|
+
} else {
|
1221
|
+
rotxy[1] = +rotxy[1];
|
1222
|
+
rotxy[2] = +rotxy[2];
|
1223
|
+
}
|
1224
|
+
toFloat(rot) && o.rotate(0, true);
|
1225
|
+
for (var att in params) {
|
1226
|
+
if (params[has](att)) {
|
1227
|
+
if (!availableAttrs[has](att)) {
|
1228
|
+
continue;
|
1229
|
+
}
|
1230
|
+
var value = params[att];
|
1231
|
+
attrs[att] = value;
|
1232
|
+
switch (att) {
|
1233
|
+
case "blur":
|
1234
|
+
o.blur(value);
|
1235
|
+
break;
|
1236
|
+
case "rotation":
|
1237
|
+
o.rotate(value, true);
|
1238
|
+
break;
|
1239
|
+
case "href":
|
1240
|
+
case "title":
|
1241
|
+
case "target":
|
1242
|
+
var pn = node.parentNode;
|
1243
|
+
if (lowerCase.call(pn.tagName) != "a") {
|
1244
|
+
var hl = $("a");
|
1245
|
+
pn.insertBefore(hl, node);
|
1246
|
+
hl[appendChild](node);
|
1247
|
+
pn = hl;
|
1248
|
+
}
|
1249
|
+
if (att == "target" && value == "blank") {
|
1250
|
+
pn.setAttributeNS(o.paper.xlink, "show", "new");
|
1251
|
+
} else {
|
1252
|
+
pn.setAttributeNS(o.paper.xlink, att, value);
|
1253
|
+
}
|
1254
|
+
break;
|
1255
|
+
case "cursor":
|
1256
|
+
node.style.cursor = value;
|
1257
|
+
break;
|
1258
|
+
case "clip-rect":
|
1259
|
+
var rect = Str(value)[split](separator);
|
1260
|
+
if (rect[length] == 4) {
|
1261
|
+
o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode);
|
1262
|
+
var el = $("clipPath"),
|
1263
|
+
rc = $("rect");
|
1264
|
+
el.id = createUUID();
|
1265
|
+
$(rc, {
|
1266
|
+
x: rect[0],
|
1267
|
+
y: rect[1],
|
1268
|
+
width: rect[2],
|
1269
|
+
height: rect[3]
|
1270
|
+
});
|
1271
|
+
el[appendChild](rc);
|
1272
|
+
o.paper.defs[appendChild](el);
|
1273
|
+
$(node, {"clip-path": "url(#" + el.id + ")"});
|
1274
|
+
o.clip = rc;
|
1275
|
+
}
|
1276
|
+
if (!value) {
|
1277
|
+
var clip = doc.getElementById(node.getAttribute("clip-path")[rp](/(^url\(#|\)$)/g, E));
|
1278
|
+
clip && clip.parentNode.removeChild(clip);
|
1279
|
+
$(node, {"clip-path": E});
|
1280
|
+
delete o.clip;
|
1281
|
+
}
|
1282
|
+
break;
|
1283
|
+
case "path":
|
1284
|
+
if (o.type == "path") {
|
1285
|
+
$(node, {d: value ? attrs.path = pathToAbsolute(value) : "M0,0"});
|
1286
|
+
}
|
1287
|
+
break;
|
1288
|
+
case "width":
|
1289
|
+
node[setAttribute](att, value);
|
1290
|
+
if (attrs.fx) {
|
1291
|
+
att = "x";
|
1292
|
+
value = attrs.x;
|
1293
|
+
} else {
|
1294
|
+
break;
|
1295
|
+
}
|
1296
|
+
case "x":
|
1297
|
+
if (attrs.fx) {
|
1298
|
+
value = -attrs.x - (attrs.width || 0);
|
1299
|
+
}
|
1300
|
+
case "rx":
|
1301
|
+
if (att == "rx" && o.type == "rect") {
|
1302
|
+
break;
|
1303
|
+
}
|
1304
|
+
case "cx":
|
1305
|
+
rotxy && (att == "x" || att == "cx") && (rotxy[1] += value - attrs[att]);
|
1306
|
+
node[setAttribute](att, value);
|
1307
|
+
o.pattern && updatePosition(o);
|
1308
|
+
break;
|
1309
|
+
case "height":
|
1310
|
+
node[setAttribute](att, value);
|
1311
|
+
if (attrs.fy) {
|
1312
|
+
att = "y";
|
1313
|
+
value = attrs.y;
|
1314
|
+
} else {
|
1315
|
+
break;
|
1316
|
+
}
|
1317
|
+
case "y":
|
1318
|
+
if (attrs.fy) {
|
1319
|
+
value = -attrs.y - (attrs.height || 0);
|
1320
|
+
}
|
1321
|
+
case "ry":
|
1322
|
+
if (att == "ry" && o.type == "rect") {
|
1323
|
+
break;
|
1324
|
+
}
|
1325
|
+
case "cy":
|
1326
|
+
rotxy && (att == "y" || att == "cy") && (rotxy[2] += value - attrs[att]);
|
1327
|
+
node[setAttribute](att, value);
|
1328
|
+
o.pattern && updatePosition(o);
|
1329
|
+
break;
|
1330
|
+
case "r":
|
1331
|
+
if (o.type == "rect") {
|
1332
|
+
$(node, {rx: value, ry: value});
|
1333
|
+
} else {
|
1334
|
+
node[setAttribute](att, value);
|
1335
|
+
}
|
1336
|
+
break;
|
1337
|
+
case "src":
|
1338
|
+
if (o.type == "image") {
|
1339
|
+
node.setAttributeNS(o.paper.xlink, "href", value);
|
1340
|
+
}
|
1341
|
+
break;
|
1342
|
+
case "stroke-width":
|
1343
|
+
node.style.strokeWidth = value;
|
1344
|
+
// Need following line for Firefox
|
1345
|
+
node[setAttribute](att, value);
|
1346
|
+
if (attrs["stroke-dasharray"]) {
|
1347
|
+
addDashes(o, attrs["stroke-dasharray"]);
|
1348
|
+
}
|
1349
|
+
break;
|
1350
|
+
case "stroke-dasharray":
|
1351
|
+
addDashes(o, value);
|
1352
|
+
break;
|
1353
|
+
case "translation":
|
1354
|
+
var xy = Str(value)[split](separator);
|
1355
|
+
xy[0] = +xy[0] || 0;
|
1356
|
+
xy[1] = +xy[1] || 0;
|
1357
|
+
if (rotxy) {
|
1358
|
+
rotxy[1] += xy[0];
|
1359
|
+
rotxy[2] += xy[1];
|
1360
|
+
}
|
1361
|
+
translate.call(o, xy[0], xy[1]);
|
1362
|
+
break;
|
1363
|
+
case "scale":
|
1364
|
+
xy = Str(value)[split](separator);
|
1365
|
+
o.scale(+xy[0] || 1, +xy[1] || +xy[0] || 1, isNaN(toFloat(xy[2])) ? null : +xy[2], isNaN(toFloat(xy[3])) ? null : +xy[3]);
|
1366
|
+
break;
|
1367
|
+
case fillString:
|
1368
|
+
var isURL = Str(value).match(ISURL);
|
1369
|
+
if (isURL) {
|
1370
|
+
el = $("pattern");
|
1371
|
+
var ig = $("image");
|
1372
|
+
el.id = createUUID();
|
1373
|
+
$(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse", height: 1, width: 1});
|
1374
|
+
$(ig, {x: 0, y: 0});
|
1375
|
+
ig.setAttributeNS(o.paper.xlink, "href", isURL[1]);
|
1376
|
+
el[appendChild](ig);
|
1377
|
+
|
1378
|
+
var img = doc.createElement("img");
|
1379
|
+
img.style.cssText = "position:absolute;left:-9999em;top-9999em";
|
1380
|
+
img.onload = function () {
|
1381
|
+
$(el, {width: this.offsetWidth, height: this.offsetHeight});
|
1382
|
+
$(ig, {width: this.offsetWidth, height: this.offsetHeight});
|
1383
|
+
doc.body.removeChild(this);
|
1384
|
+
o.paper.safari();
|
1385
|
+
};
|
1386
|
+
doc.body[appendChild](img);
|
1387
|
+
img.src = isURL[1];
|
1388
|
+
o.paper.defs[appendChild](el);
|
1389
|
+
node.style.fill = "url(#" + el.id + ")";
|
1390
|
+
$(node, {fill: "url(#" + el.id + ")"});
|
1391
|
+
o.pattern = el;
|
1392
|
+
o.pattern && updatePosition(o);
|
1393
|
+
break;
|
1394
|
+
}
|
1395
|
+
var clr = R.getRGB(value);
|
1396
|
+
if (!clr.error) {
|
1397
|
+
delete params.gradient;
|
1398
|
+
delete attrs.gradient;
|
1399
|
+
!R.is(attrs.opacity, "undefined") &&
|
1400
|
+
R.is(params.opacity, "undefined") &&
|
1401
|
+
$(node, {opacity: attrs.opacity});
|
1402
|
+
!R.is(attrs["fill-opacity"], "undefined") &&
|
1403
|
+
R.is(params["fill-opacity"], "undefined") &&
|
1404
|
+
$(node, {"fill-opacity": attrs["fill-opacity"]});
|
1405
|
+
} else if ((({circle: 1, ellipse: 1})[has](o.type) || Str(value).charAt() != "r") && addGradientFill(node, value, o.paper)) {
|
1406
|
+
attrs.gradient = value;
|
1407
|
+
attrs.fill = "none";
|
1408
|
+
break;
|
1409
|
+
}
|
1410
|
+
clr[has]("opacity") && $(node, {"fill-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});
|
1411
|
+
case "stroke":
|
1412
|
+
clr = R.getRGB(value);
|
1413
|
+
node[setAttribute](att, clr.hex);
|
1414
|
+
att == "stroke" && clr[has]("opacity") && $(node, {"stroke-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});
|
1415
|
+
break;
|
1416
|
+
case "gradient":
|
1417
|
+
(({circle: 1, ellipse: 1})[has](o.type) || Str(value).charAt() != "r") && addGradientFill(node, value, o.paper);
|
1418
|
+
break;
|
1419
|
+
case "opacity":
|
1420
|
+
if (attrs.gradient && !attrs[has]("stroke-opacity")) {
|
1421
|
+
$(node, {"stroke-opacity": value > 1 ? value / 100 : value});
|
1422
|
+
}
|
1423
|
+
// fall
|
1424
|
+
case "fill-opacity":
|
1425
|
+
if (attrs.gradient) {
|
1426
|
+
var gradient = doc.getElementById(node.getAttribute(fillString)[rp](/^url\(#|\)$/g, E));
|
1427
|
+
if (gradient) {
|
1428
|
+
var stops = gradient.getElementsByTagName("stop");
|
1429
|
+
stops[stops[length] - 1][setAttribute]("stop-opacity", value);
|
1430
|
+
}
|
1431
|
+
break;
|
1432
|
+
}
|
1433
|
+
default:
|
1434
|
+
att == "font-size" && (value = toInt(value, 10) + "px");
|
1435
|
+
var cssrule = att[rp](/(\-.)/g, function (w) {
|
1436
|
+
return upperCase.call(w.substring(1));
|
1437
|
+
});
|
1438
|
+
node.style[cssrule] = value;
|
1439
|
+
// Need following line for Firefox
|
1440
|
+
node[setAttribute](att, value);
|
1441
|
+
break;
|
1442
|
+
}
|
1443
|
+
}
|
1444
|
+
}
|
1445
|
+
|
1446
|
+
tuneText(o, params);
|
1447
|
+
if (rotxy) {
|
1448
|
+
o.rotate(rotxy.join(S));
|
1449
|
+
} else {
|
1450
|
+
toFloat(rot) && o.rotate(rot, true);
|
1451
|
+
}
|
1452
|
+
};
|
1453
|
+
var leading = 1.2,
|
1454
|
+
tuneText = function (el, params) {
|
1455
|
+
if (el.type != "text" || !(params[has]("text") || params[has]("font") || params[has]("font-size") || params[has]("x") || params[has]("y"))) {
|
1456
|
+
return;
|
1457
|
+
}
|
1458
|
+
var a = el.attrs,
|
1459
|
+
node = el.node,
|
1460
|
+
fontSize = node.firstChild ? toInt(doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size"), 10) : 10;
|
1461
|
+
|
1462
|
+
if (params[has]("text")) {
|
1463
|
+
a.text = params.text;
|
1464
|
+
while (node.firstChild) {
|
1465
|
+
node.removeChild(node.firstChild);
|
1466
|
+
}
|
1467
|
+
var texts = Str(params.text)[split]("\n");
|
1468
|
+
for (var i = 0, ii = texts[length]; i < ii; i++) if (texts[i]) {
|
1469
|
+
var tspan = $("tspan");
|
1470
|
+
i && $(tspan, {dy: fontSize * leading, x: a.x});
|
1471
|
+
tspan[appendChild](doc.createTextNode(texts[i]));
|
1472
|
+
node[appendChild](tspan);
|
1473
|
+
}
|
1474
|
+
} else {
|
1475
|
+
texts = node.getElementsByTagName("tspan");
|
1476
|
+
for (i = 0, ii = texts[length]; i < ii; i++) {
|
1477
|
+
i && $(texts[i], {dy: fontSize * leading, x: a.x});
|
1478
|
+
}
|
1479
|
+
}
|
1480
|
+
$(node, {y: a.y});
|
1481
|
+
var bb = el.getBBox(),
|
1482
|
+
dif = a.y - (bb.y + bb.height / 2);
|
1483
|
+
dif && R.is(dif, "finite") && $(node, {y: a.y + dif});
|
1484
|
+
},
|
1485
|
+
Element = function (node, svg) {
|
1486
|
+
var X = 0,
|
1487
|
+
Y = 0;
|
1488
|
+
this[0] = node;
|
1489
|
+
this.id = R._oid++;
|
1490
|
+
this.node = node;
|
1491
|
+
node.raphael = this;
|
1492
|
+
this.paper = svg;
|
1493
|
+
this.attrs = this.attrs || {};
|
1494
|
+
this.transformations = []; // rotate, translate, scale
|
1495
|
+
this._ = {
|
1496
|
+
tx: 0,
|
1497
|
+
ty: 0,
|
1498
|
+
rt: {deg: 0, cx: 0, cy: 0},
|
1499
|
+
sx: 1,
|
1500
|
+
sy: 1
|
1501
|
+
};
|
1502
|
+
!svg.bottom && (svg.bottom = this);
|
1503
|
+
this.prev = svg.top;
|
1504
|
+
svg.top && (svg.top.next = this);
|
1505
|
+
svg.top = this;
|
1506
|
+
this.next = null;
|
1507
|
+
};
|
1508
|
+
var elproto = Element[proto];
|
1509
|
+
Element[proto].rotate = function (deg, cx, cy) {
|
1510
|
+
if (this.removed) {
|
1511
|
+
return this;
|
1512
|
+
}
|
1513
|
+
if (deg == null) {
|
1514
|
+
if (this._.rt.cx) {
|
1515
|
+
return [this._.rt.deg, this._.rt.cx, this._.rt.cy][join](S);
|
1516
|
+
}
|
1517
|
+
return this._.rt.deg;
|
1518
|
+
}
|
1519
|
+
var bbox = this.getBBox();
|
1520
|
+
deg = Str(deg)[split](separator);
|
1521
|
+
if (deg[length] - 1) {
|
1522
|
+
cx = toFloat(deg[1]);
|
1523
|
+
cy = toFloat(deg[2]);
|
1524
|
+
}
|
1525
|
+
deg = toFloat(deg[0]);
|
1526
|
+
if (cx != null && cx !== false) {
|
1527
|
+
this._.rt.deg = deg;
|
1528
|
+
} else {
|
1529
|
+
this._.rt.deg += deg;
|
1530
|
+
}
|
1531
|
+
(cy == null) && (cx = null);
|
1532
|
+
this._.rt.cx = cx;
|
1533
|
+
this._.rt.cy = cy;
|
1534
|
+
cx = cx == null ? bbox.x + bbox.width / 2 : cx;
|
1535
|
+
cy = cy == null ? bbox.y + bbox.height / 2 : cy;
|
1536
|
+
if (this._.rt.deg) {
|
1537
|
+
this.transformations[0] = R.format("rotate({0} {1} {2})", this._.rt.deg, cx, cy);
|
1538
|
+
this.clip && $(this.clip, {transform: R.format("rotate({0} {1} {2})", -this._.rt.deg, cx, cy)});
|
1539
|
+
} else {
|
1540
|
+
this.transformations[0] = E;
|
1541
|
+
this.clip && $(this.clip, {transform: E});
|
1542
|
+
}
|
1543
|
+
$(this.node, {transform: this.transformations[join](S)});
|
1544
|
+
return this;
|
1545
|
+
};
|
1546
|
+
Element[proto].hide = function () {
|
1547
|
+
!this.removed && (this.node.style.display = "none");
|
1548
|
+
return this;
|
1549
|
+
};
|
1550
|
+
Element[proto].show = function () {
|
1551
|
+
!this.removed && (this.node.style.display = "");
|
1552
|
+
return this;
|
1553
|
+
};
|
1554
|
+
Element[proto].remove = function () {
|
1555
|
+
if (this.removed) {
|
1556
|
+
return;
|
1557
|
+
}
|
1558
|
+
tear(this, this.paper);
|
1559
|
+
this.node.parentNode.removeChild(this.node);
|
1560
|
+
for (var i in this) {
|
1561
|
+
delete this[i];
|
1562
|
+
}
|
1563
|
+
this.removed = true;
|
1564
|
+
};
|
1565
|
+
Element[proto].getBBox = function () {
|
1566
|
+
if (this.removed) {
|
1567
|
+
return this;
|
1568
|
+
}
|
1569
|
+
if (this.type == "path") {
|
1570
|
+
return pathDimensions(this.attrs.path);
|
1571
|
+
}
|
1572
|
+
if (this.node.style.display == "none") {
|
1573
|
+
this.show();
|
1574
|
+
var hide = true;
|
1575
|
+
}
|
1576
|
+
var bbox = {};
|
1577
|
+
try {
|
1578
|
+
bbox = this.node.getBBox();
|
1579
|
+
} catch(e) {
|
1580
|
+
// Firefox 3.0.x plays badly here
|
1581
|
+
} finally {
|
1582
|
+
bbox = bbox || {};
|
1583
|
+
}
|
1584
|
+
if (this.type == "text") {
|
1585
|
+
bbox = {x: bbox.x, y: Infinity, width: 0, height: 0};
|
1586
|
+
for (var i = 0, ii = this.node.getNumberOfChars(); i < ii; i++) {
|
1587
|
+
var bb = this.node.getExtentOfChar(i);
|
1588
|
+
(bb.y < bbox.y) && (bbox.y = bb.y);
|
1589
|
+
(bb.y + bb.height - bbox.y > bbox.height) && (bbox.height = bb.y + bb.height - bbox.y);
|
1590
|
+
(bb.x + bb.width - bbox.x > bbox.width) && (bbox.width = bb.x + bb.width - bbox.x);
|
1591
|
+
}
|
1592
|
+
}
|
1593
|
+
hide && this.hide();
|
1594
|
+
return bbox;
|
1595
|
+
};
|
1596
|
+
Element[proto].attr = function (name, value) {
|
1597
|
+
if (this.removed) {
|
1598
|
+
return this;
|
1599
|
+
}
|
1600
|
+
if (name == null) {
|
1601
|
+
var res = {};
|
1602
|
+
for (var i in this.attrs) if (this.attrs[has](i)) {
|
1603
|
+
res[i] = this.attrs[i];
|
1604
|
+
}
|
1605
|
+
this._.rt.deg && (res.rotation = this.rotate());
|
1606
|
+
(this._.sx != 1 || this._.sy != 1) && (res.scale = this.scale());
|
1607
|
+
res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient;
|
1608
|
+
return res;
|
1609
|
+
}
|
1610
|
+
if (value == null && R.is(name, string)) {
|
1611
|
+
if (name == "translation") {
|
1612
|
+
return translate.call(this);
|
1613
|
+
}
|
1614
|
+
if (name == "rotation") {
|
1615
|
+
return this.rotate();
|
1616
|
+
}
|
1617
|
+
if (name == "scale") {
|
1618
|
+
return this.scale();
|
1619
|
+
}
|
1620
|
+
if (name == fillString && this.attrs.fill == "none" && this.attrs.gradient) {
|
1621
|
+
return this.attrs.gradient;
|
1622
|
+
}
|
1623
|
+
return this.attrs[name];
|
1624
|
+
}
|
1625
|
+
if (value == null && R.is(name, array)) {
|
1626
|
+
var values = {};
|
1627
|
+
for (var j = 0, jj = name.length; j < jj; j++) {
|
1628
|
+
values[name[j]] = this.attr(name[j]);
|
1629
|
+
}
|
1630
|
+
return values;
|
1631
|
+
}
|
1632
|
+
if (value != null) {
|
1633
|
+
var params = {};
|
1634
|
+
params[name] = value;
|
1635
|
+
} else if (name != null && R.is(name, "object")) {
|
1636
|
+
params = name;
|
1637
|
+
}
|
1638
|
+
for (var key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) {
|
1639
|
+
var par = this.paper.customAttributes[key].apply(this, [][concat](params[key]));
|
1640
|
+
this.attrs[key] = params[key];
|
1641
|
+
for (var subkey in par) if (par[has](subkey)) {
|
1642
|
+
params[subkey] = par[subkey];
|
1643
|
+
}
|
1644
|
+
}
|
1645
|
+
setFillAndStroke(this, params);
|
1646
|
+
return this;
|
1647
|
+
};
|
1648
|
+
Element[proto].toFront = function () {
|
1649
|
+
if (this.removed) {
|
1650
|
+
return this;
|
1651
|
+
}
|
1652
|
+
this.node.parentNode[appendChild](this.node);
|
1653
|
+
var svg = this.paper;
|
1654
|
+
svg.top != this && tofront(this, svg);
|
1655
|
+
return this;
|
1656
|
+
};
|
1657
|
+
Element[proto].toBack = function () {
|
1658
|
+
if (this.removed) {
|
1659
|
+
return this;
|
1660
|
+
}
|
1661
|
+
if (this.node.parentNode.firstChild != this.node) {
|
1662
|
+
this.node.parentNode.insertBefore(this.node, this.node.parentNode.firstChild);
|
1663
|
+
toback(this, this.paper);
|
1664
|
+
var svg = this.paper;
|
1665
|
+
}
|
1666
|
+
return this;
|
1667
|
+
};
|
1668
|
+
Element[proto].insertAfter = function (element) {
|
1669
|
+
if (this.removed) {
|
1670
|
+
return this;
|
1671
|
+
}
|
1672
|
+
var node = element.node || element[element.length - 1].node;
|
1673
|
+
if (node.nextSibling) {
|
1674
|
+
node.parentNode.insertBefore(this.node, node.nextSibling);
|
1675
|
+
} else {
|
1676
|
+
node.parentNode[appendChild](this.node);
|
1677
|
+
}
|
1678
|
+
insertafter(this, element, this.paper);
|
1679
|
+
return this;
|
1680
|
+
};
|
1681
|
+
Element[proto].insertBefore = function (element) {
|
1682
|
+
if (this.removed) {
|
1683
|
+
return this;
|
1684
|
+
}
|
1685
|
+
var node = element.node || element[0].node;
|
1686
|
+
node.parentNode.insertBefore(this.node, node);
|
1687
|
+
insertbefore(this, element, this.paper);
|
1688
|
+
return this;
|
1689
|
+
};
|
1690
|
+
Element[proto].blur = function (size) {
|
1691
|
+
// Experimental. No Safari support. Use it on your own risk.
|
1692
|
+
var t = this;
|
1693
|
+
if (+size !== 0) {
|
1694
|
+
var fltr = $("filter"),
|
1695
|
+
blur = $("feGaussianBlur");
|
1696
|
+
t.attrs.blur = size;
|
1697
|
+
fltr.id = createUUID();
|
1698
|
+
$(blur, {stdDeviation: +size || 1.5});
|
1699
|
+
fltr.appendChild(blur);
|
1700
|
+
t.paper.defs.appendChild(fltr);
|
1701
|
+
t._blur = fltr;
|
1702
|
+
$(t.node, {filter: "url(#" + fltr.id + ")"});
|
1703
|
+
} else {
|
1704
|
+
if (t._blur) {
|
1705
|
+
t._blur.parentNode.removeChild(t._blur);
|
1706
|
+
delete t._blur;
|
1707
|
+
delete t.attrs.blur;
|
1708
|
+
}
|
1709
|
+
t.node.removeAttribute("filter");
|
1710
|
+
}
|
1711
|
+
};
|
1712
|
+
var theCircle = function (svg, x, y, r) {
|
1713
|
+
var el = $("circle");
|
1714
|
+
svg.canvas && svg.canvas[appendChild](el);
|
1715
|
+
var res = new Element(el, svg);
|
1716
|
+
res.attrs = {cx: x, cy: y, r: r, fill: "none", stroke: "#000"};
|
1717
|
+
res.type = "circle";
|
1718
|
+
$(el, res.attrs);
|
1719
|
+
return res;
|
1720
|
+
},
|
1721
|
+
theRect = function (svg, x, y, w, h, r) {
|
1722
|
+
var el = $("rect");
|
1723
|
+
svg.canvas && svg.canvas[appendChild](el);
|
1724
|
+
var res = new Element(el, svg);
|
1725
|
+
res.attrs = {x: x, y: y, width: w, height: h, r: r || 0, rx: r || 0, ry: r || 0, fill: "none", stroke: "#000"};
|
1726
|
+
res.type = "rect";
|
1727
|
+
$(el, res.attrs);
|
1728
|
+
return res;
|
1729
|
+
},
|
1730
|
+
theEllipse = function (svg, x, y, rx, ry) {
|
1731
|
+
var el = $("ellipse");
|
1732
|
+
svg.canvas && svg.canvas[appendChild](el);
|
1733
|
+
var res = new Element(el, svg);
|
1734
|
+
res.attrs = {cx: x, cy: y, rx: rx, ry: ry, fill: "none", stroke: "#000"};
|
1735
|
+
res.type = "ellipse";
|
1736
|
+
$(el, res.attrs);
|
1737
|
+
return res;
|
1738
|
+
},
|
1739
|
+
theImage = function (svg, src, x, y, w, h) {
|
1740
|
+
var el = $("image");
|
1741
|
+
$(el, {x: x, y: y, width: w, height: h, preserveAspectRatio: "none"});
|
1742
|
+
el.setAttributeNS(svg.xlink, "href", src);
|
1743
|
+
svg.canvas && svg.canvas[appendChild](el);
|
1744
|
+
var res = new Element(el, svg);
|
1745
|
+
res.attrs = {x: x, y: y, width: w, height: h, src: src};
|
1746
|
+
res.type = "image";
|
1747
|
+
return res;
|
1748
|
+
},
|
1749
|
+
theText = function (svg, x, y, text) {
|
1750
|
+
var el = $("text");
|
1751
|
+
$(el, {x: x, y: y, "text-anchor": "middle"});
|
1752
|
+
svg.canvas && svg.canvas[appendChild](el);
|
1753
|
+
var res = new Element(el, svg);
|
1754
|
+
res.attrs = {x: x, y: y, "text-anchor": "middle", text: text, font: availableAttrs.font, stroke: "none", fill: "#000"};
|
1755
|
+
res.type = "text";
|
1756
|
+
setFillAndStroke(res, res.attrs);
|
1757
|
+
return res;
|
1758
|
+
},
|
1759
|
+
setSize = function (width, height) {
|
1760
|
+
this.width = width || this.width;
|
1761
|
+
this.height = height || this.height;
|
1762
|
+
this.canvas[setAttribute]("width", this.width);
|
1763
|
+
this.canvas[setAttribute]("height", this.height);
|
1764
|
+
return this;
|
1765
|
+
},
|
1766
|
+
create = function () {
|
1767
|
+
var con = getContainer[apply](0, arguments),
|
1768
|
+
container = con && con.container,
|
1769
|
+
x = con.x,
|
1770
|
+
y = con.y,
|
1771
|
+
width = con.width,
|
1772
|
+
height = con.height;
|
1773
|
+
if (!container) {
|
1774
|
+
throw new Error("SVG container not found.");
|
1775
|
+
}
|
1776
|
+
var cnvs = $("svg");
|
1777
|
+
x = x || 0;
|
1778
|
+
y = y || 0;
|
1779
|
+
width = width || 512;
|
1780
|
+
height = height || 342;
|
1781
|
+
$(cnvs, {
|
1782
|
+
xmlns: "http://www.w3.org/2000/svg",
|
1783
|
+
version: 1.1,
|
1784
|
+
width: width,
|
1785
|
+
height: height
|
1786
|
+
});
|
1787
|
+
if (container == 1) {
|
1788
|
+
cnvs.style.cssText = "position:absolute;left:" + x + "px;top:" + y + "px";
|
1789
|
+
doc.body[appendChild](cnvs);
|
1790
|
+
} else {
|
1791
|
+
if (container.firstChild) {
|
1792
|
+
container.insertBefore(cnvs, container.firstChild);
|
1793
|
+
} else {
|
1794
|
+
container[appendChild](cnvs);
|
1795
|
+
}
|
1796
|
+
}
|
1797
|
+
container = new Paper;
|
1798
|
+
container.width = width;
|
1799
|
+
container.height = height;
|
1800
|
+
container.canvas = cnvs;
|
1801
|
+
plugins.call(container, container, R.fn);
|
1802
|
+
container.clear();
|
1803
|
+
return container;
|
1804
|
+
};
|
1805
|
+
paperproto.clear = function () {
|
1806
|
+
var c = this.canvas;
|
1807
|
+
while (c.firstChild) {
|
1808
|
+
c.removeChild(c.firstChild);
|
1809
|
+
}
|
1810
|
+
this.bottom = this.top = null;
|
1811
|
+
(this.desc = $("desc"))[appendChild](doc.createTextNode("Created with Rapha\xebl"));
|
1812
|
+
c[appendChild](this.desc);
|
1813
|
+
c[appendChild](this.defs = $("defs"));
|
1814
|
+
};
|
1815
|
+
paperproto.remove = function () {
|
1816
|
+
this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
|
1817
|
+
for (var i in this) {
|
1818
|
+
this[i] = removed(i);
|
1819
|
+
}
|
1820
|
+
};
|
1821
|
+
}
|
1822
|
+
|
1823
|
+
// VML
|
1824
|
+
if (R.vml) {
|
1825
|
+
var map = {M: "m", L: "l", C: "c", Z: "x", m: "t", l: "r", c: "v", z: "x"},
|
1826
|
+
bites = /([clmz]),?([^clmz]*)/gi,
|
1827
|
+
blurregexp = / progid:\S+Blur\([^\)]+\)/g,
|
1828
|
+
val = /-?[^,\s-]+/g,
|
1829
|
+
coordsize = 1e3 + S + 1e3,
|
1830
|
+
zoom = 10,
|
1831
|
+
pathlike = {path: 1, rect: 1},
|
1832
|
+
path2vml = function (path) {
|
1833
|
+
var total = /[ahqstv]/ig,
|
1834
|
+
command = pathToAbsolute;
|
1835
|
+
Str(path).match(total) && (command = path2curve);
|
1836
|
+
total = /[clmz]/g;
|
1837
|
+
if (command == pathToAbsolute && !Str(path).match(total)) {
|
1838
|
+
var res = Str(path)[rp](bites, function (all, command, args) {
|
1839
|
+
var vals = [],
|
1840
|
+
isMove = lowerCase.call(command) == "m",
|
1841
|
+
res = map[command];
|
1842
|
+
args[rp](val, function (value) {
|
1843
|
+
if (isMove && vals[length] == 2) {
|
1844
|
+
res += vals + map[command == "m" ? "l" : "L"];
|
1845
|
+
vals = [];
|
1846
|
+
}
|
1847
|
+
vals[push](round(value * zoom));
|
1848
|
+
});
|
1849
|
+
return res + vals;
|
1850
|
+
});
|
1851
|
+
return res;
|
1852
|
+
}
|
1853
|
+
var pa = command(path), p, r;
|
1854
|
+
res = [];
|
1855
|
+
for (var i = 0, ii = pa[length]; i < ii; i++) {
|
1856
|
+
p = pa[i];
|
1857
|
+
r = lowerCase.call(pa[i][0]);
|
1858
|
+
r == "z" && (r = "x");
|
1859
|
+
for (var j = 1, jj = p[length]; j < jj; j++) {
|
1860
|
+
r += round(p[j] * zoom) + (j != jj - 1 ? "," : E);
|
1861
|
+
}
|
1862
|
+
res[push](r);
|
1863
|
+
}
|
1864
|
+
return res[join](S);
|
1865
|
+
};
|
1866
|
+
|
1867
|
+
R[toString] = function () {
|
1868
|
+
return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version;
|
1869
|
+
};
|
1870
|
+
thePath = function (pathString, vml) {
|
1871
|
+
var g = createNode("group");
|
1872
|
+
g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px";
|
1873
|
+
g.coordsize = vml.coordsize;
|
1874
|
+
g.coordorigin = vml.coordorigin;
|
1875
|
+
var el = createNode("shape"), ol = el.style;
|
1876
|
+
ol.width = vml.width + "px";
|
1877
|
+
ol.height = vml.height + "px";
|
1878
|
+
el.coordsize = coordsize;
|
1879
|
+
el.coordorigin = vml.coordorigin;
|
1880
|
+
g[appendChild](el);
|
1881
|
+
var p = new Element(el, g, vml),
|
1882
|
+
attr = {fill: "none", stroke: "#000"};
|
1883
|
+
pathString && (attr.path = pathString);
|
1884
|
+
p.type = "path";
|
1885
|
+
p.path = [];
|
1886
|
+
p.Path = E;
|
1887
|
+
setFillAndStroke(p, attr);
|
1888
|
+
vml.canvas[appendChild](g);
|
1889
|
+
return p;
|
1890
|
+
};
|
1891
|
+
setFillAndStroke = function (o, params) {
|
1892
|
+
o.attrs = o.attrs || {};
|
1893
|
+
var node = o.node,
|
1894
|
+
a = o.attrs,
|
1895
|
+
s = node.style,
|
1896
|
+
xy,
|
1897
|
+
newpath = (params.x != a.x || params.y != a.y || params.width != a.width || params.height != a.height || params.r != a.r) && o.type == "rect",
|
1898
|
+
res = o;
|
1899
|
+
|
1900
|
+
for (var par in params) if (params[has](par)) {
|
1901
|
+
a[par] = params[par];
|
1902
|
+
}
|
1903
|
+
if (newpath) {
|
1904
|
+
a.path = rectPath(a.x, a.y, a.width, a.height, a.r);
|
1905
|
+
o.X = a.x;
|
1906
|
+
o.Y = a.y;
|
1907
|
+
o.W = a.width;
|
1908
|
+
o.H = a.height;
|
1909
|
+
}
|
1910
|
+
params.href && (node.href = params.href);
|
1911
|
+
params.title && (node.title = params.title);
|
1912
|
+
params.target && (node.target = params.target);
|
1913
|
+
params.cursor && (s.cursor = params.cursor);
|
1914
|
+
"blur" in params && o.blur(params.blur);
|
1915
|
+
if (params.path && o.type == "path" || newpath) {
|
1916
|
+
node.path = path2vml(a.path);
|
1917
|
+
}
|
1918
|
+
if (params.rotation != null) {
|
1919
|
+
o.rotate(params.rotation, true);
|
1920
|
+
}
|
1921
|
+
if (params.translation) {
|
1922
|
+
xy = Str(params.translation)[split](separator);
|
1923
|
+
translate.call(o, xy[0], xy[1]);
|
1924
|
+
if (o._.rt.cx != null) {
|
1925
|
+
o._.rt.cx +=+ xy[0];
|
1926
|
+
o._.rt.cy +=+ xy[1];
|
1927
|
+
o.setBox(o.attrs, xy[0], xy[1]);
|
1928
|
+
}
|
1929
|
+
}
|
1930
|
+
if (params.scale) {
|
1931
|
+
xy = Str(params.scale)[split](separator);
|
1932
|
+
o.scale(+xy[0] || 1, +xy[1] || +xy[0] || 1, +xy[2] || null, +xy[3] || null);
|
1933
|
+
}
|
1934
|
+
if ("clip-rect" in params) {
|
1935
|
+
var rect = Str(params["clip-rect"])[split](separator);
|
1936
|
+
if (rect[length] == 4) {
|
1937
|
+
rect[2] = +rect[2] + (+rect[0]);
|
1938
|
+
rect[3] = +rect[3] + (+rect[1]);
|
1939
|
+
var div = node.clipRect || doc.createElement("div"),
|
1940
|
+
dstyle = div.style,
|
1941
|
+
group = node.parentNode;
|
1942
|
+
dstyle.clip = R.format("rect({1}px {2}px {3}px {0}px)", rect);
|
1943
|
+
if (!node.clipRect) {
|
1944
|
+
dstyle.position = "absolute";
|
1945
|
+
dstyle.top = 0;
|
1946
|
+
dstyle.left = 0;
|
1947
|
+
dstyle.width = o.paper.width + "px";
|
1948
|
+
dstyle.height = o.paper.height + "px";
|
1949
|
+
group.parentNode.insertBefore(div, group);
|
1950
|
+
div[appendChild](group);
|
1951
|
+
node.clipRect = div;
|
1952
|
+
}
|
1953
|
+
}
|
1954
|
+
if (!params["clip-rect"]) {
|
1955
|
+
node.clipRect && (node.clipRect.style.clip = E);
|
1956
|
+
}
|
1957
|
+
}
|
1958
|
+
if (o.type == "image" && params.src) {
|
1959
|
+
node.src = params.src;
|
1960
|
+
}
|
1961
|
+
if (o.type == "image" && params.opacity) {
|
1962
|
+
node.filterOpacity = ms + ".Alpha(opacity=" + (params.opacity * 100) + ")";
|
1963
|
+
s.filter = (node.filterMatrix || E) + (node.filterOpacity || E);
|
1964
|
+
}
|
1965
|
+
params.font && (s.font = params.font);
|
1966
|
+
params["font-family"] && (s.fontFamily = '"' + params["font-family"][split](",")[0][rp](/^['"]+|['"]+$/g, E) + '"');
|
1967
|
+
params["font-size"] && (s.fontSize = params["font-size"]);
|
1968
|
+
params["font-weight"] && (s.fontWeight = params["font-weight"]);
|
1969
|
+
params["font-style"] && (s.fontStyle = params["font-style"]);
|
1970
|
+
if (params.opacity != null ||
|
1971
|
+
params["stroke-width"] != null ||
|
1972
|
+
params.fill != null ||
|
1973
|
+
params.stroke != null ||
|
1974
|
+
params["stroke-width"] != null ||
|
1975
|
+
params["stroke-opacity"] != null ||
|
1976
|
+
params["fill-opacity"] != null ||
|
1977
|
+
params["stroke-dasharray"] != null ||
|
1978
|
+
params["stroke-miterlimit"] != null ||
|
1979
|
+
params["stroke-linejoin"] != null ||
|
1980
|
+
params["stroke-linecap"] != null) {
|
1981
|
+
node = o.shape || node;
|
1982
|
+
var fill = (node.getElementsByTagName(fillString) && node.getElementsByTagName(fillString)[0]),
|
1983
|
+
newfill = false;
|
1984
|
+
!fill && (newfill = fill = createNode(fillString));
|
1985
|
+
if ("fill-opacity" in params || "opacity" in params) {
|
1986
|
+
var opacity = ((+a["fill-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+R.getRGB(params.fill).o + 1 || 2) - 1);
|
1987
|
+
opacity = mmin(mmax(opacity, 0), 1);
|
1988
|
+
fill.opacity = opacity;
|
1989
|
+
}
|
1990
|
+
params.fill && (fill.on = true);
|
1991
|
+
if (fill.on == null || params.fill == "none") {
|
1992
|
+
fill.on = false;
|
1993
|
+
}
|
1994
|
+
if (fill.on && params.fill) {
|
1995
|
+
var isURL = params.fill.match(ISURL);
|
1996
|
+
if (isURL) {
|
1997
|
+
fill.src = isURL[1];
|
1998
|
+
fill.type = "tile";
|
1999
|
+
} else {
|
2000
|
+
fill.color = R.getRGB(params.fill).hex;
|
2001
|
+
fill.src = E;
|
2002
|
+
fill.type = "solid";
|
2003
|
+
if (R.getRGB(params.fill).error && (res.type in {circle: 1, ellipse: 1} || Str(params.fill).charAt() != "r") && addGradientFill(res, params.fill)) {
|
2004
|
+
a.fill = "none";
|
2005
|
+
a.gradient = params.fill;
|
2006
|
+
}
|
2007
|
+
}
|
2008
|
+
}
|
2009
|
+
newfill && node[appendChild](fill);
|
2010
|
+
var stroke = (node.getElementsByTagName("stroke") && node.getElementsByTagName("stroke")[0]),
|
2011
|
+
newstroke = false;
|
2012
|
+
!stroke && (newstroke = stroke = createNode("stroke"));
|
2013
|
+
if ((params.stroke && params.stroke != "none") ||
|
2014
|
+
params["stroke-width"] ||
|
2015
|
+
params["stroke-opacity"] != null ||
|
2016
|
+
params["stroke-dasharray"] ||
|
2017
|
+
params["stroke-miterlimit"] ||
|
2018
|
+
params["stroke-linejoin"] ||
|
2019
|
+
params["stroke-linecap"]) {
|
2020
|
+
stroke.on = true;
|
2021
|
+
}
|
2022
|
+
(params.stroke == "none" || stroke.on == null || params.stroke == 0 || params["stroke-width"] == 0) && (stroke.on = false);
|
2023
|
+
var strokeColor = R.getRGB(params.stroke);
|
2024
|
+
stroke.on && params.stroke && (stroke.color = strokeColor.hex);
|
2025
|
+
opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+strokeColor.o + 1 || 2) - 1);
|
2026
|
+
var width = (toFloat(params["stroke-width"]) || 1) * .75;
|
2027
|
+
opacity = mmin(mmax(opacity, 0), 1);
|
2028
|
+
params["stroke-width"] == null && (width = a["stroke-width"]);
|
2029
|
+
params["stroke-width"] && (stroke.weight = width);
|
2030
|
+
width && width < 1 && (opacity *= width) && (stroke.weight = 1);
|
2031
|
+
stroke.opacity = opacity;
|
2032
|
+
|
2033
|
+
params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter");
|
2034
|
+
stroke.miterlimit = params["stroke-miterlimit"] || 8;
|
2035
|
+
params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round");
|
2036
|
+
if (params["stroke-dasharray"]) {
|
2037
|
+
var dasharray = {
|
2038
|
+
"-": "shortdash",
|
2039
|
+
".": "shortdot",
|
2040
|
+
"-.": "shortdashdot",
|
2041
|
+
"-..": "shortdashdotdot",
|
2042
|
+
". ": "dot",
|
2043
|
+
"- ": "dash",
|
2044
|
+
"--": "longdash",
|
2045
|
+
"- .": "dashdot",
|
2046
|
+
"--.": "longdashdot",
|
2047
|
+
"--..": "longdashdotdot"
|
2048
|
+
};
|
2049
|
+
stroke.dashstyle = dasharray[has](params["stroke-dasharray"]) ? dasharray[params["stroke-dasharray"]] : E;
|
2050
|
+
}
|
2051
|
+
newstroke && node[appendChild](stroke);
|
2052
|
+
}
|
2053
|
+
if (res.type == "text") {
|
2054
|
+
s = res.paper.span.style;
|
2055
|
+
a.font && (s.font = a.font);
|
2056
|
+
a["font-family"] && (s.fontFamily = a["font-family"]);
|
2057
|
+
a["font-size"] && (s.fontSize = a["font-size"]);
|
2058
|
+
a["font-weight"] && (s.fontWeight = a["font-weight"]);
|
2059
|
+
a["font-style"] && (s.fontStyle = a["font-style"]);
|
2060
|
+
res.node.string && (res.paper.span.innerHTML = Str(res.node.string)[rp](/</g, "<")[rp](/&/g, "&")[rp](/\n/g, "<br>"));
|
2061
|
+
res.W = a.w = res.paper.span.offsetWidth;
|
2062
|
+
res.H = a.h = res.paper.span.offsetHeight;
|
2063
|
+
res.X = a.x;
|
2064
|
+
res.Y = a.y + round(res.H / 2);
|
2065
|
+
|
2066
|
+
// text-anchor emulationm
|
2067
|
+
switch (a["text-anchor"]) {
|
2068
|
+
case "start":
|
2069
|
+
res.node.style["v-text-align"] = "left";
|
2070
|
+
res.bbx = round(res.W / 2);
|
2071
|
+
break;
|
2072
|
+
case "end":
|
2073
|
+
res.node.style["v-text-align"] = "right";
|
2074
|
+
res.bbx = -round(res.W / 2);
|
2075
|
+
break;
|
2076
|
+
default:
|
2077
|
+
res.node.style["v-text-align"] = "center";
|
2078
|
+
break;
|
2079
|
+
}
|
2080
|
+
}
|
2081
|
+
};
|
2082
|
+
addGradientFill = function (o, gradient) {
|
2083
|
+
o.attrs = o.attrs || {};
|
2084
|
+
var attrs = o.attrs,
|
2085
|
+
fill,
|
2086
|
+
type = "linear",
|
2087
|
+
fxfy = ".5 .5";
|
2088
|
+
o.attrs.gradient = gradient;
|
2089
|
+
gradient = Str(gradient)[rp](radial_gradient, function (all, fx, fy) {
|
2090
|
+
type = "radial";
|
2091
|
+
if (fx && fy) {
|
2092
|
+
fx = toFloat(fx);
|
2093
|
+
fy = toFloat(fy);
|
2094
|
+
pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && (fy = math.sqrt(.25 - pow(fx - .5, 2)) * ((fy > .5) * 2 - 1) + .5);
|
2095
|
+
fxfy = fx + S + fy;
|
2096
|
+
}
|
2097
|
+
return E;
|
2098
|
+
});
|
2099
|
+
gradient = gradient[split](/\s*\-\s*/);
|
2100
|
+
if (type == "linear") {
|
2101
|
+
var angle = gradient.shift();
|
2102
|
+
angle = -toFloat(angle);
|
2103
|
+
if (isNaN(angle)) {
|
2104
|
+
return null;
|
2105
|
+
}
|
2106
|
+
}
|
2107
|
+
var dots = parseDots(gradient);
|
2108
|
+
if (!dots) {
|
2109
|
+
return null;
|
2110
|
+
}
|
2111
|
+
o = o.shape || o.node;
|
2112
|
+
fill = o.getElementsByTagName(fillString)[0] || createNode(fillString);
|
2113
|
+
!fill.parentNode && o.appendChild(fill);
|
2114
|
+
if (dots[length]) {
|
2115
|
+
fill.on = true;
|
2116
|
+
fill.method = "none";
|
2117
|
+
fill.color = dots[0].color;
|
2118
|
+
fill.color2 = dots[dots[length] - 1].color;
|
2119
|
+
var clrs = [];
|
2120
|
+
for (var i = 0, ii = dots[length]; i < ii; i++) {
|
2121
|
+
dots[i].offset && clrs[push](dots[i].offset + S + dots[i].color);
|
2122
|
+
}
|
2123
|
+
fill.colors && (fill.colors.value = clrs[length] ? clrs[join]() : "0% " + fill.color);
|
2124
|
+
if (type == "radial") {
|
2125
|
+
fill.type = "gradientradial";
|
2126
|
+
fill.focus = "100%";
|
2127
|
+
fill.focussize = fxfy;
|
2128
|
+
fill.focusposition = fxfy;
|
2129
|
+
} else {
|
2130
|
+
fill.type = "gradient";
|
2131
|
+
fill.angle = (270 - angle) % 360;
|
2132
|
+
}
|
2133
|
+
}
|
2134
|
+
return 1;
|
2135
|
+
};
|
2136
|
+
Element = function (node, group, vml) {
|
2137
|
+
var Rotation = 0,
|
2138
|
+
RotX = 0,
|
2139
|
+
RotY = 0,
|
2140
|
+
Scale = 1;
|
2141
|
+
this[0] = node;
|
2142
|
+
this.id = R._oid++;
|
2143
|
+
this.node = node;
|
2144
|
+
node.raphael = this;
|
2145
|
+
this.X = 0;
|
2146
|
+
this.Y = 0;
|
2147
|
+
this.attrs = {};
|
2148
|
+
this.Group = group;
|
2149
|
+
this.paper = vml;
|
2150
|
+
this._ = {
|
2151
|
+
tx: 0,
|
2152
|
+
ty: 0,
|
2153
|
+
rt: {deg:0},
|
2154
|
+
sx: 1,
|
2155
|
+
sy: 1
|
2156
|
+
};
|
2157
|
+
!vml.bottom && (vml.bottom = this);
|
2158
|
+
this.prev = vml.top;
|
2159
|
+
vml.top && (vml.top.next = this);
|
2160
|
+
vml.top = this;
|
2161
|
+
this.next = null;
|
2162
|
+
};
|
2163
|
+
elproto = Element[proto];
|
2164
|
+
elproto.rotate = function (deg, cx, cy) {
|
2165
|
+
if (this.removed) {
|
2166
|
+
return this;
|
2167
|
+
}
|
2168
|
+
if (deg == null) {
|
2169
|
+
if (this._.rt.cx) {
|
2170
|
+
return [this._.rt.deg, this._.rt.cx, this._.rt.cy][join](S);
|
2171
|
+
}
|
2172
|
+
return this._.rt.deg;
|
2173
|
+
}
|
2174
|
+
deg = Str(deg)[split](separator);
|
2175
|
+
if (deg[length] - 1) {
|
2176
|
+
cx = toFloat(deg[1]);
|
2177
|
+
cy = toFloat(deg[2]);
|
2178
|
+
}
|
2179
|
+
deg = toFloat(deg[0]);
|
2180
|
+
if (cx != null) {
|
2181
|
+
this._.rt.deg = deg;
|
2182
|
+
} else {
|
2183
|
+
this._.rt.deg += deg;
|
2184
|
+
}
|
2185
|
+
cy == null && (cx = null);
|
2186
|
+
this._.rt.cx = cx;
|
2187
|
+
this._.rt.cy = cy;
|
2188
|
+
this.setBox(this.attrs, cx, cy);
|
2189
|
+
this.Group.style.rotation = this._.rt.deg;
|
2190
|
+
// gradient fix for rotation. TODO
|
2191
|
+
// var fill = (this.shape || this.node).getElementsByTagName(fillString);
|
2192
|
+
// fill = fill[0] || {};
|
2193
|
+
// var b = ((360 - this._.rt.deg) - 270) % 360;
|
2194
|
+
// !R.is(fill.angle, "undefined") && (fill.angle = b);
|
2195
|
+
return this;
|
2196
|
+
};
|
2197
|
+
elproto.setBox = function (params, cx, cy) {
|
2198
|
+
if (this.removed) {
|
2199
|
+
return this;
|
2200
|
+
}
|
2201
|
+
var gs = this.Group.style,
|
2202
|
+
os = (this.shape && this.shape.style) || this.node.style;
|
2203
|
+
params = params || {};
|
2204
|
+
for (var i in params) if (params[has](i)) {
|
2205
|
+
this.attrs[i] = params[i];
|
2206
|
+
}
|
2207
|
+
cx = cx || this._.rt.cx;
|
2208
|
+
cy = cy || this._.rt.cy;
|
2209
|
+
var attr = this.attrs,
|
2210
|
+
x,
|
2211
|
+
y,
|
2212
|
+
w,
|
2213
|
+
h;
|
2214
|
+
switch (this.type) {
|
2215
|
+
case "circle":
|
2216
|
+
x = attr.cx - attr.r;
|
2217
|
+
y = attr.cy - attr.r;
|
2218
|
+
w = h = attr.r * 2;
|
2219
|
+
break;
|
2220
|
+
case "ellipse":
|
2221
|
+
x = attr.cx - attr.rx;
|
2222
|
+
y = attr.cy - attr.ry;
|
2223
|
+
w = attr.rx * 2;
|
2224
|
+
h = attr.ry * 2;
|
2225
|
+
break;
|
2226
|
+
case "image":
|
2227
|
+
x = +attr.x;
|
2228
|
+
y = +attr.y;
|
2229
|
+
w = attr.width || 0;
|
2230
|
+
h = attr.height || 0;
|
2231
|
+
break;
|
2232
|
+
case "text":
|
2233
|
+
this.textpath.v = ["m", round(attr.x), ", ", round(attr.y - 2), "l", round(attr.x) + 1, ", ", round(attr.y - 2)][join](E);
|
2234
|
+
x = attr.x - round(this.W / 2);
|
2235
|
+
y = attr.y - this.H / 2;
|
2236
|
+
w = this.W;
|
2237
|
+
h = this.H;
|
2238
|
+
break;
|
2239
|
+
case "rect":
|
2240
|
+
case "path":
|
2241
|
+
if (!this.attrs.path) {
|
2242
|
+
x = 0;
|
2243
|
+
y = 0;
|
2244
|
+
w = this.paper.width;
|
2245
|
+
h = this.paper.height;
|
2246
|
+
} else {
|
2247
|
+
var dim = pathDimensions(this.attrs.path);
|
2248
|
+
x = dim.x;
|
2249
|
+
y = dim.y;
|
2250
|
+
w = dim.width;
|
2251
|
+
h = dim.height;
|
2252
|
+
}
|
2253
|
+
break;
|
2254
|
+
default:
|
2255
|
+
x = 0;
|
2256
|
+
y = 0;
|
2257
|
+
w = this.paper.width;
|
2258
|
+
h = this.paper.height;
|
2259
|
+
break;
|
2260
|
+
}
|
2261
|
+
cx = (cx == null) ? x + w / 2 : cx;
|
2262
|
+
cy = (cy == null) ? y + h / 2 : cy;
|
2263
|
+
var left = cx - this.paper.width / 2,
|
2264
|
+
top = cy - this.paper.height / 2, t;
|
2265
|
+
gs.left != (t = left + "px") && (gs.left = t);
|
2266
|
+
gs.top != (t = top + "px") && (gs.top = t);
|
2267
|
+
this.X = pathlike[has](this.type) ? -left : x;
|
2268
|
+
this.Y = pathlike[has](this.type) ? -top : y;
|
2269
|
+
this.W = w;
|
2270
|
+
this.H = h;
|
2271
|
+
if (pathlike[has](this.type)) {
|
2272
|
+
os.left != (t = -left * zoom + "px") && (os.left = t);
|
2273
|
+
os.top != (t = -top * zoom + "px") && (os.top = t);
|
2274
|
+
} else if (this.type == "text") {
|
2275
|
+
os.left != (t = -left + "px") && (os.left = t);
|
2276
|
+
os.top != (t = -top + "px") && (os.top = t);
|
2277
|
+
} else {
|
2278
|
+
gs.width != (t = this.paper.width + "px") && (gs.width = t);
|
2279
|
+
gs.height != (t = this.paper.height + "px") && (gs.height = t);
|
2280
|
+
os.left != (t = x - left + "px") && (os.left = t);
|
2281
|
+
os.top != (t = y - top + "px") && (os.top = t);
|
2282
|
+
os.width != (t = w + "px") && (os.width = t);
|
2283
|
+
os.height != (t = h + "px") && (os.height = t);
|
2284
|
+
}
|
2285
|
+
};
|
2286
|
+
elproto.hide = function () {
|
2287
|
+
!this.removed && (this.Group.style.display = "none");
|
2288
|
+
return this;
|
2289
|
+
};
|
2290
|
+
elproto.show = function () {
|
2291
|
+
!this.removed && (this.Group.style.display = "block");
|
2292
|
+
return this;
|
2293
|
+
};
|
2294
|
+
elproto.getBBox = function () {
|
2295
|
+
if (this.removed) {
|
2296
|
+
return this;
|
2297
|
+
}
|
2298
|
+
if (pathlike[has](this.type)) {
|
2299
|
+
return pathDimensions(this.attrs.path);
|
2300
|
+
}
|
2301
|
+
return {
|
2302
|
+
x: this.X + (this.bbx || 0),
|
2303
|
+
y: this.Y,
|
2304
|
+
width: this.W,
|
2305
|
+
height: this.H
|
2306
|
+
};
|
2307
|
+
};
|
2308
|
+
elproto.remove = function () {
|
2309
|
+
if (this.removed) {
|
2310
|
+
return;
|
2311
|
+
}
|
2312
|
+
tear(this, this.paper);
|
2313
|
+
this.node.parentNode.removeChild(this.node);
|
2314
|
+
this.Group.parentNode.removeChild(this.Group);
|
2315
|
+
this.shape && this.shape.parentNode.removeChild(this.shape);
|
2316
|
+
for (var i in this) {
|
2317
|
+
delete this[i];
|
2318
|
+
}
|
2319
|
+
this.removed = true;
|
2320
|
+
};
|
2321
|
+
elproto.attr = function (name, value) {
|
2322
|
+
if (this.removed) {
|
2323
|
+
return this;
|
2324
|
+
}
|
2325
|
+
if (name == null) {
|
2326
|
+
var res = {};
|
2327
|
+
for (var i in this.attrs) if (this.attrs[has](i)) {
|
2328
|
+
res[i] = this.attrs[i];
|
2329
|
+
}
|
2330
|
+
this._.rt.deg && (res.rotation = this.rotate());
|
2331
|
+
(this._.sx != 1 || this._.sy != 1) && (res.scale = this.scale());
|
2332
|
+
res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient;
|
2333
|
+
return res;
|
2334
|
+
}
|
2335
|
+
if (value == null && R.is(name, "string")) {
|
2336
|
+
if (name == "translation") {
|
2337
|
+
return translate.call(this);
|
2338
|
+
}
|
2339
|
+
if (name == "rotation") {
|
2340
|
+
return this.rotate();
|
2341
|
+
}
|
2342
|
+
if (name == "scale") {
|
2343
|
+
return this.scale();
|
2344
|
+
}
|
2345
|
+
if (name == fillString && this.attrs.fill == "none" && this.attrs.gradient) {
|
2346
|
+
return this.attrs.gradient;
|
2347
|
+
}
|
2348
|
+
return this.attrs[name];
|
2349
|
+
}
|
2350
|
+
if (this.attrs && value == null && R.is(name, array)) {
|
2351
|
+
var ii, values = {};
|
2352
|
+
for (i = 0, ii = name[length]; i < ii; i++) {
|
2353
|
+
values[name[i]] = this.attr(name[i]);
|
2354
|
+
}
|
2355
|
+
return values;
|
2356
|
+
}
|
2357
|
+
var params;
|
2358
|
+
if (value != null) {
|
2359
|
+
params = {};
|
2360
|
+
params[name] = value;
|
2361
|
+
}
|
2362
|
+
value == null && R.is(name, "object") && (params = name);
|
2363
|
+
if (params) {
|
2364
|
+
for (var key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) {
|
2365
|
+
var par = this.paper.customAttributes[key].apply(this, [][concat](params[key]));
|
2366
|
+
this.attrs[key] = params[key];
|
2367
|
+
for (var subkey in par) if (par[has](subkey)) {
|
2368
|
+
params[subkey] = par[subkey];
|
2369
|
+
}
|
2370
|
+
}
|
2371
|
+
if (params.text && this.type == "text") {
|
2372
|
+
this.node.string = params.text;
|
2373
|
+
}
|
2374
|
+
setFillAndStroke(this, params);
|
2375
|
+
if (params.gradient && (({circle: 1, ellipse: 1})[has](this.type) || Str(params.gradient).charAt() != "r")) {
|
2376
|
+
addGradientFill(this, params.gradient);
|
2377
|
+
}
|
2378
|
+
(!pathlike[has](this.type) || this._.rt.deg) && this.setBox(this.attrs);
|
2379
|
+
}
|
2380
|
+
return this;
|
2381
|
+
};
|
2382
|
+
elproto.toFront = function () {
|
2383
|
+
!this.removed && this.Group.parentNode[appendChild](this.Group);
|
2384
|
+
this.paper.top != this && tofront(this, this.paper);
|
2385
|
+
return this;
|
2386
|
+
};
|
2387
|
+
elproto.toBack = function () {
|
2388
|
+
if (this.removed) {
|
2389
|
+
return this;
|
2390
|
+
}
|
2391
|
+
if (this.Group.parentNode.firstChild != this.Group) {
|
2392
|
+
this.Group.parentNode.insertBefore(this.Group, this.Group.parentNode.firstChild);
|
2393
|
+
toback(this, this.paper);
|
2394
|
+
}
|
2395
|
+
return this;
|
2396
|
+
};
|
2397
|
+
elproto.insertAfter = function (element) {
|
2398
|
+
if (this.removed) {
|
2399
|
+
return this;
|
2400
|
+
}
|
2401
|
+
if (element.constructor == Set) {
|
2402
|
+
element = element[element.length - 1];
|
2403
|
+
}
|
2404
|
+
if (element.Group.nextSibling) {
|
2405
|
+
element.Group.parentNode.insertBefore(this.Group, element.Group.nextSibling);
|
2406
|
+
} else {
|
2407
|
+
element.Group.parentNode[appendChild](this.Group);
|
2408
|
+
}
|
2409
|
+
insertafter(this, element, this.paper);
|
2410
|
+
return this;
|
2411
|
+
};
|
2412
|
+
elproto.insertBefore = function (element) {
|
2413
|
+
if (this.removed) {
|
2414
|
+
return this;
|
2415
|
+
}
|
2416
|
+
if (element.constructor == Set) {
|
2417
|
+
element = element[0];
|
2418
|
+
}
|
2419
|
+
element.Group.parentNode.insertBefore(this.Group, element.Group);
|
2420
|
+
insertbefore(this, element, this.paper);
|
2421
|
+
return this;
|
2422
|
+
};
|
2423
|
+
elproto.blur = function (size) {
|
2424
|
+
var s = this.node.runtimeStyle,
|
2425
|
+
f = s.filter;
|
2426
|
+
f = f.replace(blurregexp, E);
|
2427
|
+
if (+size !== 0) {
|
2428
|
+
this.attrs.blur = size;
|
2429
|
+
s.filter = f + S + ms + ".Blur(pixelradius=" + (+size || 1.5) + ")";
|
2430
|
+
s.margin = R.format("-{0}px 0 0 -{0}px", round(+size || 1.5));
|
2431
|
+
} else {
|
2432
|
+
s.filter = f;
|
2433
|
+
s.margin = 0;
|
2434
|
+
delete this.attrs.blur;
|
2435
|
+
}
|
2436
|
+
};
|
2437
|
+
|
2438
|
+
theCircle = function (vml, x, y, r) {
|
2439
|
+
var g = createNode("group"),
|
2440
|
+
o = createNode("oval"),
|
2441
|
+
ol = o.style;
|
2442
|
+
g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px";
|
2443
|
+
g.coordsize = coordsize;
|
2444
|
+
g.coordorigin = vml.coordorigin;
|
2445
|
+
g[appendChild](o);
|
2446
|
+
var res = new Element(o, g, vml);
|
2447
|
+
res.type = "circle";
|
2448
|
+
setFillAndStroke(res, {stroke: "#000", fill: "none"});
|
2449
|
+
res.attrs.cx = x;
|
2450
|
+
res.attrs.cy = y;
|
2451
|
+
res.attrs.r = r;
|
2452
|
+
res.setBox({x: x - r, y: y - r, width: r * 2, height: r * 2});
|
2453
|
+
vml.canvas[appendChild](g);
|
2454
|
+
return res;
|
2455
|
+
};
|
2456
|
+
function rectPath(x, y, w, h, r) {
|
2457
|
+
if (r) {
|
2458
|
+
return R.format("M{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},{4}l0,{7}a{3},{3},0,0,1,{3},{4}z", x + r, y, w - r * 2, r, -r, h - r * 2, r * 2 - w, r * 2 - h);
|
2459
|
+
} else {
|
2460
|
+
return R.format("M{0},{1}l{2},0,0,{3},{4},0z", x, y, w, h, -w);
|
2461
|
+
}
|
2462
|
+
}
|
2463
|
+
theRect = function (vml, x, y, w, h, r) {
|
2464
|
+
var path = rectPath(x, y, w, h, r),
|
2465
|
+
res = vml.path(path),
|
2466
|
+
a = res.attrs;
|
2467
|
+
res.X = a.x = x;
|
2468
|
+
res.Y = a.y = y;
|
2469
|
+
res.W = a.width = w;
|
2470
|
+
res.H = a.height = h;
|
2471
|
+
a.r = r;
|
2472
|
+
a.path = path;
|
2473
|
+
res.type = "rect";
|
2474
|
+
return res;
|
2475
|
+
};
|
2476
|
+
theEllipse = function (vml, x, y, rx, ry) {
|
2477
|
+
var g = createNode("group"),
|
2478
|
+
o = createNode("oval"),
|
2479
|
+
ol = o.style;
|
2480
|
+
g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px";
|
2481
|
+
g.coordsize = coordsize;
|
2482
|
+
g.coordorigin = vml.coordorigin;
|
2483
|
+
g[appendChild](o);
|
2484
|
+
var res = new Element(o, g, vml);
|
2485
|
+
res.type = "ellipse";
|
2486
|
+
setFillAndStroke(res, {stroke: "#000"});
|
2487
|
+
res.attrs.cx = x;
|
2488
|
+
res.attrs.cy = y;
|
2489
|
+
res.attrs.rx = rx;
|
2490
|
+
res.attrs.ry = ry;
|
2491
|
+
res.setBox({x: x - rx, y: y - ry, width: rx * 2, height: ry * 2});
|
2492
|
+
vml.canvas[appendChild](g);
|
2493
|
+
return res;
|
2494
|
+
};
|
2495
|
+
theImage = function (vml, src, x, y, w, h) {
|
2496
|
+
var g = createNode("group"),
|
2497
|
+
o = createNode("image");
|
2498
|
+
g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px";
|
2499
|
+
g.coordsize = coordsize;
|
2500
|
+
g.coordorigin = vml.coordorigin;
|
2501
|
+
o.src = src;
|
2502
|
+
g[appendChild](o);
|
2503
|
+
var res = new Element(o, g, vml);
|
2504
|
+
res.type = "image";
|
2505
|
+
res.attrs.src = src;
|
2506
|
+
res.attrs.x = x;
|
2507
|
+
res.attrs.y = y;
|
2508
|
+
res.attrs.w = w;
|
2509
|
+
res.attrs.h = h;
|
2510
|
+
res.setBox({x: x, y: y, width: w, height: h});
|
2511
|
+
vml.canvas[appendChild](g);
|
2512
|
+
return res;
|
2513
|
+
};
|
2514
|
+
theText = function (vml, x, y, text) {
|
2515
|
+
var g = createNode("group"),
|
2516
|
+
el = createNode("shape"),
|
2517
|
+
ol = el.style,
|
2518
|
+
path = createNode("path"),
|
2519
|
+
ps = path.style,
|
2520
|
+
o = createNode("textpath");
|
2521
|
+
g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px";
|
2522
|
+
g.coordsize = coordsize;
|
2523
|
+
g.coordorigin = vml.coordorigin;
|
2524
|
+
path.v = R.format("m{0},{1}l{2},{1}", round(x * 10), round(y * 10), round(x * 10) + 1);
|
2525
|
+
path.textpathok = true;
|
2526
|
+
ol.width = vml.width;
|
2527
|
+
ol.height = vml.height;
|
2528
|
+
o.string = Str(text);
|
2529
|
+
o.on = true;
|
2530
|
+
el[appendChild](o);
|
2531
|
+
el[appendChild](path);
|
2532
|
+
g[appendChild](el);
|
2533
|
+
var res = new Element(o, g, vml);
|
2534
|
+
res.shape = el;
|
2535
|
+
res.textpath = path;
|
2536
|
+
res.type = "text";
|
2537
|
+
res.attrs.text = text;
|
2538
|
+
res.attrs.x = x;
|
2539
|
+
res.attrs.y = y;
|
2540
|
+
res.attrs.w = 1;
|
2541
|
+
res.attrs.h = 1;
|
2542
|
+
setFillAndStroke(res, {font: availableAttrs.font, stroke: "none", fill: "#000"});
|
2543
|
+
res.setBox();
|
2544
|
+
vml.canvas[appendChild](g);
|
2545
|
+
return res;
|
2546
|
+
};
|
2547
|
+
setSize = function (width, height) {
|
2548
|
+
var cs = this.canvas.style;
|
2549
|
+
width == +width && (width += "px");
|
2550
|
+
height == +height && (height += "px");
|
2551
|
+
cs.width = width;
|
2552
|
+
cs.height = height;
|
2553
|
+
cs.clip = "rect(0 " + width + " " + height + " 0)";
|
2554
|
+
return this;
|
2555
|
+
};
|
2556
|
+
var createNode;
|
2557
|
+
doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)");
|
2558
|
+
try {
|
2559
|
+
!doc.namespaces.rvml && doc.namespaces.add("rvml", "urn:schemas-microsoft-com:vml");
|
2560
|
+
createNode = function (tagName) {
|
2561
|
+
return doc.createElement('<rvml:' + tagName + ' class="rvml">');
|
2562
|
+
};
|
2563
|
+
} catch (e) {
|
2564
|
+
createNode = function (tagName) {
|
2565
|
+
return doc.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');
|
2566
|
+
};
|
2567
|
+
}
|
2568
|
+
create = function () {
|
2569
|
+
var con = getContainer[apply](0, arguments),
|
2570
|
+
container = con.container,
|
2571
|
+
height = con.height,
|
2572
|
+
s,
|
2573
|
+
width = con.width,
|
2574
|
+
x = con.x,
|
2575
|
+
y = con.y;
|
2576
|
+
if (!container) {
|
2577
|
+
throw new Error("VML container not found.");
|
2578
|
+
}
|
2579
|
+
var res = new Paper,
|
2580
|
+
c = res.canvas = doc.createElement("div"),
|
2581
|
+
cs = c.style;
|
2582
|
+
x = x || 0;
|
2583
|
+
y = y || 0;
|
2584
|
+
width = width || 512;
|
2585
|
+
height = height || 342;
|
2586
|
+
width == +width && (width += "px");
|
2587
|
+
height == +height && (height += "px");
|
2588
|
+
res.width = 1e3;
|
2589
|
+
res.height = 1e3;
|
2590
|
+
res.coordsize = zoom * 1e3 + S + zoom * 1e3;
|
2591
|
+
res.coordorigin = "0 0";
|
2592
|
+
res.span = doc.createElement("span");
|
2593
|
+
res.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";
|
2594
|
+
c[appendChild](res.span);
|
2595
|
+
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);
|
2596
|
+
if (container == 1) {
|
2597
|
+
doc.body[appendChild](c);
|
2598
|
+
cs.left = x + "px";
|
2599
|
+
cs.top = y + "px";
|
2600
|
+
cs.position = "absolute";
|
2601
|
+
} else {
|
2602
|
+
if (container.firstChild) {
|
2603
|
+
container.insertBefore(c, container.firstChild);
|
2604
|
+
} else {
|
2605
|
+
container[appendChild](c);
|
2606
|
+
}
|
2607
|
+
}
|
2608
|
+
plugins.call(res, res, R.fn);
|
2609
|
+
return res;
|
2610
|
+
};
|
2611
|
+
paperproto.clear = function () {
|
2612
|
+
this.canvas.innerHTML = E;
|
2613
|
+
this.span = doc.createElement("span");
|
2614
|
+
this.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";
|
2615
|
+
this.canvas[appendChild](this.span);
|
2616
|
+
this.bottom = this.top = null;
|
2617
|
+
};
|
2618
|
+
paperproto.remove = function () {
|
2619
|
+
this.canvas.parentNode.removeChild(this.canvas);
|
2620
|
+
for (var i in this) {
|
2621
|
+
this[i] = removed(i);
|
2622
|
+
}
|
2623
|
+
return true;
|
2624
|
+
};
|
2625
|
+
}
|
2626
|
+
|
2627
|
+
// rest
|
2628
|
+
// WebKit rendering bug workaround method
|
2629
|
+
var version = navigator.userAgent.match(/Version\/(.*?)\s/);
|
2630
|
+
if ((navigator.vendor == "Apple Computer, Inc.") && (version && version[1] < 4 || navigator.platform.slice(0, 2) == "iP")) {
|
2631
|
+
paperproto.safari = function () {
|
2632
|
+
var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: "none"});
|
2633
|
+
win.setTimeout(function () {rect.remove();});
|
2634
|
+
};
|
2635
|
+
} else {
|
2636
|
+
paperproto.safari = function () {};
|
2637
|
+
}
|
2638
|
+
|
2639
|
+
// Events
|
2640
|
+
var preventDefault = function () {
|
2641
|
+
this.returnValue = false;
|
2642
|
+
},
|
2643
|
+
preventTouch = function () {
|
2644
|
+
return this.originalEvent.preventDefault();
|
2645
|
+
},
|
2646
|
+
stopPropagation = function () {
|
2647
|
+
this.cancelBubble = true;
|
2648
|
+
},
|
2649
|
+
stopTouch = function () {
|
2650
|
+
return this.originalEvent.stopPropagation();
|
2651
|
+
},
|
2652
|
+
addEvent = (function () {
|
2653
|
+
if (doc.addEventListener) {
|
2654
|
+
return function (obj, type, fn, element) {
|
2655
|
+
var realName = supportsTouch && touchMap[type] ? touchMap[type] : type;
|
2656
|
+
var f = function (e) {
|
2657
|
+
if (supportsTouch && touchMap[has](type)) {
|
2658
|
+
for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) {
|
2659
|
+
if (e.targetTouches[i].target == obj) {
|
2660
|
+
var olde = e;
|
2661
|
+
e = e.targetTouches[i];
|
2662
|
+
e.originalEvent = olde;
|
2663
|
+
e.preventDefault = preventTouch;
|
2664
|
+
e.stopPropagation = stopTouch;
|
2665
|
+
break;
|
2666
|
+
}
|
2667
|
+
}
|
2668
|
+
}
|
2669
|
+
return fn.call(element, e);
|
2670
|
+
};
|
2671
|
+
obj.addEventListener(realName, f, false);
|
2672
|
+
return function () {
|
2673
|
+
obj.removeEventListener(realName, f, false);
|
2674
|
+
return true;
|
2675
|
+
};
|
2676
|
+
};
|
2677
|
+
} else if (doc.attachEvent) {
|
2678
|
+
return function (obj, type, fn, element) {
|
2679
|
+
var f = function (e) {
|
2680
|
+
e = e || win.event;
|
2681
|
+
e.preventDefault = e.preventDefault || preventDefault;
|
2682
|
+
e.stopPropagation = e.stopPropagation || stopPropagation;
|
2683
|
+
return fn.call(element, e);
|
2684
|
+
};
|
2685
|
+
obj.attachEvent("on" + type, f);
|
2686
|
+
var detacher = function () {
|
2687
|
+
obj.detachEvent("on" + type, f);
|
2688
|
+
return true;
|
2689
|
+
};
|
2690
|
+
return detacher;
|
2691
|
+
};
|
2692
|
+
}
|
2693
|
+
})(),
|
2694
|
+
drag = [],
|
2695
|
+
dragMove = function (e) {
|
2696
|
+
var x = e.clientX,
|
2697
|
+
y = e.clientY,
|
2698
|
+
scrollY = doc.documentElement.scrollTop || doc.body.scrollTop,
|
2699
|
+
scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft,
|
2700
|
+
dragi,
|
2701
|
+
j = drag.length;
|
2702
|
+
while (j--) {
|
2703
|
+
dragi = drag[j];
|
2704
|
+
if (supportsTouch) {
|
2705
|
+
var i = e.touches.length,
|
2706
|
+
touch;
|
2707
|
+
while (i--) {
|
2708
|
+
touch = e.touches[i];
|
2709
|
+
if (touch.identifier == dragi.el._drag.id) {
|
2710
|
+
x = touch.clientX;
|
2711
|
+
y = touch.clientY;
|
2712
|
+
(e.originalEvent ? e.originalEvent : e).preventDefault();
|
2713
|
+
break;
|
2714
|
+
}
|
2715
|
+
}
|
2716
|
+
} else {
|
2717
|
+
e.preventDefault();
|
2718
|
+
}
|
2719
|
+
x += scrollX;
|
2720
|
+
y += scrollY;
|
2721
|
+
dragi.move && dragi.move.call(dragi.move_scope || dragi.el, x - dragi.el._drag.x, y - dragi.el._drag.y, x, y, e);
|
2722
|
+
}
|
2723
|
+
},
|
2724
|
+
dragUp = function (e) {
|
2725
|
+
R.unmousemove(dragMove).unmouseup(dragUp);
|
2726
|
+
var i = drag.length,
|
2727
|
+
dragi;
|
2728
|
+
while (i--) {
|
2729
|
+
dragi = drag[i];
|
2730
|
+
dragi.el._drag = {};
|
2731
|
+
dragi.end && dragi.end.call(dragi.end_scope || dragi.start_scope || dragi.move_scope || dragi.el, e);
|
2732
|
+
}
|
2733
|
+
drag = [];
|
2734
|
+
};
|
2735
|
+
for (var i = events[length]; i--;) {
|
2736
|
+
(function (eventName) {
|
2737
|
+
R[eventName] = Element[proto][eventName] = function (fn, scope) {
|
2738
|
+
if (R.is(fn, "function")) {
|
2739
|
+
this.events = this.events || [];
|
2740
|
+
this.events.push({name: eventName, f: fn, unbind: addEvent(this.shape || this.node || doc, eventName, fn, scope || this)});
|
2741
|
+
}
|
2742
|
+
return this;
|
2743
|
+
};
|
2744
|
+
R["un" + eventName] = Element[proto]["un" + eventName] = function (fn) {
|
2745
|
+
var events = this.events,
|
2746
|
+
l = events[length];
|
2747
|
+
while (l--) if (events[l].name == eventName && events[l].f == fn) {
|
2748
|
+
events[l].unbind();
|
2749
|
+
events.splice(l, 1);
|
2750
|
+
!events.length && delete this.events;
|
2751
|
+
return this;
|
2752
|
+
}
|
2753
|
+
return this;
|
2754
|
+
};
|
2755
|
+
})(events[i]);
|
2756
|
+
}
|
2757
|
+
elproto.hover = function (f_in, f_out, scope_in, scope_out) {
|
2758
|
+
return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in);
|
2759
|
+
};
|
2760
|
+
elproto.unhover = function (f_in, f_out) {
|
2761
|
+
return this.unmouseover(f_in).unmouseout(f_out);
|
2762
|
+
};
|
2763
|
+
elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) {
|
2764
|
+
this._drag = {};
|
2765
|
+
this.mousedown(function (e) {
|
2766
|
+
(e.originalEvent || e).preventDefault();
|
2767
|
+
var scrollY = doc.documentElement.scrollTop || doc.body.scrollTop,
|
2768
|
+
scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft;
|
2769
|
+
this._drag.x = e.clientX + scrollX;
|
2770
|
+
this._drag.y = e.clientY + scrollY;
|
2771
|
+
this._drag.id = e.identifier;
|
2772
|
+
onstart && onstart.call(start_scope || move_scope || this, e.clientX + scrollX, e.clientY + scrollY, e);
|
2773
|
+
!drag.length && R.mousemove(dragMove).mouseup(dragUp);
|
2774
|
+
drag.push({el: this, move: onmove, end: onend, move_scope: move_scope, start_scope: start_scope, end_scope: end_scope});
|
2775
|
+
});
|
2776
|
+
return this;
|
2777
|
+
};
|
2778
|
+
elproto.undrag = function (onmove, onstart, onend) {
|
2779
|
+
var i = drag.length;
|
2780
|
+
while (i--) {
|
2781
|
+
drag[i].el == this && (drag[i].move == onmove && drag[i].end == onend) && drag.splice(i++, 1);
|
2782
|
+
}
|
2783
|
+
!drag.length && R.unmousemove(dragMove).unmouseup(dragUp);
|
2784
|
+
};
|
2785
|
+
paperproto.circle = function (x, y, r) {
|
2786
|
+
return theCircle(this, x || 0, y || 0, r || 0);
|
2787
|
+
};
|
2788
|
+
paperproto.rect = function (x, y, w, h, r) {
|
2789
|
+
return theRect(this, x || 0, y || 0, w || 0, h || 0, r || 0);
|
2790
|
+
};
|
2791
|
+
paperproto.ellipse = function (x, y, rx, ry) {
|
2792
|
+
return theEllipse(this, x || 0, y || 0, rx || 0, ry || 0);
|
2793
|
+
};
|
2794
|
+
paperproto.path = function (pathString) {
|
2795
|
+
pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E);
|
2796
|
+
return thePath(R.format[apply](R, arguments), this);
|
2797
|
+
};
|
2798
|
+
paperproto.image = function (src, x, y, w, h) {
|
2799
|
+
return theImage(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0);
|
2800
|
+
};
|
2801
|
+
paperproto.text = function (x, y, text) {
|
2802
|
+
return theText(this, x || 0, y || 0, Str(text));
|
2803
|
+
};
|
2804
|
+
paperproto.set = function (itemsArray) {
|
2805
|
+
arguments[length] > 1 && (itemsArray = Array[proto].splice.call(arguments, 0, arguments[length]));
|
2806
|
+
return new Set(itemsArray);
|
2807
|
+
};
|
2808
|
+
paperproto.setSize = setSize;
|
2809
|
+
paperproto.top = paperproto.bottom = null;
|
2810
|
+
paperproto.raphael = R;
|
2811
|
+
function x_y() {
|
2812
|
+
return this.x + S + this.y;
|
2813
|
+
}
|
2814
|
+
elproto.resetScale = function () {
|
2815
|
+
if (this.removed) {
|
2816
|
+
return this;
|
2817
|
+
}
|
2818
|
+
this._.sx = 1;
|
2819
|
+
this._.sy = 1;
|
2820
|
+
this.attrs.scale = "1 1";
|
2821
|
+
};
|
2822
|
+
elproto.scale = function (x, y, cx, cy) {
|
2823
|
+
if (this.removed) {
|
2824
|
+
return this;
|
2825
|
+
}
|
2826
|
+
if (x == null && y == null) {
|
2827
|
+
return {
|
2828
|
+
x: this._.sx,
|
2829
|
+
y: this._.sy,
|
2830
|
+
toString: x_y
|
2831
|
+
};
|
2832
|
+
}
|
2833
|
+
y = y || x;
|
2834
|
+
!+y && (y = x);
|
2835
|
+
var dx,
|
2836
|
+
dy,
|
2837
|
+
dcx,
|
2838
|
+
dcy,
|
2839
|
+
a = this.attrs;
|
2840
|
+
if (x != 0) {
|
2841
|
+
var bb = this.getBBox(),
|
2842
|
+
rcx = bb.x + bb.width / 2,
|
2843
|
+
rcy = bb.y + bb.height / 2,
|
2844
|
+
kx = abs(x / this._.sx),
|
2845
|
+
ky = abs(y / this._.sy);
|
2846
|
+
cx = (+cx || cx == 0) ? cx : rcx;
|
2847
|
+
cy = (+cy || cy == 0) ? cy : rcy;
|
2848
|
+
var posx = this._.sx > 0,
|
2849
|
+
posy = this._.sy > 0,
|
2850
|
+
dirx = ~~(x / abs(x)),
|
2851
|
+
diry = ~~(y / abs(y)),
|
2852
|
+
dkx = kx * dirx,
|
2853
|
+
dky = ky * diry,
|
2854
|
+
s = this.node.style,
|
2855
|
+
ncx = cx + abs(rcx - cx) * dkx * (rcx > cx == posx ? 1 : -1),
|
2856
|
+
ncy = cy + abs(rcy - cy) * dky * (rcy > cy == posy ? 1 : -1),
|
2857
|
+
fr = (x * dirx > y * diry ? ky : kx);
|
2858
|
+
switch (this.type) {
|
2859
|
+
case "rect":
|
2860
|
+
case "image":
|
2861
|
+
var neww = a.width * kx,
|
2862
|
+
newh = a.height * ky;
|
2863
|
+
this.attr({
|
2864
|
+
height: newh,
|
2865
|
+
r: a.r * fr,
|
2866
|
+
width: neww,
|
2867
|
+
x: ncx - neww / 2,
|
2868
|
+
y: ncy - newh / 2
|
2869
|
+
});
|
2870
|
+
break;
|
2871
|
+
case "circle":
|
2872
|
+
case "ellipse":
|
2873
|
+
this.attr({
|
2874
|
+
rx: a.rx * kx,
|
2875
|
+
ry: a.ry * ky,
|
2876
|
+
r: a.r * fr,
|
2877
|
+
cx: ncx,
|
2878
|
+
cy: ncy
|
2879
|
+
});
|
2880
|
+
break;
|
2881
|
+
case "text":
|
2882
|
+
this.attr({
|
2883
|
+
x: ncx,
|
2884
|
+
y: ncy
|
2885
|
+
});
|
2886
|
+
break;
|
2887
|
+
case "path":
|
2888
|
+
var path = pathToRelative(a.path),
|
2889
|
+
skip = true,
|
2890
|
+
fx = posx ? dkx : kx,
|
2891
|
+
fy = posy ? dky : ky;
|
2892
|
+
for (var i = 0, ii = path[length]; i < ii; i++) {
|
2893
|
+
var p = path[i],
|
2894
|
+
P0 = upperCase.call(p[0]);
|
2895
|
+
if (P0 == "M" && skip) {
|
2896
|
+
continue;
|
2897
|
+
} else {
|
2898
|
+
skip = false;
|
2899
|
+
}
|
2900
|
+
if (P0 == "A") {
|
2901
|
+
p[path[i][length] - 2] *= fx;
|
2902
|
+
p[path[i][length] - 1] *= fy;
|
2903
|
+
p[1] *= kx;
|
2904
|
+
p[2] *= ky;
|
2905
|
+
p[5] = +(dirx + diry ? !!+p[5] : !+p[5]);
|
2906
|
+
} else if (P0 == "H") {
|
2907
|
+
for (var j = 1, jj = p[length]; j < jj; j++) {
|
2908
|
+
p[j] *= fx;
|
2909
|
+
}
|
2910
|
+
} else if (P0 == "V") {
|
2911
|
+
for (j = 1, jj = p[length]; j < jj; j++) {
|
2912
|
+
p[j] *= fy;
|
2913
|
+
}
|
2914
|
+
} else {
|
2915
|
+
for (j = 1, jj = p[length]; j < jj; j++) {
|
2916
|
+
p[j] *= (j % 2) ? fx : fy;
|
2917
|
+
}
|
2918
|
+
}
|
2919
|
+
}
|
2920
|
+
var dim2 = pathDimensions(path);
|
2921
|
+
dx = ncx - dim2.x - dim2.width / 2;
|
2922
|
+
dy = ncy - dim2.y - dim2.height / 2;
|
2923
|
+
path[0][1] += dx;
|
2924
|
+
path[0][2] += dy;
|
2925
|
+
this.attr({path: path});
|
2926
|
+
break;
|
2927
|
+
}
|
2928
|
+
if (this.type in {text: 1, image:1} && (dirx != 1 || diry != 1)) {
|
2929
|
+
if (this.transformations) {
|
2930
|
+
this.transformations[2] = "scale("[concat](dirx, ",", diry, ")");
|
2931
|
+
this.node[setAttribute]("transform", this.transformations[join](S));
|
2932
|
+
dx = (dirx == -1) ? -a.x - (neww || 0) : a.x;
|
2933
|
+
dy = (diry == -1) ? -a.y - (newh || 0) : a.y;
|
2934
|
+
this.attr({x: dx, y: dy});
|
2935
|
+
a.fx = dirx - 1;
|
2936
|
+
a.fy = diry - 1;
|
2937
|
+
} else {
|
2938
|
+
this.node.filterMatrix = ms + ".Matrix(M11="[concat](dirx,
|
2939
|
+
", M12=0, M21=0, M22=", diry,
|
2940
|
+
", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')");
|
2941
|
+
s.filter = (this.node.filterMatrix || E) + (this.node.filterOpacity || E);
|
2942
|
+
}
|
2943
|
+
} else {
|
2944
|
+
if (this.transformations) {
|
2945
|
+
this.transformations[2] = E;
|
2946
|
+
this.node[setAttribute]("transform", this.transformations[join](S));
|
2947
|
+
a.fx = 0;
|
2948
|
+
a.fy = 0;
|
2949
|
+
} else {
|
2950
|
+
this.node.filterMatrix = E;
|
2951
|
+
s.filter = (this.node.filterMatrix || E) + (this.node.filterOpacity || E);
|
2952
|
+
}
|
2953
|
+
}
|
2954
|
+
a.scale = [x, y, cx, cy][join](S);
|
2955
|
+
this._.sx = x;
|
2956
|
+
this._.sy = y;
|
2957
|
+
}
|
2958
|
+
return this;
|
2959
|
+
};
|
2960
|
+
elproto.clone = function () {
|
2961
|
+
if (this.removed) {
|
2962
|
+
return null;
|
2963
|
+
}
|
2964
|
+
var attr = this.attr();
|
2965
|
+
delete attr.scale;
|
2966
|
+
delete attr.translation;
|
2967
|
+
return this.paper[this.type]().attr(attr);
|
2968
|
+
};
|
2969
|
+
var curveslengths = {},
|
2970
|
+
getPointAtSegmentLength = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) {
|
2971
|
+
var len = 0,
|
2972
|
+
precision = 100,
|
2973
|
+
name = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y].join(),
|
2974
|
+
cache = curveslengths[name],
|
2975
|
+
old, dot;
|
2976
|
+
!cache && (curveslengths[name] = cache = {data: []});
|
2977
|
+
cache.timer && clearTimeout(cache.timer);
|
2978
|
+
cache.timer = setTimeout(function () {delete curveslengths[name];}, 2000);
|
2979
|
+
if (length != null) {
|
2980
|
+
var total = getPointAtSegmentLength(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);
|
2981
|
+
precision = ~~total * 10;
|
2982
|
+
}
|
2983
|
+
for (var i = 0; i < precision + 1; i++) {
|
2984
|
+
if (cache.data[length] > i) {
|
2985
|
+
dot = cache.data[i * precision];
|
2986
|
+
} else {
|
2987
|
+
dot = R.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, i / precision);
|
2988
|
+
cache.data[i] = dot;
|
2989
|
+
}
|
2990
|
+
i && (len += pow(pow(old.x - dot.x, 2) + pow(old.y - dot.y, 2), .5));
|
2991
|
+
if (length != null && len >= length) {
|
2992
|
+
return dot;
|
2993
|
+
}
|
2994
|
+
old = dot;
|
2995
|
+
}
|
2996
|
+
if (length == null) {
|
2997
|
+
return len;
|
2998
|
+
}
|
2999
|
+
},
|
3000
|
+
getLengthFactory = function (istotal, subpath) {
|
3001
|
+
return function (path, length, onlystart) {
|
3002
|
+
path = path2curve(path);
|
3003
|
+
var x, y, p, l, sp = "", subpaths = {}, point,
|
3004
|
+
len = 0;
|
3005
|
+
for (var i = 0, ii = path.length; i < ii; i++) {
|
3006
|
+
p = path[i];
|
3007
|
+
if (p[0] == "M") {
|
3008
|
+
x = +p[1];
|
3009
|
+
y = +p[2];
|
3010
|
+
} else {
|
3011
|
+
l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
|
3012
|
+
if (len + l > length) {
|
3013
|
+
if (subpath && !subpaths.start) {
|
3014
|
+
point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
|
3015
|
+
sp += ["C", point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y];
|
3016
|
+
if (onlystart) {return sp;}
|
3017
|
+
subpaths.start = sp;
|
3018
|
+
sp = ["M", point.x, point.y + "C", point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]][join]();
|
3019
|
+
len += l;
|
3020
|
+
x = +p[5];
|
3021
|
+
y = +p[6];
|
3022
|
+
continue;
|
3023
|
+
}
|
3024
|
+
if (!istotal && !subpath) {
|
3025
|
+
point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
|
3026
|
+
return {x: point.x, y: point.y, alpha: point.alpha};
|
3027
|
+
}
|
3028
|
+
}
|
3029
|
+
len += l;
|
3030
|
+
x = +p[5];
|
3031
|
+
y = +p[6];
|
3032
|
+
}
|
3033
|
+
sp += p;
|
3034
|
+
}
|
3035
|
+
subpaths.end = sp;
|
3036
|
+
point = istotal ? len : subpath ? subpaths : R.findDotsAtSegment(x, y, p[1], p[2], p[3], p[4], p[5], p[6], 1);
|
3037
|
+
point.alpha && (point = {x: point.x, y: point.y, alpha: point.alpha});
|
3038
|
+
return point;
|
3039
|
+
};
|
3040
|
+
};
|
3041
|
+
var getTotalLength = getLengthFactory(1),
|
3042
|
+
getPointAtLength = getLengthFactory(),
|
3043
|
+
getSubpathsAtLength = getLengthFactory(0, 1);
|
3044
|
+
elproto.getTotalLength = function () {
|
3045
|
+
if (this.type != "path") {return;}
|
3046
|
+
if (this.node.getTotalLength) {
|
3047
|
+
return this.node.getTotalLength();
|
3048
|
+
}
|
3049
|
+
return getTotalLength(this.attrs.path);
|
3050
|
+
};
|
3051
|
+
elproto.getPointAtLength = function (length) {
|
3052
|
+
if (this.type != "path") {return;}
|
3053
|
+
return getPointAtLength(this.attrs.path, length);
|
3054
|
+
};
|
3055
|
+
elproto.getSubpath = function (from, to) {
|
3056
|
+
if (this.type != "path") {return;}
|
3057
|
+
if (abs(this.getTotalLength() - to) < "1e-6") {
|
3058
|
+
return getSubpathsAtLength(this.attrs.path, from).end;
|
3059
|
+
}
|
3060
|
+
var a = getSubpathsAtLength(this.attrs.path, to, 1);
|
3061
|
+
return from ? getSubpathsAtLength(a, from).end : a;
|
3062
|
+
};
|
3063
|
+
|
3064
|
+
// animation easing formulas
|
3065
|
+
R.easing_formulas = {
|
3066
|
+
linear: function (n) {
|
3067
|
+
return n;
|
3068
|
+
},
|
3069
|
+
"<": function (n) {
|
3070
|
+
return pow(n, 3);
|
3071
|
+
},
|
3072
|
+
">": function (n) {
|
3073
|
+
return pow(n - 1, 3) + 1;
|
3074
|
+
},
|
3075
|
+
"<>": function (n) {
|
3076
|
+
n = n * 2;
|
3077
|
+
if (n < 1) {
|
3078
|
+
return pow(n, 3) / 2;
|
3079
|
+
}
|
3080
|
+
n -= 2;
|
3081
|
+
return (pow(n, 3) + 2) / 2;
|
3082
|
+
},
|
3083
|
+
backIn: function (n) {
|
3084
|
+
var s = 1.70158;
|
3085
|
+
return n * n * ((s + 1) * n - s);
|
3086
|
+
},
|
3087
|
+
backOut: function (n) {
|
3088
|
+
n = n - 1;
|
3089
|
+
var s = 1.70158;
|
3090
|
+
return n * n * ((s + 1) * n + s) + 1;
|
3091
|
+
},
|
3092
|
+
elastic: function (n) {
|
3093
|
+
if (n == 0 || n == 1) {
|
3094
|
+
return n;
|
3095
|
+
}
|
3096
|
+
var p = .3,
|
3097
|
+
s = p / 4;
|
3098
|
+
return pow(2, -10 * n) * math.sin((n - s) * (2 * PI) / p) + 1;
|
3099
|
+
},
|
3100
|
+
bounce: function (n) {
|
3101
|
+
var s = 7.5625,
|
3102
|
+
p = 2.75,
|
3103
|
+
l;
|
3104
|
+
if (n < (1 / p)) {
|
3105
|
+
l = s * n * n;
|
3106
|
+
} else {
|
3107
|
+
if (n < (2 / p)) {
|
3108
|
+
n -= (1.5 / p);
|
3109
|
+
l = s * n * n + .75;
|
3110
|
+
} else {
|
3111
|
+
if (n < (2.5 / p)) {
|
3112
|
+
n -= (2.25 / p);
|
3113
|
+
l = s * n * n + .9375;
|
3114
|
+
} else {
|
3115
|
+
n -= (2.625 / p);
|
3116
|
+
l = s * n * n + .984375;
|
3117
|
+
}
|
3118
|
+
}
|
3119
|
+
}
|
3120
|
+
return l;
|
3121
|
+
}
|
3122
|
+
};
|
3123
|
+
|
3124
|
+
var animationElements = [],
|
3125
|
+
animation = function () {
|
3126
|
+
var Now = +new Date;
|
3127
|
+
for (var l = 0; l < animationElements[length]; l++) {
|
3128
|
+
var e = animationElements[l];
|
3129
|
+
if (e.stop || e.el.removed) {
|
3130
|
+
continue;
|
3131
|
+
}
|
3132
|
+
var time = Now - e.start,
|
3133
|
+
ms = e.ms,
|
3134
|
+
easing = e.easing,
|
3135
|
+
from = e.from,
|
3136
|
+
diff = e.diff,
|
3137
|
+
to = e.to,
|
3138
|
+
t = e.t,
|
3139
|
+
that = e.el,
|
3140
|
+
set = {},
|
3141
|
+
now;
|
3142
|
+
if (time < ms) {
|
3143
|
+
var pos = easing(time / ms);
|
3144
|
+
for (var attr in from) if (from[has](attr)) {
|
3145
|
+
switch (availableAnimAttrs[attr]) {
|
3146
|
+
case "along":
|
3147
|
+
now = pos * ms * diff[attr];
|
3148
|
+
to.back && (now = to.len - now);
|
3149
|
+
var point = getPointAtLength(to[attr], now);
|
3150
|
+
that.translate(diff.sx - diff.x || 0, diff.sy - diff.y || 0);
|
3151
|
+
diff.x = point.x;
|
3152
|
+
diff.y = point.y;
|
3153
|
+
that.translate(point.x - diff.sx, point.y - diff.sy);
|
3154
|
+
to.rot && that.rotate(diff.r + point.alpha, point.x, point.y);
|
3155
|
+
break;
|
3156
|
+
case nu:
|
3157
|
+
now = +from[attr] + pos * ms * diff[attr];
|
3158
|
+
break;
|
3159
|
+
case "colour":
|
3160
|
+
now = "rgb(" + [
|
3161
|
+
upto255(round(from[attr].r + pos * ms * diff[attr].r)),
|
3162
|
+
upto255(round(from[attr].g + pos * ms * diff[attr].g)),
|
3163
|
+
upto255(round(from[attr].b + pos * ms * diff[attr].b))
|
3164
|
+
][join](",") + ")";
|
3165
|
+
break;
|
3166
|
+
case "path":
|
3167
|
+
now = [];
|
3168
|
+
for (var i = 0, ii = from[attr][length]; i < ii; i++) {
|
3169
|
+
now[i] = [from[attr][i][0]];
|
3170
|
+
for (var j = 1, jj = from[attr][i][length]; j < jj; j++) {
|
3171
|
+
now[i][j] = +from[attr][i][j] + pos * ms * diff[attr][i][j];
|
3172
|
+
}
|
3173
|
+
now[i] = now[i][join](S);
|
3174
|
+
}
|
3175
|
+
now = now[join](S);
|
3176
|
+
break;
|
3177
|
+
case "csv":
|
3178
|
+
switch (attr) {
|
3179
|
+
case "translation":
|
3180
|
+
var x = pos * ms * diff[attr][0] - t.x,
|
3181
|
+
y = pos * ms * diff[attr][1] - t.y;
|
3182
|
+
t.x += x;
|
3183
|
+
t.y += y;
|
3184
|
+
now = x + S + y;
|
3185
|
+
break;
|
3186
|
+
case "rotation":
|
3187
|
+
now = +from[attr][0] + pos * ms * diff[attr][0];
|
3188
|
+
from[attr][1] && (now += "," + from[attr][1] + "," + from[attr][2]);
|
3189
|
+
break;
|
3190
|
+
case "scale":
|
3191
|
+
now = [+from[attr][0] + pos * ms * diff[attr][0], +from[attr][1] + pos * ms * diff[attr][1], (2 in to[attr] ? to[attr][2] : E), (3 in to[attr] ? to[attr][3] : E)][join](S);
|
3192
|
+
break;
|
3193
|
+
case "clip-rect":
|
3194
|
+
now = [];
|
3195
|
+
i = 4;
|
3196
|
+
while (i--) {
|
3197
|
+
now[i] = +from[attr][i] + pos * ms * diff[attr][i];
|
3198
|
+
}
|
3199
|
+
break;
|
3200
|
+
}
|
3201
|
+
break;
|
3202
|
+
default:
|
3203
|
+
var from2 = [].concat(from[attr]);
|
3204
|
+
now = [];
|
3205
|
+
i = that.paper.customAttributes[attr].length;
|
3206
|
+
while (i--) {
|
3207
|
+
now[i] = +from2[i] + pos * ms * diff[attr][i];
|
3208
|
+
}
|
3209
|
+
break;
|
3210
|
+
}
|
3211
|
+
set[attr] = now;
|
3212
|
+
}
|
3213
|
+
that.attr(set);
|
3214
|
+
that._run && that._run.call(that);
|
3215
|
+
} else {
|
3216
|
+
if (to.along) {
|
3217
|
+
point = getPointAtLength(to.along, to.len * !to.back);
|
3218
|
+
that.translate(diff.sx - (diff.x || 0) + point.x - diff.sx, diff.sy - (diff.y || 0) + point.y - diff.sy);
|
3219
|
+
to.rot && that.rotate(diff.r + point.alpha, point.x, point.y);
|
3220
|
+
}
|
3221
|
+
(t.x || t.y) && that.translate(-t.x, -t.y);
|
3222
|
+
to.scale && (to.scale += E);
|
3223
|
+
that.attr(to);
|
3224
|
+
animationElements.splice(l--, 1);
|
3225
|
+
}
|
3226
|
+
}
|
3227
|
+
R.svg && that && that.paper && that.paper.safari();
|
3228
|
+
animationElements[length] && setTimeout(animation);
|
3229
|
+
},
|
3230
|
+
keyframesRun = function (attr, element, time, prev, prevcallback) {
|
3231
|
+
var dif = time - prev;
|
3232
|
+
element.timeouts.push(setTimeout(function () {
|
3233
|
+
R.is(prevcallback, "function") && prevcallback.call(element);
|
3234
|
+
element.animate(attr, dif, attr.easing);
|
3235
|
+
}, prev));
|
3236
|
+
},
|
3237
|
+
upto255 = function (color) {
|
3238
|
+
return mmax(mmin(color, 255), 0);
|
3239
|
+
},
|
3240
|
+
translate = function (x, y) {
|
3241
|
+
if (x == null) {
|
3242
|
+
return {x: this._.tx, y: this._.ty, toString: x_y};
|
3243
|
+
}
|
3244
|
+
this._.tx += +x;
|
3245
|
+
this._.ty += +y;
|
3246
|
+
switch (this.type) {
|
3247
|
+
case "circle":
|
3248
|
+
case "ellipse":
|
3249
|
+
this.attr({cx: +x + this.attrs.cx, cy: +y + this.attrs.cy});
|
3250
|
+
break;
|
3251
|
+
case "rect":
|
3252
|
+
case "image":
|
3253
|
+
case "text":
|
3254
|
+
this.attr({x: +x + this.attrs.x, y: +y + this.attrs.y});
|
3255
|
+
break;
|
3256
|
+
case "path":
|
3257
|
+
var path = pathToRelative(this.attrs.path);
|
3258
|
+
path[0][1] += +x;
|
3259
|
+
path[0][2] += +y;
|
3260
|
+
this.attr({path: path});
|
3261
|
+
break;
|
3262
|
+
}
|
3263
|
+
return this;
|
3264
|
+
};
|
3265
|
+
elproto.animateWith = function (element, params, ms, easing, callback) {
|
3266
|
+
for (var i = 0, ii = animationElements.length; i < ii; i++) {
|
3267
|
+
if (animationElements[i].el.id == element.id) {
|
3268
|
+
params.start = animationElements[i].start;
|
3269
|
+
}
|
3270
|
+
}
|
3271
|
+
return this.animate(params, ms, easing, callback);
|
3272
|
+
};
|
3273
|
+
elproto.animateAlong = along();
|
3274
|
+
elproto.animateAlongBack = along(1);
|
3275
|
+
function along(isBack) {
|
3276
|
+
return function (path, ms, rotate, callback) {
|
3277
|
+
var params = {back: isBack};
|
3278
|
+
R.is(rotate, "function") ? (callback = rotate) : (params.rot = rotate);
|
3279
|
+
path && path.constructor == Element && (path = path.attrs.path);
|
3280
|
+
path && (params.along = path);
|
3281
|
+
return this.animate(params, ms, callback);
|
3282
|
+
};
|
3283
|
+
}
|
3284
|
+
function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) {
|
3285
|
+
var cx = 3 * p1x,
|
3286
|
+
bx = 3 * (p2x - p1x) - cx,
|
3287
|
+
ax = 1 - cx - bx,
|
3288
|
+
cy = 3 * p1y,
|
3289
|
+
by = 3 * (p2y - p1y) - cy,
|
3290
|
+
ay = 1 - cy - by;
|
3291
|
+
function sampleCurveX(t) {
|
3292
|
+
return ((ax * t + bx) * t + cx) * t;
|
3293
|
+
}
|
3294
|
+
function solve(x, epsilon) {
|
3295
|
+
var t = solveCurveX(x, epsilon);
|
3296
|
+
return ((ay * t + by) * t + cy) * t;
|
3297
|
+
}
|
3298
|
+
function solveCurveX(x, epsilon) {
|
3299
|
+
var t0, t1, t2, x2, d2, i;
|
3300
|
+
for(t2 = x, i = 0; i < 8; i++) {
|
3301
|
+
x2 = sampleCurveX(t2) - x;
|
3302
|
+
if (abs(x2) < epsilon) {
|
3303
|
+
return t2;
|
3304
|
+
}
|
3305
|
+
d2 = (3 * ax * t2 + 2 * bx) * t2 + cx;
|
3306
|
+
if (abs(d2) < 1e-6) {
|
3307
|
+
break;
|
3308
|
+
}
|
3309
|
+
t2 = t2 - x2 / d2;
|
3310
|
+
}
|
3311
|
+
t0 = 0;
|
3312
|
+
t1 = 1;
|
3313
|
+
t2 = x;
|
3314
|
+
if (t2 < t0) {
|
3315
|
+
return t0;
|
3316
|
+
}
|
3317
|
+
if (t2 > t1) {
|
3318
|
+
return t1;
|
3319
|
+
}
|
3320
|
+
while (t0 < t1) {
|
3321
|
+
x2 = sampleCurveX(t2);
|
3322
|
+
if (abs(x2 - x) < epsilon) {
|
3323
|
+
return t2;
|
3324
|
+
}
|
3325
|
+
if (x > x2) {
|
3326
|
+
t0 = t2;
|
3327
|
+
} else {
|
3328
|
+
t1 = t2;
|
3329
|
+
}
|
3330
|
+
t2 = (t1 - t0) / 2 + t0;
|
3331
|
+
}
|
3332
|
+
return t2;
|
3333
|
+
}
|
3334
|
+
return solve(t, 1 / (200 * duration));
|
3335
|
+
}
|
3336
|
+
elproto.onAnimation = function (f) {
|
3337
|
+
this._run = f || 0;
|
3338
|
+
return this;
|
3339
|
+
};
|
3340
|
+
elproto.animate = function (params, ms, easing, callback) {
|
3341
|
+
var element = this;
|
3342
|
+
element.timeouts = element.timeouts || [];
|
3343
|
+
if (R.is(easing, "function") || !easing) {
|
3344
|
+
callback = easing || null;
|
3345
|
+
}
|
3346
|
+
if (element.removed) {
|
3347
|
+
callback && callback.call(element);
|
3348
|
+
return element;
|
3349
|
+
}
|
3350
|
+
var from = {},
|
3351
|
+
to = {},
|
3352
|
+
animateable = false,
|
3353
|
+
diff = {};
|
3354
|
+
for (var attr in params) if (params[has](attr)) {
|
3355
|
+
if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) {
|
3356
|
+
animateable = true;
|
3357
|
+
from[attr] = element.attr(attr);
|
3358
|
+
(from[attr] == null) && (from[attr] = availableAttrs[attr]);
|
3359
|
+
to[attr] = params[attr];
|
3360
|
+
switch (availableAnimAttrs[attr]) {
|
3361
|
+
case "along":
|
3362
|
+
var len = getTotalLength(params[attr]);
|
3363
|
+
var point = getPointAtLength(params[attr], len * !!params.back);
|
3364
|
+
var bb = element.getBBox();
|
3365
|
+
diff[attr] = len / ms;
|
3366
|
+
diff.tx = bb.x;
|
3367
|
+
diff.ty = bb.y;
|
3368
|
+
diff.sx = point.x;
|
3369
|
+
diff.sy = point.y;
|
3370
|
+
to.rot = params.rot;
|
3371
|
+
to.back = params.back;
|
3372
|
+
to.len = len;
|
3373
|
+
params.rot && (diff.r = toFloat(element.rotate()) || 0);
|
3374
|
+
break;
|
3375
|
+
case nu:
|
3376
|
+
diff[attr] = (to[attr] - from[attr]) / ms;
|
3377
|
+
break;
|
3378
|
+
case "colour":
|
3379
|
+
from[attr] = R.getRGB(from[attr]);
|
3380
|
+
var toColour = R.getRGB(to[attr]);
|
3381
|
+
diff[attr] = {
|
3382
|
+
r: (toColour.r - from[attr].r) / ms,
|
3383
|
+
g: (toColour.g - from[attr].g) / ms,
|
3384
|
+
b: (toColour.b - from[attr].b) / ms
|
3385
|
+
};
|
3386
|
+
break;
|
3387
|
+
case "path":
|
3388
|
+
var pathes = path2curve(from[attr], to[attr]);
|
3389
|
+
from[attr] = pathes[0];
|
3390
|
+
var toPath = pathes[1];
|
3391
|
+
diff[attr] = [];
|
3392
|
+
for (var i = 0, ii = from[attr][length]; i < ii; i++) {
|
3393
|
+
diff[attr][i] = [0];
|
3394
|
+
for (var j = 1, jj = from[attr][i][length]; j < jj; j++) {
|
3395
|
+
diff[attr][i][j] = (toPath[i][j] - from[attr][i][j]) / ms;
|
3396
|
+
}
|
3397
|
+
}
|
3398
|
+
break;
|
3399
|
+
case "csv":
|
3400
|
+
var values = Str(params[attr])[split](separator),
|
3401
|
+
from2 = Str(from[attr])[split](separator);
|
3402
|
+
switch (attr) {
|
3403
|
+
case "translation":
|
3404
|
+
from[attr] = [0, 0];
|
3405
|
+
diff[attr] = [values[0] / ms, values[1] / ms];
|
3406
|
+
break;
|
3407
|
+
case "rotation":
|
3408
|
+
from[attr] = (from2[1] == values[1] && from2[2] == values[2]) ? from2 : [0, values[1], values[2]];
|
3409
|
+
diff[attr] = [(values[0] - from[attr][0]) / ms, 0, 0];
|
3410
|
+
break;
|
3411
|
+
case "scale":
|
3412
|
+
params[attr] = values;
|
3413
|
+
from[attr] = Str(from[attr])[split](separator);
|
3414
|
+
diff[attr] = [(values[0] - from[attr][0]) / ms, (values[1] - from[attr][1]) / ms, 0, 0];
|
3415
|
+
break;
|
3416
|
+
case "clip-rect":
|
3417
|
+
from[attr] = Str(from[attr])[split](separator);
|
3418
|
+
diff[attr] = [];
|
3419
|
+
i = 4;
|
3420
|
+
while (i--) {
|
3421
|
+
diff[attr][i] = (values[i] - from[attr][i]) / ms;
|
3422
|
+
}
|
3423
|
+
break;
|
3424
|
+
}
|
3425
|
+
to[attr] = values;
|
3426
|
+
break;
|
3427
|
+
default:
|
3428
|
+
values = [].concat(params[attr]);
|
3429
|
+
from2 = [].concat(from[attr]);
|
3430
|
+
diff[attr] = [];
|
3431
|
+
i = element.paper.customAttributes[attr][length];
|
3432
|
+
while (i--) {
|
3433
|
+
diff[attr][i] = ((values[i] || 0) - (from2[i] || 0)) / ms;
|
3434
|
+
}
|
3435
|
+
break;
|
3436
|
+
}
|
3437
|
+
}
|
3438
|
+
}
|
3439
|
+
if (!animateable) {
|
3440
|
+
var attrs = [],
|
3441
|
+
lastcall;
|
3442
|
+
for (var key in params) if (params[has](key) && animKeyFrames.test(key)) {
|
3443
|
+
attr = {value: params[key]};
|
3444
|
+
key == "from" && (key = 0);
|
3445
|
+
key == "to" && (key = 100);
|
3446
|
+
attr.key = toInt(key, 10);
|
3447
|
+
attrs.push(attr);
|
3448
|
+
}
|
3449
|
+
attrs.sort(sortByKey);
|
3450
|
+
if (attrs[0].key) {
|
3451
|
+
attrs.unshift({key: 0, value: element.attrs});
|
3452
|
+
}
|
3453
|
+
for (i = 0, ii = attrs[length]; i < ii; i++) {
|
3454
|
+
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);
|
3455
|
+
}
|
3456
|
+
lastcall = attrs[attrs[length] - 1].value.callback;
|
3457
|
+
if (lastcall) {
|
3458
|
+
element.timeouts.push(setTimeout(function () {lastcall.call(element);}, ms));
|
3459
|
+
}
|
3460
|
+
} else {
|
3461
|
+
var easyeasy = R.easing_formulas[easing];
|
3462
|
+
if (!easyeasy) {
|
3463
|
+
easyeasy = Str(easing).match(bezierrg);
|
3464
|
+
if (easyeasy && easyeasy[length] == 5) {
|
3465
|
+
var curve = easyeasy;
|
3466
|
+
easyeasy = function (t) {
|
3467
|
+
return CubicBezierAtTime(t, +curve[1], +curve[2], +curve[3], +curve[4], ms);
|
3468
|
+
};
|
3469
|
+
} else {
|
3470
|
+
easyeasy = function (t) {
|
3471
|
+
return t;
|
3472
|
+
};
|
3473
|
+
}
|
3474
|
+
}
|
3475
|
+
animationElements.push({
|
3476
|
+
start: params.start || +new Date,
|
3477
|
+
ms: ms,
|
3478
|
+
easing: easyeasy,
|
3479
|
+
from: from,
|
3480
|
+
diff: diff,
|
3481
|
+
to: to,
|
3482
|
+
el: element,
|
3483
|
+
t: {x: 0, y: 0}
|
3484
|
+
});
|
3485
|
+
R.is(callback, "function") && (element._ac = setTimeout(function () {
|
3486
|
+
callback.call(element);
|
3487
|
+
}, ms));
|
3488
|
+
animationElements[length] == 1 && setTimeout(animation);
|
3489
|
+
}
|
3490
|
+
return this;
|
3491
|
+
};
|
3492
|
+
elproto.stop = function () {
|
3493
|
+
for (var i = 0; i < animationElements.length; i++) {
|
3494
|
+
animationElements[i].el.id == this.id && animationElements.splice(i--, 1);
|
3495
|
+
}
|
3496
|
+
for (i = 0, ii = this.timeouts && this.timeouts.length; i < ii; i++) {
|
3497
|
+
clearTimeout(this.timeouts[i]);
|
3498
|
+
}
|
3499
|
+
this.timeouts = [];
|
3500
|
+
clearTimeout(this._ac);
|
3501
|
+
delete this._ac;
|
3502
|
+
return this;
|
3503
|
+
};
|
3504
|
+
elproto.translate = function (x, y) {
|
3505
|
+
return this.attr({translation: x + " " + y});
|
3506
|
+
};
|
3507
|
+
elproto[toString] = function () {
|
3508
|
+
return "Rapha\xebl\u2019s object";
|
3509
|
+
};
|
3510
|
+
R.ae = animationElements;
|
3511
|
+
|
3512
|
+
// Set
|
3513
|
+
var Set = function (items) {
|
3514
|
+
this.items = [];
|
3515
|
+
this[length] = 0;
|
3516
|
+
this.type = "set";
|
3517
|
+
if (items) {
|
3518
|
+
for (var i = 0, ii = items[length]; i < ii; i++) {
|
3519
|
+
if (items[i] && (items[i].constructor == Element || items[i].constructor == Set)) {
|
3520
|
+
this[this.items[length]] = this.items[this.items[length]] = items[i];
|
3521
|
+
this[length]++;
|
3522
|
+
}
|
3523
|
+
}
|
3524
|
+
}
|
3525
|
+
};
|
3526
|
+
Set[proto][push] = function () {
|
3527
|
+
var item,
|
3528
|
+
len;
|
3529
|
+
for (var i = 0, ii = arguments[length]; i < ii; i++) {
|
3530
|
+
item = arguments[i];
|
3531
|
+
if (item && (item.constructor == Element || item.constructor == Set)) {
|
3532
|
+
len = this.items[length];
|
3533
|
+
this[len] = this.items[len] = item;
|
3534
|
+
this[length]++;
|
3535
|
+
}
|
3536
|
+
}
|
3537
|
+
return this;
|
3538
|
+
};
|
3539
|
+
Set[proto].pop = function () {
|
3540
|
+
delete this[this[length]--];
|
3541
|
+
return this.items.pop();
|
3542
|
+
};
|
3543
|
+
for (var method in elproto) if (elproto[has](method)) {
|
3544
|
+
Set[proto][method] = (function (methodname) {
|
3545
|
+
return function () {
|
3546
|
+
for (var i = 0, ii = this.items[length]; i < ii; i++) {
|
3547
|
+
this.items[i][methodname][apply](this.items[i], arguments);
|
3548
|
+
}
|
3549
|
+
return this;
|
3550
|
+
};
|
3551
|
+
})(method);
|
3552
|
+
}
|
3553
|
+
Set[proto].attr = function (name, value) {
|
3554
|
+
if (name && R.is(name, array) && R.is(name[0], "object")) {
|
3555
|
+
for (var j = 0, jj = name[length]; j < jj; j++) {
|
3556
|
+
this.items[j].attr(name[j]);
|
3557
|
+
}
|
3558
|
+
} else {
|
3559
|
+
for (var i = 0, ii = this.items[length]; i < ii; i++) {
|
3560
|
+
this.items[i].attr(name, value);
|
3561
|
+
}
|
3562
|
+
}
|
3563
|
+
return this;
|
3564
|
+
};
|
3565
|
+
Set[proto].animate = function (params, ms, easing, callback) {
|
3566
|
+
(R.is(easing, "function") || !easing) && (callback = easing || null);
|
3567
|
+
var len = this.items[length],
|
3568
|
+
i = len,
|
3569
|
+
item,
|
3570
|
+
set = this,
|
3571
|
+
collector;
|
3572
|
+
callback && (collector = function () {
|
3573
|
+
!--len && callback.call(set);
|
3574
|
+
});
|
3575
|
+
easing = R.is(easing, string) ? easing : collector;
|
3576
|
+
item = this.items[--i].animate(params, ms, easing, collector);
|
3577
|
+
while (i--) {
|
3578
|
+
this.items[i] && !this.items[i].removed && this.items[i].animateWith(item, params, ms, easing, collector);
|
3579
|
+
}
|
3580
|
+
return this;
|
3581
|
+
};
|
3582
|
+
Set[proto].insertAfter = function (el) {
|
3583
|
+
var i = this.items[length];
|
3584
|
+
while (i--) {
|
3585
|
+
this.items[i].insertAfter(el);
|
3586
|
+
}
|
3587
|
+
return this;
|
3588
|
+
};
|
3589
|
+
Set[proto].getBBox = function () {
|
3590
|
+
var x = [],
|
3591
|
+
y = [],
|
3592
|
+
w = [],
|
3593
|
+
h = [];
|
3594
|
+
for (var i = this.items[length]; i--;) {
|
3595
|
+
var box = this.items[i].getBBox();
|
3596
|
+
x[push](box.x);
|
3597
|
+
y[push](box.y);
|
3598
|
+
w[push](box.x + box.width);
|
3599
|
+
h[push](box.y + box.height);
|
3600
|
+
}
|
3601
|
+
x = mmin[apply](0, x);
|
3602
|
+
y = mmin[apply](0, y);
|
3603
|
+
return {
|
3604
|
+
x: x,
|
3605
|
+
y: y,
|
3606
|
+
width: mmax[apply](0, w) - x,
|
3607
|
+
height: mmax[apply](0, h) - y
|
3608
|
+
};
|
3609
|
+
};
|
3610
|
+
Set[proto].clone = function (s) {
|
3611
|
+
s = new Set;
|
3612
|
+
for (var i = 0, ii = this.items[length]; i < ii; i++) {
|
3613
|
+
s[push](this.items[i].clone());
|
3614
|
+
}
|
3615
|
+
return s;
|
3616
|
+
};
|
3617
|
+
|
3618
|
+
R.registerFont = function (font) {
|
3619
|
+
if (!font.face) {
|
3620
|
+
return font;
|
3621
|
+
}
|
3622
|
+
this.fonts = this.fonts || {};
|
3623
|
+
var fontcopy = {
|
3624
|
+
w: font.w,
|
3625
|
+
face: {},
|
3626
|
+
glyphs: {}
|
3627
|
+
},
|
3628
|
+
family = font.face["font-family"];
|
3629
|
+
for (var prop in font.face) if (font.face[has](prop)) {
|
3630
|
+
fontcopy.face[prop] = font.face[prop];
|
3631
|
+
}
|
3632
|
+
if (this.fonts[family]) {
|
3633
|
+
this.fonts[family][push](fontcopy);
|
3634
|
+
} else {
|
3635
|
+
this.fonts[family] = [fontcopy];
|
3636
|
+
}
|
3637
|
+
if (!font.svg) {
|
3638
|
+
fontcopy.face["units-per-em"] = toInt(font.face["units-per-em"], 10);
|
3639
|
+
for (var glyph in font.glyphs) if (font.glyphs[has](glyph)) {
|
3640
|
+
var path = font.glyphs[glyph];
|
3641
|
+
fontcopy.glyphs[glyph] = {
|
3642
|
+
w: path.w,
|
3643
|
+
k: {},
|
3644
|
+
d: path.d && "M" + path.d[rp](/[mlcxtrv]/g, function (command) {
|
3645
|
+
return {l: "L", c: "C", x: "z", t: "m", r: "l", v: "c"}[command] || "M";
|
3646
|
+
}) + "z"
|
3647
|
+
};
|
3648
|
+
if (path.k) {
|
3649
|
+
for (var k in path.k) if (path[has](k)) {
|
3650
|
+
fontcopy.glyphs[glyph].k[k] = path.k[k];
|
3651
|
+
}
|
3652
|
+
}
|
3653
|
+
}
|
3654
|
+
}
|
3655
|
+
return font;
|
3656
|
+
};
|
3657
|
+
paperproto.getFont = function (family, weight, style, stretch) {
|
3658
|
+
stretch = stretch || "normal";
|
3659
|
+
style = style || "normal";
|
3660
|
+
weight = +weight || {normal: 400, bold: 700, lighter: 300, bolder: 800}[weight] || 400;
|
3661
|
+
if (!R.fonts) {
|
3662
|
+
return;
|
3663
|
+
}
|
3664
|
+
var font = R.fonts[family];
|
3665
|
+
if (!font) {
|
3666
|
+
var name = new RegExp("(^|\\s)" + family[rp](/[^\w\d\s+!~.:_-]/g, E) + "(\\s|$)", "i");
|
3667
|
+
for (var fontName in R.fonts) if (R.fonts[has](fontName)) {
|
3668
|
+
if (name.test(fontName)) {
|
3669
|
+
font = R.fonts[fontName];
|
3670
|
+
break;
|
3671
|
+
}
|
3672
|
+
}
|
3673
|
+
}
|
3674
|
+
var thefont;
|
3675
|
+
if (font) {
|
3676
|
+
for (var i = 0, ii = font[length]; i < ii; i++) {
|
3677
|
+
thefont = font[i];
|
3678
|
+
if (thefont.face["font-weight"] == weight && (thefont.face["font-style"] == style || !thefont.face["font-style"]) && thefont.face["font-stretch"] == stretch) {
|
3679
|
+
break;
|
3680
|
+
}
|
3681
|
+
}
|
3682
|
+
}
|
3683
|
+
return thefont;
|
3684
|
+
};
|
3685
|
+
paperproto.print = function (x, y, string, font, size, origin, letter_spacing) {
|
3686
|
+
origin = origin || "middle"; // baseline|middle
|
3687
|
+
letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1);
|
3688
|
+
var out = this.set(),
|
3689
|
+
letters = Str(string)[split](E),
|
3690
|
+
shift = 0,
|
3691
|
+
path = E,
|
3692
|
+
scale;
|
3693
|
+
R.is(font, string) && (font = this.getFont(font));
|
3694
|
+
if (font) {
|
3695
|
+
scale = (size || 16) / font.face["units-per-em"];
|
3696
|
+
var bb = font.face.bbox.split(separator),
|
3697
|
+
top = +bb[0],
|
3698
|
+
height = +bb[1] + (origin == "baseline" ? bb[3] - bb[1] + (+font.face.descent) : (bb[3] - bb[1]) / 2);
|
3699
|
+
for (var i = 0, ii = letters[length]; i < ii; i++) {
|
3700
|
+
var prev = i && font.glyphs[letters[i - 1]] || {},
|
3701
|
+
curr = font.glyphs[letters[i]];
|
3702
|
+
shift += i ? (prev.w || font.w) + (prev.k && prev.k[letters[i]] || 0) + (font.w * letter_spacing) : 0;
|
3703
|
+
curr && curr.d && out[push](this.path(curr.d).attr({fill: "#000", stroke: "none", translation: [shift, 0]}));
|
3704
|
+
}
|
3705
|
+
out.scale(scale, scale, top, height).translate(x - top, y - height);
|
3706
|
+
}
|
3707
|
+
return out;
|
3708
|
+
};
|
3709
|
+
|
3710
|
+
R.format = function (token, params) {
|
3711
|
+
var args = R.is(params, array) ? [0][concat](params) : arguments;
|
3712
|
+
token && R.is(token, string) && args[length] - 1 && (token = token[rp](formatrg, function (str, i) {
|
3713
|
+
return args[++i] == null ? E : args[i];
|
3714
|
+
}));
|
3715
|
+
return token || E;
|
3716
|
+
};
|
3717
|
+
R.ninja = function () {
|
3718
|
+
oldRaphael.was ? (win.Raphael = oldRaphael.is) : delete Raphael;
|
3719
|
+
return R;
|
3720
|
+
};
|
3721
|
+
R.el = elproto;
|
3722
|
+
R.st = Set[proto];
|
3723
|
+
|
3724
|
+
oldRaphael.was ? (win.Raphael = R) : (Raphael = R);
|
3725
|
+
})();
|