1
// ┌────────────────────────────────────────────────────────────────────┐ \\
2
// │ Raphaël 2.0.2 - JavaScript Vector Library │ \\
3
// ├────────────────────────────────────────────────────────────────────┤ \\
4
// │ Copyright © 2008-2012 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
5
// │ Copyright © 2008-2012 Sencha Labs (http://sencha.com) │ \\
6
// ├────────────────────────────────────────────────────────────────────┤ \\
7
// │ Licensed under the MIT (http://raphaeljs.com/license.html) license.│ \\
8
// └────────────────────────────────────────────────────────────────────┘ \\
9
// ┌──────────────────────────────────────────────────────────────────────────────────────┐ \\
10
// │ Eve 0.3.4 - JavaScript Events Library │ \\
11
// ├──────────────────────────────────────────────────────────────────────────────────────┤ \\
12
// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://dmitry.baranovskiy.com/) │ \\
13
// │ Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. │ \\
14
// └──────────────────────────────────────────────────────────────────────────────────────┘ \\
17
var version = "0.3.4",
18
has = "hasOwnProperty",
22
numsort = function (a, b) {
29
eve = function (name, scope) {
32
args = Array.prototype.slice.call(arguments, 2),
33
listeners = eve.listeners(name),
44
for (var i = 0, ii = listeners.length; i < ii; i++) if ("zIndex" in listeners[i]) {
45
indexed.push(listeners[i].zIndex);
46
if (listeners[i].zIndex < 0) {
47
queue[listeners[i].zIndex] = listeners[i];
50
indexed.sort(numsort);
51
while (indexed[z] < 0) {
52
l = queue[indexed[z++]];
53
out.push(l.apply(scope, args));
59
for (i = 0; i < ii; i++) {
62
if (l.zIndex == indexed[z]) {
63
out.push(l.apply(scope, args));
69
l = queue[indexed[z]];
70
l && out.push(l.apply(scope, args));
79
out.push(l.apply(scope, args));
87
return out.length ? out : null;
90
eve.listeners = function (name) {
91
var names = name.split(separator),
103
for (i = 0, ii = names.length; i < ii; i++) {
105
for (j = 0, jj = es.length; j < jj; j++) {
107
items = [e[names[i]], e[wildcard]];
113
out = out.concat(item.f || []);
123
eve.on = function (name, f) {
124
var names = name.split(separator),
126
for (var i = 0, ii = names.length; i < ii; i++) {
128
!e[names[i]] && (e[names[i]] = {n: {}});
132
for (i = 0, ii = e.f.length; i < ii; i++) if (e.f[i] == f) {
136
return function (zIndex) {
137
if (+zIndex == +zIndex) {
143
eve.stop = function () {
147
eve.nt = function (subname) {
149
return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event);
151
return current_event;
155
eve.off = eve.unbind = function (name, f) {
156
var names = name.split(separator),
162
for (i = 0, ii = names.length; i < ii; i++) {
163
for (j = 0; j < cur.length; j += splice.length - 2) {
166
if (names[i] != wildcard) {
168
splice.push(e[names[i]]);
171
for (key in e) if (e[has](key)) {
175
cur.splice.apply(cur, splice);
178
for (i = 0, ii = cur.length; i < ii; i++) {
183
for (j = 0, jj = e.f.length; j < jj; j++) if (e.f[j] == f) {
187
!e.f.length && delete e.f;
189
for (key in e.n) if (e.n[has](key) && e.n[key].f) {
190
var funcs = e.n[key].f;
191
for (j = 0, jj = funcs.length; j < jj; j++) if (funcs[j] == f) {
195
!funcs.length && delete e.n[key].f;
199
for (key in e.n) if (e.n[has](key) && e.n[key].f) {
208
eve.once = function (name, f) {
209
var f2 = function () {
210
var res = f.apply(this, arguments);
211
eve.unbind(name, f2);
214
return eve.on(name, f2);
217
eve.version = version;
218
eve.toString = function () {
219
return "You are running Eve " + version;
221
(typeof module != "undefined" && module.exports) ? (module.exports = eve) : (typeof define != "undefined" ? (define("eve", [], function() { return eve; })) : (glob.eve = eve));
225
// ┌─────────────────────────────────────────────────────────────────────┐ \\
226
// │ "Raphaël 2.0.2" - JavaScript Vector Library │ \\
227
// ├─────────────────────────────────────────────────────────────────────┤ \\
228
// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
229
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
230
// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
231
// └─────────────────────────────────────────────────────────────────────┘ \\
235
if (R.is(first, "function")) {
236
return loaded ? first() : eve.on("DOMload", first);
237
} else if (R.is(first, array)) {
238
return R._engine.create[apply](R, first.splice(0, 3 + R.is(first[0], nu))).add(first);
240
var args = Array.prototype.slice.call(arguments, 0);
241
if (R.is(args[args.length - 1], "function")) {
243
return loaded ? f.call(R._engine.create[apply](R, args)) : eve.on("DOMload", function () {
244
f.call(R._engine.create[apply](R, args));
247
return R._engine.create[apply](R, arguments);
255
elements = {circle: 1, rect: 1, path: 1, ellipse: 1, text: 1, image: 1},
256
formatrg = /\{(\d+)\}/g,
258
has = "hasOwnProperty",
264
was: Object.prototype[has].call(g.win, "Raphael"),
267
Paper = function () {
270
this.ca = this.customAttributes = {};
273
appendChild = "appendChild",
276
supportsTouch = "createTouch" in g.doc,
281
events = "click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend touchcancel"[split](S),
283
mousedown: "touchstart",
284
mousemove: "touchmove",
287
lowerCase = Str.prototype.toLowerCase,
297
toString = "toString",
299
objectToString = Object.prototype.toString,
302
ISURL = R._ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i,
303
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,
304
isnan = {"NaN": 1, "Infinity": 1, "-Infinity": 1},
305
bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,
307
setAttribute = "setAttribute",
308
toFloat = parseFloat,
310
upperCase = Str.prototype.toUpperCase,
311
availableAttrs = R._availableAttrs = {
313
"arrow-start": "none",
315
"clip-rect": "0 0 1e9 1e9",
321
font: '10px "Arial"',
322
"font-family": '"Arial"',
324
"font-style": "normal",
328
href: "http://raphaeljs.com/",
337
"stroke-dasharray": "",
338
"stroke-linecap": "butt",
339
"stroke-linejoin": "butt",
340
"stroke-miterlimit": 0,
344
"text-anchor": "middle",
351
availableAnimAttrs = R._availableAnimAttrs = {
366
"stroke-opacity": nu,
368
transform: "transform",
373
whitespace = /[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]/g,
374
commaSpaces = /[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/,
375
hsrg = {hs: 1, rg: 1},
376
p2s = /,?([achlmqrstvxz]),?/gi,
377
pathCommand = /([achlmrqstvz])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/ig,
378
tCommand = /([rstm])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/ig,
379
pathValues = /(-?\d*\.?\d*(?:e[\-+]?\d+)?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/ig,
380
radial_gradient = R._radial_gradient = /^r(?:\(([^,]+?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*([^\)]+?)\))?/,
382
sortByKey = function (a, b) {
383
return a.key - b.key;
385
sortByNumber = function (a, b) {
386
return toFloat(a) - toFloat(b);
388
fun = function () {},
389
pipe = function (x) {
392
rectPath = R._rectPath = function (x, y, w, h, r) {
394
return [["M", x + r, y], ["l", w - r * 2, 0], ["a", r, r, 0, 0, 1, r, r], ["l", 0, h - r * 2], ["a", r, r, 0, 0, 1, -r, r], ["l", r * 2 - w, 0], ["a", r, r, 0, 0, 1, -r, -r], ["l", 0, r * 2 - h], ["a", r, r, 0, 0, 1, r, -r], ["z"]];
396
return [["M", x, y], ["l", w, 0], ["l", 0, h], ["l", -w, 0], ["z"]];
398
ellipsePath = function (x, y, rx, ry) {
402
return [["M", x, y], ["m", 0, -ry], ["a", rx, ry, 0, 1, 1, 0, 2 * ry], ["a", rx, ry, 0, 1, 1, 0, -2 * ry], ["z"]];
404
getPath = R._getPath = {
405
path: function (el) {
406
return el.attr("path");
408
circle: function (el) {
410
return ellipsePath(a.cx, a.cy, a.r);
412
ellipse: function (el) {
414
return ellipsePath(a.cx, a.cy, a.rx, a.ry);
416
rect: function (el) {
418
return rectPath(a.x, a.y, a.width, a.height, a.r);
420
image: function (el) {
422
return rectPath(a.x, a.y, a.width, a.height);
424
text: function (el) {
425
var bbox = el._getBBox();
426
return rectPath(bbox.x, bbox.y, bbox.width, bbox.height);
429
mapPath = R.mapPath = function (path, matrix) {
433
var x, y, i, j, ii, jj, pathi;
434
path = path2curve(path);
435
for (i = 0, ii = path.length; i < ii; i++) {
437
for (j = 1, jj = pathi.length; j < jj; j += 2) {
438
x = matrix.x(pathi[j], pathi[j + 1]);
439
y = matrix.y(pathi[j], pathi[j + 1]);
449
R.type = (g.win.SVGAngle || g.doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML");
450
if (R.type == "VML") {
451
var d = g.doc.createElement("div"),
453
d.innerHTML = '<v:shape adj="1"/>';
455
b.style.behavior = "url(#default#VML)";
456
if (!(b && typeof b.adj == "object")) {
463
R.svg = !(R.vml = R.type == "VML");
466
R.fn = paperproto = Paper.prototype = R.prototype;
470
R.is = function (o, type) {
471
type = lowerCase.call(type);
472
if (type == "finite") {
473
return !isnan[has](+o);
475
if (type == "array") {
476
return o instanceof Array;
478
return (type == "null" && o === null) ||
479
(type == typeof o && o !== null) ||
480
(type == "object" && o === Object(o)) ||
481
(type == "array" && Array.isArray && Array.isArray(o)) ||
482
objectToString.call(o).slice(8, -1).toLowerCase() == type;
485
R.angle = function (x1, y1, x2, y2, x3, y3) {
492
return (180 + math.atan2(-y, -x) * 180 / PI + 360) % 360;
494
return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3);
498
R.rad = function (deg) {
499
return deg % 360 * PI / 180;
502
R.deg = function (rad) {
503
return rad * 180 / PI % 360;
506
R.snapTo = function (values, value, tolerance) {
507
tolerance = R.is(tolerance, "finite") ? tolerance : 10;
508
if (R.is(values, array)) {
509
var i = values.length;
510
while (i--) if (abs(values[i] - value) <= tolerance) {
515
var rem = value % values;
516
if (rem < tolerance) {
519
if (rem > values - tolerance) {
520
return value - rem + values;
527
var createUUID = R.createUUID = (function (uuidRegEx, uuidReplacer) {
529
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx, uuidReplacer).toUpperCase();
531
})(/[xy]/g, function (c) {
532
var r = math.random() * 16 | 0,
533
v = c == "x" ? r : (r & 3 | 8);
534
return v.toString(16);
538
R.setWindow = function (newwin) {
539
eve("setWindow", R, g.win, newwin);
541
g.doc = g.win.document;
542
if (R._engine.initWin) {
543
R._engine.initWin(g.win);
546
var toHex = function (color) {
548
// http://dean.edwards.name/weblog/2009/10/convert-any-colour-value-to-hex-in-msie/
549
var trim = /^\s+|\s+$/g;
552
var docum = new ActiveXObject("htmlfile");
553
docum.write("<body>");
557
bod = createPopup().document.body;
559
var range = bod.createTextRange();
560
toHex = cacher(function (color) {
562
bod.style.color = Str(color).replace(trim, E);
563
var value = range.queryCommandValue("ForeColor");
564
value = ((value & 255) << 16) | (value & 65280) | ((value & 16711680) >>> 16);
565
return "#" + ("000000" + value.toString(16)).slice(-6);
571
var i = g.doc.createElement("i");
572
i.title = "Rapha\xebl Colour Picker";
573
i.style.display = "none";
574
g.doc.body.appendChild(i);
575
toHex = cacher(function (color) {
576
i.style.color = color;
577
return g.doc.defaultView.getComputedStyle(i, E).getPropertyValue("color");
582
hsbtoString = function () {
583
return "hsb(" + [this.h, this.s, this.b] + ")";
585
hsltoString = function () {
586
return "hsl(" + [this.h, this.s, this.l] + ")";
588
rgbtoString = function () {
591
prepareRGB = function (r, g, b) {
592
if (g == null && R.is(r, "object") && "r" in r && "g" in r && "b" in r) {
597
if (g == null && R.is(r, string)) {
598
var clr = R.getRGB(r);
603
if (r > 1 || g > 1 || b > 1) {
611
packageRGB = function (r, g, b, o) {
620
toString: rgbtoString
622
R.is(o, "finite") && (rgb.opacity = o);
627
R.color = function (clr) {
629
if (R.is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) {
630
rgb = R.hsb2rgb(clr);
635
} else if (R.is(clr, "object") && "h" in clr && "s" in clr && "l" in clr) {
636
rgb = R.hsl2rgb(clr);
642
if (R.is(clr, "string")) {
645
if (R.is(clr, "object") && "r" in clr && "g" in clr && "b" in clr) {
646
rgb = R.rgb2hsl(clr);
650
rgb = R.rgb2hsb(clr);
654
clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1;
657
clr.toString = rgbtoString;
661
R.hsb2rgb = function (h, s, v, o) {
662
if (this.is(h, "object") && "h" in h && "s" in h && "b" in h) {
672
X = C * (1 - abs(h % 2 - 1));
676
R += [C, X, 0, 0, X, C][h];
677
G += [X, C, C, X, 0, 0][h];
678
B += [0, 0, X, C, C, X][h];
679
return packageRGB(R, G, B, o);
682
R.hsl2rgb = function (h, s, l, o) {
683
if (this.is(h, "object") && "h" in h && "s" in h && "l" in h) {
688
if (h > 1 || s > 1 || l > 1) {
696
C = 2 * s * (l < .5 ? l : 1 - l);
697
X = C * (1 - abs(h % 2 - 1));
698
R = G = B = l - C / 2;
701
R += [C, X, 0, 0, X, C][h];
702
G += [X, C, C, X, 0, 0][h];
703
B += [0, 0, X, C, C, X][h];
704
return packageRGB(R, G, B, o);
707
R.rgb2hsb = function (r, g, b) {
708
b = prepareRGB(r, g, b);
715
C = V - mmin(r, g, b);
717
V == r ? (g - b) / C :
718
V == g ? (b - r) / C + 2 :
721
H = ((H + 360) % 6) * 60 / 360;
722
S = C == 0 ? 0 : C / V;
723
return {h: H, s: S, b: V, toString: hsbtoString};
726
R.rgb2hsl = function (r, g, b) {
727
b = prepareRGB(r, g, b);
732
var H, S, L, M, m, C;
737
M == r ? (g - b) / C :
738
M == g ? (b - r) / C + 2 :
740
H = ((H + 360) % 6) * 60 / 360;
743
L < .5 ? C / (2 * L) :
745
return {h: H, s: S, l: L, toString: hsltoString};
747
R._path2string = function () {
748
return this.join(",").replace(p2s, "$1");
750
function repush(array, item) {
751
for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) {
752
return array.push(array.splice(i, 1)[0]);
755
function cacher(f, scope, postprocessor) {
757
var arg = Array.prototype.slice.call(arguments, 0),
758
args = arg.join("\u2400"),
759
cache = newf.cache = newf.cache || {},
760
count = newf.count = newf.count || [];
761
if (cache[has](args)) {
763
return postprocessor ? postprocessor(cache[args]) : cache[args];
765
count.length >= 1e3 && delete cache[count.shift()];
767
cache[args] = f[apply](scope, arg);
768
return postprocessor ? postprocessor(cache[args]) : cache[args];
773
var preload = R._preload = function (src, f) {
774
var img = g.doc.createElement("img");
775
img.style.cssText = "position:absolute;left:-9999em;top:-9999em";
776
img.onload = function () {
779
g.doc.body.removeChild(this);
781
img.onerror = function () {
782
g.doc.body.removeChild(this);
784
g.doc.body.appendChild(img);
788
function clrToString() {
793
R.getRGB = cacher(function (colour) {
794
if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) {
795
return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString};
797
if (colour == "none") {
798
return {r: -1, g: -1, b: -1, hex: "none", toString: clrToString};
800
!(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() == "#") && (colour = toHex(colour));
808
rgb = colour.match(colourRegExp);
811
blue = toInt(rgb[2].substring(5), 16);
812
green = toInt(rgb[2].substring(3, 5), 16);
813
red = toInt(rgb[2].substring(1, 3), 16);
816
blue = toInt((t = rgb[3].charAt(3)) + t, 16);
817
green = toInt((t = rgb[3].charAt(2)) + t, 16);
818
red = toInt((t = rgb[3].charAt(1)) + t, 16);
821
values = rgb[4][split](commaSpaces);
822
red = toFloat(values[0]);
823
values[0].slice(-1) == "%" && (red *= 2.55);
824
green = toFloat(values[1]);
825
values[1].slice(-1) == "%" && (green *= 2.55);
826
blue = toFloat(values[2]);
827
values[2].slice(-1) == "%" && (blue *= 2.55);
828
rgb[1].toLowerCase().slice(0, 4) == "rgba" && (opacity = toFloat(values[3]));
829
values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
832
values = rgb[5][split](commaSpaces);
833
red = toFloat(values[0]);
834
values[0].slice(-1) == "%" && (red *= 2.55);
835
green = toFloat(values[1]);
836
values[1].slice(-1) == "%" && (green *= 2.55);
837
blue = toFloat(values[2]);
838
values[2].slice(-1) == "%" && (blue *= 2.55);
839
(values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
840
rgb[1].toLowerCase().slice(0, 4) == "hsba" && (opacity = toFloat(values[3]));
841
values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
842
return R.hsb2rgb(red, green, blue, opacity);
845
values = rgb[6][split](commaSpaces);
846
red = toFloat(values[0]);
847
values[0].slice(-1) == "%" && (red *= 2.55);
848
green = toFloat(values[1]);
849
values[1].slice(-1) == "%" && (green *= 2.55);
850
blue = toFloat(values[2]);
851
values[2].slice(-1) == "%" && (blue *= 2.55);
852
(values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
853
rgb[1].toLowerCase().slice(0, 4) == "hsla" && (opacity = toFloat(values[3]));
854
values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
855
return R.hsl2rgb(red, green, blue, opacity);
857
rgb = {r: red, g: green, b: blue, toString: clrToString};
858
rgb.hex = "#" + (16777216 | blue | (green << 8) | (red << 16)).toString(16).slice(1);
859
R.is(opacity, "finite") && (rgb.opacity = opacity);
862
return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString};
865
R.hsb = cacher(function (h, s, b) {
866
return R.hsb2rgb(h, s, b).hex;
869
R.hsl = cacher(function (h, s, l) {
870
return R.hsl2rgb(h, s, l).hex;
873
R.rgb = cacher(function (r, g, b) {
874
return "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1);
877
R.getColor = function (value) {
878
var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75},
879
rgb = this.hsb2rgb(start.h, start.s, start.b);
884
start.s <= 0 && (this.getColor.start = {h: 0, s: 1, b: start.b});
889
R.getColor.reset = function () {
893
// http://schepers.cc/getting-to-the-point
894
function catmullRom2bezier(crp, z) {
896
for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
898
{x: +crp[i - 2], y: +crp[i - 1]},
899
{x: +crp[i], y: +crp[i + 1]},
900
{x: +crp[i + 2], y: +crp[i + 3]},
901
{x: +crp[i + 4], y: +crp[i + 5]}
905
p[0] = {x: +crp[iLen - 2], y: +crp[iLen - 1]};
906
} else if (iLen - 4 == i) {
907
p[3] = {x: +crp[0], y: +crp[1]};
908
} else if (iLen - 2 == i) {
909
p[2] = {x: +crp[0], y: +crp[1]};
910
p[3] = {x: +crp[2], y: +crp[3]};
916
p[0] = {x: +crp[i], y: +crp[i + 1]};
920
(-p[0].x + 6 * p[1].x + p[2].x) / 6,
921
(-p[0].y + 6 * p[1].y + p[2].y) / 6,
922
(p[1].x + 6 * p[2].x - p[3].x) / 6,
923
(p[1].y + 6*p[2].y - p[3].y) / 6,
932
R.parsePathString = cacher(function (pathString) {
936
var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0},
938
if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption
939
data = pathClone(pathString);
942
Str(pathString).replace(pathCommand, function (a, b, c) {
944
name = b.toLowerCase();
945
c.replace(pathValues, function (a, b) {
946
b && params.push(+b);
948
if (name == "m" && params.length > 2) {
949
data.push([b][concat](params.splice(0, 2)));
951
b = b == "m" ? "l" : "L";
954
data.push([b][concat](params));
955
} else while (params.length >= paramCounts[name]) {
956
data.push([b][concat](params.splice(0, paramCounts[name])));
957
if (!paramCounts[name]) {
963
data.toString = R._path2string;
967
R.parseTransformString = cacher(function (TString) {
971
var paramCounts = {r: 3, s: 4, t: 2, m: 6},
973
if (R.is(TString, array) && R.is(TString[0], array)) { // rough assumption
974
data = pathClone(TString);
977
Str(TString).replace(tCommand, function (a, b, c) {
979
name = lowerCase.call(b);
980
c.replace(pathValues, function (a, b) {
981
b && params.push(+b);
983
data.push([b][concat](params));
986
data.toString = R._path2string;
990
R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
996
x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x,
997
y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y,
998
mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x),
999
my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y),
1000
nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x),
1001
ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y),
1002
ax = t1 * p1x + t * c1x,
1003
ay = t1 * p1y + t * c1y,
1004
cx = t1 * c2x + t * p2x,
1005
cy = t1 * c2y + t * p2y,
1006
alpha = (90 - math.atan2(mx - nx, my - ny) * 180 / PI);
1007
(mx > nx || my < ny) && (alpha += 180);
1013
start: {x: ax, y: ay},
1014
end: {x: cx, y: cy},
1018
R._removedFactory = function (methodname) {
1019
return function () {
1020
throw new Error("Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object");
1023
var pathDimensions = cacher(function (path) {
1025
return {x: 0, y: 0, width: 0, height: 0};
1027
path = path2curve(path);
1033
for (var i = 0, ii = path.length; i < ii; i++) {
1041
var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
1042
X = X[concat](dim.min.x, dim.max.x);
1043
Y = Y[concat](dim.min.y, dim.max.y);
1048
var xmin = mmin[apply](0, X),
1049
ymin = mmin[apply](0, Y);
1053
width: mmax[apply](0, X) - xmin,
1054
height: mmax[apply](0, Y) - ymin
1056
}, null, function (o) {
1064
pathClone = function (pathArray) {
1066
if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption
1067
pathArray = R.parsePathString(pathArray);
1069
for (var i = 0, ii = pathArray.length; i < ii; i++) {
1071
for (var j = 0, jj = pathArray[i].length; j < jj; j++) {
1072
res[i][j] = pathArray[i][j];
1075
res.toString = R._path2string;
1078
pathToRelative = R._pathToRelative = cacher(function (pathArray) {
1079
if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption
1080
pathArray = R.parsePathString(pathArray);
1088
if (pathArray[0][0] == "M") {
1089
x = pathArray[0][1];
1090
y = pathArray[0][2];
1094
res.push(["M", x, y]);
1096
for (var i = start, ii = pathArray.length; i < ii; i++) {
1097
var r = res[i] = [],
1099
if (pa[0] != lowerCase.call(pa[0])) {
1100
r[0] = lowerCase.call(pa[0]);
1108
r[6] = +(pa[6] - x).toFixed(3);
1109
r[7] = +(pa[7] - y).toFixed(3);
1112
r[1] = +(pa[1] - y).toFixed(3);
1118
for (var j = 1, jj = pa.length; j < jj; j++) {
1119
r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3);
1128
for (var k = 0, kk = pa.length; k < kk; k++) {
1132
var len = res[i].length;
1133
switch (res[i][0]) {
1139
x += +res[i][len - 1];
1142
y += +res[i][len - 1];
1145
x += +res[i][len - 2];
1146
y += +res[i][len - 1];
1149
res.toString = R._path2string;
1152
pathToAbsolute = R._pathToAbsolute = cacher(function (pathArray) {
1153
if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption
1154
pathArray = R.parsePathString(pathArray);
1156
if (!pathArray || !pathArray.length) {
1157
return [["M", 0, 0]];
1165
if (pathArray[0][0] == "M") {
1166
x = +pathArray[0][1];
1167
y = +pathArray[0][2];
1171
res[0] = ["M", x, y];
1173
var crz = pathArray.length == 3 && pathArray[0][0] == "M" && pathArray[1][0].toUpperCase() == "R" && pathArray[2][0].toUpperCase() == "Z";
1174
for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
1177
if (pa[0] != upperCase.call(pa[0])) {
1178
r[0] = upperCase.call(pa[0]);
1186
r[6] = +(pa[6] + x);
1187
r[7] = +(pa[7] + y);
1196
var dots = [x, y][concat](pa.slice(1));
1197
for (var j = 2, jj = dots.length; j < jj; j++) {
1198
dots[j] = +dots[j] + x;
1199
dots[++j] = +dots[j] + y;
1202
res = res[concat](catmullRom2bezier(dots, crz));
1208
for (j = 1, jj = pa.length; j < jj; j++) {
1209
r[j] = +pa[j] + ((j % 2) ? x : y);
1212
} else if (pa[0] == "R") {
1213
dots = [x, y][concat](pa.slice(1));
1215
res = res[concat](catmullRom2bezier(dots, crz));
1216
r = ["R"][concat](pa.slice(-2));
1218
for (var k = 0, kk = pa.length; k < kk; k++) {
1234
mx = r[r.length - 2];
1235
my = r[r.length - 1];
1237
x = r[r.length - 2];
1238
y = r[r.length - 1];
1241
res.toString = R._path2string;
1243
}, null, pathClone),
1244
l2c = function (x1, y1, x2, y2) {
1245
return [x1, y1, x2, y2, x2, y2];
1247
q2c = function (x1, y1, ax, ay, x2, y2) {
1251
_13 * x1 + _23 * ax,
1252
_13 * y1 + _23 * ay,
1253
_13 * x2 + _23 * ax,
1254
_13 * y2 + _23 * ay,
1259
a2c = function (x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
1260
// for more information of where this math came from visit:
1261
// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
1262
var _120 = PI * 120 / 180,
1263
rad = PI / 180 * (+angle || 0),
1266
rotate = cacher(function (x, y, rad) {
1267
var X = x * math.cos(rad) - y * math.sin(rad),
1268
Y = x * math.sin(rad) + y * math.cos(rad);
1269
return {x: X, y: Y};
1272
xy = rotate(x1, y1, -rad);
1275
xy = rotate(x2, y2, -rad);
1278
var cos = math.cos(PI / 180 * angle),
1279
sin = math.sin(PI / 180 * angle),
1282
var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
1290
k = (large_arc_flag == sweep_flag ? -1 : 1) *
1291
math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))),
1292
cx = k * rx * y / ry + (x1 + x2) / 2,
1293
cy = k * -ry * x / rx + (y1 + y2) / 2,
1294
f1 = math.asin(((y1 - cy) / ry).toFixed(9)),
1295
f2 = math.asin(((y2 - cy) / ry).toFixed(9));
1297
f1 = x1 < cx ? PI - f1 : f1;
1298
f2 = x2 < cx ? PI - f2 : f2;
1299
f1 < 0 && (f1 = PI * 2 + f1);
1300
f2 < 0 && (f2 = PI * 2 + f2);
1301
if (sweep_flag && f1 > f2) {
1304
if (!sweep_flag && f2 > f1) {
1314
if (abs(df) > _120) {
1318
f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
1319
x2 = cx + rx * math.cos(f2);
1320
y2 = cy + ry * math.sin(f2);
1321
res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
1324
var c1 = math.cos(f1),
1328
t = math.tan(df / 4),
1329
hx = 4 / 3 * rx * t,
1330
hy = 4 / 3 * ry * t,
1332
m2 = [x1 + hx * s1, y1 - hy * c1],
1333
m3 = [x2 + hx * s2, y2 - hy * c2],
1335
m2[0] = 2 * m1[0] - m2[0];
1336
m2[1] = 2 * m1[1] - m2[1];
1338
return [m2, m3, m4][concat](res);
1340
res = [m2, m3, m4][concat](res).join()[split](",");
1342
for (var i = 0, ii = res.length; i < ii; i++) {
1343
newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
1348
findDotAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
1351
x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x,
1352
y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y
1355
curveDim = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
1356
var a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x),
1357
b = 2 * (c1x - p1x) - 2 * (c2x - c1x),
1359
t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a,
1360
t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a,
1364
abs(t1) > "1e12" && (t1 = .5);
1365
abs(t2) > "1e12" && (t2 = .5);
1366
if (t1 > 0 && t1 < 1) {
1367
dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);
1371
if (t2 > 0 && t2 < 1) {
1372
dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);
1376
a = (c2y - 2 * c1y + p1y) - (p2y - 2 * c2y + c1y);
1377
b = 2 * (c1y - p1y) - 2 * (c2y - c1y);
1379
t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a;
1380
t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a;
1381
abs(t1) > "1e12" && (t1 = .5);
1382
abs(t2) > "1e12" && (t2 = .5);
1383
if (t1 > 0 && t1 < 1) {
1384
dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);
1388
if (t2 > 0 && t2 < 1) {
1389
dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);
1394
min: {x: mmin[apply](0, x), y: mmin[apply](0, y)},
1395
max: {x: mmax[apply](0, x), y: mmax[apply](0, y)}
1398
path2curve = R._path2curve = cacher(function (path, path2) {
1399
var p = pathToAbsolute(path),
1400
p2 = path2 && pathToAbsolute(path2),
1401
attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
1402
attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
1403
processPath = function (path, d) {
1406
return ["C", d.x, d.y, d.x, d.y, d.x, d.y];
1408
!(path[0] in {T:1, Q:1}) && (d.qx = d.qy = null);
1415
path = ["C"][concat](a2c[apply](0, [d.x, d.y][concat](path.slice(1))));
1418
nx = d.x + (d.x - (d.bx || d.x));
1419
ny = d.y + (d.y - (d.by || d.y));
1420
path = ["C", nx, ny][concat](path.slice(1));
1423
d.qx = d.x + (d.x - (d.qx || d.x));
1424
d.qy = d.y + (d.y - (d.qy || d.y));
1425
path = ["C"][concat](q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
1430
path = ["C"][concat](q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
1433
path = ["C"][concat](l2c(d.x, d.y, path[1], path[2]));
1436
path = ["C"][concat](l2c(d.x, d.y, path[1], d.y));
1439
path = ["C"][concat](l2c(d.x, d.y, d.x, path[1]));
1442
path = ["C"][concat](l2c(d.x, d.y, d.X, d.Y));
1447
fixArc = function (pp, i) {
1448
if (pp[i].length > 7) {
1452
pp.splice(i++, 0, ["C"][concat](pi.splice(0, 6)));
1455
ii = mmax(p.length, p2 && p2.length || 0);
1458
fixM = function (path1, path2, a1, a2, i) {
1459
if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M") {
1460
path2.splice(i, 0, ["M", a2.x, a2.y]);
1465
ii = mmax(p.length, p2 && p2.length || 0);
1468
for (var i = 0, ii = mmax(p.length, p2 && p2.length || 0); i < ii; i++) {
1469
p[i] = processPath(p[i], attrs);
1471
p2 && (p2[i] = processPath(p2[i], attrs2));
1472
p2 && fixArc(p2, i);
1473
fixM(p, p2, attrs, attrs2, i);
1474
fixM(p2, p, attrs2, attrs, i);
1477
seglen = seg.length,
1478
seg2len = p2 && seg2.length;
1479
attrs.x = seg[seglen - 2];
1480
attrs.y = seg[seglen - 1];
1481
attrs.bx = toFloat(seg[seglen - 4]) || attrs.x;
1482
attrs.by = toFloat(seg[seglen - 3]) || attrs.y;
1483
attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x);
1484
attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y);
1485
attrs2.x = p2 && seg2[seg2len - 2];
1486
attrs2.y = p2 && seg2[seg2len - 1];
1488
return p2 ? [p, p2] : p;
1489
}, null, pathClone),
1490
parseDots = R._parseDots = cacher(function (gradient) {
1492
for (var i = 0, ii = gradient.length; i < ii; i++) {
1494
par = gradient[i].match(/^([^:]*):?([\d\.]*)/);
1495
dot.color = R.getRGB(par[1]);
1496
if (dot.color.error) {
1499
dot.color = dot.color.hex;
1500
par[2] && (dot.offset = par[2] + "%");
1503
for (i = 1, ii = dots.length - 1; i < ii; i++) {
1504
if (!dots[i].offset) {
1505
var start = toFloat(dots[i - 1].offset || 0),
1507
for (var j = i + 1; j < ii; j++) {
1508
if (dots[j].offset) {
1509
end = dots[j].offset;
1518
var d = (end - start) / (j - i + 1);
1519
for (; i < j; i++) {
1521
dots[i].offset = start + "%";
1527
tear = R._tear = function (el, paper) {
1528
el == paper.top && (paper.top = el.prev);
1529
el == paper.bottom && (paper.bottom = el.next);
1530
el.next && (el.next.prev = el.prev);
1531
el.prev && (el.prev.next = el.next);
1533
tofront = R._tofront = function (el, paper) {
1534
if (paper.top === el) {
1539
el.prev = paper.top;
1540
paper.top.next = el;
1543
toback = R._toback = function (el, paper) {
1544
if (paper.bottom === el) {
1548
el.next = paper.bottom;
1550
paper.bottom.prev = el;
1553
insertafter = R._insertafter = function (el, el2, paper) {
1555
el2 == paper.top && (paper.top = el);
1556
el2.next && (el2.next.prev = el);
1561
insertbefore = R._insertbefore = function (el, el2, paper) {
1563
el2 == paper.bottom && (paper.bottom = el);
1564
el2.prev && (el2.prev.next = el);
1569
extractTransform = R._extractTransform = function (el, tstr) {
1571
return el._.transform;
1573
tstr = Str(tstr).replace(/\.{3}|\u2026/g, el._.transform || E);
1574
var tdata = R.parseTransformString(tstr),
1582
_.transform = tdata || [];
1584
for (var i = 0, ii = tdata.length; i < ii; i++) {
1587
command = Str(t[0]).toLowerCase(),
1588
absolute = t[0] != command,
1589
inver = absolute ? m.invert() : 0,
1595
if (command == "t" && tlen == 3) {
1599
x2 = inver.x(t[1], t[2]);
1600
y2 = inver.y(t[1], t[2]);
1601
m.translate(x2 - x1, y2 - y1);
1603
m.translate(t[1], t[2]);
1605
} else if (command == "r") {
1607
bb = bb || el.getBBox(1);
1608
m.rotate(t[1], bb.x + bb.width / 2, bb.y + bb.height / 2);
1610
} else if (tlen == 4) {
1612
x2 = inver.x(t[2], t[3]);
1613
y2 = inver.y(t[2], t[3]);
1614
m.rotate(t[1], x2, y2);
1616
m.rotate(t[1], t[2], t[3]);
1620
} else if (command == "s") {
1621
if (tlen == 2 || tlen == 3) {
1622
bb = bb || el.getBBox(1);
1623
m.scale(t[1], t[tlen - 1], bb.x + bb.width / 2, bb.y + bb.height / 2);
1626
} else if (tlen == 5) {
1628
x2 = inver.x(t[3], t[4]);
1629
y2 = inver.y(t[3], t[4]);
1630
m.scale(t[1], t[2], x2, y2);
1632
m.scale(t[1], t[2], t[3], t[4]);
1637
} else if (command == "m" && tlen == 7) {
1638
m.add(t[1], t[2], t[3], t[4], t[5], t[6]);
1653
if (sx == 1 && sy == 1 && !deg && _.bbox) {
1660
getEmpty = function (item) {
1662
switch (l.toLowerCase()) {
1663
case "t": return [l, 0, 0];
1664
case "m": return [l, 1, 0, 0, 1, 0, 0];
1665
case "r": if (item.length == 4) {
1666
return [l, 0, item[2], item[3]];
1670
case "s": if (item.length == 5) {
1671
return [l, 1, 1, item[3], item[4]];
1672
} else if (item.length == 3) {
1679
equaliseTransform = R._equaliseTransform = function (t1, t2) {
1680
t2 = Str(t2).replace(/\.{3}|\u2026/g, t1);
1681
t1 = R.parseTransformString(t1) || [];
1682
t2 = R.parseTransformString(t2) || [];
1683
var maxlength = mmax(t1.length, t2.length),
1688
for (; i < maxlength; i++) {
1689
tt1 = t1[i] || getEmpty(t2[i]);
1690
tt2 = t2[i] || getEmpty(tt1);
1691
if ((tt1[0] != tt2[0]) ||
1692
(tt1[0].toLowerCase() == "r" && (tt1[2] != tt2[2] || tt1[3] != tt2[3])) ||
1693
(tt1[0].toLowerCase() == "s" && (tt1[3] != tt2[3] || tt1[4] != tt2[4]))
1699
for (j = 0, jj = mmax(tt1.length, tt2.length); j < jj; j++) {
1700
j in tt1 && (from[i][j] = tt1[j]);
1701
j in tt2 && (to[i][j] = tt2[j]);
1709
R._getContainer = function (x, y, w, h) {
1711
container = h == null && !R.is(x, "object") ? g.doc.getElementById(x) : x;
1712
if (container == null) {
1715
if (container.tagName) {
1718
container: container,
1719
width: container.style.pixelWidth || container.offsetWidth,
1720
height: container.style.pixelHeight || container.offsetHeight
1724
container: container,
1739
R.pathToRelative = pathToRelative;
1742
R.path2curve = path2curve;
1744
R.matrix = function (a, b, c, d, e, f) {
1745
return new Matrix(a, b, c, d, e, f);
1747
function Matrix(a, b, c, d, e, f) {
1764
(function (matrixproto) {
1766
matrixproto.add = function (a, b, c, d, e, f) {
1767
var out = [[], [], []],
1768
m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]],
1769
matrix = [[a, c, e], [b, d, f], [0, 0, 1]],
1772
if (a && a instanceof Matrix) {
1773
matrix = [[a.a, a.c, a.e], [a.b, a.d, a.f], [0, 0, 1]];
1776
for (x = 0; x < 3; x++) {
1777
for (y = 0; y < 3; y++) {
1779
for (z = 0; z < 3; z++) {
1780
res += m[x][z] * matrix[z][y];
1793
matrixproto.invert = function () {
1795
x = me.a * me.d - me.b * me.c;
1796
return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x);
1799
matrixproto.clone = function () {
1800
return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f);
1803
matrixproto.translate = function (x, y) {
1804
this.add(1, 0, 0, 1, x, y);
1807
matrixproto.scale = function (x, y, cx, cy) {
1808
y == null && (y = x);
1809
(cx || cy) && this.add(1, 0, 0, 1, cx, cy);
1810
this.add(x, 0, 0, y, 0, 0);
1811
(cx || cy) && this.add(1, 0, 0, 1, -cx, -cy);
1814
matrixproto.rotate = function (a, x, y) {
1818
var cos = +math.cos(a).toFixed(9),
1819
sin = +math.sin(a).toFixed(9);
1820
this.add(cos, sin, -sin, cos, x, y);
1821
this.add(1, 0, 0, 1, -x, -y);
1824
matrixproto.x = function (x, y) {
1825
return x * this.a + y * this.c + this.e;
1828
matrixproto.y = function (x, y) {
1829
return x * this.b + y * this.d + this.f;
1831
matrixproto.get = function (i) {
1832
return +this[Str.fromCharCode(97 + i)].toFixed(4);
1834
matrixproto.toString = function () {
1836
"matrix(" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)].join() + ")" :
1837
[this.get(0), this.get(2), this.get(1), this.get(3), 0, 0].join();
1839
matrixproto.toFilter = function () {
1840
return "progid:DXImageTransform.Microsoft.Matrix(M11=" + this.get(0) +
1841
", M12=" + this.get(2) + ", M21=" + this.get(1) + ", M22=" + this.get(3) +
1842
", Dx=" + this.get(4) + ", Dy=" + this.get(5) + ", sizingmethod='auto expand')";
1844
matrixproto.offset = function () {
1845
return [this.e.toFixed(4), this.f.toFixed(4)];
1848
return a[0] * a[0] + a[1] * a[1];
1850
function normalize(a) {
1851
var mag = math.sqrt(norm(a));
1852
a[0] && (a[0] /= mag);
1853
a[1] && (a[1] /= mag);
1856
matrixproto.split = function () {
1863
var row = [[this.a, this.c], [this.b, this.d]];
1864
out.scalex = math.sqrt(norm(row[0]));
1867
out.shear = row[0][0] * row[1][0] + row[0][1] * row[1][1];
1868
row[1] = [row[1][0] - row[0][0] * out.shear, row[1][1] - row[0][1] * out.shear];
1870
out.scaley = math.sqrt(norm(row[1]));
1872
out.shear /= out.scaley;
1875
var sin = -row[0][1],
1878
out.rotate = R.deg(math.acos(cos));
1880
out.rotate = 360 - out.rotate;
1883
out.rotate = R.deg(math.asin(sin));
1886
out.isSimple = !+out.shear.toFixed(9) && (out.scalex.toFixed(9) == out.scaley.toFixed(9) || !out.rotate);
1887
out.isSuperSimple = !+out.shear.toFixed(9) && out.scalex.toFixed(9) == out.scaley.toFixed(9) && !out.rotate;
1888
out.noRotation = !+out.shear.toFixed(9) && !out.rotate;
1892
matrixproto.toTransformString = function (shorter) {
1893
var s = shorter || this[split]();
1895
s.scalex = +s.scalex.toFixed(4);
1896
s.scaley = +s.scaley.toFixed(4);
1897
s.rotate = +s.rotate.toFixed(4);
1898
return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) +
1899
(s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) +
1900
(s.rotate ? "r" + [s.rotate, 0, 0] : E);
1902
return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];
1905
})(Matrix.prototype);
1907
// WebKit rendering bug workaround method
1908
var version = navigator.userAgent.match(/Version\/(.*?)\s/) || navigator.userAgent.match(/Chrome\/(\d+)/);
1909
if ((navigator.vendor == "Apple Computer, Inc.") && (version && version[1] < 4 || navigator.platform.slice(0, 2) == "iP") ||
1910
(navigator.vendor == "Google Inc." && version && version[1] < 8)) {
1912
paperproto.safari = function () {
1913
var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: "none"});
1914
setTimeout(function () {rect.remove();});
1917
paperproto.safari = fun;
1920
var preventDefault = function () {
1921
this.returnValue = false;
1923
preventTouch = function () {
1924
return this.originalEvent.preventDefault();
1926
stopPropagation = function () {
1927
this.cancelBubble = true;
1929
stopTouch = function () {
1930
return this.originalEvent.stopPropagation();
1932
addEvent = (function () {
1933
if (g.doc.addEventListener) {
1934
return function (obj, type, fn, element) {
1935
var realName = supportsTouch && touchMap[type] ? touchMap[type] : type,
1937
var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
1938
scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,
1939
x = e.clientX + scrollX,
1940
y = e.clientY + scrollY;
1941
if (supportsTouch && touchMap[has](type)) {
1942
for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) {
1943
if (e.targetTouches[i].target == obj) {
1945
e = e.targetTouches[i];
1946
e.originalEvent = olde;
1947
e.preventDefault = preventTouch;
1948
e.stopPropagation = stopTouch;
1953
return fn.call(element, e, x, y);
1955
obj.addEventListener(realName, f, false);
1956
return function () {
1957
obj.removeEventListener(realName, f, false);
1961
} else if (g.doc.attachEvent) {
1962
return function (obj, type, fn, element) {
1963
var f = function (e) {
1964
e = e || g.win.event;
1965
var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
1966
scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,
1967
x = e.clientX + scrollX,
1968
y = e.clientY + scrollY;
1969
e.preventDefault = e.preventDefault || preventDefault;
1970
e.stopPropagation = e.stopPropagation || stopPropagation;
1971
return fn.call(element, e, x, y);
1973
obj.attachEvent("on" + type, f);
1974
var detacher = function () {
1975
obj.detachEvent("on" + type, f);
1983
dragMove = function (e) {
1986
scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
1987
scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,
1992
if (supportsTouch) {
1993
var i = e.touches.length,
1996
touch = e.touches[i];
1997
if (touch.identifier == dragi.el._drag.id) {
2000
(e.originalEvent ? e.originalEvent : e).preventDefault();
2007
var node = dragi.el.node,
2009
next = node.nextSibling,
2010
parent = node.parentNode,
2011
display = node.style.display;
2012
g.win.opera && parent.removeChild(node);
2013
node.style.display = "none";
2014
o = dragi.el.paper.getElementByPoint(x, y);
2015
node.style.display = display;
2016
g.win.opera && (next ? parent.insertBefore(node, next) : parent.appendChild(node));
2017
o && eve("drag.over." + dragi.el.id, dragi.el, o);
2020
eve("drag.move." + dragi.el.id, dragi.move_scope || dragi.el, x - dragi.el._drag.x, y - dragi.el._drag.y, x, y, e);
2023
dragUp = function (e) {
2024
R.unmousemove(dragMove).unmouseup(dragUp);
2025
var i = drag.length,
2029
dragi.el._drag = {};
2030
eve("drag.end." + dragi.el.id, dragi.end_scope || dragi.start_scope || dragi.move_scope || dragi.el, e);
2035
elproto = R.el = {};
2068
for (var i = events.length; i--;) {
2069
(function (eventName) {
2070
R[eventName] = elproto[eventName] = function (fn, scope) {
2071
if (R.is(fn, "function")) {
2072
this.events = this.events || [];
2073
this.events.push({name: eventName, f: fn, unbind: addEvent(this.shape || this.node || g.doc, eventName, fn, scope || this)});
2077
R["un" + eventName] = elproto["un" + eventName] = function (fn) {
2078
var events = this.events || [],
2080
while (l--) if (events[l].name == eventName && events[l].f == fn) {
2082
events.splice(l, 1);
2083
!events.length && delete this.events;
2092
elproto.data = function (key, value) {
2093
var data = eldata[this.id] = eldata[this.id] || {};
2094
if (arguments.length == 1) {
2095
if (R.is(key, "object")) {
2096
for (var i in key) if (key[has](i)) {
2097
this.data(i, key[i]);
2101
eve("data.get." + this.id, this, data[key], key);
2105
eve("data.set." + this.id, this, value, key);
2109
elproto.removeData = function (key) {
2111
eldata[this.id] = {};
2113
eldata[this.id] && delete eldata[this.id][key];
2118
elproto.hover = function (f_in, f_out, scope_in, scope_out) {
2119
return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in);
2122
elproto.unhover = function (f_in, f_out) {
2123
return this.unmouseover(f_in).unmouseout(f_out);
2127
elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) {
2129
(e.originalEvent || e).preventDefault();
2130
var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
2131
scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft;
2132
this._drag.x = e.clientX + scrollX;
2133
this._drag.y = e.clientY + scrollY;
2134
this._drag.id = e.identifier;
2135
!drag.length && R.mousemove(dragMove).mouseup(dragUp);
2136
drag.push({el: this, move_scope: move_scope, start_scope: start_scope, end_scope: end_scope});
2137
onstart && eve.on("drag.start." + this.id, onstart);
2138
onmove && eve.on("drag.move." + this.id, onmove);
2139
onend && eve.on("drag.end." + this.id, onend);
2140
eve("drag.start." + this.id, start_scope || move_scope || this, e.clientX + scrollX, e.clientY + scrollY, e);
2143
draggable.push({el: this, start: start});
2144
this.mousedown(start);
2148
elproto.onDragOver = function (f) {
2149
f ? eve.on("drag.over." + this.id, f) : eve.unbind("drag.over." + this.id);
2152
elproto.undrag = function () {
2153
var i = draggable.length;
2154
while (i--) if (draggable[i].el == this) {
2155
this.unmousedown(draggable[i].start);
2156
draggable.splice(i, 1);
2157
eve.unbind("drag.*." + this.id);
2159
!draggable.length && R.unmousemove(dragMove).unmouseup(dragUp);
2162
paperproto.circle = function (x, y, r) {
2163
var out = R._engine.circle(this, x || 0, y || 0, r || 0);
2164
this.__set__ && this.__set__.push(out);
2168
paperproto.rect = function (x, y, w, h, r) {
2169
var out = R._engine.rect(this, x || 0, y || 0, w || 0, h || 0, r || 0);
2170
this.__set__ && this.__set__.push(out);
2174
paperproto.ellipse = function (x, y, rx, ry) {
2175
var out = R._engine.ellipse(this, x || 0, y || 0, rx || 0, ry || 0);
2176
this.__set__ && this.__set__.push(out);
2180
paperproto.path = function (pathString) {
2181
pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E);
2182
var out = R._engine.path(R.format[apply](R, arguments), this);
2183
this.__set__ && this.__set__.push(out);
2187
paperproto.image = function (src, x, y, w, h) {
2188
var out = R._engine.image(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0);
2189
this.__set__ && this.__set__.push(out);
2193
paperproto.text = function (x, y, text) {
2194
var out = R._engine.text(this, x || 0, y || 0, Str(text));
2195
this.__set__ && this.__set__.push(out);
2199
paperproto.set = function (itemsArray) {
2200
!R.is(itemsArray, "array") && (itemsArray = Array.prototype.splice.call(arguments, 0, arguments.length));
2201
var out = new Set(itemsArray);
2202
this.__set__ && this.__set__.push(out);
2206
paperproto.setStart = function (set) {
2207
this.__set__ = set || this.set();
2210
paperproto.setFinish = function (set) {
2211
var out = this.__set__;
2212
delete this.__set__;
2216
paperproto.setSize = function (width, height) {
2217
return R._engine.setSize.call(this, width, height);
2220
paperproto.setViewBox = function (x, y, w, h, fit) {
2221
return R._engine.setViewBox.call(this, x, y, w, h, fit);
2225
paperproto.top = paperproto.bottom = null;
2227
paperproto.raphael = R;
2228
var getOffset = function (elem) {
2229
var box = elem.getBoundingClientRect(),
2230
doc = elem.ownerDocument,
2232
docElem = doc.documentElement,
2233
clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
2234
top = box.top + (g.win.pageYOffset || docElem.scrollTop || body.scrollTop ) - clientTop,
2235
left = box.left + (g.win.pageXOffset || docElem.scrollLeft || body.scrollLeft) - clientLeft;
2242
paperproto.getElementByPoint = function (x, y) {
2245
target = g.doc.elementFromPoint(x, y);
2246
if (g.win.opera && target.tagName == "svg") {
2247
var so = getOffset(svg),
2248
sr = svg.createSVGRect();
2251
sr.width = sr.height = 1;
2252
var hits = svg.getIntersectionList(sr, null);
2254
target = hits[hits.length - 1];
2260
while (target.parentNode && target != svg.parentNode && !target.raphael) {
2261
target = target.parentNode;
2263
target == paper.canvas.parentNode && (target = svg);
2264
target = target && target.raphael ? paper.getById(target.raphaelid) : null;
2268
paperproto.getById = function (id) {
2269
var bot = this.bottom;
2279
paperproto.forEach = function (callback, thisArg) {
2280
var bot = this.bottom;
2282
if (callback.call(thisArg, bot) === false) {
2290
return this.x + S + this.y;
2292
function x_y_w_h() {
2293
return this.x + S + this.y + S + this.width + " \xd7 " + this.height;
2296
elproto.getBBox = function (isWithoutTransform) {
2301
if (isWithoutTransform) {
2302
if (_.dirty || !_.bboxwt) {
2303
this.realPath = getPath[this.type](this);
2304
_.bboxwt = pathDimensions(this.realPath);
2305
_.bboxwt.toString = x_y_w_h;
2310
if (_.dirty || _.dirtyT || !_.bbox) {
2311
if (_.dirty || !this.realPath) {
2313
this.realPath = getPath[this.type](this);
2315
_.bbox = pathDimensions(mapPath(this.realPath, this.matrix));
2316
_.bbox.toString = x_y_w_h;
2317
_.dirty = _.dirtyT = 0;
2322
elproto.clone = function () {
2326
var out = this.paper[this.type]().attr(this.attr());
2327
this.__set__ && this.__set__.push(out);
2331
elproto.glow = function (glow) {
2332
if (this.type == "text") {
2337
width: (glow.width || 10) + (+this.attr("stroke-width") || 1),
2338
fill: glow.fill || false,
2339
opacity: glow.opacity || .5,
2340
offsetx: glow.offsetx || 0,
2341
offsety: glow.offsety || 0,
2342
color: glow.color || "#000"
2347
path = this.realPath || getPath[this.type](this);
2348
path = this.matrix ? mapPath(path, this.matrix) : path;
2349
for (var i = 1; i < c + 1; i++) {
2350
out.push(r.path(path).attr({
2352
fill: s.fill ? s.color : "none",
2353
"stroke-linejoin": "round",
2354
"stroke-linecap": "round",
2355
"stroke-width": +(s.width / c * i).toFixed(3),
2356
opacity: +(s.opacity / c).toFixed(3)
2359
return out.insertBefore(this).translate(s.offsetx, s.offsety);
2361
var curveslengths = {},
2362
getPointAtSegmentLength = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) {
2365
name = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y].join(),
2366
cache = curveslengths[name],
2368
!cache && (curveslengths[name] = cache = {data: []});
2369
cache.timer && clearTimeout(cache.timer);
2370
cache.timer = setTimeout(function () {delete curveslengths[name];}, 2e3);
2371
if (length != null && !cache.precision) {
2372
var total = getPointAtSegmentLength(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);
2373
cache.precision = ~~total * 10;
2376
precision = cache.precision || precision;
2377
for (var i = 0; i < precision + 1; i++) {
2378
if (cache.data[i * precision]) {
2379
dot = cache.data[i * precision];
2381
dot = R.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, i / precision);
2382
cache.data[i * precision] = dot;
2384
i && (len += pow(pow(old.x - dot.x, 2) + pow(old.y - dot.y, 2), .5));
2385
if (length != null && len >= length) {
2390
if (length == null) {
2394
getLengthFactory = function (istotal, subpath) {
2395
return function (path, length, onlystart) {
2396
path = path2curve(path);
2397
var x, y, p, l, sp = "", subpaths = {}, point,
2399
for (var i = 0, ii = path.length; i < ii; i++) {
2405
l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
2406
if (len + l > length) {
2407
if (subpath && !subpaths.start) {
2408
point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
2409
sp += ["C" + point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y];
2410
if (onlystart) {return sp;}
2411
subpaths.start = sp;
2412
sp = ["M" + point.x, point.y + "C" + point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]].join();
2418
if (!istotal && !subpath) {
2419
point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
2420
return {x: point.x, y: point.y, alpha: point.alpha};
2427
sp += p.shift() + p;
2430
point = istotal ? len : subpath ? subpaths : R.findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1);
2431
point.alpha && (point = {x: point.x, y: point.y, alpha: point.alpha});
2435
var getTotalLength = getLengthFactory(1),
2436
getPointAtLength = getLengthFactory(),
2437
getSubpathsAtLength = getLengthFactory(0, 1);
2439
R.getTotalLength = getTotalLength;
2441
R.getPointAtLength = getPointAtLength;
2443
R.getSubpath = function (path, from, to) {
2444
if (this.getTotalLength(path) - to < 1e-6) {
2445
return getSubpathsAtLength(path, from).end;
2447
var a = getSubpathsAtLength(path, to, 1);
2448
return from ? getSubpathsAtLength(a, from).end : a;
2451
elproto.getTotalLength = function () {
2452
if (this.type != "path") {return;}
2453
if (this.node.getTotalLength) {
2454
return this.node.getTotalLength();
2456
return getTotalLength(this.attrs.path);
2459
elproto.getPointAtLength = function (length) {
2460
if (this.type != "path") {return;}
2461
return getPointAtLength(this.attrs.path, length);
2464
elproto.getSubpath = function (from, to) {
2465
if (this.type != "path") {return;}
2466
return R.getSubpath(this.attrs.path, from, to);
2469
var ef = R.easing_formulas = {
2470
linear: function (n) {
2479
"<>": function (n) {
2480
var q = .48 - n / 1.04,
2481
Q = math.sqrt(.1734 + q * q),
2483
X = pow(abs(x), 1 / 3) * (x < 0 ? -1 : 1),
2485
Y = pow(abs(y), 1 / 3) * (y < 0 ? -1 : 1),
2487
return (1 - t) * 3 * t * t + t * t * t;
2489
backIn: function (n) {
2491
return n * n * ((s + 1) * n - s);
2493
backOut: function (n) {
2496
return n * n * ((s + 1) * n + s) + 1;
2498
elastic: function (n) {
2502
return pow(2, -10 * n) * math.sin((n - .075) * (2 * PI) / .3) + 1;
2504
bounce: function (n) {
2513
l = s * n * n + .75;
2515
if (n < (2.5 / p)) {
2517
l = s * n * n + .9375;
2520
l = s * n * n + .984375;
2527
ef.easeIn = ef["ease-in"] = ef["<"];
2528
ef.easeOut = ef["ease-out"] = ef[">"];
2529
ef.easeInOut = ef["ease-in-out"] = ef["<>"];
2530
ef["back-in"] = ef.backIn;
2531
ef["back-out"] = ef.backOut;
2533
var animationElements = [],
2534
requestAnimFrame = window.requestAnimationFrame ||
2535
window.webkitRequestAnimationFrame ||
2536
window.mozRequestAnimationFrame ||
2537
window.oRequestAnimationFrame ||
2538
window.msRequestAnimationFrame ||
2539
function (callback) {
2540
setTimeout(callback, 16);
2542
animation = function () {
2543
var Now = +new Date,
2545
for (; l < animationElements.length; l++) {
2546
var e = animationElements[l];
2547
if (e.el.removed || e.paused) {
2550
var time = Now - e.start,
2563
time = (e.initstatus * e.anim.top - e.prev) / (e.percent - e.prev) * ms;
2564
e.status = e.initstatus;
2565
delete e.initstatus;
2566
e.stop && animationElements.splice(l--, 1);
2568
e.status = (e.prev + (e.percent - e.prev) * (time / ms)) / e.anim.top;
2574
var pos = easing(time / ms);
2575
for (var attr in from) if (from[has](attr)) {
2576
switch (availableAnimAttrs[attr]) {
2578
now = +from[attr] + pos * ms * diff[attr];
2582
upto255(round(from[attr].r + pos * ms * diff[attr].r)),
2583
upto255(round(from[attr].g + pos * ms * diff[attr].g)),
2584
upto255(round(from[attr].b + pos * ms * diff[attr].b))
2589
for (var i = 0, ii = from[attr].length; i < ii; i++) {
2590
now[i] = [from[attr][i][0]];
2591
for (var j = 1, jj = from[attr][i].length; j < jj; j++) {
2592
now[i][j] = +from[attr][i][j] + pos * ms * diff[attr][i][j];
2594
now[i] = now[i].join(S);
2599
if (diff[attr].real) {
2601
for (i = 0, ii = from[attr].length; i < ii; i++) {
2602
now[i] = [from[attr][i][0]];
2603
for (j = 1, jj = from[attr][i].length; j < jj; j++) {
2604
now[i][j] = from[attr][i][j] + pos * ms * diff[attr][i][j];
2608
var get = function (i) {
2609
return +from[attr][i] + pos * ms * diff[attr][i];
2611
// now = [["r", get(2), 0, 0], ["t", get(3), get(4)], ["s", get(0), get(1), 0, 0]];
2612
now = [["m", get(0), get(1), get(2), get(3), get(4), get(5)]];
2616
if (attr == "clip-rect") {
2620
now[i] = +from[attr][i] + pos * ms * diff[attr][i];
2625
var from2 = [][concat](from[attr]);
2627
i = that.paper.customAttributes[attr].length;
2629
now[i] = +from2[i] + pos * ms * diff[attr][i];
2636
(function (id, that, anim) {
2637
setTimeout(function () {
2638
eve("anim.frame." + id, that, anim);
2640
})(that.id, that, e.anim);
2642
(function(f, el, a) {
2643
setTimeout(function() {
2644
eve("anim.frame." + el.id, el, a);
2645
eve("anim.finish." + el.id, el, a);
2646
R.is(f, "function") && f.call(el);
2648
})(e.callback, that, e.anim);
2650
animationElements.splice(l--, 1);
2651
if (e.repeat > 1 && !e.next) {
2652
for (key in to) if (to[has](key)) {
2653
init[key] = e.totalOrigin[key];
2656
runAnimation(e.anim, e.el, e.anim.percents[0], null, e.totalOrigin, e.repeat - 1);
2658
if (e.next && !e.stop) {
2659
runAnimation(e.anim, e.el, e.next, null, e.totalOrigin, e.repeat);
2663
R.svg && that && that.paper && that.paper.safari();
2664
animationElements.length && requestAnimFrame(animation);
2666
upto255 = function (color) {
2667
return color > 255 ? 255 : color < 0 ? 0 : color;
2670
elproto.animateWith = function (el, anim, params, ms, easing, callback) {
2672
if (element.removed) {
2673
callback && callback.call(element);
2676
var a = params instanceof Animation ? params : R.animation(params, ms, easing, callback),
2678
runAnimation(a, element, a.percents[0], null, element.attr());
2679
for (var i = 0, ii = animationElements.length; i < ii; i++) {
2680
if (animationElements[i].anim == anim && animationElements[i].el == el) {
2681
animationElements[ii - 1].start = animationElements[i].start;
2688
// var a = params ? R.animation(params, ms, easing, callback) : anim,
2689
// status = element.status(anim);
2690
// return this.animate(a).status(a, status * anim.ms / a.ms);
2692
function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) {
2694
bx = 3 * (p2x - p1x) - cx,
2697
by = 3 * (p2y - p1y) - cy,
2699
function sampleCurveX(t) {
2700
return ((ax * t + bx) * t + cx) * t;
2702
function solve(x, epsilon) {
2703
var t = solveCurveX(x, epsilon);
2704
return ((ay * t + by) * t + cy) * t;
2706
function solveCurveX(x, epsilon) {
2707
var t0, t1, t2, x2, d2, i;
2708
for(t2 = x, i = 0; i < 8; i++) {
2709
x2 = sampleCurveX(t2) - x;
2710
if (abs(x2) < epsilon) {
2713
d2 = (3 * ax * t2 + 2 * bx) * t2 + cx;
2714
if (abs(d2) < 1e-6) {
2729
x2 = sampleCurveX(t2);
2730
if (abs(x2 - x) < epsilon) {
2738
t2 = (t1 - t0) / 2 + t0;
2742
return solve(t, 1 / (200 * duration));
2744
elproto.onAnimation = function (f) {
2745
f ? eve.on("anim.frame." + this.id, f) : eve.unbind("anim.frame." + this.id);
2748
function Animation(anim, ms) {
2754
for (var attr in anim) if (anim[has](attr)) {
2755
newAnim[toFloat(attr)] = anim[attr];
2756
percents.push(toFloat(attr));
2758
percents.sort(sortByNumber);
2760
this.anim = newAnim;
2761
this.top = percents[percents.length - 1];
2762
this.percents = percents;
2765
Animation.prototype.delay = function (delay) {
2766
var a = new Animation(this.anim, this.ms);
2767
a.times = this.times;
2768
a.del = +delay || 0;
2772
Animation.prototype.repeat = function (times) {
2773
var a = new Animation(this.anim, this.ms);
2775
a.times = math.floor(mmax(times, 0)) || 1;
2778
function runAnimation(anim, element, percent, status, totalOrigin, times) {
2779
percent = toFloat(percent);
2792
for (i = 0, ii = animationElements.length; i < ii; i++) {
2793
var e = animationElements[i];
2794
if (e.el.id == element.id && e.anim == anim) {
2795
if (e.percent != percent) {
2796
animationElements.splice(i, 1);
2801
element.attr(e.totalOrigin);
2806
status = +to; // NaN
2808
for (var i = 0, ii = anim.percents.length; i < ii; i++) {
2809
if (anim.percents[i] == percent || anim.percents[i] > status * anim.top) {
2810
percent = anim.percents[i];
2811
prev = anim.percents[i - 1] || 0;
2812
ms = ms / anim.top * (percent - prev);
2813
next = anim.percents[i + 1];
2814
params = anim.anim[percent];
2816
} else if (status) {
2817
element.attr(anim.anim[anim.percents[i]]);
2824
for (var attr in params) if (params[has](attr)) {
2825
if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) {
2826
from[attr] = element.attr(attr);
2827
(from[attr] == null) && (from[attr] = availableAttrs[attr]);
2828
to[attr] = params[attr];
2829
switch (availableAnimAttrs[attr]) {
2831
diff[attr] = (to[attr] - from[attr]) / ms;
2834
from[attr] = R.getRGB(from[attr]);
2835
var toColour = R.getRGB(to[attr]);
2837
r: (toColour.r - from[attr].r) / ms,
2838
g: (toColour.g - from[attr].g) / ms,
2839
b: (toColour.b - from[attr].b) / ms
2843
var pathes = path2curve(from[attr], to[attr]),
2845
from[attr] = pathes[0];
2847
for (i = 0, ii = from[attr].length; i < ii; i++) {
2848
diff[attr][i] = [0];
2849
for (var j = 1, jj = from[attr][i].length; j < jj; j++) {
2850
diff[attr][i][j] = (toPath[i][j] - from[attr][i][j]) / ms;
2856
eq = equaliseTransform(_[attr], to[attr]);
2858
from[attr] = eq.from;
2861
diff[attr].real = true;
2862
for (i = 0, ii = from[attr].length; i < ii; i++) {
2863
diff[attr][i] = [from[attr][i][0]];
2864
for (j = 1, jj = from[attr][i].length; j < jj; j++) {
2865
diff[attr][i][j] = (to[attr][i][j] - from[attr][i][j]) / ms;
2869
var m = (element.matrix || new Matrix),
2871
_: {transform: _.transform},
2872
getBBox: function () {
2873
return element.getBBox(1);
2884
extractTransform(to2, to[attr]);
2885
to[attr] = to2._.transform;
2887
(to2.matrix.a - m.a) / ms,
2888
(to2.matrix.b - m.b) / ms,
2889
(to2.matrix.c - m.c) / ms,
2890
(to2.matrix.d - m.d) / ms,
2891
(to2.matrix.e - m.e) / ms,
2892
(to2.matrix.e - m.f) / ms
2894
// from[attr] = [_.sx, _.sy, _.deg, _.dx, _.dy];
2895
// var to2 = {_:{}, getBBox: function () { return element.getBBox(); }};
2896
// extractTransform(to2, to[attr]);
2898
// (to2._.sx - _.sx) / ms,
2899
// (to2._.sy - _.sy) / ms,
2900
// (to2._.deg - _.deg) / ms,
2901
// (to2._.dx - _.dx) / ms,
2902
// (to2._.dy - _.dy) / ms
2907
var values = Str(params[attr])[split](separator),
2908
from2 = Str(from[attr])[split](separator);
2909
if (attr == "clip-rect") {
2914
diff[attr][i] = (values[i] - from[attr][i]) / ms;
2920
values = [][concat](params[attr]);
2921
from2 = [][concat](from[attr]);
2923
i = element.paper.customAttributes[attr].length;
2925
diff[attr][i] = ((values[i] || 0) - (from2[i] || 0)) / ms;
2931
var easing = params.easing,
2932
easyeasy = R.easing_formulas[easing];
2934
easyeasy = Str(easing).match(bezierrg);
2935
if (easyeasy && easyeasy.length == 5) {
2936
var curve = easyeasy;
2937
easyeasy = function (t) {
2938
return CubicBezierAtTime(t, +curve[1], +curve[2], +curve[3], +curve[4], ms);
2944
timestamp = params.start || anim.start || +new Date;
2948
timestamp: timestamp,
2949
start: timestamp + (anim.del || 0),
2951
initstatus: status || 0,
2959
callback: params.callback,
2962
repeat: times || anim.times,
2963
origin: element.attr(),
2964
totalOrigin: totalOrigin
2966
animationElements.push(e);
2967
if (status && !isInAnim && !isInAnimSet) {
2969
e.start = new Date - ms * status;
2970
if (animationElements.length == 1) {
2975
e.start = new Date - e.ms * status;
2977
animationElements.length == 1 && requestAnimFrame(animation);
2979
isInAnim.initstatus = status;
2980
isInAnim.start = new Date - isInAnim.ms * status;
2982
eve("anim.start." + element.id, element, anim);
2985
R.animation = function (params, ms, easing, callback) {
2986
if (params instanceof Animation) {
2989
if (R.is(easing, "function") || !easing) {
2990
callback = callback || easing || null;
2993
params = Object(params);
2998
for (attr in params) if (params[has](attr) && toFloat(attr) != attr && toFloat(attr) + "%" != attr) {
3000
p[attr] = params[attr];
3003
return new Animation(params, ms);
3005
easing && (p.easing = easing);
3006
callback && (p.callback = callback);
3007
return new Animation({100: p}, ms);
3011
elproto.animate = function (params, ms, easing, callback) {
3013
if (element.removed) {
3014
callback && callback.call(element);
3017
var anim = params instanceof Animation ? params : R.animation(params, ms, easing, callback);
3018
runAnimation(anim, element, anim.percents[0], null, element.attr());
3022
elproto.setTime = function (anim, value) {
3023
if (anim && value != null) {
3024
this.status(anim, mmin(value, anim.ms) / anim.ms);
3029
elproto.status = function (anim, value) {
3034
if (value != null) {
3035
runAnimation(anim, this, -1, mmin(value, 1));
3038
len = animationElements.length;
3039
for (; i < len; i++) {
3040
e = animationElements[i];
3041
if (e.el.id == this.id && (!anim || e.anim == anim)) {
3058
elproto.pause = function (anim) {
3059
for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {
3060
if (eve("anim.pause." + this.id, this, animationElements[i].anim) !== false) {
3061
animationElements[i].paused = true;
3067
elproto.resume = function (anim) {
3068
for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {
3069
var e = animationElements[i];
3070
if (eve("anim.resume." + this.id, this, e.anim) !== false) {
3072
this.status(e.anim, e.status);
3078
elproto.stop = function (anim) {
3079
for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {
3080
if (eve("anim.stop." + this.id, this, animationElements[i].anim) !== false) {
3081
animationElements.splice(i--, 1);
3086
elproto.toString = function () {
3087
return "Rapha\xebl\u2019s object";
3091
var Set = function (items) {
3096
for (var i = 0, ii = items.length; i < ii; i++) {
3097
if (items[i] && (items[i].constructor == elproto.constructor || items[i].constructor == Set)) {
3098
this[this.items.length] = this.items[this.items.length] = items[i];
3104
setproto = Set.prototype;
3106
setproto.push = function () {
3109
for (var i = 0, ii = arguments.length; i < ii; i++) {
3110
item = arguments[i];
3111
if (item && (item.constructor == elproto.constructor || item.constructor == Set)) {
3112
len = this.items.length;
3113
this[len] = this.items[len] = item;
3120
setproto.pop = function () {
3121
this.length && delete this[this.length--];
3122
return this.items.pop();
3125
setproto.forEach = function (callback, thisArg) {
3126
for (var i = 0, ii = this.items.length; i < ii; i++) {
3127
if (callback.call(thisArg, this.items[i], i) === false) {
3133
for (var method in elproto) if (elproto[has](method)) {
3134
setproto[method] = (function (methodname) {
3135
return function () {
3136
var arg = arguments;
3137
return this.forEach(function (el) {
3138
el[methodname][apply](el, arg);
3143
setproto.attr = function (name, value) {
3144
if (name && R.is(name, array) && R.is(name[0], "object")) {
3145
for (var j = 0, jj = name.length; j < jj; j++) {
3146
this.items[j].attr(name[j]);
3149
for (var i = 0, ii = this.items.length; i < ii; i++) {
3150
this.items[i].attr(name, value);
3156
setproto.clear = function () {
3157
while (this.length) {
3162
setproto.splice = function (index, count, insertion) {
3163
index = index < 0 ? mmax(this.length + index, 0) : index;
3164
count = mmax(0, mmin(this.length - index, count));
3169
for (i = 2; i < arguments.length; i++) {
3170
args.push(arguments[i]);
3172
for (i = 0; i < count; i++) {
3173
todel.push(this[index + i]);
3175
for (; i < this.length - index; i++) {
3176
tail.push(this[index + i]);
3178
var arglen = args.length;
3179
for (i = 0; i < arglen + tail.length; i++) {
3180
this.items[index + i] = this[index + i] = i < arglen ? args[i] : tail[i - arglen];
3182
i = this.items.length = this.length -= count - arglen;
3186
return new Set(todel);
3189
setproto.exclude = function (el) {
3190
for (var i = 0, ii = this.length; i < ii; i++) if (this[i] == el) {
3195
setproto.animate = function (params, ms, easing, callback) {
3196
(R.is(easing, "function") || !easing) && (callback = easing || null);
3197
var len = this.items.length,
3205
callback && (collector = function () {
3206
!--len && callback.call(set);
3208
easing = R.is(easing, string) ? easing : collector;
3209
var anim = R.animation(params, ms, easing, collector);
3210
item = this.items[--i].animate(anim);
3212
this.items[i] && !this.items[i].removed && this.items[i].animateWith(item, anim, anim);
3216
setproto.insertAfter = function (el) {
3217
var i = this.items.length;
3219
this.items[i].insertAfter(el);
3223
setproto.getBBox = function () {
3228
for (var i = this.items.length; i--;) if (!this.items[i].removed) {
3229
var box = this.items[i].getBBox();
3232
w.push(box.x + box.width);
3233
h.push(box.y + box.height);
3235
x = mmin[apply](0, x);
3236
y = mmin[apply](0, y);
3240
width: mmax[apply](0, w) - x,
3241
height: mmax[apply](0, h) - y
3244
setproto.clone = function (s) {
3246
for (var i = 0, ii = this.items.length; i < ii; i++) {
3247
s.push(this.items[i].clone());
3251
setproto.toString = function () {
3252
return "Rapha\xebl\u2018s set";
3256
R.registerFont = function (font) {
3260
this.fonts = this.fonts || {};
3266
family = font.face["font-family"];
3267
for (var prop in font.face) if (font.face[has](prop)) {
3268
fontcopy.face[prop] = font.face[prop];
3270
if (this.fonts[family]) {
3271
this.fonts[family].push(fontcopy);
3273
this.fonts[family] = [fontcopy];
3276
fontcopy.face["units-per-em"] = toInt(font.face["units-per-em"], 10);
3277
for (var glyph in font.glyphs) if (font.glyphs[has](glyph)) {
3278
var path = font.glyphs[glyph];
3279
fontcopy.glyphs[glyph] = {
3282
d: path.d && "M" + path.d.replace(/[mlcxtrv]/g, function (command) {
3283
return {l: "L", c: "C", x: "z", t: "m", r: "l", v: "c"}[command] || "M";
3287
for (var k in path.k) if (path[has](k)) {
3288
fontcopy.glyphs[glyph].k[k] = path.k[k];
3296
paperproto.getFont = function (family, weight, style, stretch) {
3297
stretch = stretch || "normal";
3298
style = style || "normal";
3299
weight = +weight || {normal: 400, bold: 700, lighter: 300, bolder: 800}[weight] || 400;
3303
var font = R.fonts[family];
3305
var name = new RegExp("(^|\\s)" + family.replace(/[^\w\d\s+!~.:_-]/g, E) + "(\\s|$)", "i");
3306
for (var fontName in R.fonts) if (R.fonts[has](fontName)) {
3307
if (name.test(fontName)) {
3308
font = R.fonts[fontName];
3315
for (var i = 0, ii = font.length; i < ii; i++) {
3317
if (thefont.face["font-weight"] == weight && (thefont.face["font-style"] == style || !thefont.face["font-style"]) && thefont.face["font-stretch"] == stretch) {
3325
paperproto.print = function (x, y, string, font, size, origin, letter_spacing) {
3326
origin = origin || "middle"; // baseline|middle
3327
letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1);
3328
var out = this.set(),
3329
letters = Str(string)[split](E),
3333
R.is(font, string) && (font = this.getFont(font));
3335
scale = (size || 16) / font.face["units-per-em"];
3336
var bb = font.face.bbox[split](separator),
3338
height = +bb[1] + (origin == "baseline" ? bb[3] - bb[1] + (+font.face.descent) : (bb[3] - bb[1]) / 2);
3339
for (var i = 0, ii = letters.length; i < ii; i++) {
3340
var prev = i && font.glyphs[letters[i - 1]] || {},
3341
curr = font.glyphs[letters[i]];
3342
shift += i ? (prev.w || font.w) + (prev.k && prev.k[letters[i]] || 0) + (font.w * letter_spacing) : 0;
3343
curr && curr.d && out.push(this.path(curr.d).attr({
3346
transform: [["t", shift * scale, 0]]
3349
out.transform(["...s", scale, scale, top, height, "t", (x - top) / scale, (y - height) / scale]);
3355
paperproto.add = function (json) {
3356
if (R.is(json, "array")) {
3357
var res = this.set(),
3361
for (; i < ii; i++) {
3363
elements[has](j.type) && res.push(this[j.type]().attr(j));
3370
R.format = function (token, params) {
3371
var args = R.is(params, array) ? [0][concat](params) : arguments;
3372
token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) {
3373
return args[++i] == null ? E : args[i];
3378
R.fullfill = (function () {
3379
var tokenRegex = /\{([^\}]+)\}/g,
3380
objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties
3381
replacer = function (all, key, obj) {
3383
key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) {
3384
name = name || quotedName;
3389
typeof res == "function" && isFunc && (res = res());
3392
res = (res == null || res == obj ? all : res) + "";
3395
return function (str, obj) {
3396
return String(str).replace(tokenRegex, function (all, key) {
3397
return replacer(all, key, obj);
3402
R.ninja = function () {
3403
oldRaphael.was ? (g.win.Raphael = oldRaphael.is) : delete Raphael;
3408
// Firefox <3.6 fix: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html
3409
(function (doc, loaded, f) {
3410
if (doc.readyState == null && doc.addEventListener){
3411
doc.addEventListener(loaded, f = function () {
3412
doc.removeEventListener(loaded, f, false);
3413
doc.readyState = "complete";
3415
doc.readyState = "loading";
3417
function isLoaded() {
3418
(/in/).test(doc.readyState) ? setTimeout(isLoaded, 9) : R.eve("DOMload");
3421
})(document, "DOMContentLoaded");
3423
oldRaphael.was ? (g.win.Raphael = R) : (Raphael = R);
3425
eve.on("DOMload", function () {
3431
// ┌─────────────────────────────────────────────────────────────────────┐ \\
3432
// │ Raphaël - JavaScript Vector Library │ \\
3433
// ├─────────────────────────────────────────────────────────────────────┤ \\
3434
// │ SVG Module │ \\
3435
// ├─────────────────────────────────────────────────────────────────────┤ \\
3436
// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
3437
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
3438
// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
3439
// └─────────────────────────────────────────────────────────────────────┘ \\
3440
window.Raphael.svg && function (R) {
3441
var has = "hasOwnProperty",
3443
toFloat = parseFloat,
3449
separator = /[, ]+/,
3453
var xlink = "http://www.w3.org/1999/xlink",
3455
block: "M5,0 0,2.5 5,5z",
3456
classic: "M5,0 0,2.5 5,5 3.5,3 3.5,2z",
3457
diamond: "M2.5,0 5,2.5 2.5,5 0,2.5z",
3458
open: "M6,1 1,3.5 6,6",
3459
oval: "M2.5,0A2.5,2.5,0,0,1,2.5,5 2.5,2.5,0,0,1,2.5,0z"
3462
R.toString = function () {
3463
return "Your browser supports SVG.\nYou are running Rapha\xebl " + this.version;
3465
var $ = function (el, attr) {
3467
if (typeof el == "string") {
3470
for (var key in attr) if (attr[has](key)) {
3471
if (key.substring(0, 6) == "xlink:") {
3472
el.setAttributeNS(xlink, key.substring(6), Str(attr[key]));
3474
el.setAttribute(key, Str(attr[key]));
3478
el = R._g.doc.createElementNS("http://www.w3.org/2000/svg", el);
3479
el.style && (el.style.webkitTapHighlightColor = "rgba(0,0,0,0)");
3483
addGradientFill = function (element, gradient) {
3484
var type = "linear",
3485
id = element.id + gradient,
3488
SVG = element.paper,
3490
el = R._g.doc.getElementById(id);
3492
gradient = Str(gradient).replace(R._radial_gradient, function (all, _fx, _fy) {
3497
var dir = ((fy > .5) * 2 - 1);
3498
pow(fx - .5, 2) + pow(fy - .5, 2) > .25 &&
3499
(fy = math.sqrt(.25 - pow(fx - .5, 2)) * dir + .5) &&
3501
(fy = fy.toFixed(5) - 1e-5 * dir);
3505
gradient = gradient.split(/\s*\-\s*/);
3506
if (type == "linear") {
3507
var angle = gradient.shift();
3508
angle = -toFloat(angle);
3512
var vector = [0, 0, math.cos(R.rad(angle)), math.sin(R.rad(angle))],
3513
max = 1 / (mmax(abs(vector[2]), abs(vector[3])) || 1);
3516
if (vector[2] < 0) {
3517
vector[0] = -vector[2];
3520
if (vector[3] < 0) {
3521
vector[1] = -vector[3];
3525
var dots = R._parseDots(gradient);
3529
id = id.replace(/[\(\)\s,\xb0#]/g, "_");
3531
if (element.gradient && id != element.gradient.id) {
3532
SVG.defs.removeChild(element.gradient);
3533
delete element.gradient;
3536
if (!element.gradient) {
3537
el = $(type + "Gradient", {id: id});
3538
element.gradient = el;
3539
$(el, type == "radial" ? {
3547
gradientTransform: element.matrix.invert()
3549
SVG.defs.appendChild(el);
3550
for (var i = 0, ii = dots.length; i < ii; i++) {
3551
el.appendChild($("stop", {
3552
offset: dots[i].offset ? dots[i].offset : i ? "100%" : "0%",
3553
"stop-color": dots[i].color || "#fff"
3559
fill: "url(#" + id + ")",
3568
updatePosition = function (o) {
3569
var bbox = o.getBBox(1);
3570
$(o.pattern, {patternTransform: o.matrix.invert() + " translate(" + bbox.x + "," + bbox.y + ")"});
3572
addArrow = function (o, value, isEnd) {
3573
if (o.type == "path") {
3574
var values = Str(value).toLowerCase().split("-"),
3576
se = isEnd ? "end" : "start",
3579
stroke = attrs["stroke-width"],
3591
switch (values[i]) {
3600
case "wide": h = 5; break;
3601
case "narrow": h = 2; break;
3602
case "long": w = 5; break;
3603
case "short": w = 2; break;
3606
if (type == "open") {
3611
refX = isEnd ? 4 : 1;
3614
stroke: attrs.stroke
3625
o._.arrows.endPath && markerCounter[o._.arrows.endPath]--;
3626
o._.arrows.endMarker && markerCounter[o._.arrows.endMarker]--;
3628
o._.arrows.startPath && markerCounter[o._.arrows.startPath]--;
3629
o._.arrows.startMarker && markerCounter[o._.arrows.startMarker]--;
3634
if (type != "none") {
3635
var pathId = "raphael-marker-" + type,
3636
markerId = "raphael-marker-" + se + type + w + h + o.id;
3637
if (!R._g.doc.getElementById(pathId)) {
3638
p.defs.appendChild($($("path"), {
3639
"stroke-linecap": "round",
3643
markerCounter[pathId] = 1;
3645
markerCounter[pathId]++;
3647
var marker = R._g.doc.getElementById(markerId),
3650
marker = $($("marker"), {
3659
"xlink:href": "#" + pathId,
3660
transform: (isEnd ? "rotate(180 " + w / 2 + " " + h / 2 + ") " : E) + "scale(" + w / t + "," + h / t + ")",
3661
"stroke-width": (1 / ((w / t + h / t) / 2)).toFixed(4)
3663
marker.appendChild(use);
3664
p.defs.appendChild(marker);
3665
markerCounter[markerId] = 1;
3667
markerCounter[markerId]++;
3668
use = marker.getElementsByTagName("use")[0];
3671
var delta = dx * (type != "diamond" && type != "oval");
3673
from = o._.arrows.startdx * stroke || 0;
3674
to = R.getTotalLength(attrs.path) - delta * stroke;
3676
from = delta * stroke;
3677
to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0);
3680
attr["marker-" + se] = "url(#" + markerId + ")";
3682
attr.d = Raphael.getSubpath(attrs.path, from, to);
3685
o._.arrows[se + "Path"] = pathId;
3686
o._.arrows[se + "Marker"] = markerId;
3687
o._.arrows[se + "dx"] = delta;
3688
o._.arrows[se + "Type"] = type;
3689
o._.arrows[se + "String"] = value;
3692
from = o._.arrows.startdx * stroke || 0;
3693
to = R.getTotalLength(attrs.path) - from;
3696
to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0);
3698
o._.arrows[se + "Path"] && $(node, {d: Raphael.getSubpath(attrs.path, from, to)});
3699
delete o._.arrows[se + "Path"];
3700
delete o._.arrows[se + "Marker"];
3701
delete o._.arrows[se + "dx"];
3702
delete o._.arrows[se + "Type"];
3703
delete o._.arrows[se + "String"];
3705
for (attr in markerCounter) if (markerCounter[has](attr) && !markerCounter[attr]) {
3706
var item = R._g.doc.getElementById(attr);
3707
item && item.parentNode.removeChild(item);
3717
"-..": [3, 1, 1, 1, 1, 1],
3721
"- .": [4, 3, 1, 3],
3722
"--.": [8, 3, 1, 3],
3723
"--..": [8, 3, 1, 3, 1, 3]
3725
addDashes = function (o, value, params) {
3726
value = dasharray[Str(value).toLowerCase()];
3728
var width = o.attrs["stroke-width"] || "1",
3729
butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0,
3733
dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt;
3735
$(o.node, {"stroke-dasharray": dashes.join(",")});
3738
setFillAndStroke = function (o, params) {
3741
vis = node.style.visibility;
3742
node.style.visibility = "hidden";
3743
for (var att in params) {
3744
if (params[has](att)) {
3745
if (!R._availableAttrs[has](att)) {
3748
var value = params[att];
3757
var pn = node.parentNode;
3758
if (pn.tagName.toLowerCase() != "a") {
3760
pn.insertBefore(hl, node);
3761
hl.appendChild(node);
3764
if (att == "target") {
3765
pn.setAttributeNS(xlink, "show", value == "blank" ? "new" : value);
3767
pn.setAttributeNS(xlink, att, value);
3771
node.style.cursor = value;
3780
addArrow(o, value, 1);
3783
var rect = Str(value).split(separator);
3784
if (rect.length == 4) {
3785
o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode);
3786
var el = $("clipPath"),
3788
el.id = R.createUUID();
3796
o.paper.defs.appendChild(el);
3797
$(node, {"clip-path": "url(#" + el.id + ")"});
3801
var path = node.getAttribute("clip-path");
3803
var clip = R._g.doc.getElementById(path.replace(/(^url\(#|\)$)/g, E));
3804
clip && clip.parentNode.removeChild(clip);
3805
$(node, {"clip-path": E});
3811
if (o.type == "path") {
3812
$(node, {d: value ? attrs.path = R._pathToAbsolute(value) : "M0,0"});
3815
"startString" in o._.arrows && addArrow(o, o._.arrows.startString);
3816
"endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);
3821
node.setAttribute(att, value);
3831
value = -attrs.x - (attrs.width || 0);
3834
if (att == "rx" && o.type == "rect") {
3838
node.setAttribute(att, value);
3839
o.pattern && updatePosition(o);
3843
node.setAttribute(att, value);
3853
value = -attrs.y - (attrs.height || 0);
3856
if (att == "ry" && o.type == "rect") {
3860
node.setAttribute(att, value);
3861
o.pattern && updatePosition(o);
3865
if (o.type == "rect") {
3866
$(node, {rx: value, ry: value});
3868
node.setAttribute(att, value);
3873
if (o.type == "image") {
3874
node.setAttributeNS(xlink, "href", value);
3877
case "stroke-width":
3878
if (o._.sx != 1 || o._.sy != 1) {
3879
value /= mmax(abs(o._.sx), abs(o._.sy)) || 1;
3881
if (o.paper._vbSize) {
3882
value *= o.paper._vbSize;
3884
node.setAttribute(att, value);
3885
if (attrs["stroke-dasharray"]) {
3886
addDashes(o, attrs["stroke-dasharray"], params);
3889
"startString" in o._.arrows && addArrow(o, o._.arrows.startString);
3890
"endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);
3893
case "stroke-dasharray":
3894
addDashes(o, value, params);
3897
var isURL = Str(value).match(R._ISURL);
3900
var ig = $("image");
3901
el.id = R.createUUID();
3902
$(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse", height: 1, width: 1});
3903
$(ig, {x: 0, y: 0, "xlink:href": isURL[1]});
3907
R._preload(isURL[1], function () {
3908
var w = this.offsetWidth,
3909
h = this.offsetHeight;
3910
$(el, {width: w, height: h});
3911
$(ig, {width: w, height: h});
3915
o.paper.defs.appendChild(el);
3916
$(node, {fill: "url(#" + el.id + ")"});
3918
o.pattern && updatePosition(o);
3921
var clr = R.getRGB(value);
3923
delete params.gradient;
3924
delete attrs.gradient;
3925
!R.is(attrs.opacity, "undefined") &&
3926
R.is(params.opacity, "undefined") &&
3927
$(node, {opacity: attrs.opacity});
3928
!R.is(attrs["fill-opacity"], "undefined") &&
3929
R.is(params["fill-opacity"], "undefined") &&
3930
$(node, {"fill-opacity": attrs["fill-opacity"]});
3931
} else if ((o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value)) {
3932
if ("opacity" in attrs || "fill-opacity" in attrs) {
3933
var gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E));
3935
var stops = gradient.getElementsByTagName("stop");
3936
$(stops[stops.length - 1], {"stop-opacity": ("opacity" in attrs ? attrs.opacity : 1) * ("fill-opacity" in attrs ? attrs["fill-opacity"] : 1)});
3939
attrs.gradient = value;
3940
attrs.fill = "none";
3943
clr[has]("opacity") && $(node, {"fill-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});
3945
clr = R.getRGB(value);
3946
node.setAttribute(att, clr.hex);
3947
att == "stroke" && clr[has]("opacity") && $(node, {"stroke-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});
3948
if (att == "stroke" && o._.arrows) {
3949
"startString" in o._.arrows && addArrow(o, o._.arrows.startString);
3950
"endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);
3954
(o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value);
3957
if (attrs.gradient && !attrs[has]("stroke-opacity")) {
3958
$(node, {"stroke-opacity": value > 1 ? value / 100 : value});
3961
case "fill-opacity":
3962
if (attrs.gradient) {
3963
gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E));
3965
stops = gradient.getElementsByTagName("stop");
3966
$(stops[stops.length - 1], {"stop-opacity": value});
3971
att == "font-size" && (value = toInt(value, 10) + "px");
3972
var cssrule = att.replace(/(\-.)/g, function (w) {
3973
return w.substring(1).toUpperCase();
3975
node.style[cssrule] = value;
3977
node.setAttribute(att, value);
3983
tuneText(o, params);
3984
node.style.visibility = vis;
3987
tuneText = function (el, params) {
3988
if (el.type != "text" || !(params[has]("text") || params[has]("font") || params[has]("font-size") || params[has]("x") || params[has]("y"))) {
3993
fontSize = node.firstChild ? toInt(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size"), 10) : 10;
3995
if (params[has]("text")) {
3996
a.text = params.text;
3997
while (node.firstChild) {
3998
node.removeChild(node.firstChild);
4000
var texts = Str(params.text).split("\n"),
4003
for (var i = 0, ii = texts.length; i < ii; i++) {
4005
i && $(tspan, {dy: fontSize * leading, x: a.x});
4006
tspan.appendChild(R._g.doc.createTextNode(texts[i]));
4007
node.appendChild(tspan);
4011
tspans = node.getElementsByTagName("tspan");
4012
for (i = 0, ii = tspans.length; i < ii; i++) if (i) {
4013
$(tspans[i], {dy: fontSize * leading, x: a.x});
4015
$(tspans[0], {dy: 0});
4018
$(node, {x: a.x, y: a.y});
4020
var bb = el._getBBox(),
4021
dif = a.y - (bb.y + bb.height / 2);
4022
dif && R.is(dif, "finite") && $(tspans[0], {dy: dif});
4024
Element = function (node, svg) {
4028
this[0] = this.node = node;
4030
node.raphael = true;
4033
node.raphaelid = this.id;
4034
this.matrix = R.matrix();
4035
this.realPath = null;
4038
this.attrs = this.attrs || {};
4048
!svg.bottom && (svg.bottom = this);
4050
this.prev = svg.top;
4051
svg.top && (svg.top.next = this);
4058
Element.prototype = elproto;
4059
elproto.constructor = Element;
4061
R._engine.path = function (pathString, SVG) {
4063
SVG.canvas && SVG.canvas.appendChild(el);
4064
var p = new Element(el, SVG);
4066
setFillAndStroke(p, {
4074
elproto.rotate = function (deg, cx, cy) {
4078
deg = Str(deg).split(separator);
4079
if (deg.length - 1) {
4080
cx = toFloat(deg[1]);
4081
cy = toFloat(deg[2]);
4083
deg = toFloat(deg[0]);
4084
(cy == null) && (cx = cy);
4085
if (cx == null || cy == null) {
4086
var bbox = this.getBBox(1);
4087
cx = bbox.x + bbox.width / 2;
4088
cy = bbox.y + bbox.height / 2;
4090
this.transform(this._.transform.concat([["r", deg, cx, cy]]));
4094
elproto.scale = function (sx, sy, cx, cy) {
4098
sx = Str(sx).split(separator);
4099
if (sx.length - 1) {
4100
sy = toFloat(sx[1]);
4101
cx = toFloat(sx[2]);
4102
cy = toFloat(sx[3]);
4104
sx = toFloat(sx[0]);
4105
(sy == null) && (sy = sx);
4106
(cy == null) && (cx = cy);
4107
if (cx == null || cy == null) {
4108
var bbox = this.getBBox(1);
4110
cx = cx == null ? bbox.x + bbox.width / 2 : cx;
4111
cy = cy == null ? bbox.y + bbox.height / 2 : cy;
4112
this.transform(this._.transform.concat([["s", sx, sy, cx, cy]]));
4116
elproto.translate = function (dx, dy) {
4120
dx = Str(dx).split(separator);
4121
if (dx.length - 1) {
4122
dy = toFloat(dx[1]);
4124
dx = toFloat(dx[0]) || 0;
4126
this.transform(this._.transform.concat([["t", dx, dy]]));
4130
elproto.transform = function (tstr) {
4135
R._extractTransform(this, tstr);
4137
this.clip && $(this.clip, {transform: this.matrix.invert()});
4138
this.pattern && updatePosition(this);
4139
this.node && $(this.node, {transform: this.matrix});
4141
if (_.sx != 1 || _.sy != 1) {
4142
var sw = this.attrs[has]("stroke-width") ? this.attrs["stroke-width"] : 1;
4143
this.attr({"stroke-width": sw});
4149
elproto.hide = function () {
4150
!this.removed && this.paper.safari(this.node.style.display = "none");
4154
elproto.show = function () {
4155
!this.removed && this.paper.safari(this.node.style.display = "");
4159
elproto.remove = function () {
4163
var paper = this.paper;
4164
paper.__set__ && paper.__set__.exclude(this);
4165
eve.unbind("*.*." + this.id);
4166
if (this.gradient) {
4167
paper.defs.removeChild(this.gradient);
4169
R._tear(this, paper);
4170
if (this.node.parentNode.tagName.toLowerCase() == "a") {
4171
this.node.parentNode.parentNode.removeChild(this.node.parentNode);
4173
this.node.parentNode.removeChild(this.node);
4175
for (var i in this) {
4176
this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
4178
this.removed = true;
4180
elproto._getBBox = function () {
4181
if (this.node.style.display == "none") {
4187
bbox = this.node.getBBox();
4189
// Firefox 3.0.x plays badly here
4193
hide && this.hide();
4197
elproto.attr = function (name, value) {
4203
for (var a in this.attrs) if (this.attrs[has](a)) {
4204
res[a] = this.attrs[a];
4206
res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient;
4207
res.transform = this._.transform;
4210
if (value == null && R.is(name, "string")) {
4211
if (name == "fill" && this.attrs.fill == "none" && this.attrs.gradient) {
4212
return this.attrs.gradient;
4214
if (name == "transform") {
4215
return this._.transform;
4217
var names = name.split(separator),
4219
for (var i = 0, ii = names.length; i < ii; i++) {
4221
if (name in this.attrs) {
4222
out[name] = this.attrs[name];
4223
} else if (R.is(this.paper.customAttributes[name], "function")) {
4224
out[name] = this.paper.customAttributes[name].def;
4226
out[name] = R._availableAttrs[name];
4229
return ii - 1 ? out : out[names[0]];
4231
if (value == null && R.is(name, "array")) {
4233
for (i = 0, ii = name.length; i < ii; i++) {
4234
out[name[i]] = this.attr(name[i]);
4238
if (value != null) {
4240
params[name] = value;
4241
} else if (name != null && R.is(name, "object")) {
4244
for (var key in params) {
4245
eve("attr." + key + "." + this.id, this, params[key]);
4247
for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) {
4248
var par = this.paper.customAttributes[key].apply(this, [].concat(params[key]));
4249
this.attrs[key] = params[key];
4250
for (var subkey in par) if (par[has](subkey)) {
4251
params[subkey] = par[subkey];
4254
setFillAndStroke(this, params);
4258
elproto.toFront = function () {
4262
if (this.node.parentNode.tagName.toLowerCase() == "a") {
4263
this.node.parentNode.parentNode.appendChild(this.node.parentNode);
4265
this.node.parentNode.appendChild(this.node);
4267
var svg = this.paper;
4268
svg.top != this && R._tofront(this, svg);
4272
elproto.toBack = function () {
4276
var parent = this.node.parentNode;
4277
if (parent.tagName.toLowerCase() == "a") {
4278
parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild);
4279
} else if (parent.firstChild != this.node) {
4280
parent.insertBefore(this.node, this.node.parentNode.firstChild);
4282
R._toback(this, this.paper);
4283
var svg = this.paper;
4287
elproto.insertAfter = function (element) {
4291
var node = element.node || element[element.length - 1].node;
4292
if (node.nextSibling) {
4293
node.parentNode.insertBefore(this.node, node.nextSibling);
4295
node.parentNode.appendChild(this.node);
4297
R._insertafter(this, element, this.paper);
4301
elproto.insertBefore = function (element) {
4305
var node = element.node || element[0].node;
4306
node.parentNode.insertBefore(this.node, node);
4307
R._insertbefore(this, element, this.paper);
4310
elproto.blur = function (size) {
4311
// Experimental. No Safari support. Use it on your own risk.
4314
var fltr = $("filter"),
4315
blur = $("feGaussianBlur");
4316
t.attrs.blur = size;
4317
fltr.id = R.createUUID();
4318
$(blur, {stdDeviation: +size || 1.5});
4319
fltr.appendChild(blur);
4320
t.paper.defs.appendChild(fltr);
4322
$(t.node, {filter: "url(#" + fltr.id + ")"});
4325
t._blur.parentNode.removeChild(t._blur);
4327
delete t.attrs.blur;
4329
t.node.removeAttribute("filter");
4332
R._engine.circle = function (svg, x, y, r) {
4333
var el = $("circle");
4334
svg.canvas && svg.canvas.appendChild(el);
4335
var res = new Element(el, svg);
4336
res.attrs = {cx: x, cy: y, r: r, fill: "none", stroke: "#000"};
4337
res.type = "circle";
4341
R._engine.rect = function (svg, x, y, w, h, r) {
4343
svg.canvas && svg.canvas.appendChild(el);
4344
var res = new Element(el, svg);
4345
res.attrs = {x: x, y: y, width: w, height: h, r: r || 0, rx: r || 0, ry: r || 0, fill: "none", stroke: "#000"};
4350
R._engine.ellipse = function (svg, x, y, rx, ry) {
4351
var el = $("ellipse");
4352
svg.canvas && svg.canvas.appendChild(el);
4353
var res = new Element(el, svg);
4354
res.attrs = {cx: x, cy: y, rx: rx, ry: ry, fill: "none", stroke: "#000"};
4355
res.type = "ellipse";
4359
R._engine.image = function (svg, src, x, y, w, h) {
4360
var el = $("image");
4361
$(el, {x: x, y: y, width: w, height: h, preserveAspectRatio: "none"});
4362
el.setAttributeNS(xlink, "href", src);
4363
svg.canvas && svg.canvas.appendChild(el);
4364
var res = new Element(el, svg);
4365
res.attrs = {x: x, y: y, width: w, height: h, src: src};
4369
R._engine.text = function (svg, x, y, text) {
4371
svg.canvas && svg.canvas.appendChild(el);
4372
var res = new Element(el, svg);
4376
"text-anchor": "middle",
4378
font: R._availableAttrs.font,
4383
setFillAndStroke(res, res.attrs);
4386
R._engine.setSize = function (width, height) {
4387
this.width = width || this.width;
4388
this.height = height || this.height;
4389
this.canvas.setAttribute("width", this.width);
4390
this.canvas.setAttribute("height", this.height);
4391
if (this._viewBox) {
4392
this.setViewBox.apply(this, this._viewBox);
4396
R._engine.create = function () {
4397
var con = R._getContainer.apply(0, arguments),
4398
container = con && con.container,
4402
height = con.height;
4404
throw new Error("SVG container not found.");
4406
var cnvs = $("svg"),
4407
css = "overflow:hidden;",
4411
width = width || 512;
4412
height = height || 342;
4417
xmlns: "http://www.w3.org/2000/svg"
4419
if (container == 1) {
4420
cnvs.style.cssText = css + "position:absolute;left:" + x + "px;top:" + y + "px";
4421
R._g.doc.body.appendChild(cnvs);
4424
cnvs.style.cssText = css + "position:relative";
4425
if (container.firstChild) {
4426
container.insertBefore(cnvs, container.firstChild);
4428
container.appendChild(cnvs);
4431
container = new R._Paper;
4432
container.width = width;
4433
container.height = height;
4434
container.canvas = cnvs;
4436
container._left = container._top = 0;
4437
isFloating && (container.renderfix = function () {});
4438
container.renderfix();
4441
R._engine.setViewBox = function (x, y, w, h, fit) {
4442
eve("setViewBox", this, this._viewBox, [x, y, w, h, fit]);
4443
var size = mmax(w / this.width, h / this.height),
4445
aspectRatio = fit ? "meet" : "xMinYMin",
4452
delete this._vbSize;
4453
vb = "0 0 " + this.width + S + this.height;
4455
this._vbSize = size;
4456
vb = x + S + y + S + w + S + h;
4460
preserveAspectRatio: aspectRatio
4462
while (size && top) {
4463
sw = "stroke-width" in top.attrs ? top.attrs["stroke-width"] : 1;
4464
top.attr({"stroke-width": sw});
4469
this._viewBox = [x, y, w, h, !!fit];
4473
R.prototype.renderfix = function () {
4474
var cnvs = this.canvas,
4478
pos = cnvs.getScreenCTM() || cnvs.createSVGMatrix();
4480
pos = cnvs.createSVGMatrix();
4482
var left = -pos.e % 1,
4486
this._left = (this._left + left) % 1;
4487
s.left = this._left + "px";
4490
this._top = (this._top + top) % 1;
4491
s.top = this._top + "px";
4496
R.prototype.clear = function () {
4497
R.eve("clear", this);
4498
var c = this.canvas;
4499
while (c.firstChild) {
4500
c.removeChild(c.firstChild);
4502
this.bottom = this.top = null;
4503
(this.desc = $("desc")).appendChild(R._g.doc.createTextNode("Created with Rapha\xebl " + R.version));
4504
c.appendChild(this.desc);
4505
c.appendChild(this.defs = $("defs"));
4508
R.prototype.remove = function () {
4509
eve("remove", this);
4510
this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
4511
for (var i in this) {
4512
this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
4515
var setproto = R.st;
4516
for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) {
4517
setproto[method] = (function (methodname) {
4518
return function () {
4519
var arg = arguments;
4520
return this.forEach(function (el) {
4521
el[methodname].apply(el, arg);
4528
// ┌─────────────────────────────────────────────────────────────────────┐ \\
4529
// │ Raphaël - JavaScript Vector Library │ \\
4530
// ├─────────────────────────────────────────────────────────────────────┤ \\
4531
// │ VML Module │ \\
4532
// ├─────────────────────────────────────────────────────────────────────┤ \\
4533
// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
4534
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
4535
// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
4536
// └─────────────────────────────────────────────────────────────────────┘ \\
4537
window.Raphael.vml && function (R) {
4538
var has = "hasOwnProperty",
4540
toFloat = parseFloat,
4546
fillString = "fill",
4547
separator = /[, ]+/,
4549
ms = " progid:DXImageTransform.Microsoft",
4552
map = {M: "m", L: "l", C: "c", Z: "x", m: "t", l: "r", c: "v", z: "x"},
4553
bites = /([clmz]),?([^clmz]*)/gi,
4554
blurregexp = / progid:\S+Blur\([^\)]+\)/g,
4555
val = /-?[^,\s-]+/g,
4556
cssDot = "position:absolute;left:0;top:0;width:1px;height:1px",
4558
pathTypes = {path: 1, rect: 1, image: 1},
4559
ovalTypes = {circle: 1, ellipse: 1},
4560
path2vml = function (path) {
4561
var total = /[ahqstv]/ig,
4562
command = R._pathToAbsolute;
4563
Str(path).match(total) && (command = R._path2curve);
4565
if (command == R._pathToAbsolute && !Str(path).match(total)) {
4566
var res = Str(path).replace(bites, function (all, command, args) {
4568
isMove = command.toLowerCase() == "m",
4570
args.replace(val, function (value) {
4571
if (isMove && vals.length == 2) {
4572
res += vals + map[command == "m" ? "l" : "L"];
4575
vals.push(round(value * zoom));
4581
var pa = command(path), p, r;
4583
for (var i = 0, ii = pa.length; i < ii; i++) {
4585
r = pa[i][0].toLowerCase();
4586
r == "z" && (r = "x");
4587
for (var j = 1, jj = p.length; j < jj; j++) {
4588
r += round(p[j] * zoom) + (j != jj - 1 ? "," : E);
4594
compensation = function (deg, dx, dy) {
4596
m.rotate(-deg, .5, .5);
4602
setCoords = function (p, sx, sy, dx, dy, deg) {
4605
fillpos = _.fillpos,
4613
s.visibility = "hidden";
4617
o.coordsize = abs(kx) + S + abs(ky);
4618
s.rotation = deg * (sx * sy < 0 ? -1 : 1);
4620
var c = compensation(deg, dx, dy);
4624
sx < 0 && (flip += "x");
4625
sy < 0 && (flip += " y") && (y = -1);
4627
o.coordorigin = (dx * -kx) + S + (dy * -ky);
4628
if (fillpos || _.fillsize) {
4629
var fill = o.getElementsByTagName(fillString);
4630
fill = fill && fill[0];
4631
o.removeChild(fill);
4633
c = compensation(deg, m.x(fillpos[0], fillpos[1]), m.y(fillpos[0], fillpos[1]));
4634
fill.position = c.dx * y + S + c.dy * y;
4637
fill.size = _.fillsize[0] * abs(sx) + S + _.fillsize[1] * abs(sy);
4639
o.appendChild(fill);
4641
s.visibility = "visible";
4643
R.toString = function () {
4644
return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version;
4646
var addArrow = function (o, value, isEnd) {
4647
var values = Str(value).toLowerCase().split("-"),
4648
se = isEnd ? "end" : "start",
4654
switch (values[i]) {
4664
case "narrow": h = values[i]; break;
4666
case "short": w = values[i]; break;
4669
var stroke = o.node.getElementsByTagName("stroke")[0];
4670
stroke[se + "arrow"] = type;
4671
stroke[se + "arrowlength"] = w;
4672
stroke[se + "arrowwidth"] = h;
4674
setFillAndStroke = function (o, params) {
4675
// o.paper.canvas.style.display = "none";
4676
o.attrs = o.attrs || {};
4681
newpath = pathTypes[o.type] && (params.x != a.x || params.y != a.y || params.width != a.width || params.height != a.height || params.cx != a.cx || params.cy != a.cy || params.rx != a.rx || params.ry != a.ry || params.r != a.r),
4682
isOval = ovalTypes[o.type] && (a.cx != params.cx || a.cy != params.cy || a.r != params.r || a.rx != params.rx || a.ry != params.ry),
4686
for (var par in params) if (params[has](par)) {
4687
a[par] = params[par];
4690
a.path = R._getPath[o.type](o);
4693
params.href && (node.href = params.href);
4694
params.title && (node.title = params.title);
4695
params.target && (node.target = params.target);
4696
params.cursor && (s.cursor = params.cursor);
4697
"blur" in params && o.blur(params.blur);
4698
if (params.path && o.type == "path" || newpath) {
4699
node.path = path2vml(~Str(a.path).toLowerCase().indexOf("r") ? R._pathToAbsolute(a.path) : a.path);
4700
if (o.type == "image") {
4701
o._.fillpos = [a.x, a.y];
4702
o._.fillsize = [a.width, a.height];
4703
setCoords(o, 1, 1, 0, 0, 0);
4706
"transform" in params && o.transform(params.transform);
4710
rx = +a.rx || +a.r || 0,
4711
ry = +a.ry || +a.r || 0;
4712
node.path = R.format("ar{0},{1},{2},{3},{4},{1},{4},{1}x", round((cx - rx) * zoom), round((cy - ry) * zoom), round((cx + rx) * zoom), round((cy + ry) * zoom), round(cx * zoom));
4714
if ("clip-rect" in params) {
4715
var rect = Str(params["clip-rect"]).split(separator);
4716
if (rect.length == 4) {
4717
rect[2] = +rect[2] + (+rect[0]);
4718
rect[3] = +rect[3] + (+rect[1]);
4719
var div = node.clipRect || R._g.doc.createElement("div"),
4721
dstyle.clip = R.format("rect({1}px {2}px {3}px {0}px)", rect);
4722
if (!node.clipRect) {
4723
dstyle.position = "absolute";
4726
dstyle.width = o.paper.width + "px";
4727
dstyle.height = o.paper.height + "px";
4728
node.parentNode.insertBefore(div, node);
4729
div.appendChild(node);
4730
node.clipRect = div;
4733
if (!params["clip-rect"]) {
4734
node.clipRect && (node.clipRect.style.clip = "auto");
4738
var textpathStyle = o.textpath.style;
4739
params.font && (textpathStyle.font = params.font);
4740
params["font-family"] && (textpathStyle.fontFamily = '"' + params["font-family"].split(",")[0].replace(/^['"]+|['"]+$/g, E) + '"');
4741
params["font-size"] && (textpathStyle.fontSize = params["font-size"]);
4742
params["font-weight"] && (textpathStyle.fontWeight = params["font-weight"]);
4743
params["font-style"] && (textpathStyle.fontStyle = params["font-style"]);
4745
if ("arrow-start" in params) {
4746
addArrow(res, params["arrow-start"]);
4748
if ("arrow-end" in params) {
4749
addArrow(res, params["arrow-end"], 1);
4751
if (params.opacity != null ||
4752
params["stroke-width"] != null ||
4753
params.fill != null ||
4754
params.src != null ||
4755
params.stroke != null ||
4756
params["stroke-width"] != null ||
4757
params["stroke-opacity"] != null ||
4758
params["fill-opacity"] != null ||
4759
params["stroke-dasharray"] != null ||
4760
params["stroke-miterlimit"] != null ||
4761
params["stroke-linejoin"] != null ||
4762
params["stroke-linecap"] != null) {
4763
var fill = node.getElementsByTagName(fillString),
4765
fill = fill && fill[0];
4766
!fill && (newfill = fill = createNode(fillString));
4767
if (o.type == "image" && params.src) {
4768
fill.src = params.src;
4770
params.fill && (fill.on = true);
4771
if (fill.on == null || params.fill == "none" || params.fill === null) {
4774
if (fill.on && params.fill) {
4775
var isURL = Str(params.fill).match(R._ISURL);
4777
fill.parentNode == node && node.removeChild(fill);
4779
fill.src = isURL[1];
4781
var bbox = o.getBBox(1);
4782
fill.position = bbox.x + S + bbox.y;
4783
o._.fillpos = [bbox.x, bbox.y];
4785
R._preload(isURL[1], function () {
4786
o._.fillsize = [this.offsetWidth, this.offsetHeight];
4789
fill.color = R.getRGB(params.fill).hex;
4791
fill.type = "solid";
4792
if (R.getRGB(params.fill).error && (res.type in {circle: 1, ellipse: 1} || Str(params.fill).charAt() != "r") && addGradientFill(res, params.fill, fill)) {
4794
a.gradient = params.fill;
4795
fill.rotate = false;
4799
if ("fill-opacity" in params || "opacity" in params) {
4800
var opacity = ((+a["fill-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+R.getRGB(params.fill).o + 1 || 2) - 1);
4801
opacity = mmin(mmax(opacity, 0), 1);
4802
fill.opacity = opacity;
4804
fill.color = "none";
4807
node.appendChild(fill);
4808
var stroke = (node.getElementsByTagName("stroke") && node.getElementsByTagName("stroke")[0]),
4810
!stroke && (newstroke = stroke = createNode("stroke"));
4811
if ((params.stroke && params.stroke != "none") ||
4812
params["stroke-width"] ||
4813
params["stroke-opacity"] != null ||
4814
params["stroke-dasharray"] ||
4815
params["stroke-miterlimit"] ||
4816
params["stroke-linejoin"] ||
4817
params["stroke-linecap"]) {
4820
(params.stroke == "none" || params.stroke === null || stroke.on == null || params.stroke == 0 || params["stroke-width"] == 0) && (stroke.on = false);
4821
var strokeColor = R.getRGB(params.stroke);
4822
stroke.on && params.stroke && (stroke.color = strokeColor.hex);
4823
opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+strokeColor.o + 1 || 2) - 1);
4824
var width = (toFloat(params["stroke-width"]) || 1) * .75;
4825
opacity = mmin(mmax(opacity, 0), 1);
4826
params["stroke-width"] == null && (width = a["stroke-width"]);
4827
params["stroke-width"] && (stroke.weight = width);
4828
width && width < 1 && (opacity *= width) && (stroke.weight = 1);
4829
stroke.opacity = opacity;
4831
params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter");
4832
stroke.miterlimit = params["stroke-miterlimit"] || 8;
4833
params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round");
4834
if (params["stroke-dasharray"]) {
4838
"-.": "shortdashdot",
4839
"-..": "shortdashdotdot",
4844
"--.": "longdashdot",
4845
"--..": "longdashdotdot"
4847
stroke.dashstyle = dasharray[has](params["stroke-dasharray"]) ? dasharray[params["stroke-dasharray"]] : E;
4849
newstroke && node.appendChild(stroke);
4851
if (res.type == "text") {
4852
res.paper.canvas.style.display = E;
4853
var span = res.paper.span,
4855
fontSize = a.font && a.font.match(/\d+(?:\.\d*)?(?=px)/);
4857
a.font && (s.font = a.font);
4858
a["font-family"] && (s.fontFamily = a["font-family"]);
4859
a["font-weight"] && (s.fontWeight = a["font-weight"]);
4860
a["font-style"] && (s.fontStyle = a["font-style"]);
4861
fontSize = toFloat(a["font-size"] || fontSize && fontSize[0]) || 10;
4862
s.fontSize = fontSize * m + "px";
4863
res.textpath.string && (span.innerHTML = Str(res.textpath.string).replace(/</g, "<").replace(/&/g, "&").replace(/\n/g, "<br>"));
4864
var brect = span.getBoundingClientRect();
4865
res.W = a.w = (brect.right - brect.left) / m;
4866
res.H = a.h = (brect.bottom - brect.top) / m;
4867
// res.paper.canvas.style.display = "none";
4869
res.Y = a.y + res.H / 2;
4871
("x" in params || "y" in params) && (res.path.v = R.format("m{0},{1}l{2},{1}", round(a.x * zoom), round(a.y * zoom), round(a.x * zoom) + 1));
4872
var dirtyattrs = ["x", "y", "text", "font", "font-family", "font-weight", "font-style", "font-size"];
4873
for (var d = 0, dd = dirtyattrs.length; d < dd; d++) if (dirtyattrs[d] in params) {
4878
// text-anchor emulation
4879
switch (a["text-anchor"]) {
4881
res.textpath.style["v-text-align"] = "left";
4882
res.bbx = res.W / 2;
4885
res.textpath.style["v-text-align"] = "right";
4886
res.bbx = -res.W / 2;
4889
res.textpath.style["v-text-align"] = "center";
4893
res.textpath.style["v-text-kern"] = true;
4895
// res.paper.canvas.style.display = E;
4897
addGradientFill = function (o, gradient, fill) {
4898
o.attrs = o.attrs || {};
4899
var attrs = o.attrs,
4905
o.attrs.gradient = gradient;
4906
gradient = Str(gradient).replace(R._radial_gradient, function (all, fx, fy) {
4911
pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && (fy = math.sqrt(.25 - pow(fx - .5, 2)) * ((fy > .5) * 2 - 1) + .5);
4916
gradient = gradient.split(/\s*\-\s*/);
4917
if (type == "linear") {
4918
var angle = gradient.shift();
4919
angle = -toFloat(angle);
4924
var dots = R._parseDots(gradient);
4928
o = o.shape || o.node;
4930
o.removeChild(fill);
4932
fill.method = "none";
4933
fill.color = dots[0].color;
4934
fill.color2 = dots[dots.length - 1].color;
4936
for (var i = 0, ii = dots.length; i < ii; i++) {
4937
dots[i].offset && clrs.push(dots[i].offset + S + dots[i].color);
4939
fill.colors = clrs.length ? clrs.join() : "0% " + fill.color;
4940
if (type == "radial") {
4941
fill.type = "gradientTitle";
4942
fill.focus = "100%";
4943
fill.focussize = "0 0";
4944
fill.focusposition = fxfy;
4947
// fill.rotate= true;
4948
fill.type = "gradient";
4949
fill.angle = (270 - angle) % 360;
4951
o.appendChild(fill);
4955
Element = function (node, vml) {
4956
this[0] = this.node = node;
4957
node.raphael = true;
4959
node.raphaelid = this.id;
4964
this.matrix = R.matrix();
4975
!vml.bottom && (vml.bottom = this);
4976
this.prev = vml.top;
4977
vml.top && (vml.top.next = this);
4983
Element.prototype = elproto;
4984
elproto.constructor = Element;
4985
elproto.transform = function (tstr) {
4987
return this._.transform;
4989
var vbs = this.paper._viewBoxShift,
4990
vbt = vbs ? "s" + [vbs.scale, vbs.scale] + "-1-1t" + [vbs.dx, vbs.dy] : E,
4993
oldt = tstr = Str(tstr).replace(/\.{3}|\u2026/g, this._.transform || E);
4995
R._extractTransform(this, vbt + tstr);
4996
var matrix = this.matrix.clone(),
5000
isGrad = ~Str(this.attrs.fill).indexOf("-"),
5001
isPatt = !Str(this.attrs.fill).indexOf("url(");
5002
matrix.translate(-.5, -.5);
5003
if (isPatt || isGrad || this.type == "image") {
5004
skew.matrix = "1 0 0 1";
5005
skew.offset = "0 0";
5006
split = matrix.split();
5007
if ((isGrad && split.noRotation) || !split.isSimple) {
5008
o.style.filter = matrix.toFilter();
5009
var bb = this.getBBox(),
5010
bbt = this.getBBox(1),
5013
o.coordorigin = (dx * -zoom) + S + (dy * -zoom);
5014
setCoords(this, 1, 1, dx, dy, 0);
5017
setCoords(this, split.scalex, split.scaley, split.dx, split.dy, split.rotate);
5021
skew.matrix = Str(matrix);
5022
skew.offset = matrix.offset();
5024
oldt && (this._.transform = oldt);
5027
elproto.rotate = function (deg, cx, cy) {
5034
deg = Str(deg).split(separator);
5035
if (deg.length - 1) {
5036
cx = toFloat(deg[1]);
5037
cy = toFloat(deg[2]);
5039
deg = toFloat(deg[0]);
5040
(cy == null) && (cx = cy);
5041
if (cx == null || cy == null) {
5042
var bbox = this.getBBox(1);
5043
cx = bbox.x + bbox.width / 2;
5044
cy = bbox.y + bbox.height / 2;
5047
this.transform(this._.transform.concat([["r", deg, cx, cy]]));
5050
elproto.translate = function (dx, dy) {
5054
dx = Str(dx).split(separator);
5055
if (dx.length - 1) {
5056
dy = toFloat(dx[1]);
5058
dx = toFloat(dx[0]) || 0;
5061
this._.bbox.x += dx;
5062
this._.bbox.y += dy;
5064
this.transform(this._.transform.concat([["t", dx, dy]]));
5067
elproto.scale = function (sx, sy, cx, cy) {
5071
sx = Str(sx).split(separator);
5072
if (sx.length - 1) {
5073
sy = toFloat(sx[1]);
5074
cx = toFloat(sx[2]);
5075
cy = toFloat(sx[3]);
5076
isNaN(cx) && (cx = null);
5077
isNaN(cy) && (cy = null);
5079
sx = toFloat(sx[0]);
5080
(sy == null) && (sy = sx);
5081
(cy == null) && (cx = cy);
5082
if (cx == null || cy == null) {
5083
var bbox = this.getBBox(1);
5085
cx = cx == null ? bbox.x + bbox.width / 2 : cx;
5086
cy = cy == null ? bbox.y + bbox.height / 2 : cy;
5088
this.transform(this._.transform.concat([["s", sx, sy, cx, cy]]));
5092
elproto.hide = function () {
5093
!this.removed && (this.node.style.display = "none");
5096
elproto.show = function () {
5097
!this.removed && (this.node.style.display = E);
5100
elproto._getBBox = function () {
5105
x: this.X + (this.bbx || 0) - this.W / 2,
5111
elproto.remove = function () {
5115
this.paper.__set__ && this.paper.__set__.exclude(this);
5116
R.eve.unbind("*.*." + this.id);
5117
R._tear(this, this.paper);
5118
this.node.parentNode.removeChild(this.node);
5119
this.shape && this.shape.parentNode.removeChild(this.shape);
5120
for (var i in this) {
5121
this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
5123
this.removed = true;
5125
elproto.attr = function (name, value) {
5131
for (var a in this.attrs) if (this.attrs[has](a)) {
5132
res[a] = this.attrs[a];
5134
res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient;
5135
res.transform = this._.transform;
5138
if (value == null && R.is(name, "string")) {
5139
if (name == fillString && this.attrs.fill == "none" && this.attrs.gradient) {
5140
return this.attrs.gradient;
5142
var names = name.split(separator),
5144
for (var i = 0, ii = names.length; i < ii; i++) {
5146
if (name in this.attrs) {
5147
out[name] = this.attrs[name];
5148
} else if (R.is(this.paper.customAttributes[name], "function")) {
5149
out[name] = this.paper.customAttributes[name].def;
5151
out[name] = R._availableAttrs[name];
5154
return ii - 1 ? out : out[names[0]];
5156
if (this.attrs && value == null && R.is(name, "array")) {
5158
for (i = 0, ii = name.length; i < ii; i++) {
5159
out[name[i]] = this.attr(name[i]);
5164
if (value != null) {
5166
params[name] = value;
5168
value == null && R.is(name, "object") && (params = name);
5169
for (var key in params) {
5170
eve("attr." + key + "." + this.id, this, params[key]);
5173
for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) {
5174
var par = this.paper.customAttributes[key].apply(this, [].concat(params[key]));
5175
this.attrs[key] = params[key];
5176
for (var subkey in par) if (par[has](subkey)) {
5177
params[subkey] = par[subkey];
5180
// this.paper.canvas.style.display = "none";
5181
if (params.text && this.type == "text") {
5182
this.textpath.string = params.text;
5184
setFillAndStroke(this, params);
5185
// this.paper.canvas.style.display = E;
5189
elproto.toFront = function () {
5190
!this.removed && this.node.parentNode.appendChild(this.node);
5191
this.paper && this.paper.top != this && R._tofront(this, this.paper);
5194
elproto.toBack = function () {
5198
if (this.node.parentNode.firstChild != this.node) {
5199
this.node.parentNode.insertBefore(this.node, this.node.parentNode.firstChild);
5200
R._toback(this, this.paper);
5204
elproto.insertAfter = function (element) {
5208
if (element.constructor == R.st.constructor) {
5209
element = element[element.length - 1];
5211
if (element.node.nextSibling) {
5212
element.node.parentNode.insertBefore(this.node, element.node.nextSibling);
5214
element.node.parentNode.appendChild(this.node);
5216
R._insertafter(this, element, this.paper);
5219
elproto.insertBefore = function (element) {
5223
if (element.constructor == R.st.constructor) {
5224
element = element[0];
5226
element.node.parentNode.insertBefore(this.node, element.node);
5227
R._insertbefore(this, element, this.paper);
5230
elproto.blur = function (size) {
5231
var s = this.node.runtimeStyle,
5233
f = f.replace(blurregexp, E);
5235
this.attrs.blur = size;
5236
s.filter = f + S + ms + ".Blur(pixelradius=" + (+size || 1.5) + ")";
5237
s.margin = R.format("-{0}px 0 0 -{0}px", round(+size || 1.5));
5241
delete this.attrs.blur;
5245
R._engine.path = function (pathString, vml) {
5246
var el = createNode("shape");
5247
el.style.cssText = cssDot;
5248
el.coordsize = zoom + S + zoom;
5249
el.coordorigin = vml.coordorigin;
5250
var p = new Element(el, vml),
5251
attr = {fill: "none", stroke: "#000"};
5252
pathString && (attr.path = pathString);
5256
setFillAndStroke(p, attr);
5257
vml.canvas.appendChild(el);
5258
var skew = createNode("skew");
5260
el.appendChild(skew);
5265
R._engine.rect = function (vml, x, y, w, h, r) {
5266
var path = R._rectPath(x, y, w, h, r),
5267
res = vml.path(path),
5271
res.W = a.width = w;
5272
res.H = a.height = h;
5278
R._engine.ellipse = function (vml, x, y, rx, ry) {
5279
var res = vml.path(),
5285
res.type = "ellipse";
5286
setFillAndStroke(res, {
5294
R._engine.circle = function (vml, x, y, r) {
5295
var res = vml.path(),
5299
res.W = res.H = r * 2;
5300
res.type = "circle";
5301
setFillAndStroke(res, {
5308
R._engine.image = function (vml, src, x, y, w, h) {
5309
var path = R._rectPath(x, y, w, h),
5310
res = vml.path(path).attr({stroke: "none"}),
5313
fill = node.getElementsByTagName(fillString)[0];
5317
res.W = a.width = w;
5318
res.H = a.height = h;
5321
fill.parentNode == node && node.removeChild(fill);
5325
res._.fillpos = [x, y];
5326
res._.fillsize = [w, h];
5327
node.appendChild(fill);
5328
setCoords(res, 1, 1, 0, 0, 0);
5331
R._engine.text = function (vml, x, y, text) {
5332
var el = createNode("shape"),
5333
path = createNode("path"),
5334
o = createNode("textpath");
5338
path.v = R.format("m{0},{1}l{2},{1}", round(x * zoom), round(y * zoom), round(x * zoom) + 1);
5339
path.textpathok = true;
5340
o.string = Str(text);
5342
el.style.cssText = cssDot;
5343
el.coordsize = zoom + S + zoom;
5344
el.coordorigin = "0 0";
5345
var p = new Element(el, vml),
5349
font: R._availableAttrs.font,
5356
p.attrs.text = Str(text);
5361
setFillAndStroke(p, attr);
5363
el.appendChild(path);
5364
vml.canvas.appendChild(el);
5365
var skew = createNode("skew");
5367
el.appendChild(skew);
5372
R._engine.setSize = function (width, height) {
5373
var cs = this.canvas.style;
5375
this.height = height;
5376
width == +width && (width += "px");
5377
height == +height && (height += "px");
5380
cs.clip = "rect(0 " + width + " " + height + " 0)";
5381
if (this._viewBox) {
5382
R._engine.setViewBox.apply(this, this._viewBox);
5386
R._engine.setViewBox = function (x, y, w, h, fit) {
5387
R.eve("setViewBox", this, this._viewBox, [x, y, w, h, fit]);
5388
var width = this.width,
5389
height = this.height,
5390
size = 1 / mmax(w / width, h / height),
5395
if (w * H < width) {
5396
x -= (width - w * H) / 2 / H;
5398
if (h * W < height) {
5399
y -= (height - h * W) / 2 / W;
5402
this._viewBox = [x, y, w, h, !!fit];
5403
this._viewBoxShift = {
5408
this.forEach(function (el) {
5409
el.transform("...");
5414
R._engine.initWin = function (win) {
5415
var doc = win.document;
5416
doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)");
5418
!doc.namespaces.rvml && doc.namespaces.add("rvml", "urn:schemas-microsoft-com:vml");
5419
createNode = function (tagName) {
5420
return doc.createElement('<rvml:' + tagName + ' class="rvml">');
5423
createNode = function (tagName) {
5424
return doc.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');
5428
R._engine.initWin(R._g.win);
5429
R._engine.create = function () {
5430
var con = R._getContainer.apply(0, arguments),
5431
container = con.container,
5432
height = con.height,
5438
throw new Error("VML container not found.");
5440
var res = new R._Paper,
5441
c = res.canvas = R._g.doc.createElement("div"),
5445
width = width || 512;
5446
height = height || 342;
5448
res.height = height;
5449
width == +width && (width += "px");
5450
height == +height && (height += "px");
5451
res.coordsize = zoom * 1e3 + S + zoom * 1e3;
5452
res.coordorigin = "0 0";
5453
res.span = R._g.doc.createElement("span");
5454
res.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;";
5455
c.appendChild(res.span);
5456
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);
5457
if (container == 1) {
5458
R._g.doc.body.appendChild(c);
5461
cs.position = "absolute";
5463
if (container.firstChild) {
5464
container.insertBefore(c, container.firstChild);
5466
container.appendChild(c);
5469
// plugins.call(res, res, R.fn);
5470
res.renderfix = function () {};
5473
R.prototype.clear = function () {
5474
R.eve("clear", this);
5475
this.canvas.innerHTML = E;
5476
this.span = R._g.doc.createElement("span");
5477
this.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";
5478
this.canvas.appendChild(this.span);
5479
this.bottom = this.top = null;
5481
R.prototype.remove = function () {
5482
R.eve("remove", this);
5483
this.canvas.parentNode.removeChild(this.canvas);
5484
for (var i in this) {
5485
this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
5490
var setproto = R.st;
5491
for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) {
5492
setproto[method] = (function (methodname) {
5493
return function () {
5494
var arg = arguments;
5495
return this.forEach(function (el) {
5496
el[methodname].apply(el, arg);