Mercurial > laserkard
diff awesome_js/raphael.js @ 29:7742910e0479 laserkard
[svn r30] implemented drawing text on the picture dynamically. still need to center stuff
author | rlm |
---|---|
date | Sat, 16 Jan 2010 12:25:43 -0500 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/awesome_js/raphael.js Sat Jan 16 12:25:43 2010 -0500 1.3 @@ -0,0 +1,3215 @@ 1.4 +/*! 1.5 + * Raphael 1.3.0 - JavaScript Vector Library 1.6 + * 1.7 + * Copyright (c) 2008 - 2009 Dmitry Baranovskiy (http://raphaeljs.com) 1.8 + * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. 1.9 + */ 1.10 + 1.11 + 1.12 +window.Raphael = (function () { 1.13 + var separator = /[, ]+/, 1.14 + elements = /^(circle|rect|path|ellipse|text|image)$/, 1.15 + doc = document, 1.16 + win = window, 1.17 + oldRaphael = { 1.18 + was: "Raphael" in win, 1.19 + is: win.Raphael 1.20 + }, 1.21 + R = function () { 1.22 + if (R.is(arguments[0], "array")) { 1.23 + var a = arguments[0], 1.24 + cnv = create[apply](R, a.splice(0, 3 + R.is(a[0], nu))), 1.25 + res = cnv.set(); 1.26 + for (var i = 0, ii = a[length]; i < ii; i++) { 1.27 + var j = a[i] || {}; 1.28 + elements.test(j.type) && res[push](cnv[j.type]().attr(j)); 1.29 + } 1.30 + return res; 1.31 + } 1.32 + return create[apply](R, arguments); 1.33 + }, 1.34 + Paper = function () {}, 1.35 + appendChild = "appendChild", 1.36 + apply = "apply", 1.37 + concat = "concat", 1.38 + E = "", 1.39 + S = " ", 1.40 + split = "split", 1.41 + events = "click dblclick mousedown mousemove mouseout mouseover mouseup"[split](S), 1.42 + has = "hasOwnProperty", 1.43 + join = "join", 1.44 + length = "length", 1.45 + proto = "prototype", 1.46 + lowerCase = String[proto].toLowerCase, 1.47 + math = Math, 1.48 + mmax = math.max, 1.49 + mmin = math.min, 1.50 + nu = "number", 1.51 + toString = "toString", 1.52 + objectToString = Object[proto][toString], 1.53 + paper = {}, 1.54 + pow = math.pow, 1.55 + push = "push", 1.56 + rg = /^(?=[\da-f]$)/, 1.57 + ISURL = /^url\(['"]?([^\)]+)['"]?\)$/i, 1.58 + colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgb\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|rgb\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\)|hs[bl]\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|hs[bl]\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\))\s*$/i, 1.59 + round = math.round, 1.60 + setAttribute = "setAttribute", 1.61 + toFloat = parseFloat, 1.62 + toInt = parseInt, 1.63 + upperCase = String[proto].toUpperCase, 1.64 + availableAttrs = {"clip-rect": "0 0 1e9 1e9", cursor: "default", cx: 0, cy: 0, fill: "#fff", "fill-opacity": 1, font: '10px "Arial"', "font-family": '"Arial"', "font-size": "10", "font-style": "normal", "font-weight": 400, gradient: 0, height: 0, href: "http://raphaeljs.com/", opacity: 1, path: "M0,0", r: 0, rotation: 0, rx: 0, ry: 0, scale: "1 1", src: "", stroke: "#000", "stroke-dasharray": "", "stroke-linecap": "butt", "stroke-linejoin": "butt", "stroke-miterlimit": 0, "stroke-opacity": 1, "stroke-width": 1, target: "_blank", "text-anchor": "middle", title: "Raphael", translation: "0 0", width: 0, x: 0, y: 0}, 1.65 + availableAnimAttrs = {along: "along", "clip-rect": "csv", cx: nu, cy: nu, fill: "colour", "fill-opacity": nu, "font-size": nu, height: nu, opacity: nu, path: "path", r: nu, rotation: "csv", rx: nu, ry: nu, scale: "csv", stroke: "colour", "stroke-opacity": nu, "stroke-width": nu, translation: "csv", width: nu, x: nu, y: nu}, 1.66 + rp = "replace"; 1.67 + R.version = "1.3.0"; 1.68 + R.type = (win.SVGAngle || doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML"); 1.69 + if (R.type == "VML") { 1.70 + var d = document.createElement("div"); 1.71 + d.innerHTML = '<!--[if vml]><br><br><![endif]-->'; 1.72 + if (d.childNodes[length] != 2) { 1.73 + return null; 1.74 + } 1.75 + } 1.76 + R.svg = !(R.vml = R.type == "VML"); 1.77 + Paper[proto] = R[proto]; 1.78 + R._id = 0; 1.79 + R._oid = 0; 1.80 + R.fn = {}; 1.81 + R.is = function (o, type) { 1.82 + type = lowerCase.call(type); 1.83 + return ((type == "object" || type == "undefined") && typeof o == type) || (o == null && type == "null") || lowerCase.call(objectToString.call(o).slice(8, -1)) == type; 1.84 + }; 1.85 + R.setWindow = function (newwin) { 1.86 + win = newwin; 1.87 + doc = win.document; 1.88 + }; 1.89 + // colour utilities 1.90 + var toHex = function (color) { 1.91 + if (R.vml) { 1.92 + // http://dean.edwards.name/weblog/2009/10/convert-any-colour-value-to-hex-in-msie/ 1.93 + var trim = /^\s+|\s+$/g; 1.94 + toHex = cacher(function (color) { 1.95 + var bod; 1.96 + color = (color + E)[rp](trim, E); 1.97 + try { 1.98 + var docum = new ActiveXObject("htmlfile"); 1.99 + docum.write("<body>"); 1.100 + docum.close(); 1.101 + bod = docum.body; 1.102 + } catch(e) { 1.103 + bod = createPopup().document.body; 1.104 + } 1.105 + var range = bod.createTextRange(); 1.106 + try { 1.107 + bod.style.color = color; 1.108 + var value = range.queryCommandValue("ForeColor"); 1.109 + value = ((value & 255) << 16) | (value & 65280) | ((value & 16711680) >>> 16); 1.110 + return "#" + ("000000" + value[toString](16)).slice(-6); 1.111 + } catch(e) { 1.112 + return "none"; 1.113 + } 1.114 + }); 1.115 + } else { 1.116 + var i = doc.createElement("i"); 1.117 + i.title = "Rapha\xebl Colour Picker"; 1.118 + i.style.display = "none"; 1.119 + doc.body[appendChild](i); 1.120 + toHex = cacher(function (color) { 1.121 + i.style.color = color; 1.122 + return doc.defaultView.getComputedStyle(i, E).getPropertyValue("color"); 1.123 + }); 1.124 + } 1.125 + return toHex(color); 1.126 + }; 1.127 + R.hsb2rgb = cacher(function (hue, saturation, brightness) { 1.128 + if (R.is(hue, "object") && "h" in hue && "s" in hue && "b" in hue) { 1.129 + brightness = hue.b; 1.130 + saturation = hue.s; 1.131 + hue = hue.h; 1.132 + } 1.133 + var red, 1.134 + green, 1.135 + blue; 1.136 + if (brightness == 0) { 1.137 + return {r: 0, g: 0, b: 0, hex: "#000"}; 1.138 + } 1.139 + if (hue > 1 || saturation > 1 || brightness > 1) { 1.140 + hue /= 255; 1.141 + saturation /= 255; 1.142 + brightness /= 255; 1.143 + } 1.144 + var i = ~~(hue * 6), 1.145 + f = (hue * 6) - i, 1.146 + p = brightness * (1 - saturation), 1.147 + q = brightness * (1 - (saturation * f)), 1.148 + t = brightness * (1 - (saturation * (1 - f))); 1.149 + red = [brightness, q, p, p, t, brightness, brightness][i]; 1.150 + green = [t, brightness, brightness, q, p, p, t][i]; 1.151 + blue = [p, p, t, brightness, brightness, q, p][i]; 1.152 + red *= 255; 1.153 + green *= 255; 1.154 + blue *= 255; 1.155 + var rgb = {r: red, g: green, b: blue}, 1.156 + r = (~~red)[toString](16), 1.157 + g = (~~green)[toString](16), 1.158 + b = (~~blue)[toString](16); 1.159 + r = r[rp](rg, "0"); 1.160 + g = g[rp](rg, "0"); 1.161 + b = b[rp](rg, "0"); 1.162 + rgb.hex = "#" + r + g + b; 1.163 + return rgb; 1.164 + }, R); 1.165 + R.rgb2hsb = cacher(function (red, green, blue) { 1.166 + if (R.is(red, "object") && "r" in red && "g" in red && "b" in red) { 1.167 + blue = red.b; 1.168 + green = red.g; 1.169 + red = red.r; 1.170 + } 1.171 + if (R.is(red, "string")) { 1.172 + var clr = R.getRGB(red); 1.173 + red = clr.r; 1.174 + green = clr.g; 1.175 + blue = clr.b; 1.176 + } 1.177 + if (red > 1 || green > 1 || blue > 1) { 1.178 + red /= 255; 1.179 + green /= 255; 1.180 + blue /= 255; 1.181 + } 1.182 + var max = mmax(red, green, blue), 1.183 + min = mmin(red, green, blue), 1.184 + hue, 1.185 + saturation, 1.186 + brightness = max; 1.187 + if (min == max) { 1.188 + return {h: 0, s: 0, b: max}; 1.189 + } else { 1.190 + var delta = (max - min); 1.191 + saturation = delta / max; 1.192 + if (red == max) { 1.193 + hue = (green - blue) / delta; 1.194 + } else if (green == max) { 1.195 + hue = 2 + ((blue - red) / delta); 1.196 + } else { 1.197 + hue = 4 + ((red - green) / delta); 1.198 + } 1.199 + hue /= 6; 1.200 + hue < 0 && hue++; 1.201 + hue > 1 && hue--; 1.202 + } 1.203 + return {h: hue, s: saturation, b: brightness}; 1.204 + }, R); 1.205 + var p2s = /,?([achlmqrstvxz]),?/gi; 1.206 + R._path2string = function () { 1.207 + return this.join(",")[rp](p2s, "$1"); 1.208 + }; 1.209 + function cacher(f, scope, postprocessor) { 1.210 + function newf() { 1.211 + var arg = Array[proto].slice.call(arguments, 0), 1.212 + args = arg[join]("\u25ba"), 1.213 + cache = newf.cache = newf.cache || {}, 1.214 + count = newf.count = newf.count || []; 1.215 + if (cache[has](args)) { 1.216 + return postprocessor ? postprocessor(cache[args]) : cache[args]; 1.217 + } 1.218 + count[length] >= 1e3 && delete cache[count.shift()]; 1.219 + count[push](args); 1.220 + cache[args] = f[apply](scope, arg); 1.221 + return postprocessor ? postprocessor(cache[args]) : cache[args]; 1.222 + } 1.223 + return newf; 1.224 + } 1.225 + 1.226 + R.getRGB = cacher(function (colour) { 1.227 + if (!colour || !!((colour = colour + E).indexOf("-") + 1)) { 1.228 + return {r: -1, g: -1, b: -1, hex: "none", error: 1}; 1.229 + } 1.230 + if (colour == "none") { 1.231 + return {r: -1, g: -1, b: -1, hex: "none"}; 1.232 + } 1.233 + !(({hs: 1, rg: 1})[has](colour.substring(0, 2)) || colour.charAt() == "#") && (colour = toHex(colour)); 1.234 + var res, 1.235 + red, 1.236 + green, 1.237 + blue, 1.238 + t, 1.239 + rgb = colour.match(colourRegExp); 1.240 + if (rgb) { 1.241 + if (rgb[2]) { 1.242 + blue = toInt(rgb[2].substring(5), 16); 1.243 + green = toInt(rgb[2].substring(3, 5), 16); 1.244 + red = toInt(rgb[2].substring(1, 3), 16); 1.245 + } 1.246 + if (rgb[3]) { 1.247 + blue = toInt((t = rgb[3].charAt(3)) + t, 16); 1.248 + green = toInt((t = rgb[3].charAt(2)) + t, 16); 1.249 + red = toInt((t = rgb[3].charAt(1)) + t, 16); 1.250 + } 1.251 + if (rgb[4]) { 1.252 + rgb = rgb[4][split](/\s*,\s*/); 1.253 + red = toFloat(rgb[0]); 1.254 + green = toFloat(rgb[1]); 1.255 + blue = toFloat(rgb[2]); 1.256 + } 1.257 + if (rgb[5]) { 1.258 + rgb = rgb[5][split](/\s*,\s*/); 1.259 + red = toFloat(rgb[0]) * 2.55; 1.260 + green = toFloat(rgb[1]) * 2.55; 1.261 + blue = toFloat(rgb[2]) * 2.55; 1.262 + } 1.263 + if (rgb[6]) { 1.264 + rgb = rgb[6][split](/\s*,\s*/); 1.265 + red = toFloat(rgb[0]); 1.266 + green = toFloat(rgb[1]); 1.267 + blue = toFloat(rgb[2]); 1.268 + return R.hsb2rgb(red, green, blue); 1.269 + } 1.270 + if (rgb[7]) { 1.271 + rgb = rgb[7][split](/\s*,\s*/); 1.272 + red = toFloat(rgb[0]) * 2.55; 1.273 + green = toFloat(rgb[1]) * 2.55; 1.274 + blue = toFloat(rgb[2]) * 2.55; 1.275 + return R.hsb2rgb(red, green, blue); 1.276 + } 1.277 + rgb = {r: red, g: green, b: blue}; 1.278 + var r = (~~red)[toString](16), 1.279 + g = (~~green)[toString](16), 1.280 + b = (~~blue)[toString](16); 1.281 + r = r[rp](rg, "0"); 1.282 + g = g[rp](rg, "0"); 1.283 + b = b[rp](rg, "0"); 1.284 + rgb.hex = "#" + r + g + b; 1.285 + return rgb; 1.286 + } 1.287 + return {r: -1, g: -1, b: -1, hex: "none", error: 1}; 1.288 + }, R); 1.289 + R.getColor = function (value) { 1.290 + var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75}, 1.291 + rgb = this.hsb2rgb(start.h, start.s, start.b); 1.292 + start.h += .075; 1.293 + if (start.h > 1) { 1.294 + start.h = 0; 1.295 + start.s -= .2; 1.296 + start.s <= 0 && (this.getColor.start = {h: 0, s: 1, b: start.b}); 1.297 + } 1.298 + return rgb.hex; 1.299 + }; 1.300 + R.getColor.reset = function () { 1.301 + delete this.start; 1.302 + }; 1.303 + // path utilities 1.304 + R.parsePathString = cacher(function (pathString) { 1.305 + if (!pathString) { 1.306 + return null; 1.307 + } 1.308 + var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0}, 1.309 + data = []; 1.310 + if (R.is(pathString, "array") && R.is(pathString[0], "array")) { // rough assumption 1.311 + data = pathClone(pathString); 1.312 + } 1.313 + if (!data[length]) { 1.314 + (pathString + E)[rp](/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig, function (a, b, c) { 1.315 + var params = [], 1.316 + name = lowerCase.call(b); 1.317 + c[rp](/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig, function (a, b) { 1.318 + b && params[push](+b); 1.319 + }); 1.320 + while (params[length] >= paramCounts[name]) { 1.321 + data[push]([b][concat](params.splice(0, paramCounts[name]))); 1.322 + if (!paramCounts[name]) { 1.323 + break; 1.324 + }; 1.325 + } 1.326 + }); 1.327 + } 1.328 + data[toString] = R._path2string; 1.329 + return data; 1.330 + }); 1.331 + R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { 1.332 + var t1 = 1 - t, 1.333 + x = pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x, 1.334 + y = pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y, 1.335 + mx = p1x + 2 * t * (c1x - p1x) + t * t * (c2x - 2 * c1x + p1x), 1.336 + my = p1y + 2 * t * (c1y - p1y) + t * t * (c2y - 2 * c1y + p1y), 1.337 + nx = c1x + 2 * t * (c2x - c1x) + t * t * (p2x - 2 * c2x + c1x), 1.338 + ny = c1y + 2 * t * (c2y - c1y) + t * t * (p2y - 2 * c2y + c1y), 1.339 + ax = (1 - t) * p1x + t * c1x, 1.340 + ay = (1 - t) * p1y + t * c1y, 1.341 + cx = (1 - t) * c2x + t * p2x, 1.342 + cy = (1 - t) * c2y + t * p2y, 1.343 + alpha = (90 - math.atan((mx - nx) / (my - ny)) * 180 / math.PI); 1.344 + (mx > nx || my < ny) && (alpha += 180); 1.345 + return {x: x, y: y, m: {x: mx, y: my}, n: {x: nx, y: ny}, start: {x: ax, y: ay}, end: {x: cx, y: cy}, alpha: alpha}; 1.346 + }; 1.347 + var pathDimensions = cacher(function (path) { 1.348 + if (!path) { 1.349 + return {x: 0, y: 0, width: 0, height: 0}; 1.350 + } 1.351 + path = path2curve(path); 1.352 + var x = 0, 1.353 + y = 0, 1.354 + X = [], 1.355 + Y = [], 1.356 + p; 1.357 + for (var i = 0, ii = path[length]; i < ii; i++) { 1.358 + p = path[i]; 1.359 + if (p[0] == "M") { 1.360 + x = p[1]; 1.361 + y = p[2]; 1.362 + X[push](x); 1.363 + Y[push](y); 1.364 + } else { 1.365 + var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]); 1.366 + X = X[concat](dim.min.x, dim.max.x); 1.367 + Y = Y[concat](dim.min.y, dim.max.y); 1.368 + x = p[5]; 1.369 + y = p[6]; 1.370 + } 1.371 + } 1.372 + var xmin = mmin[apply](0, X), 1.373 + ymin = mmin[apply](0, Y); 1.374 + return { 1.375 + x: xmin, 1.376 + y: ymin, 1.377 + width: mmax[apply](0, X) - xmin, 1.378 + height: mmax[apply](0, Y) - ymin 1.379 + }; 1.380 + }), 1.381 + pathClone = function (pathArray) { 1.382 + var res = []; 1.383 + if (!R.is(pathArray, "array") || !R.is(pathArray && pathArray[0], "array")) { // rough assumption 1.384 + pathArray = R.parsePathString(pathArray); 1.385 + } 1.386 + for (var i = 0, ii = pathArray[length]; i < ii; i++) { 1.387 + res[i] = []; 1.388 + for (var j = 0, jj = pathArray[i][length]; j < jj; j++) { 1.389 + res[i][j] = pathArray[i][j]; 1.390 + } 1.391 + } 1.392 + res[toString] = R._path2string; 1.393 + return res; 1.394 + }, 1.395 + pathToRelative = cacher(function (pathArray) { 1.396 + if (!R.is(pathArray, "array") || !R.is(pathArray && pathArray[0], "array")) { // rough assumption 1.397 + pathArray = R.parsePathString(pathArray); 1.398 + } 1.399 + var res = [], 1.400 + x = 0, 1.401 + y = 0, 1.402 + mx = 0, 1.403 + my = 0, 1.404 + start = 0; 1.405 + if (pathArray[0][0] == "M") { 1.406 + x = pathArray[0][1]; 1.407 + y = pathArray[0][2]; 1.408 + mx = x; 1.409 + my = y; 1.410 + start++; 1.411 + res[push](["M", x, y]); 1.412 + } 1.413 + for (var i = start, ii = pathArray[length]; i < ii; i++) { 1.414 + var r = res[i] = [], 1.415 + pa = pathArray[i]; 1.416 + if (pa[0] != lowerCase.call(pa[0])) { 1.417 + r[0] = lowerCase.call(pa[0]); 1.418 + switch (r[0]) { 1.419 + case "a": 1.420 + r[1] = pa[1]; 1.421 + r[2] = pa[2]; 1.422 + r[3] = pa[3]; 1.423 + r[4] = pa[4]; 1.424 + r[5] = pa[5]; 1.425 + r[6] = +(pa[6] - x).toFixed(3); 1.426 + r[7] = +(pa[7] - y).toFixed(3); 1.427 + break; 1.428 + case "v": 1.429 + r[1] = +(pa[1] - y).toFixed(3); 1.430 + break; 1.431 + case "m": 1.432 + mx = pa[1]; 1.433 + my = pa[2]; 1.434 + default: 1.435 + for (var j = 1, jj = pa[length]; j < jj; j++) { 1.436 + r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3); 1.437 + } 1.438 + } 1.439 + } else { 1.440 + r = res[i] = []; 1.441 + if (pa[0] == "m") { 1.442 + mx = pa[1] + x; 1.443 + my = pa[2] + y; 1.444 + } 1.445 + for (var k = 0, kk = pa[length]; k < kk; k++) { 1.446 + res[i][k] = pa[k]; 1.447 + } 1.448 + } 1.449 + var len = res[i][length]; 1.450 + switch (res[i][0]) { 1.451 + case "z": 1.452 + x = mx; 1.453 + y = my; 1.454 + break; 1.455 + case "h": 1.456 + x += +res[i][len - 1]; 1.457 + break; 1.458 + case "v": 1.459 + y += +res[i][len - 1]; 1.460 + break; 1.461 + default: 1.462 + x += +res[i][len - 2]; 1.463 + y += +res[i][len - 1]; 1.464 + } 1.465 + } 1.466 + res[toString] = R._path2string; 1.467 + return res; 1.468 + }, 0, pathClone), 1.469 + pathToAbsolute = cacher(function (pathArray) { 1.470 + if (!R.is(pathArray, "array") || !R.is(pathArray && pathArray[0], "array")) { // rough assumption 1.471 + pathArray = R.parsePathString(pathArray); 1.472 + } 1.473 + var res = [], 1.474 + x = 0, 1.475 + y = 0, 1.476 + mx = 0, 1.477 + my = 0, 1.478 + start = 0; 1.479 + if (pathArray[0][0] == "M") { 1.480 + x = +pathArray[0][1]; 1.481 + y = +pathArray[0][2]; 1.482 + mx = x; 1.483 + my = y; 1.484 + start++; 1.485 + res[0] = ["M", x, y]; 1.486 + } 1.487 + for (var i = start, ii = pathArray[length]; i < ii; i++) { 1.488 + var r = res[i] = [], 1.489 + pa = pathArray[i]; 1.490 + if (pa[0] != upperCase.call(pa[0])) { 1.491 + r[0] = upperCase.call(pa[0]); 1.492 + switch (r[0]) { 1.493 + case "A": 1.494 + r[1] = pa[1]; 1.495 + r[2] = pa[2]; 1.496 + r[3] = pa[3]; 1.497 + r[4] = pa[4]; 1.498 + r[5] = pa[5]; 1.499 + r[6] = +(pa[6] + x); 1.500 + r[7] = +(pa[7] + y); 1.501 + break; 1.502 + case "V": 1.503 + r[1] = +pa[1] + y; 1.504 + break; 1.505 + case "H": 1.506 + r[1] = +pa[1] + x; 1.507 + break; 1.508 + case "M": 1.509 + mx = +pa[1] + x; 1.510 + my = +pa[2] + y; 1.511 + default: 1.512 + for (var j = 1, jj = pa[length]; j < jj; j++) { 1.513 + r[j] = +pa[j] + ((j % 2) ? x : y); 1.514 + } 1.515 + } 1.516 + } else { 1.517 + for (var k = 0, kk = pa[length]; k < kk; k++) { 1.518 + res[i][k] = pa[k]; 1.519 + } 1.520 + } 1.521 + switch (r[0]) { 1.522 + case "Z": 1.523 + x = mx; 1.524 + y = my; 1.525 + break; 1.526 + case "H": 1.527 + x = r[1]; 1.528 + break; 1.529 + case "V": 1.530 + y = r[1]; 1.531 + break; 1.532 + default: 1.533 + x = res[i][res[i][length] - 2]; 1.534 + y = res[i][res[i][length] - 1]; 1.535 + } 1.536 + } 1.537 + res[toString] = R._path2string; 1.538 + return res; 1.539 + }, null, pathClone), 1.540 + l2c = function (x1, y1, x2, y2) { 1.541 + return [x1, y1, x2, y2, x2, y2]; 1.542 + }, 1.543 + q2c = function (x1, y1, ax, ay, x2, y2) { 1.544 + var _13 = 1 / 3, 1.545 + _23 = 2 / 3; 1.546 + return [ 1.547 + _13 * x1 + _23 * ax, 1.548 + _13 * y1 + _23 * ay, 1.549 + _13 * x2 + _23 * ax, 1.550 + _13 * y2 + _23 * ay, 1.551 + x2, 1.552 + y2 1.553 + ]; 1.554 + }, 1.555 + a2c = function (x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) { 1.556 + // for more information of where this math came from visit: 1.557 + // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes 1.558 + var PI = math.PI, 1.559 + _120 = PI * 120 / 180, 1.560 + rad = PI / 180 * (+angle || 0), 1.561 + res = [], 1.562 + xy, 1.563 + rotate = cacher(function (x, y, rad) { 1.564 + var X = x * math.cos(rad) - y * math.sin(rad), 1.565 + Y = x * math.sin(rad) + y * math.cos(rad); 1.566 + return {x: X, y: Y}; 1.567 + }); 1.568 + if (!recursive) { 1.569 + xy = rotate(x1, y1, -rad); 1.570 + x1 = xy.x; 1.571 + y1 = xy.y; 1.572 + xy = rotate(x2, y2, -rad); 1.573 + x2 = xy.x; 1.574 + y2 = xy.y; 1.575 + var cos = math.cos(PI / 180 * angle), 1.576 + sin = math.sin(PI / 180 * angle), 1.577 + x = (x1 - x2) / 2, 1.578 + y = (y1 - y2) / 2; 1.579 + rx = mmax(rx, math.abs(x)); 1.580 + ry = mmax(ry, math.abs(y)); 1.581 + var rx2 = rx * rx, 1.582 + ry2 = ry * ry, 1.583 + k = (large_arc_flag == sweep_flag ? -1 : 1) * 1.584 + math.sqrt(math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))), 1.585 + cx = k * rx * y / ry + (x1 + x2) / 2, 1.586 + cy = k * -ry * x / rx + (y1 + y2) / 2, 1.587 + f1 = math.asin(((y1 - cy) / ry).toFixed(7)), 1.588 + f2 = math.asin(((y2 - cy) / ry).toFixed(7)); 1.589 + 1.590 + f1 = x1 < cx ? PI - f1 : f1; 1.591 + f2 = x2 < cx ? PI - f2 : f2; 1.592 + f1 < 0 && (f1 = PI * 2 + f1); 1.593 + f2 < 0 && (f2 = PI * 2 + f2); 1.594 + if (sweep_flag && f1 > f2) { 1.595 + f1 = f1 - PI * 2; 1.596 + } 1.597 + if (!sweep_flag && f2 > f1) { 1.598 + f2 = f2 - PI * 2; 1.599 + } 1.600 + } else { 1.601 + f1 = recursive[0]; 1.602 + f2 = recursive[1]; 1.603 + cx = recursive[2]; 1.604 + cy = recursive[3]; 1.605 + } 1.606 + var df = f2 - f1; 1.607 + if (math.abs(df) > _120) { 1.608 + var f2old = f2, 1.609 + x2old = x2, 1.610 + y2old = y2; 1.611 + f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1); 1.612 + x2 = cx + rx * math.cos(f2); 1.613 + y2 = cy + ry * math.sin(f2); 1.614 + res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]); 1.615 + } 1.616 + df = f2 - f1; 1.617 + var c1 = math.cos(f1), 1.618 + s1 = math.sin(f1), 1.619 + c2 = math.cos(f2), 1.620 + s2 = math.sin(f2), 1.621 + t = math.tan(df / 4), 1.622 + hx = 4 / 3 * rx * t, 1.623 + hy = 4 / 3 * ry * t, 1.624 + m1 = [x1, y1], 1.625 + m2 = [x1 + hx * s1, y1 - hy * c1], 1.626 + m3 = [x2 + hx * s2, y2 - hy * c2], 1.627 + m4 = [x2, y2]; 1.628 + m2[0] = 2 * m1[0] - m2[0]; 1.629 + m2[1] = 2 * m1[1] - m2[1]; 1.630 + if (recursive) { 1.631 + return [m2, m3, m4][concat](res); 1.632 + } else { 1.633 + res = [m2, m3, m4][concat](res)[join]()[split](","); 1.634 + var newres = []; 1.635 + for (var i = 0, ii = res[length]; i < ii; i++) { 1.636 + newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x; 1.637 + } 1.638 + return newres; 1.639 + } 1.640 + }, 1.641 + findDotAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { 1.642 + var t1 = 1 - t; 1.643 + return { 1.644 + x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x, 1.645 + y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y 1.646 + }; 1.647 + }, 1.648 + curveDim = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { 1.649 + var a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x), 1.650 + b = 2 * (c1x - p1x) - 2 * (c2x - c1x), 1.651 + c = p1x - c1x, 1.652 + t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a, 1.653 + t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a, 1.654 + y = [p1y, p2y], 1.655 + x = [p1x, p2x], 1.656 + dot; 1.657 + math.abs(t1) > 1e12 && (t1 = .5); 1.658 + math.abs(t2) > 1e12 && (t2 = .5); 1.659 + if (t1 > 0 && t1 < 1) { 1.660 + dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1); 1.661 + x[push](dot.x); 1.662 + y[push](dot.y); 1.663 + } 1.664 + if (t2 > 0 && t2 < 1) { 1.665 + dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2); 1.666 + x[push](dot.x); 1.667 + y[push](dot.y); 1.668 + } 1.669 + a = (c2y - 2 * c1y + p1y) - (p2y - 2 * c2y + c1y); 1.670 + b = 2 * (c1y - p1y) - 2 * (c2y - c1y); 1.671 + c = p1y - c1y; 1.672 + t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a; 1.673 + t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a; 1.674 + math.abs(t1) > 1e12 && (t1 = .5); 1.675 + math.abs(t2) > 1e12 && (t2 = .5); 1.676 + if (t1 > 0 && t1 < 1) { 1.677 + dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1); 1.678 + x[push](dot.x); 1.679 + y[push](dot.y); 1.680 + } 1.681 + if (t2 > 0 && t2 < 1) { 1.682 + dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2); 1.683 + x[push](dot.x); 1.684 + y[push](dot.y); 1.685 + } 1.686 + return { 1.687 + min: {x: mmin[apply](0, x), y: mmin[apply](0, y)}, 1.688 + max: {x: mmax[apply](0, x), y: mmax[apply](0, y)} 1.689 + }; 1.690 + }), 1.691 + path2curve = cacher(function (path, path2) { 1.692 + var p = pathToAbsolute(path), 1.693 + p2 = path2 && pathToAbsolute(path2), 1.694 + attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null}, 1.695 + attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null}, 1.696 + processPath = function (path, d) { 1.697 + var nx, ny; 1.698 + if (!path) { 1.699 + return ["C", d.x, d.y, d.x, d.y, d.x, d.y]; 1.700 + } 1.701 + !(path[0] in {T:1, Q:1}) && (d.qx = d.qy = null); 1.702 + switch (path[0]) { 1.703 + case "M": 1.704 + d.X = path[1]; 1.705 + d.Y = path[2]; 1.706 + break; 1.707 + case "A": 1.708 + path = ["C"][concat](a2c[apply](0, [d.x, d.y][concat](path.slice(1)))); 1.709 + break; 1.710 + case "S": 1.711 + nx = d.x + (d.x - (d.bx || d.x)); 1.712 + ny = d.y + (d.y - (d.by || d.y)); 1.713 + path = ["C", nx, ny][concat](path.slice(1)); 1.714 + break; 1.715 + case "T": 1.716 + d.qx = d.x + (d.x - (d.qx || d.x)); 1.717 + d.qy = d.y + (d.y - (d.qy || d.y)); 1.718 + path = ["C"][concat](q2c(d.x, d.y, d.qx, d.qy, path[1], path[2])); 1.719 + break; 1.720 + case "Q": 1.721 + d.qx = path[1]; 1.722 + d.qy = path[2]; 1.723 + path = ["C"][concat](q2c(d.x, d.y, path[1], path[2], path[3], path[4])); 1.724 + break; 1.725 + case "L": 1.726 + path = ["C"][concat](l2c(d.x, d.y, path[1], path[2])); 1.727 + break; 1.728 + case "H": 1.729 + path = ["C"][concat](l2c(d.x, d.y, path[1], d.y)); 1.730 + break; 1.731 + case "V": 1.732 + path = ["C"][concat](l2c(d.x, d.y, d.x, path[1])); 1.733 + break; 1.734 + case "Z": 1.735 + path = ["C"][concat](l2c(d.x, d.y, d.X, d.Y)); 1.736 + break; 1.737 + } 1.738 + return path; 1.739 + }, 1.740 + fixArc = function (pp, i) { 1.741 + if (pp[i][length] > 7) { 1.742 + pp[i].shift(); 1.743 + var pi = pp[i]; 1.744 + while (pi[length]) { 1.745 + pp.splice(i++, 0, ["C"][concat](pi.splice(0, 6))); 1.746 + } 1.747 + pp.splice(i, 1); 1.748 + ii = mmax(p[length], p2 && p2[length] || 0); 1.749 + } 1.750 + }, 1.751 + fixM = function (path1, path2, a1, a2, i) { 1.752 + if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M") { 1.753 + path2.splice(i, 0, ["M", a2.x, a2.y]); 1.754 + a1.bx = 0; 1.755 + a1.by = 0; 1.756 + a1.x = path1[i][1]; 1.757 + a1.y = path1[i][2]; 1.758 + ii = mmax(p[length], p2 && p2[length] || 0); 1.759 + } 1.760 + }; 1.761 + for (var i = 0, ii = mmax(p[length], p2 && p2[length] || 0); i < ii; i++) { 1.762 + p[i] = processPath(p[i], attrs); 1.763 + fixArc(p, i); 1.764 + p2 && (p2[i] = processPath(p2[i], attrs2)); 1.765 + p2 && fixArc(p2, i); 1.766 + fixM(p, p2, attrs, attrs2, i); 1.767 + fixM(p2, p, attrs2, attrs, i); 1.768 + var seg = p[i], 1.769 + seg2 = p2 && p2[i], 1.770 + seglen = seg[length], 1.771 + seg2len = p2 && seg2[length]; 1.772 + attrs.x = seg[seglen - 2]; 1.773 + attrs.y = seg[seglen - 1]; 1.774 + attrs.bx = toFloat(seg[seglen - 4]) || attrs.x; 1.775 + attrs.by = toFloat(seg[seglen - 3]) || attrs.y; 1.776 + attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x); 1.777 + attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y); 1.778 + attrs2.x = p2 && seg2[seg2len - 2]; 1.779 + attrs2.y = p2 && seg2[seg2len - 1]; 1.780 + } 1.781 + return p2 ? [p, p2] : p; 1.782 + }, null, pathClone), 1.783 + parseDots = cacher(function (gradient) { 1.784 + var dots = []; 1.785 + for (var i = 0, ii = gradient[length]; i < ii; i++) { 1.786 + var dot = {}, 1.787 + par = gradient[i].match(/^([^:]*):?([\d\.]*)/); 1.788 + dot.color = R.getRGB(par[1]); 1.789 + if (dot.color.error) { 1.790 + return null; 1.791 + } 1.792 + dot.color = dot.color.hex; 1.793 + par[2] && (dot.offset = par[2] + "%"); 1.794 + dots[push](dot); 1.795 + } 1.796 + for (var i = 1, ii = dots[length] - 1; i < ii; i++) { 1.797 + if (!dots[i].offset) { 1.798 + var start = toFloat(dots[i - 1].offset || 0), 1.799 + end = 0; 1.800 + for (var j = i + 1; j < ii; j++) { 1.801 + if (dots[j].offset) { 1.802 + end = dots[j].offset; 1.803 + break; 1.804 + } 1.805 + } 1.806 + if (!end) { 1.807 + end = 100; 1.808 + j = ii; 1.809 + } 1.810 + end = toFloat(end); 1.811 + var d = (end - start) / (j - i + 1); 1.812 + for (; i < j; i++) { 1.813 + start += d; 1.814 + dots[i].offset = start + "%"; 1.815 + } 1.816 + } 1.817 + } 1.818 + return dots; 1.819 + }), 1.820 + getContainer = function () { 1.821 + var container, 1.822 + x, 1.823 + y, 1.824 + width, 1.825 + height; 1.826 + if (R.is(arguments[0], "string") || R.is(arguments[0], "object")) { 1.827 + if (R.is(arguments[0], "string")) { 1.828 + container = doc.getElementById(arguments[0]); 1.829 + } else { 1.830 + container = arguments[0]; 1.831 + } 1.832 + if (container.tagName) { 1.833 + if (arguments[1] == null) { 1.834 + return { 1.835 + container: container, 1.836 + width: container.style.pixelWidth || container.offsetWidth, 1.837 + height: container.style.pixelHeight || container.offsetHeight 1.838 + }; 1.839 + } else { 1.840 + return {container: container, width: arguments[1], height: arguments[2]}; 1.841 + } 1.842 + } 1.843 + } else if (R.is(arguments[0], nu) && arguments[length] > 3) { 1.844 + return {container: 1, x: arguments[0], y: arguments[1], width: arguments[2], height: arguments[3]}; 1.845 + } 1.846 + }, 1.847 + plugins = function (con, add) { 1.848 + var that = this; 1.849 + for (var prop in add) if (add[has](prop) && !(prop in con)) { 1.850 + switch (typeof add[prop]) { 1.851 + case "function": 1.852 + (function (f) { 1.853 + con[prop] = con === that ? f : function () { return f[apply](that, arguments); }; 1.854 + })(add[prop]); 1.855 + break; 1.856 + case "object": 1.857 + con[prop] = con[prop] || {}; 1.858 + plugins.call(this, con[prop], add[prop]); 1.859 + break; 1.860 + default: 1.861 + con[prop] = add[prop]; 1.862 + break; 1.863 + } 1.864 + } 1.865 + }, 1.866 + tear = function (el, paper) { 1.867 + el == paper.top && (paper.top = el.prev); 1.868 + el == paper.bottom && (paper.bottom = el.next); 1.869 + el.next && (el.next.prev = el.prev); 1.870 + el.prev && (el.prev.next = el.next); 1.871 + }, 1.872 + tofront = function (el, paper) { 1.873 + if (paper.top === el) { 1.874 + return; 1.875 + } 1.876 + tear(el, paper); 1.877 + el.next = null; 1.878 + el.prev = paper.top; 1.879 + paper.top.next = el; 1.880 + paper.top = el; 1.881 + }, 1.882 + toback = function (el, paper) { 1.883 + if (paper.bottom === el) { 1.884 + return; 1.885 + } 1.886 + tear(el, paper); 1.887 + el.next = paper.bottom; 1.888 + el.prev = null; 1.889 + paper.bottom.prev = el; 1.890 + paper.bottom = el; 1.891 + }, 1.892 + insertafter = function (el, el2, paper) { 1.893 + tear(el, paper); 1.894 + el2 == paper.top && (paper.top = el); 1.895 + el2.next && (el2.next.prev = el); 1.896 + el.next = el2.next; 1.897 + el.prev = el2; 1.898 + el2.next = el; 1.899 + }, 1.900 + insertbefore = function (el, el2, paper) { 1.901 + tear(el, paper); 1.902 + el2 == paper.bottom && (paper.bottom = el); 1.903 + el2.prev && (el2.prev.next = el); 1.904 + el.prev = el2.prev; 1.905 + el2.prev = el; 1.906 + el.next = el2; 1.907 + }, 1.908 + removed = function (methodname) { 1.909 + return function () { 1.910 + throw new Error("Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object"); 1.911 + }; 1.912 + }, 1.913 + radial_gradient = /^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/; 1.914 + 1.915 + // SVG 1.916 + if (R.svg) { 1.917 + Paper[proto].svgns = "http://www.w3.org/2000/svg"; 1.918 + Paper[proto].xlink = "http://www.w3.org/1999/xlink"; 1.919 + var round = function (num) { 1.920 + return +num + (~~num === num) * .5; 1.921 + }, 1.922 + roundPath = function (path) { 1.923 + for (var i = 0, ii = path[length]; i < ii; i++) { 1.924 + if (lowerCase.call(path[i][0]) != "a") { 1.925 + for (var j = 1, jj = path[i][length]; j < jj; j++) { 1.926 + path[i][j] = round(path[i][j]); 1.927 + } 1.928 + } else { 1.929 + path[i][6] = round(path[i][6]); 1.930 + path[i][7] = round(path[i][7]); 1.931 + } 1.932 + } 1.933 + return path; 1.934 + }, 1.935 + $ = function (el, attr) { 1.936 + if (attr) { 1.937 + for (var key in attr) if (attr[has](key)) { 1.938 + el[setAttribute](key, attr[key]); 1.939 + } 1.940 + } else { 1.941 + return doc.createElementNS(Paper[proto].svgns, el); 1.942 + } 1.943 + }; 1.944 + R[toString] = function () { 1.945 + return "Your browser supports SVG.\nYou are running Rapha\xebl " + this.version; 1.946 + }; 1.947 + var thePath = function (pathString, SVG) { 1.948 + var el = $("path"); 1.949 + SVG.canvas && SVG.canvas[appendChild](el); 1.950 + var p = new Element(el, SVG); 1.951 + p.type = "path"; 1.952 + setFillAndStroke(p, {fill: "none", stroke: "#000", path: pathString}); 1.953 + return p; 1.954 + }; 1.955 + var addGradientFill = function (o, gradient, SVG) { 1.956 + var type = "linear", 1.957 + fx = .5, fy = .5, 1.958 + s = o.style; 1.959 + gradient = (gradient + E)[rp](radial_gradient, function (all, _fx, _fy) { 1.960 + type = "radial"; 1.961 + if (_fx && _fy) { 1.962 + fx = toFloat(_fx); 1.963 + fy = toFloat(_fy); 1.964 + var dir = ((fy > .5) * 2 - 1); 1.965 + pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && 1.966 + (fy = math.sqrt(.25 - pow(fx - .5, 2)) * dir + .5) && 1.967 + fy != .5 && 1.968 + (fy = fy.toFixed(5) - 1e-5 * dir); 1.969 + } 1.970 + return E; 1.971 + }); 1.972 + gradient = gradient[split](/\s*\-\s*/); 1.973 + if (type == "linear") { 1.974 + var angle = gradient.shift(); 1.975 + angle = -toFloat(angle); 1.976 + if (isNaN(angle)) { 1.977 + return null; 1.978 + } 1.979 + var vector = [0, 0, math.cos(angle * math.PI / 180), math.sin(angle * math.PI / 180)], 1.980 + max = 1 / (mmax(math.abs(vector[2]), math.abs(vector[3])) || 1); 1.981 + vector[2] *= max; 1.982 + vector[3] *= max; 1.983 + if (vector[2] < 0) { 1.984 + vector[0] = -vector[2]; 1.985 + vector[2] = 0; 1.986 + } 1.987 + if (vector[3] < 0) { 1.988 + vector[1] = -vector[3]; 1.989 + vector[3] = 0; 1.990 + } 1.991 + } 1.992 + var dots = parseDots(gradient); 1.993 + if (!dots) { 1.994 + return null; 1.995 + } 1.996 + var el = $(type + "Gradient"); 1.997 + el.id = "r" + (R._id++)[toString](36); 1.998 + $(el, type == "radial" ? {fx: fx, fy: fy} : {x1: vector[0], y1: vector[1], x2: vector[2], y2: vector[3]}); 1.999 + SVG.defs[appendChild](el); 1.1000 + for (var i = 0, ii = dots[length]; i < ii; i++) { 1.1001 + var stop = $("stop"); 1.1002 + $(stop, { 1.1003 + offset: dots[i].offset ? dots[i].offset : !i ? "0%" : "100%", 1.1004 + "stop-color": dots[i].color || "#fff" 1.1005 + }); 1.1006 + el[appendChild](stop); 1.1007 + }; 1.1008 + $(o, { 1.1009 + fill: "url(#" + el.id + ")", 1.1010 + opacity: 1, 1.1011 + "fill-opacity": 1 1.1012 + }); 1.1013 + s.fill = E; 1.1014 + s.opacity = 1; 1.1015 + s.fillOpacity = 1; 1.1016 + return 1; 1.1017 + }; 1.1018 + var updatePosition = function (o) { 1.1019 + var bbox = o.getBBox(); 1.1020 + $(o.pattern, {patternTransform: R.format("translate({0},{1})", bbox.x, bbox.y)}); 1.1021 + }; 1.1022 + var setFillAndStroke = function (o, params) { 1.1023 + var dasharray = { 1.1024 + "": [0], 1.1025 + "none": [0], 1.1026 + "-": [3, 1], 1.1027 + ".": [1, 1], 1.1028 + "-.": [3, 1, 1, 1], 1.1029 + "-..": [3, 1, 1, 1, 1, 1], 1.1030 + ". ": [1, 3], 1.1031 + "- ": [4, 3], 1.1032 + "--": [8, 3], 1.1033 + "- .": [4, 3, 1, 3], 1.1034 + "--.": [8, 3, 1, 3], 1.1035 + "--..": [8, 3, 1, 3, 1, 3] 1.1036 + }, 1.1037 + node = o.node, 1.1038 + attrs = o.attrs, 1.1039 + rot = o.rotate(), 1.1040 + addDashes = function (o, value) { 1.1041 + value = dasharray[lowerCase.call(value)]; 1.1042 + if (value) { 1.1043 + var width = o.attrs["stroke-width"] || "1", 1.1044 + butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0, 1.1045 + dashes = []; 1.1046 + var i = value[length]; 1.1047 + while (i--) { 1.1048 + dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt; 1.1049 + } 1.1050 + $(node, {"stroke-dasharray": dashes[join](",")}); 1.1051 + } 1.1052 + }; 1.1053 + params[has]("rotation") && (rot = params.rotation); 1.1054 + var rotxy = (rot + E)[split](separator); 1.1055 + if (!(rotxy.length - 1)) { 1.1056 + rotxy = null; 1.1057 + } else { 1.1058 + rotxy[1] = +rotxy[1]; 1.1059 + rotxy[2] = +rotxy[2]; 1.1060 + } 1.1061 + toFloat(rot) && o.rotate(0, true); 1.1062 + for (var att in params) if (params[has](att)) { 1.1063 + if (!availableAttrs[has](att)) { 1.1064 + continue; 1.1065 + } 1.1066 + var value = params[att]; 1.1067 + attrs[att] = value; 1.1068 + switch (att) { 1.1069 + case "rotation": 1.1070 + o.rotate(value, true); 1.1071 + break; 1.1072 + // Hyperlink 1.1073 + case "href": 1.1074 + case "title": 1.1075 + case "target": 1.1076 + var pn = node.parentNode; 1.1077 + if (lowerCase.call(pn.tagName) != "a") { 1.1078 + var hl = $("a"); 1.1079 + pn.insertBefore(hl, node); 1.1080 + hl[appendChild](node); 1.1081 + pn = hl; 1.1082 + } 1.1083 + pn.setAttributeNS(o.Paper[proto].xlink, att, value); 1.1084 + break; 1.1085 + case "cursor": 1.1086 + node.style.cursor = value; 1.1087 + break; 1.1088 + case "clip-rect": 1.1089 + var rect = (value + E)[split](separator); 1.1090 + if (rect[length] == 4) { 1.1091 + o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode); 1.1092 + var el = $("clipPath"), 1.1093 + rc = $("rect"); 1.1094 + el.id = "r" + (R._id++)[toString](36); 1.1095 + $(rc, { 1.1096 + x: rect[0], 1.1097 + y: rect[1], 1.1098 + width: rect[2], 1.1099 + height: rect[3] 1.1100 + }); 1.1101 + el[appendChild](rc); 1.1102 + o.paper.defs[appendChild](el); 1.1103 + $(node, {"clip-path": "url(#" + el.id + ")"}); 1.1104 + o.clip = rc; 1.1105 + } 1.1106 + if (!value) { 1.1107 + var clip = doc.getElementById(node.getAttribute("clip-path")[rp](/(^url\(#|\)$)/g, E)); 1.1108 + clip && clip.parentNode.removeChild(clip); 1.1109 + $(node, {"clip-path": E}); 1.1110 + delete o.clip; 1.1111 + } 1.1112 + break; 1.1113 + case "path": 1.1114 + if (value && o.type == "path") { 1.1115 + attrs.path = roundPath(pathToAbsolute(value)); 1.1116 + $(node, {d: attrs.path}); 1.1117 + } 1.1118 + break; 1.1119 + case "width": 1.1120 + node[setAttribute](att, value); 1.1121 + if (attrs.fx) { 1.1122 + att = "x"; 1.1123 + value = attrs.x; 1.1124 + } else { 1.1125 + break; 1.1126 + } 1.1127 + case "x": 1.1128 + if (attrs.fx) { 1.1129 + value = -attrs.x - (attrs.width || 0); 1.1130 + } 1.1131 + case "rx": 1.1132 + if (att == "rx" && o.type == "rect") { 1.1133 + break; 1.1134 + } 1.1135 + case "cx": 1.1136 + rotxy && (att == "x" || att == "cx") && (rotxy[1] += value - attrs[att]); 1.1137 + node[setAttribute](att, round(value)); 1.1138 + o.pattern && updatePosition(o); 1.1139 + break; 1.1140 + case "height": 1.1141 + node[setAttribute](att, value); 1.1142 + if (attrs.fy) { 1.1143 + att = "y"; 1.1144 + value = attrs.y; 1.1145 + } else { 1.1146 + break; 1.1147 + } 1.1148 + case "y": 1.1149 + if (attrs.fy) { 1.1150 + value = -attrs.y - (attrs.height || 0); 1.1151 + } 1.1152 + case "ry": 1.1153 + if (att == "ry" && o.type == "rect") { 1.1154 + break; 1.1155 + } 1.1156 + case "cy": 1.1157 + rotxy && (att == "y" || att == "cy") && (rotxy[2] += value - attrs[att]); 1.1158 + node[setAttribute](att, round(value)); 1.1159 + o.pattern && updatePosition(o); 1.1160 + break; 1.1161 + case "r": 1.1162 + if (o.type == "rect") { 1.1163 + $(node, {rx: value, ry: value}); 1.1164 + } else { 1.1165 + node[setAttribute](att, value); 1.1166 + } 1.1167 + break; 1.1168 + case "src": 1.1169 + if (o.type == "image") { 1.1170 + node.setAttributeNS(o.paper.xlink, "href", value); 1.1171 + } 1.1172 + break; 1.1173 + case "stroke-width": 1.1174 + node.style.strokeWidth = value; 1.1175 + // Need following line for Firefox 1.1176 + node[setAttribute](att, value); 1.1177 + if (attrs["stroke-dasharray"]) { 1.1178 + addDashes(o, attrs["stroke-dasharray"]); 1.1179 + } 1.1180 + break; 1.1181 + case "stroke-dasharray": 1.1182 + addDashes(o, value); 1.1183 + break; 1.1184 + case "translation": 1.1185 + var xy = (value + E)[split](separator); 1.1186 + xy[0] = +xy[0] || 0; 1.1187 + xy[1] = +xy[1] || 0; 1.1188 + if (rotxy) { 1.1189 + rotxy[1] += xy[0]; 1.1190 + rotxy[2] += xy[1]; 1.1191 + } 1.1192 + translate.call(o, xy[0], xy[1]); 1.1193 + break; 1.1194 + case "scale": 1.1195 + var xy = (value + E)[split](separator); 1.1196 + o.scale(+xy[0] || 1, +xy[1] || +xy[0] || 1, +xy[2] || null, +xy[3] || null); 1.1197 + break; 1.1198 + case "fill": 1.1199 + var isURL = (value + E).match(ISURL); 1.1200 + if (isURL) { 1.1201 + var el = $("pattern"), 1.1202 + ig = $("image"); 1.1203 + el.id = "r" + (R._id++)[toString](36); 1.1204 + $(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse", height: 1, width: 1}); 1.1205 + $(ig, {x: 0, y: 0}); 1.1206 + ig.setAttributeNS(o.paper.xlink, "href", isURL[1]); 1.1207 + el[appendChild](ig); 1.1208 + 1.1209 + var img = doc.createElement("img"); 1.1210 + img.style.cssText = "position:absolute;left:-9999em;top-9999em"; 1.1211 + img.onload = function () { 1.1212 + $(el, {width: this.offsetWidth, height: this.offsetHeight}); 1.1213 + $(ig, {width: this.offsetWidth, height: this.offsetHeight}); 1.1214 + doc.body.removeChild(this); 1.1215 + o.paper.safari(); 1.1216 + }; 1.1217 + doc.body[appendChild](img); 1.1218 + img.src = isURL[1]; 1.1219 + o.paper.defs[appendChild](el); 1.1220 + node.style.fill = "url(#" + el.id + ")"; 1.1221 + $(node, {fill: "url(#" + el.id + ")"}); 1.1222 + o.pattern = el; 1.1223 + o.pattern && updatePosition(o); 1.1224 + break; 1.1225 + } 1.1226 + if (!R.getRGB(value).error) { 1.1227 + delete params.gradient; 1.1228 + delete attrs.gradient; 1.1229 + !R.is(attrs.opacity, "undefined") && 1.1230 + R.is(params.opacity, "undefined") && 1.1231 + $(node, {opacity: attrs.opacity}); 1.1232 + !R.is(attrs["fill-opacity"], "undefined") && 1.1233 + R.is(params["fill-opacity"], "undefined") && 1.1234 + $(node, {"fill-opacity": attrs["fill-opacity"]}); 1.1235 + } else if ((({circle: 1, ellipse: 1})[has](o.type) || (value + E).charAt() != "r") && addGradientFill(node, value, o.paper)) { 1.1236 + attrs.gradient = value; 1.1237 + attrs.fill = "none"; 1.1238 + break; 1.1239 + } 1.1240 + case "stroke": 1.1241 + node[setAttribute](att, R.getRGB(value).hex); 1.1242 + break; 1.1243 + case "gradient": 1.1244 + (({circle: 1, ellipse: 1})[has](o.type) || (value + E).charAt() != "r") && addGradientFill(node, value, o.paper); 1.1245 + break; 1.1246 + case "opacity": 1.1247 + case "fill-opacity": 1.1248 + if (attrs.gradient) { 1.1249 + var gradient = doc.getElementById(node.getAttribute("fill")[rp](/^url\(#|\)$/g, E)); 1.1250 + if (gradient) { 1.1251 + var stops = gradient.getElementsByTagName("stop"); 1.1252 + stops[stops[length] - 1][setAttribute]("stop-opacity", value); 1.1253 + } 1.1254 + break; 1.1255 + } 1.1256 + default: 1.1257 + att == "font-size" && (value = toInt(value, 10) + "px"); 1.1258 + var cssrule = att[rp](/(\-.)/g, function (w) { 1.1259 + return upperCase.call(w.substring(1)); 1.1260 + }); 1.1261 + node.style[cssrule] = value; 1.1262 + // Need following line for Firefox 1.1263 + node[setAttribute](att, value); 1.1264 + break; 1.1265 + } 1.1266 + } 1.1267 + 1.1268 + tuneText(o, params); 1.1269 + if (rotxy) { 1.1270 + o.rotate(rotxy.join(S)); 1.1271 + } else { 1.1272 + toFloat(rot) && o.rotate(rot, true); 1.1273 + } 1.1274 + }; 1.1275 + var leading = 1.2; 1.1276 + var tuneText = function (el, params) { 1.1277 + if (el.type != "text" || !(params[has]("text") || params[has]("font") || params[has]("font-size") || params[has]("x") || params[has]("y"))) { 1.1278 + return; 1.1279 + } 1.1280 + var a = el.attrs, 1.1281 + node = el.node, 1.1282 + fontSize = node.firstChild ? toInt(doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size"), 10) : 10; 1.1283 + 1.1284 + if (params[has]("text")) { 1.1285 + a.text = params.text; 1.1286 + while (node.firstChild) { 1.1287 + node.removeChild(node.firstChild); 1.1288 + } 1.1289 + var texts = (params.text + E)[split]("\n"); 1.1290 + for (var i = 0, ii = texts[length]; i < ii; i++) if (texts[i]) { 1.1291 + var tspan = $("tspan"); 1.1292 + i && $(tspan, {dy: fontSize * leading, x: a.x}); 1.1293 + tspan[appendChild](doc.createTextNode(texts[i])); 1.1294 + node[appendChild](tspan); 1.1295 + } 1.1296 + } else { 1.1297 + var texts = node.getElementsByTagName("tspan"); 1.1298 + for (var i = 0, ii = texts[length]; i < ii; i++) { 1.1299 + i && $(texts[i], {dy: fontSize * leading, x: a.x}); 1.1300 + } 1.1301 + } 1.1302 + $(node, {y: a.y}); 1.1303 + var bb = el.getBBox(), 1.1304 + dif = a.y - (bb.y + bb.height / 2); 1.1305 + dif && isFinite(dif) && $(node, {y: a.y + dif}); 1.1306 + }; 1.1307 + var Element = function (node, svg) { 1.1308 + var X = 0, 1.1309 + Y = 0; 1.1310 + this[0] = node; 1.1311 + this.id = R._oid++; 1.1312 + this.node = node; 1.1313 + node.raphael = this; 1.1314 + this.paper = svg; 1.1315 + this.attrs = this.attrs || {}; 1.1316 + this.transformations = []; // rotate, translate, scale 1.1317 + this._ = { 1.1318 + tx: 0, 1.1319 + ty: 0, 1.1320 + rt: {deg: 0, cx: 0, cy: 0}, 1.1321 + sx: 1, 1.1322 + sy: 1 1.1323 + }; 1.1324 + !svg.bottom && (svg.bottom = this); 1.1325 + this.prev = svg.top; 1.1326 + svg.top && (svg.top.next = this); 1.1327 + svg.top = this; 1.1328 + this.next = null; 1.1329 + }; 1.1330 + Element[proto].rotate = function (deg, cx, cy) { 1.1331 + if (this.removed) { 1.1332 + return this; 1.1333 + } 1.1334 + if (deg == null) { 1.1335 + if (this._.rt.cx) { 1.1336 + return [this._.rt.deg, this._.rt.cx, this._.rt.cy][join](S); 1.1337 + } 1.1338 + return this._.rt.deg; 1.1339 + } 1.1340 + var bbox = this.getBBox(); 1.1341 + deg = (deg + E)[split](separator); 1.1342 + if (deg[length] - 1) { 1.1343 + cx = toFloat(deg[1]); 1.1344 + cy = toFloat(deg[2]); 1.1345 + } 1.1346 + deg = toFloat(deg[0]); 1.1347 + if (cx != null) { 1.1348 + this._.rt.deg = deg; 1.1349 + } else { 1.1350 + this._.rt.deg += deg; 1.1351 + } 1.1352 + (cy == null) && (cx = null); 1.1353 + this._.rt.cx = cx; 1.1354 + this._.rt.cy = cy; 1.1355 + cx = cx == null ? bbox.x + bbox.width / 2 : cx; 1.1356 + cy = cy == null ? bbox.y + bbox.height / 2 : cy; 1.1357 + if (this._.rt.deg) { 1.1358 + this.transformations[0] = R.format("rotate({0} {1} {2})", this._.rt.deg, cx, cy); 1.1359 + this.clip && $(this.clip, {transform: R.format("rotate({0} {1} {2})", -this._.rt.deg, cx, cy)}); 1.1360 + } else { 1.1361 + this.transformations[0] = E; 1.1362 + this.clip && $(this.clip, {transform: E}); 1.1363 + } 1.1364 + $(this.node, {transform: this.transformations[join](S)}); 1.1365 + return this; 1.1366 + }; 1.1367 + Element[proto].hide = function () { 1.1368 + !this.removed && (this.node.style.display = "none"); 1.1369 + return this; 1.1370 + }; 1.1371 + Element[proto].show = function () { 1.1372 + !this.removed && (this.node.style.display = ""); 1.1373 + return this; 1.1374 + }; 1.1375 + Element[proto].remove = function () { 1.1376 + if (this.removed) { 1.1377 + return; 1.1378 + } 1.1379 + tear(this, this.paper); 1.1380 + this.node.parentNode.removeChild(this.node); 1.1381 + for (var i in this) { 1.1382 + delete this[i]; 1.1383 + } 1.1384 + this.removed = true; 1.1385 + }; 1.1386 + Element[proto].getBBox = function () { 1.1387 + if (this.removed) { 1.1388 + return this; 1.1389 + } 1.1390 + if (this.type == "path") { 1.1391 + return pathDimensions(this.attrs.path); 1.1392 + } 1.1393 + if (this.node.style.display == "none") { 1.1394 + this.show(); 1.1395 + var hide = true; 1.1396 + } 1.1397 + var bbox = {}; 1.1398 + try { 1.1399 + bbox = this.node.getBBox(); 1.1400 + } catch(e) { 1.1401 + // Firefox 3.0.x plays badly here 1.1402 + } finally { 1.1403 + bbox = bbox || {}; 1.1404 + } 1.1405 + if (this.type == "text") { 1.1406 + bbox = {x: bbox.x, y: Infinity, width: 0, height: 0}; 1.1407 + for (var i = 0, ii = this.node.getNumberOfChars(); i < ii; i++) { 1.1408 + var bb = this.node.getExtentOfChar(i); 1.1409 + (bb.y < bbox.y) && (bbox.y = bb.y); 1.1410 + (bb.y + bb.height - bbox.y > bbox.height) && (bbox.height = bb.y + bb.height - bbox.y); 1.1411 + (bb.x + bb.width - bbox.x > bbox.width) && (bbox.width = bb.x + bb.width - bbox.x); 1.1412 + } 1.1413 + } 1.1414 + hide && this.hide(); 1.1415 + return bbox; 1.1416 + }; 1.1417 + Element[proto].attr = function () { 1.1418 + if (this.removed) { 1.1419 + return this; 1.1420 + } 1.1421 + if (arguments[length] == 0) { 1.1422 + var res = {}; 1.1423 + for (var i in this.attrs) if (this.attrs[has](i)) { 1.1424 + res[i] = this.attrs[i]; 1.1425 + } 1.1426 + this._.rt.deg && (res.rotation = this.rotate()); 1.1427 + (this._.sx != 1 || this._.sy != 1) && (res.scale = this.scale()); 1.1428 + res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient; 1.1429 + return res; 1.1430 + } 1.1431 + if (arguments[length] == 1 && R.is(arguments[0], "string")) { 1.1432 + if (arguments[0] == "translation") { 1.1433 + return translate.call(this); 1.1434 + } 1.1435 + if (arguments[0] == "rotation") { 1.1436 + return this.rotate(); 1.1437 + } 1.1438 + if (arguments[0] == "scale") { 1.1439 + return this.scale(); 1.1440 + } 1.1441 + if (arguments[0] == "fill" && this.attrs.fill == "none" && this.attrs.gradient) { 1.1442 + return this.attrs.gradient; 1.1443 + } 1.1444 + return this.attrs[arguments[0]]; 1.1445 + } 1.1446 + if (arguments[length] == 1 && R.is(arguments[0], "array")) { 1.1447 + var values = {}; 1.1448 + for (var j in arguments[0]) if (arguments[0][has](j)) { 1.1449 + values[arguments[0][j]] = this.attrs[arguments[0][j]]; 1.1450 + } 1.1451 + return values; 1.1452 + } 1.1453 + if (arguments[length] == 2) { 1.1454 + var params = {}; 1.1455 + params[arguments[0]] = arguments[1]; 1.1456 + setFillAndStroke(this, params); 1.1457 + } else if (arguments[length] == 1 && R.is(arguments[0], "object")) { 1.1458 + setFillAndStroke(this, arguments[0]); 1.1459 + } 1.1460 + return this; 1.1461 + }; 1.1462 + Element[proto].toFront = function () { 1.1463 + if (this.removed) { 1.1464 + return this; 1.1465 + } 1.1466 + this.node.parentNode[appendChild](this.node); 1.1467 + var svg = this.paper; 1.1468 + svg.top != this && tofront(this, svg); 1.1469 + return this; 1.1470 + }; 1.1471 + Element[proto].toBack = function () { 1.1472 + if (this.removed) { 1.1473 + return this; 1.1474 + } 1.1475 + if (this.node.parentNode.firstChild != this.node) { 1.1476 + this.node.parentNode.insertBefore(this.node, this.node.parentNode.firstChild); 1.1477 + toback(this, this.paper); 1.1478 + var svg = this.paper; 1.1479 + } 1.1480 + return this; 1.1481 + }; 1.1482 + Element[proto].insertAfter = function (element) { 1.1483 + if (this.removed) { 1.1484 + return this; 1.1485 + } 1.1486 + var node = element.node; 1.1487 + if (node.nextSibling) { 1.1488 + node.parentNode.insertBefore(this.node, node.nextSibling); 1.1489 + } else { 1.1490 + node.parentNode[appendChild](this.node); 1.1491 + } 1.1492 + insertafter(this, element, this.paper); 1.1493 + return this; 1.1494 + }; 1.1495 + Element[proto].insertBefore = function (element) { 1.1496 + if (this.removed) { 1.1497 + return this; 1.1498 + } 1.1499 + var node = element.node; 1.1500 + node.parentNode.insertBefore(this.node, node); 1.1501 + insertbefore(this, element, this.paper); 1.1502 + return this; 1.1503 + }; 1.1504 + var theCircle = function (svg, x, y, r) { 1.1505 + x = round(x); 1.1506 + y = round(y); 1.1507 + var el = $("circle"); 1.1508 + svg.canvas && svg.canvas[appendChild](el); 1.1509 + var res = new Element(el, svg); 1.1510 + res.attrs = {cx: x, cy: y, r: r, fill: "none", stroke: "#000"}; 1.1511 + res.type = "circle"; 1.1512 + $(el, res.attrs); 1.1513 + return res; 1.1514 + }; 1.1515 + var theRect = function (svg, x, y, w, h, r) { 1.1516 + x = round(x); 1.1517 + y = round(y); 1.1518 + var el = $("rect"); 1.1519 + svg.canvas && svg.canvas[appendChild](el); 1.1520 + var res = new Element(el, svg); 1.1521 + res.attrs = {x: x, y: y, width: w, height: h, r: r || 0, rx: r || 0, ry: r || 0, fill: "none", stroke: "#000"}; 1.1522 + res.type = "rect"; 1.1523 + $(el, res.attrs); 1.1524 + return res; 1.1525 + }; 1.1526 + var theEllipse = function (svg, x, y, rx, ry) { 1.1527 + x = round(x); 1.1528 + y = round(y); 1.1529 + var el = $("ellipse"); 1.1530 + svg.canvas && svg.canvas[appendChild](el); 1.1531 + var res = new Element(el, svg); 1.1532 + res.attrs = {cx: x, cy: y, rx: rx, ry: ry, fill: "none", stroke: "#000"}; 1.1533 + res.type = "ellipse"; 1.1534 + $(el, res.attrs); 1.1535 + return res; 1.1536 + }; 1.1537 + var theImage = function (svg, src, x, y, w, h) { 1.1538 + var el = $("image"); 1.1539 + $(el, {x: x, y: y, width: w, height: h, preserveAspectRatio: "none"}); 1.1540 + el.setAttributeNS(svg.xlink, "href", src); 1.1541 + svg.canvas && svg.canvas[appendChild](el); 1.1542 + var res = new Element(el, svg); 1.1543 + res.attrs = {x: x, y: y, width: w, height: h, src: src}; 1.1544 + res.type = "image"; 1.1545 + return res; 1.1546 + }; 1.1547 + var theText = function (svg, x, y, text) { 1.1548 + var el = $("text"); 1.1549 + $(el, {x: x, y: y, "text-anchor": "middle"}); 1.1550 + svg.canvas && svg.canvas[appendChild](el); 1.1551 + var res = new Element(el, svg); 1.1552 + res.attrs = {x: x, y: y, "text-anchor": "middle", text: text, font: availableAttrs.font, stroke: "none", fill: "#000"}; 1.1553 + res.type = "text"; 1.1554 + setFillAndStroke(res, res.attrs); 1.1555 + return res; 1.1556 + }; 1.1557 + var setSize = function (width, height) { 1.1558 + this.width = width || this.width; 1.1559 + this.height = height || this.height; 1.1560 + this.canvas[setAttribute]("width", this.width); 1.1561 + this.canvas[setAttribute]("height", this.height); 1.1562 + return this; 1.1563 + }; 1.1564 + var create = function () { 1.1565 + var con = getContainer[apply](null, arguments), 1.1566 + container = con && con.container, 1.1567 + x = con.x, 1.1568 + y = con.y, 1.1569 + width = con.width, 1.1570 + height = con.height; 1.1571 + if (!container) { 1.1572 + throw new Error("SVG container not found."); 1.1573 + } 1.1574 + var cnvs = $("svg"); 1.1575 + width = width || 512; 1.1576 + height = height || 342; 1.1577 + $(cnvs, { 1.1578 + xmlns: "http://www.w3.org/2000/svg", 1.1579 + version: 1.1, 1.1580 + width: width, 1.1581 + height: height 1.1582 + }); 1.1583 + if (container == 1) { 1.1584 + cnvs.style.cssText = "position:absolute;left:" + x + "px;top:" + y + "px"; 1.1585 + doc.body[appendChild](cnvs); 1.1586 + } else { 1.1587 + if (container.firstChild) { 1.1588 + container.insertBefore(cnvs, container.firstChild); 1.1589 + } else { 1.1590 + container[appendChild](cnvs); 1.1591 + } 1.1592 + } 1.1593 + container = new Paper; 1.1594 + container.width = width; 1.1595 + container.height = height; 1.1596 + container.canvas = cnvs; 1.1597 + plugins.call(container, container, R.fn); 1.1598 + container.clear(); 1.1599 + return container; 1.1600 + }; 1.1601 + Paper[proto].clear = function () { 1.1602 + var c = this.canvas; 1.1603 + while (c.firstChild) { 1.1604 + c.removeChild(c.firstChild); 1.1605 + } 1.1606 + this.bottom = this.top = null; 1.1607 + (this.desc = $("desc"))[appendChild](doc.createTextNode("Created with Rapha\xebl")); 1.1608 + c[appendChild](this.desc); 1.1609 + c[appendChild](this.defs = $("defs")); 1.1610 + }; 1.1611 + Paper[proto].remove = function () { 1.1612 + this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas); 1.1613 + for (var i in this) { 1.1614 + this[i] = removed(i); 1.1615 + } 1.1616 + }; 1.1617 + } 1.1618 + 1.1619 + // VML 1.1620 + if (R.vml) { 1.1621 + var path2vml = function (path) { 1.1622 + var total = /[ahqstv]/ig, 1.1623 + command = pathToAbsolute; 1.1624 + (path + E).match(total) && (command = path2curve); 1.1625 + total = /[clmz]/g; 1.1626 + if (command == pathToAbsolute && !(path + E).match(total)) { 1.1627 + var map = {M: "m", L: "l", C: "c", Z: "x", m: "t", l: "r", c: "v", z: "x"}, 1.1628 + bites = /([clmz]),?([^clmz]*)/gi, 1.1629 + val = /-?[^,\s-]+/g; 1.1630 + var res = (path + E)[rp](bites, function (all, command, args) { 1.1631 + var vals = []; 1.1632 + args[rp](val, function (value) { 1.1633 + vals[push](round(value)); 1.1634 + }); 1.1635 + return map[command] + vals; 1.1636 + }); 1.1637 + return res; 1.1638 + } 1.1639 + var pa = command(path), p, res = [], r; 1.1640 + for (var i = 0, ii = pa[length]; i < ii; i++) { 1.1641 + p = pa[i]; 1.1642 + r = lowerCase.call(pa[i][0]); 1.1643 + r == "z" && (r = "x"); 1.1644 + for (var j = 1, jj = p[length]; j < jj; j++) { 1.1645 + r += round(p[j]) + (j != jj - 1 ? "," : E); 1.1646 + } 1.1647 + res[push](r); 1.1648 + } 1.1649 + return res[join](S); 1.1650 + }; 1.1651 + 1.1652 + R[toString] = function () { 1.1653 + return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version; 1.1654 + }; 1.1655 + var thePath = function (pathString, VML) { 1.1656 + var g = createNode("group"); 1.1657 + g.style.cssText = "position:absolute;left:0;top:0;width:" + VML.width + "px;height:" + VML.height + "px"; 1.1658 + g.coordsize = VML.coordsize; 1.1659 + g.coordorigin = VML.coordorigin; 1.1660 + var el = createNode("shape"), ol = el.style; 1.1661 + ol.width = VML.width + "px"; 1.1662 + ol.height = VML.height + "px"; 1.1663 + el.coordsize = this.coordsize; 1.1664 + el.coordorigin = this.coordorigin; 1.1665 + g[appendChild](el); 1.1666 + var p = new Element(el, g, VML); 1.1667 + p.isAbsolute = true; 1.1668 + p.type = "path"; 1.1669 + p.path = []; 1.1670 + p.Path = E; 1.1671 + pathString && setFillAndStroke(p, {fill: "none", stroke: "#000", path: pathString}); 1.1672 + VML.canvas[appendChild](g); 1.1673 + return p; 1.1674 + }; 1.1675 + var setFillAndStroke = function (o, params) { 1.1676 + o.attrs = o.attrs || {}; 1.1677 + var node = o.node, 1.1678 + a = o.attrs, 1.1679 + s = node.style, 1.1680 + xy, 1.1681 + res = o; 1.1682 + for (var par in params) if (params[has](par)) { 1.1683 + a[par] = params[par]; 1.1684 + } 1.1685 + params.href && (node.href = params.href); 1.1686 + params.title && (node.title = params.title); 1.1687 + params.target && (node.target = params.target); 1.1688 + params.cursor && (s.cursor = params.cursor); 1.1689 + if (params.path && o.type == "path") { 1.1690 + a.path = params.path; 1.1691 + node.path = path2vml(a.path); 1.1692 + } 1.1693 + if (params.rotation != null) { 1.1694 + o.rotate(params.rotation, true); 1.1695 + } 1.1696 + if (params.translation) { 1.1697 + xy = (params.translation + E)[split](separator); 1.1698 + translate.call(o, xy[0], xy[1]); 1.1699 + if (o._.rt.cx != null) { 1.1700 + o._.rt.cx +=+ xy[0]; 1.1701 + o._.rt.cy +=+ xy[1]; 1.1702 + o.setBox(o.attrs, xy[0], xy[1]); 1.1703 + } 1.1704 + } 1.1705 + if (params.scale) { 1.1706 + xy = (params.scale + E)[split](separator); 1.1707 + o.scale(+xy[0] || 1, +xy[1] || +xy[0] || 1, +xy[2] || null, +xy[3] || null); 1.1708 + } 1.1709 + if ("clip-rect" in params) { 1.1710 + var rect = (params["clip-rect"] + E)[split](separator); 1.1711 + if (rect[length] == 4) { 1.1712 + rect[2] = +rect[2] + (+rect[0]); 1.1713 + rect[3] = +rect[3] + (+rect[1]); 1.1714 + var div = node.clipRect || doc.createElement("div"), 1.1715 + dstyle = div.style, 1.1716 + group = node.parentNode; 1.1717 + dstyle.clip = R.format("rect({1}px {2}px {3}px {0}px)", rect); 1.1718 + if (!node.clipRect) { 1.1719 + dstyle.position = "absolute"; 1.1720 + dstyle.top = 0; 1.1721 + dstyle.left = 0; 1.1722 + dstyle.width = o.paper.width + "px"; 1.1723 + dstyle.height = o.paper.height + "px"; 1.1724 + group.parentNode.insertBefore(div, group); 1.1725 + div[appendChild](group); 1.1726 + node.clipRect = div; 1.1727 + } 1.1728 + } 1.1729 + if (!params["clip-rect"]) { 1.1730 + node.clipRect && (node.clipRect.style.clip = E); 1.1731 + } 1.1732 + } 1.1733 + if (o.type == "image" && params.src) { 1.1734 + node.src = params.src; 1.1735 + } 1.1736 + if (o.type == "image" && params.opacity) { 1.1737 + node.filterOpacity = " progid:DXImageTransform.Microsoft.Alpha(opacity=" + (params.opacity * 100) + ")"; 1.1738 + s.filter = (node.filterMatrix || E) + (node.filterOpacity || E); 1.1739 + } 1.1740 + params.font && (s.font = params.font); 1.1741 + params["font-family"] && (s.fontFamily = '"' + params["font-family"][split](",")[0][rp](/^['"]+|['"]+$/g, E) + '"'); 1.1742 + params["font-size"] && (s.fontSize = params["font-size"]); 1.1743 + params["font-weight"] && (s.fontWeight = params["font-weight"]); 1.1744 + params["font-style"] && (s.fontStyle = params["font-style"]); 1.1745 + if (params.opacity != null || 1.1746 + params["stroke-width"] != null || 1.1747 + params.fill != null || 1.1748 + params.stroke != null || 1.1749 + params["stroke-width"] != null || 1.1750 + params["stroke-opacity"] != null || 1.1751 + params["fill-opacity"] != null || 1.1752 + params["stroke-dasharray"] != null || 1.1753 + params["stroke-miterlimit"] != null || 1.1754 + params["stroke-linejoin"] != null || 1.1755 + params["stroke-linecap"] != null) { 1.1756 + node = o.shape || node; 1.1757 + var fill = (node.getElementsByTagName("fill") && node.getElementsByTagName("fill")[0]), 1.1758 + newfill = false; 1.1759 + !fill && (newfill = fill = createNode("fill")); 1.1760 + if ("fill-opacity" in params || "opacity" in params) { 1.1761 + var opacity = ((+a["fill-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1); 1.1762 + opacity < 0 && (opacity = 0); 1.1763 + opacity > 1 && (opacity = 1); 1.1764 + fill.opacity = opacity; 1.1765 + } 1.1766 + params.fill && (fill.on = true); 1.1767 + if (fill.on == null || params.fill == "none") { 1.1768 + fill.on = false; 1.1769 + } 1.1770 + if (fill.on && params.fill) { 1.1771 + var isURL = params.fill.match(ISURL); 1.1772 + if (isURL) { 1.1773 + fill.src = isURL[1]; 1.1774 + fill.type = "tile"; 1.1775 + } else { 1.1776 + fill.color = R.getRGB(params.fill).hex; 1.1777 + fill.src = E; 1.1778 + fill.type = "solid"; 1.1779 + if (R.getRGB(params.fill).error && (res.type in {circle: 1, ellipse: 1} || (params.fill + E).charAt() != "r") && addGradientFill(res, params.fill)) { 1.1780 + a.fill = "none"; 1.1781 + a.gradient = params.fill; 1.1782 + } 1.1783 + } 1.1784 + } 1.1785 + newfill && node[appendChild](fill); 1.1786 + var stroke = (node.getElementsByTagName("stroke") && node.getElementsByTagName("stroke")[0]), 1.1787 + newstroke = false; 1.1788 + !stroke && (newstroke = stroke = createNode("stroke")); 1.1789 + if ((params.stroke && params.stroke != "none") || 1.1790 + params["stroke-width"] || 1.1791 + params["stroke-opacity"] != null || 1.1792 + params["stroke-dasharray"] || 1.1793 + params["stroke-miterlimit"] || 1.1794 + params["stroke-linejoin"] || 1.1795 + params["stroke-linecap"]) { 1.1796 + stroke.on = true; 1.1797 + } 1.1798 + (params.stroke == "none" || stroke.on == null || params.stroke == 0 || params["stroke-width"] == 0) && (stroke.on = false); 1.1799 + stroke.on && params.stroke && (stroke.color = R.getRGB(params.stroke).hex); 1.1800 + var opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1), 1.1801 + width = (toFloat(params["stroke-width"]) || 1) * .75; 1.1802 + opacity < 0 && (opacity = 0); 1.1803 + opacity > 1 && (opacity = 1); 1.1804 + params["stroke-width"] == null && (width = a["stroke-width"]); 1.1805 + params["stroke-width"] && (stroke.weight = width); 1.1806 + width && width < 1 && (opacity *= width) && (stroke.weight = 1); 1.1807 + stroke.opacity = opacity; 1.1808 + 1.1809 + params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter"); 1.1810 + stroke.miterlimit = params["stroke-miterlimit"] || 8; 1.1811 + params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round"); 1.1812 + if (params["stroke-dasharray"]) { 1.1813 + var dasharray = { 1.1814 + "-": "shortdash", 1.1815 + ".": "shortdot", 1.1816 + "-.": "shortdashdot", 1.1817 + "-..": "shortdashdotdot", 1.1818 + ". ": "dot", 1.1819 + "- ": "dash", 1.1820 + "--": "longdash", 1.1821 + "- .": "dashdot", 1.1822 + "--.": "longdashdot", 1.1823 + "--..": "longdashdotdot" 1.1824 + }; 1.1825 + stroke.dashstyle = dasharray[has](params["stroke-dasharray"]) ? dasharray[params["stroke-dasharray"]] : E; 1.1826 + } 1.1827 + newstroke && node[appendChild](stroke); 1.1828 + } 1.1829 + if (res.type == "text") { 1.1830 + var s = res.paper.span.style; 1.1831 + a.font && (s.font = a.font); 1.1832 + a["font-family"] && (s.fontFamily = a["font-family"]); 1.1833 + a["font-size"] && (s.fontSize = a["font-size"]); 1.1834 + a["font-weight"] && (s.fontWeight = a["font-weight"]); 1.1835 + a["font-style"] && (s.fontStyle = a["font-style"]); 1.1836 + res.node.string && (res.paper.span.innerHTML = (res.node.string + E)[rp](/</g, "<")[rp](/&/g, "&")[rp](/\n/g, "<br>")); 1.1837 + res.W = a.w = res.paper.span.offsetWidth; 1.1838 + res.H = a.h = res.paper.span.offsetHeight; 1.1839 + res.X = a.x; 1.1840 + res.Y = a.y + round(res.H / 2); 1.1841 + 1.1842 + // text-anchor emulationm 1.1843 + switch (a["text-anchor"]) { 1.1844 + case "start": 1.1845 + res.node.style["v-text-align"] = "left"; 1.1846 + res.bbx = round(res.W / 2); 1.1847 + break; 1.1848 + case "end": 1.1849 + res.node.style["v-text-align"] = "right"; 1.1850 + res.bbx = -round(res.W / 2); 1.1851 + break; 1.1852 + default: 1.1853 + res.node.style["v-text-align"] = "center"; 1.1854 + break; 1.1855 + } 1.1856 + } 1.1857 + }; 1.1858 + var addGradientFill = function (o, gradient) { 1.1859 + o.attrs = o.attrs || {}; 1.1860 + var attrs = o.attrs, 1.1861 + fill = o.node.getElementsByTagName("fill"), 1.1862 + type = "linear", 1.1863 + fxfy = ".5 .5"; 1.1864 + o.attrs.gradient = gradient; 1.1865 + gradient = (gradient + E)[rp](radial_gradient, function (all, fx, fy) { 1.1866 + type = "radial"; 1.1867 + if (fx && fy) { 1.1868 + fx = toFloat(fx); 1.1869 + fy = toFloat(fy); 1.1870 + pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && (fy = math.sqrt(.25 - pow(fx - .5, 2)) * ((fy > .5) * 2 - 1) + .5); 1.1871 + fxfy = fx + S + fy; 1.1872 + } 1.1873 + return E; 1.1874 + }); 1.1875 + gradient = gradient[split](/\s*\-\s*/); 1.1876 + if (type == "linear") { 1.1877 + var angle = gradient.shift(); 1.1878 + angle = -toFloat(angle); 1.1879 + if (isNaN(angle)) { 1.1880 + return null; 1.1881 + } 1.1882 + } 1.1883 + var dots = parseDots(gradient); 1.1884 + if (!dots) { 1.1885 + return null; 1.1886 + } 1.1887 + o = o.shape || o.node; 1.1888 + fill = fill[0] || createNode("fill"); 1.1889 + if (dots[length]) { 1.1890 + fill.on = true; 1.1891 + fill.method = "none"; 1.1892 + fill.type = (type == "radial") ? "gradientradial" : "gradient"; 1.1893 + fill.color = dots[0].color; 1.1894 + fill.color2 = dots[dots[length] - 1].color; 1.1895 + var clrs = []; 1.1896 + for (var i = 0, ii = dots[length]; i < ii; i++) { 1.1897 + dots[i].offset && clrs[push](dots[i].offset + S + dots[i].color); 1.1898 + } 1.1899 + fill.colors && (fill.colors.value = clrs[length] ? clrs[join](",") : "0% " + fill.color); 1.1900 + if (type == "radial") { 1.1901 + fill.focus = "100%"; 1.1902 + fill.focussize = fxfy; 1.1903 + fill.focusposition = fxfy; 1.1904 + } else { 1.1905 + fill.angle = (270 - angle) % 360; 1.1906 + } 1.1907 + } 1.1908 + return 1; 1.1909 + }; 1.1910 + var Element = function (node, group, vml) { 1.1911 + var Rotation = 0, 1.1912 + RotX = 0, 1.1913 + RotY = 0, 1.1914 + Scale = 1; 1.1915 + this[0] = node; 1.1916 + this.id = R._oid++; 1.1917 + this.node = node; 1.1918 + node.raphael = this; 1.1919 + this.X = 0; 1.1920 + this.Y = 0; 1.1921 + this.attrs = {}; 1.1922 + this.Group = group; 1.1923 + this.paper = vml; 1.1924 + this._ = { 1.1925 + tx: 0, 1.1926 + ty: 0, 1.1927 + rt: {deg:0}, 1.1928 + sx: 1, 1.1929 + sy: 1 1.1930 + }; 1.1931 + !vml.bottom && (vml.bottom = this); 1.1932 + this.prev = vml.top; 1.1933 + vml.top && (vml.top.next = this); 1.1934 + vml.top = this; 1.1935 + this.next = null; 1.1936 + }; 1.1937 + Element[proto].rotate = function (deg, cx, cy) { 1.1938 + if (this.removed) { 1.1939 + return this; 1.1940 + } 1.1941 + if (deg == null) { 1.1942 + if (this._.rt.cx) { 1.1943 + return [this._.rt.deg, this._.rt.cx, this._.rt.cy][join](S); 1.1944 + } 1.1945 + return this._.rt.deg; 1.1946 + } 1.1947 + deg = (deg + E)[split](separator); 1.1948 + if (deg[length] - 1) { 1.1949 + cx = toFloat(deg[1]); 1.1950 + cy = toFloat(deg[2]); 1.1951 + } 1.1952 + deg = toFloat(deg[0]); 1.1953 + if (cx != null) { 1.1954 + this._.rt.deg = deg; 1.1955 + } else { 1.1956 + this._.rt.deg += deg; 1.1957 + } 1.1958 + cy == null && (cx = null); 1.1959 + this._.rt.cx = cx; 1.1960 + this._.rt.cy = cy; 1.1961 + this.setBox(this.attrs, cx, cy); 1.1962 + this.Group.style.rotation = this._.rt.deg; 1.1963 + // gradient fix for rotation. TODO 1.1964 + // var fill = (this.shape || this.node).getElementsByTagName("fill"); 1.1965 + // fill = fill[0] || {}; 1.1966 + // var b = ((360 - this._.rt.deg) - 270) % 360; 1.1967 + // !R.is(fill.angle, "undefined") && (fill.angle = b); 1.1968 + return this; 1.1969 + }; 1.1970 + Element[proto].setBox = function (params, cx, cy) { 1.1971 + if (this.removed) { 1.1972 + return this; 1.1973 + } 1.1974 + var gs = this.Group.style, 1.1975 + os = (this.shape && this.shape.style) || this.node.style; 1.1976 + params = params || {}; 1.1977 + for (var i in params) if (params[has](i)) { 1.1978 + this.attrs[i] = params[i]; 1.1979 + } 1.1980 + cx = cx || this._.rt.cx; 1.1981 + cy = cy || this._.rt.cy; 1.1982 + var attr = this.attrs, 1.1983 + x, 1.1984 + y, 1.1985 + w, 1.1986 + h; 1.1987 + switch (this.type) { 1.1988 + case "circle": 1.1989 + x = attr.cx - attr.r; 1.1990 + y = attr.cy - attr.r; 1.1991 + w = h = attr.r * 2; 1.1992 + break; 1.1993 + case "ellipse": 1.1994 + x = attr.cx - attr.rx; 1.1995 + y = attr.cy - attr.ry; 1.1996 + w = attr.rx * 2; 1.1997 + h = attr.ry * 2; 1.1998 + break; 1.1999 + case "rect": 1.2000 + case "image": 1.2001 + x = +attr.x; 1.2002 + y = +attr.y; 1.2003 + w = attr.width || 0; 1.2004 + h = attr.height || 0; 1.2005 + break; 1.2006 + case "text": 1.2007 + this.textpath.v = ["m", round(attr.x), ", ", round(attr.y - 2), "l", round(attr.x) + 1, ", ", round(attr.y - 2)][join](E); 1.2008 + x = attr.x - round(this.W / 2); 1.2009 + y = attr.y - this.H / 2; 1.2010 + w = this.W; 1.2011 + h = this.H; 1.2012 + break; 1.2013 + case "path": 1.2014 + if (!this.attrs.path) { 1.2015 + x = 0; 1.2016 + y = 0; 1.2017 + w = this.paper.width; 1.2018 + h = this.paper.height; 1.2019 + } else { 1.2020 + var dim = pathDimensions(this.attrs.path); 1.2021 + x = dim.x; 1.2022 + y = dim.y; 1.2023 + w = dim.width; 1.2024 + h = dim.height; 1.2025 + } 1.2026 + break; 1.2027 + default: 1.2028 + x = 0; 1.2029 + y = 0; 1.2030 + w = this.paper.width; 1.2031 + h = this.paper.height; 1.2032 + break; 1.2033 + } 1.2034 + cx = (cx == null) ? x + w / 2 : cx; 1.2035 + cy = (cy == null) ? y + h / 2 : cy; 1.2036 + var left = cx - this.paper.width / 2, 1.2037 + top = cy - this.paper.height / 2; 1.2038 + if (this.type == "path" || this.type == "text") { 1.2039 + (gs.left != left + "px") && (gs.left = left + "px"); 1.2040 + (gs.top != top + "px") && (gs.top = top + "px"); 1.2041 + this.X = this.type == "text" ? x : -left; 1.2042 + this.Y = this.type == "text" ? y : -top; 1.2043 + this.W = w; 1.2044 + this.H = h; 1.2045 + (os.left != -left + "px") && (os.left = -left + "px"); 1.2046 + (os.top != -top + "px") && (os.top = -top + "px"); 1.2047 + } else { 1.2048 + (gs.left != left + "px") && (gs.left = left + "px"); 1.2049 + (gs.top != top + "px") && (gs.top = top + "px"); 1.2050 + this.X = x; 1.2051 + this.Y = y; 1.2052 + this.W = w; 1.2053 + this.H = h; 1.2054 + (gs.width != this.paper.width + "px") && (gs.width = this.paper.width + "px"); 1.2055 + (gs.height != this.paper.height + "px") && (gs.height = this.paper.height + "px"); 1.2056 + (os.left != x - left + "px") && (os.left = x - left + "px"); 1.2057 + (os.top != y - top + "px") && (os.top = y - top + "px"); 1.2058 + (os.width != w + "px") && (os.width = w + "px"); 1.2059 + (os.height != h + "px") && (os.height = h + "px"); 1.2060 + var arcsize = (+params.r || 0) / mmin(w, h); 1.2061 + if (this.type == "rect" && this.arcsize.toFixed(4) != arcsize.toFixed(4) && (arcsize || this.arcsize)) { 1.2062 + // We should replace element with the new one 1.2063 + var o = createNode("roundrect"), 1.2064 + a = {}, 1.2065 + i = 0, 1.2066 + ii = this.events && this.events[length]; 1.2067 + o.arcsize = arcsize; 1.2068 + o.raphael = this; 1.2069 + this.Group[appendChild](o); 1.2070 + this.Group.removeChild(this.node); 1.2071 + this[0] = this.node = o; 1.2072 + this.arcsize = arcsize; 1.2073 + for (var i in attr) { 1.2074 + a[i] = attr[i]; 1.2075 + } 1.2076 + delete a.scale; 1.2077 + this.attr(a); 1.2078 + if (this.events) for (; i < ii; i++) { 1.2079 + this.events[i].unbind = addEvent(this.node, this.events[i].name, this.events[i].f, this); 1.2080 + } 1.2081 + } 1.2082 + } 1.2083 + }; 1.2084 + Element[proto].hide = function () { 1.2085 + !this.removed && (this.Group.style.display = "none"); 1.2086 + return this; 1.2087 + }; 1.2088 + Element[proto].show = function () { 1.2089 + !this.removed && (this.Group.style.display = "block"); 1.2090 + return this; 1.2091 + }; 1.2092 + Element[proto].getBBox = function () { 1.2093 + if (this.removed) { 1.2094 + return this; 1.2095 + } 1.2096 + if (this.type == "path") { 1.2097 + return pathDimensions(this.attrs.path); 1.2098 + } 1.2099 + return { 1.2100 + x: this.X + (this.bbx || 0), 1.2101 + y: this.Y, 1.2102 + width: this.W, 1.2103 + height: this.H 1.2104 + }; 1.2105 + }; 1.2106 + Element[proto].remove = function () { 1.2107 + if (this.removed) { 1.2108 + return; 1.2109 + } 1.2110 + tear(this, this.paper); 1.2111 + this.node.parentNode.removeChild(this.node); 1.2112 + this.Group.parentNode.removeChild(this.Group); 1.2113 + this.shape && this.shape.parentNode.removeChild(this.shape); 1.2114 + for (var i in this) { 1.2115 + delete this[i]; 1.2116 + } 1.2117 + this.removed = true; 1.2118 + }; 1.2119 + Element[proto].attr = function () { 1.2120 + if (this.removed) { 1.2121 + return this; 1.2122 + } 1.2123 + if (arguments[length] == 0) { 1.2124 + var res = {}; 1.2125 + for (var i in this.attrs) if (this.attrs[has](i)) { 1.2126 + res[i] = this.attrs[i]; 1.2127 + } 1.2128 + this._.rt.deg && (res.rotation = this.rotate()); 1.2129 + (this._.sx != 1 || this._.sy != 1) && (res.scale = this.scale()); 1.2130 + res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient; 1.2131 + return res; 1.2132 + } 1.2133 + if (arguments[length] == 1 && R.is(arguments[0], "string")) { 1.2134 + if (arguments[0] == "translation") { 1.2135 + return translate.call(this); 1.2136 + } 1.2137 + if (arguments[0] == "rotation") { 1.2138 + return this.rotate(); 1.2139 + } 1.2140 + if (arguments[0] == "scale") { 1.2141 + return this.scale(); 1.2142 + } 1.2143 + if (arguments[0] == "fill" && this.attrs.fill == "none" && this.attrs.gradient) { 1.2144 + return this.attrs.gradient; 1.2145 + } 1.2146 + return this.attrs[arguments[0]]; 1.2147 + } 1.2148 + if (this.attrs && arguments[length] == 1 && R.is(arguments[0], "array")) { 1.2149 + var values = {}; 1.2150 + for (var i = 0, ii = arguments[0][length]; i < ii; i++) { 1.2151 + values[arguments[0][i]] = this.attrs[arguments[0][i]]; 1.2152 + }; 1.2153 + return values; 1.2154 + } 1.2155 + var params; 1.2156 + if (arguments[length] == 2) { 1.2157 + params = {}; 1.2158 + params[arguments[0]] = arguments[1]; 1.2159 + } 1.2160 + arguments[length] == 1 && R.is(arguments[0], "object") && (params = arguments[0]); 1.2161 + if (params) { 1.2162 + if (params.text && this.type == "text") { 1.2163 + this.node.string = params.text; 1.2164 + } 1.2165 + setFillAndStroke(this, params); 1.2166 + if (params.gradient && (({circle: 1, ellipse: 1})[has](this.type) || (params.gradient + E).charAt() != "r")) { 1.2167 + addGradientFill(this, params.gradient); 1.2168 + } 1.2169 + (this.type != "path" || this._.rt.deg) && this.setBox(this.attrs); 1.2170 + } 1.2171 + return this; 1.2172 + }; 1.2173 + Element[proto].toFront = function () { 1.2174 + !this.removed && this.Group.parentNode[appendChild](this.Group); 1.2175 + this.paper.top != this && tofront(this, this.paper); 1.2176 + return this; 1.2177 + }; 1.2178 + Element[proto].toBack = function () { 1.2179 + if (this.removed) { 1.2180 + return this; 1.2181 + } 1.2182 + if (this.Group.parentNode.firstChild != this.Group) { 1.2183 + this.Group.parentNode.insertBefore(this.Group, this.Group.parentNode.firstChild); 1.2184 + toback(this, this.paper); 1.2185 + } 1.2186 + return this; 1.2187 + }; 1.2188 + Element[proto].insertAfter = function (element) { 1.2189 + if (this.removed) { 1.2190 + return this; 1.2191 + } 1.2192 + if (element.Group.nextSibling) { 1.2193 + element.Group.parentNode.insertBefore(this.Group, element.Group.nextSibling); 1.2194 + } else { 1.2195 + element.Group.parentNode[appendChild](this.Group); 1.2196 + } 1.2197 + insertafter(this, element, this.paper); 1.2198 + return this; 1.2199 + }; 1.2200 + Element[proto].insertBefore = function (element) { 1.2201 + if (this.removed) { 1.2202 + return this; 1.2203 + } 1.2204 + element.Group.parentNode.insertBefore(this.Group, element.Group); 1.2205 + insertbefore(this, element, this.paper); 1.2206 + return this; 1.2207 + }; 1.2208 + 1.2209 + var theCircle = function (vml, x, y, r) { 1.2210 + var g = createNode("group"), 1.2211 + o = createNode("oval"), 1.2212 + ol = o.style; 1.2213 + g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; 1.2214 + g.coordsize = vml.coordsize; 1.2215 + g.coordorigin = vml.coordorigin; 1.2216 + g[appendChild](o); 1.2217 + var res = new Element(o, g, vml); 1.2218 + res.type = "circle"; 1.2219 + setFillAndStroke(res, {stroke: "#000", fill: "none"}); 1.2220 + res.attrs.cx = x; 1.2221 + res.attrs.cy = y; 1.2222 + res.attrs.r = r; 1.2223 + res.setBox({x: x - r, y: y - r, width: r * 2, height: r * 2}); 1.2224 + vml.canvas[appendChild](g); 1.2225 + return res; 1.2226 + }, 1.2227 + theRect = function (vml, x, y, w, h, r) { 1.2228 + var g = createNode("group"), 1.2229 + o = createNode("roundrect"), 1.2230 + arcsize = (+r || 0) / (mmin(w, h)); 1.2231 + g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; 1.2232 + g.coordsize = vml.coordsize; 1.2233 + g.coordorigin = vml.coordorigin; 1.2234 + g[appendChild](o); 1.2235 + o.arcsize = arcsize; 1.2236 + var res = new Element(o, g, vml); 1.2237 + res.type = "rect"; 1.2238 + setFillAndStroke(res, {stroke: "#000"}); 1.2239 + res.arcsize = arcsize; 1.2240 + res.setBox({x: x, y: y, width: w, height: h, r: r}); 1.2241 + vml.canvas[appendChild](g); 1.2242 + return res; 1.2243 + }, 1.2244 + theEllipse = function (vml, x, y, rx, ry) { 1.2245 + var g = createNode("group"), 1.2246 + o = createNode("oval"), 1.2247 + ol = o.style; 1.2248 + g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; 1.2249 + g.coordsize = vml.coordsize; 1.2250 + g.coordorigin = vml.coordorigin; 1.2251 + g[appendChild](o); 1.2252 + var res = new Element(o, g, vml); 1.2253 + res.type = "ellipse"; 1.2254 + setFillAndStroke(res, {stroke: "#000"}); 1.2255 + res.attrs.cx = x; 1.2256 + res.attrs.cy = y; 1.2257 + res.attrs.rx = rx; 1.2258 + res.attrs.ry = ry; 1.2259 + res.setBox({x: x - rx, y: y - ry, width: rx * 2, height: ry * 2}); 1.2260 + vml.canvas[appendChild](g); 1.2261 + return res; 1.2262 + }, 1.2263 + theImage = function (vml, src, x, y, w, h) { 1.2264 + var g = createNode("group"), 1.2265 + o = createNode("image"), 1.2266 + ol = o.style; 1.2267 + g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; 1.2268 + g.coordsize = vml.coordsize; 1.2269 + g.coordorigin = vml.coordorigin; 1.2270 + o.src = src; 1.2271 + g[appendChild](o); 1.2272 + var res = new Element(o, g, vml); 1.2273 + res.type = "image"; 1.2274 + res.attrs.src = src; 1.2275 + res.attrs.x = x; 1.2276 + res.attrs.y = y; 1.2277 + res.attrs.w = w; 1.2278 + res.attrs.h = h; 1.2279 + res.setBox({x: x, y: y, width: w, height: h}); 1.2280 + vml.canvas[appendChild](g); 1.2281 + return res; 1.2282 + }, 1.2283 + theText = function (vml, x, y, text) { 1.2284 + var g = createNode("group"), 1.2285 + el = createNode("shape"), 1.2286 + ol = el.style, 1.2287 + path = createNode("path"), 1.2288 + ps = path.style, 1.2289 + o = createNode("textpath"); 1.2290 + g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width + "px;height:" + vml.height + "px"; 1.2291 + g.coordsize = vml.coordsize; 1.2292 + g.coordorigin = vml.coordorigin; 1.2293 + path.v = R.format("m{0},{1}l{2},{1}", round(x), round(y), round(x) + 1); 1.2294 + path.textpathok = true; 1.2295 + ol.width = vml.width; 1.2296 + ol.height = vml.height; 1.2297 + o.string = text + E; 1.2298 + o.on = true; 1.2299 + el[appendChild](o); 1.2300 + el[appendChild](path); 1.2301 + g[appendChild](el); 1.2302 + var res = new Element(o, g, vml); 1.2303 + res.shape = el; 1.2304 + res.textpath = path; 1.2305 + res.type = "text"; 1.2306 + res.attrs.text = text; 1.2307 + res.attrs.x = x; 1.2308 + res.attrs.y = y; 1.2309 + res.attrs.w = 1; 1.2310 + res.attrs.h = 1; 1.2311 + setFillAndStroke(res, {font: availableAttrs.font, stroke: "none", fill: "#000"}); 1.2312 + res.setBox(); 1.2313 + vml.canvas[appendChild](g); 1.2314 + return res; 1.2315 + }, 1.2316 + setSize = function (width, height) { 1.2317 + var cs = this.canvas.style; 1.2318 + width == +width && (width += "px"); 1.2319 + height == +height && (height += "px"); 1.2320 + cs.width = width; 1.2321 + cs.height = height; 1.2322 + cs.clip = "rect(0 " + width + " " + height + " 0)"; 1.2323 + return this; 1.2324 + }, 1.2325 + createNode; 1.2326 + doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)"); 1.2327 + try { 1.2328 + !doc.namespaces.rvml && doc.namespaces.add("rvml", "urn:schemas-microsoft-com:vml"); 1.2329 + createNode = function (tagName) { 1.2330 + return doc.createElement('<rvml:' + tagName + ' class="rvml">'); 1.2331 + }; 1.2332 + } catch (e) { 1.2333 + createNode = function (tagName) { 1.2334 + return doc.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">'); 1.2335 + }; 1.2336 + } 1.2337 + var create = function () { 1.2338 + var con = getContainer[apply](null, arguments), 1.2339 + container = con.container, 1.2340 + height = con.height, 1.2341 + s, 1.2342 + width = con.width, 1.2343 + x = con.x, 1.2344 + y = con.y; 1.2345 + if (!container) { 1.2346 + throw new Error("VML container not found."); 1.2347 + } 1.2348 + var res = new Paper, 1.2349 + c = res.canvas = doc.createElement("div"), 1.2350 + cs = c.style; 1.2351 + width = width || 512; 1.2352 + height = height || 342; 1.2353 + width == +width && (width += "px"); 1.2354 + height == +height && (height += "px"); 1.2355 + res.width = 1e3; 1.2356 + res.height = 1e3; 1.2357 + res.coordsize = "1000 1000"; 1.2358 + res.coordorigin = "0 0"; 1.2359 + res.span = doc.createElement("span"); 1.2360 + res.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;"; 1.2361 + c[appendChild](res.span); 1.2362 + cs.cssText = R.format("width:{0};height:{1};position:absolute;clip:rect(0 {0} {1} 0);overflow:hidden", width, height); 1.2363 + if (container == 1) { 1.2364 + doc.body[appendChild](c); 1.2365 + cs.left = x + "px"; 1.2366 + cs.top = y + "px"; 1.2367 + } else { 1.2368 + container.style.width = width; 1.2369 + container.style.height = height; 1.2370 + if (container.firstChild) { 1.2371 + container.insertBefore(c, container.firstChild); 1.2372 + } else { 1.2373 + container[appendChild](c); 1.2374 + } 1.2375 + } 1.2376 + plugins.call(res, res, R.fn); 1.2377 + return res; 1.2378 + }; 1.2379 + Paper[proto].clear = function () { 1.2380 + this.canvas.innerHTML = E; 1.2381 + this.span = doc.createElement("span"); 1.2382 + this.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;"; 1.2383 + this.canvas[appendChild](this.span); 1.2384 + this.bottom = this.top = null; 1.2385 + }; 1.2386 + Paper[proto].remove = function () { 1.2387 + this.canvas.parentNode.removeChild(this.canvas); 1.2388 + for (var i in this) { 1.2389 + this[i] = removed(i); 1.2390 + } 1.2391 + }; 1.2392 + } 1.2393 + 1.2394 + // rest 1.2395 + // Safari or Chrome (WebKit) rendering bug workaround method 1.2396 + if ((/^Apple|^Google/).test(navigator.vendor) && !(navigator.userAgent.indexOf("Version/4.0") + 1)) { 1.2397 + Paper[proto].safari = function () { 1.2398 + var rect = this.rect(-99, -99, this.width + 99, this.height + 99); 1.2399 + setTimeout(function () {rect.remove();}); 1.2400 + }; 1.2401 + } else { 1.2402 + Paper[proto].safari = function () {}; 1.2403 + } 1.2404 + 1.2405 + // Events 1.2406 + var addEvent = (function () { 1.2407 + if (doc.addEventListener) { 1.2408 + return function (obj, type, fn, element) { 1.2409 + var f = function (e) { 1.2410 + return fn.call(element, e); 1.2411 + }; 1.2412 + obj.addEventListener(type, f, false); 1.2413 + return function () { 1.2414 + obj.removeEventListener(type, f, false); 1.2415 + return true; 1.2416 + }; 1.2417 + }; 1.2418 + } else if (doc.attachEvent) { 1.2419 + return function (obj, type, fn, element) { 1.2420 + var f = function (e) { 1.2421 + return fn.call(element, e || win.event); 1.2422 + }; 1.2423 + obj.attachEvent("on" + type, f); 1.2424 + var detacher = function () { 1.2425 + obj.detachEvent("on" + type, f); 1.2426 + return true; 1.2427 + }; 1.2428 + return detacher; 1.2429 + }; 1.2430 + } 1.2431 + })(); 1.2432 + for (var i = events[length]; i--;) { 1.2433 + (function (eventName) { 1.2434 + Element[proto][eventName] = function (fn) { 1.2435 + if (R.is(fn, "function")) { 1.2436 + this.events = this.events || []; 1.2437 + this.events.push({name: eventName, f: fn, unbind: addEvent(this.shape || this.node, eventName, fn, this)}); 1.2438 + } 1.2439 + return this; 1.2440 + }; 1.2441 + Element[proto]["un" + eventName] = function (fn) { 1.2442 + var events = this.events, 1.2443 + l = events[length]; 1.2444 + while (l--) if (events[l].name == eventName && events[l].f == fn) { 1.2445 + events[l].unbind(); 1.2446 + events.splice(l, 1); 1.2447 + !events.length && delete this.events; 1.2448 + return this; 1.2449 + } 1.2450 + return this; 1.2451 + }; 1.2452 + })(events[i]); 1.2453 + } 1.2454 + Element[proto].hover = function (f_in, f_out) { 1.2455 + return this.mouseover(f_in).mouseout(f_out); 1.2456 + }; 1.2457 + Element[proto].unhover = function (f_in, f_out) { 1.2458 + return this.unmouseover(f_in).unmouseout(f_out); 1.2459 + }; 1.2460 + Paper[proto].circle = function (x, y, r) { 1.2461 + return theCircle(this, x || 0, y || 0, r || 0); 1.2462 + }; 1.2463 + Paper[proto].rect = function (x, y, w, h, r) { 1.2464 + return theRect(this, x || 0, y || 0, w || 0, h || 0, r || 0); 1.2465 + }; 1.2466 + Paper[proto].ellipse = function (x, y, rx, ry) { 1.2467 + return theEllipse(this, x || 0, y || 0, rx || 0, ry || 0); 1.2468 + }; 1.2469 + Paper[proto].path = function (pathString) { 1.2470 + pathString && !R.is(pathString, "string") && !R.is(pathString[0], "array") && (pathString += E); 1.2471 + return thePath(R.format[apply](R, arguments), this); 1.2472 + }; 1.2473 + Paper[proto].image = function (src, x, y, w, h) { 1.2474 + return theImage(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0); 1.2475 + }; 1.2476 + Paper[proto].text = function (x, y, text) { 1.2477 + return theText(this, x || 0, y || 0, text || E); 1.2478 + }; 1.2479 + Paper[proto].set = function (itemsArray) { 1.2480 + arguments[length] > 1 && (itemsArray = Array[proto].splice.call(arguments, 0, arguments[length])); 1.2481 + return new Set(itemsArray); 1.2482 + }; 1.2483 + Paper[proto].setSize = setSize; 1.2484 + Paper[proto].top = Paper[proto].bottom = null; 1.2485 + Paper[proto].raphael = R; 1.2486 + function x_y() { 1.2487 + return this.x + S + this.y; 1.2488 + }; 1.2489 + Element[proto].scale = function (x, y, cx, cy) { 1.2490 + if (x == null && y == null) { 1.2491 + return { 1.2492 + x: this._.sx, 1.2493 + y: this._.sy, 1.2494 + toString: x_y 1.2495 + }; 1.2496 + } 1.2497 + y = y || x; 1.2498 + !+y && (y = x); 1.2499 + var dx, 1.2500 + dy, 1.2501 + dcx, 1.2502 + dcy, 1.2503 + a = this.attrs; 1.2504 + if (x != 0) { 1.2505 + var bb = this.getBBox(), 1.2506 + rcx = bb.x + bb.width / 2, 1.2507 + rcy = bb.y + bb.height / 2, 1.2508 + kx = x / this._.sx, 1.2509 + ky = y / this._.sy; 1.2510 + cx = (+cx || cx == 0) ? cx : rcx; 1.2511 + cy = (+cy || cy == 0) ? cy : rcy; 1.2512 + var dirx = ~~(x / math.abs(x)), 1.2513 + diry = ~~(y / math.abs(y)), 1.2514 + s = this.node.style, 1.2515 + ncx = cx + (rcx - cx) * kx, 1.2516 + ncy = cy + (rcy - cy) * ky; 1.2517 + switch (this.type) { 1.2518 + case "rect": 1.2519 + case "image": 1.2520 + var neww = a.width * dirx * kx, 1.2521 + newh = a.height * diry * ky; 1.2522 + this.attr({ 1.2523 + height: newh, 1.2524 + r: a.r * mmin(dirx * kx, diry * ky), 1.2525 + width: neww, 1.2526 + x: ncx - neww / 2, 1.2527 + y: ncy - newh / 2 1.2528 + }); 1.2529 + break; 1.2530 + case "circle": 1.2531 + case "ellipse": 1.2532 + this.attr({ 1.2533 + rx: a.rx * dirx * kx, 1.2534 + ry: a.ry * diry * ky, 1.2535 + r: a.r * mmin(dirx * kx, diry * ky), 1.2536 + cx: ncx, 1.2537 + cy: ncy 1.2538 + }); 1.2539 + break; 1.2540 + case "path": 1.2541 + var path = pathToRelative(a.path), 1.2542 + skip = true; 1.2543 + for (var i = 0, ii = path[length]; i < ii; i++) { 1.2544 + var p = path[i], 1.2545 + j, 1.2546 + P0 = upperCase.call(p[0]); 1.2547 + if (P0 == "M" && skip) { 1.2548 + continue; 1.2549 + } else { 1.2550 + skip = false; 1.2551 + } 1.2552 + if (P0 == "A") { 1.2553 + p[path[i][length] - 2] *= kx; 1.2554 + p[path[i][length] - 1] *= ky; 1.2555 + p[1] *= dirx * kx; 1.2556 + p[2] *= diry * ky; 1.2557 + p[5] = +(dirx + diry ? !!+p[5] : !+p[5]); 1.2558 + } else if (P0 == "H") { 1.2559 + for (j = 1, jj = p[length]; j < jj; j++) { 1.2560 + p[j] *= kx; 1.2561 + } 1.2562 + } else if (P0 == "V") { 1.2563 + for (j = 1, jj = p[length]; j < jj; j++) { 1.2564 + p[j] *= ky; 1.2565 + } 1.2566 + } else { 1.2567 + for (j = 1, jj = p[length]; j < jj; j++) { 1.2568 + p[j] *= (j % 2) ? kx : ky; 1.2569 + } 1.2570 + } 1.2571 + } 1.2572 + var dim2 = pathDimensions(path), 1.2573 + dx = ncx - dim2.x - dim2.width / 2, 1.2574 + dy = ncy - dim2.y - dim2.height / 2; 1.2575 + path[0][1] += dx; 1.2576 + path[0][2] += dy; 1.2577 + this.attr({path: path}); 1.2578 + break; 1.2579 + } 1.2580 + if (this.type in {text: 1, image:1} && (dirx != 1 || diry != 1)) { 1.2581 + if (this.transformations) { 1.2582 + this.transformations[2] = "scale("[concat](dirx, ",", diry, ")"); 1.2583 + this.node[setAttribute]("transform", this.transformations[join](S)); 1.2584 + dx = (dirx == -1) ? -a.x - (neww || 0) : a.x; 1.2585 + dy = (diry == -1) ? -a.y - (newh || 0) : a.y; 1.2586 + this.attr({x: dx, y: dy}); 1.2587 + a.fx = dirx - 1; 1.2588 + a.fy = diry - 1; 1.2589 + } else { 1.2590 + this.node.filterMatrix = " progid:DXImageTransform.Microsoft.Matrix(M11="[concat](dirx, 1.2591 + ", M12=0, M21=0, M22=", diry, 1.2592 + ", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')"); 1.2593 + s.filter = (this.node.filterMatrix || E) + (this.node.filterOpacity || E); 1.2594 + } 1.2595 + } else { 1.2596 + if (this.transformations) { 1.2597 + this.transformations[2] = E; 1.2598 + this.node[setAttribute]("transform", this.transformations[join](S)); 1.2599 + a.fx = 0; 1.2600 + a.fy = 0; 1.2601 + } else { 1.2602 + this.node.filterMatrix = E; 1.2603 + s.filter = (this.node.filterMatrix || E) + (this.node.filterOpacity || E); 1.2604 + } 1.2605 + } 1.2606 + a.scale = [x, y, cx, cy][join](S); 1.2607 + this._.sx = x; 1.2608 + this._.sy = y; 1.2609 + } 1.2610 + return this; 1.2611 + }; 1.2612 + Element[proto].clone = function () { 1.2613 + var attr = this.attr(); 1.2614 + delete attr.scale; 1.2615 + delete attr.translation; 1.2616 + return this.paper[this.type]().attr(attr); 1.2617 + }; 1.2618 + var getLengthFactory = function (istotal, subpath) { 1.2619 + return function (path, length, onlystart) { 1.2620 + path = path2curve(path); 1.2621 + var x, y, p, l, sp = "", subpaths = {}, point, 1.2622 + len = 0; 1.2623 + for (var i = 0, ii = path.length; i < ii; i++) { 1.2624 + p = path[i]; 1.2625 + if (p[0] == "M") { 1.2626 + x = +p[1]; 1.2627 + y = +p[2]; 1.2628 + } else { 1.2629 + l = segmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]); 1.2630 + if (len + l > length) { 1.2631 + if (subpath && !subpaths.start) { 1.2632 + point = R.findDotsAtSegment(x, y, p[1], p[2], p[3], p[4], p[5], p[6], (length - len) / l); 1.2633 + sp += ["C", point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y]; 1.2634 + if (onlystart) { 1.2635 + return sp; 1.2636 + } 1.2637 + subpaths.start = sp; 1.2638 + sp = ["M", point.x, point.y, "C", point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]][join](); 1.2639 + len += l; 1.2640 + x = +p[5]; 1.2641 + y = +p[6]; 1.2642 + continue; 1.2643 + } 1.2644 + if (!istotal && !subpath) { 1.2645 + point = R.findDotsAtSegment(x, y, p[1], p[2], p[3], p[4], p[5], p[6], (length - len) / l); 1.2646 + return {x: point.x, y: point.y, alpha: point.alpha}; 1.2647 + } 1.2648 + } 1.2649 + len += l; 1.2650 + x = +p[5]; 1.2651 + y = +p[6]; 1.2652 + } 1.2653 + sp += p; 1.2654 + } 1.2655 + subpaths.end = sp; 1.2656 + point = istotal ? len : subpath ? subpaths : R.findDotsAtSegment(x, y, p[1], p[2], p[3], p[4], p[5], p[6], 1); 1.2657 + point.alpha && (point = {x: point.x, y: point.y, alpha: point.alpha}); 1.2658 + return point; 1.2659 + }; 1.2660 + }, 1.2661 + segmentLength = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { 1.2662 + var old = {x: 0, y: 0}, 1.2663 + len = 0; 1.2664 + for (var i = 0; i < 1.01; i+=.01) { 1.2665 + var dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, i); 1.2666 + i && (len += math.sqrt(pow(old.x - dot.x, 2) + pow(old.y - dot.y, 2))); 1.2667 + old = dot; 1.2668 + } 1.2669 + return len; 1.2670 + }); 1.2671 + var getTotalLength = getLengthFactory(1), 1.2672 + getPointAtLength = getLengthFactory(), 1.2673 + getSubpathsAtLength = getLengthFactory(0, 1); 1.2674 + Element[proto].getTotalLength = function () { 1.2675 + if (this.type != "path") return; 1.2676 + return getTotalLength(this.attrs.path); 1.2677 + }; 1.2678 + Element[proto].getPointAtLength = function (length) { 1.2679 + if (this.type != "path") return; 1.2680 + return getPointAtLength(this.attrs.path, length); 1.2681 + }; 1.2682 + Element[proto].getSubpath = function (from, to) { 1.2683 + if (this.type != "path") return; 1.2684 + var a = getSubpathsAtLength(this.attrs.path, to, 1); 1.2685 + return from ? getSubpathsAtLength(a, from).end : a; 1.2686 + }; 1.2687 + 1.2688 + // animation easing formulas 1.2689 + R.easing_formulas = { 1.2690 + linear: function (n) { 1.2691 + return n; 1.2692 + }, 1.2693 + "<": function (n) { 1.2694 + return pow(n, 3); 1.2695 + }, 1.2696 + ">": function (n) { 1.2697 + return pow(n - 1, 3) + 1; 1.2698 + }, 1.2699 + "<>": function (n) { 1.2700 + n = n * 2; 1.2701 + if (n < 1) { 1.2702 + return pow(n, 3) / 2; 1.2703 + } 1.2704 + n -= 2; 1.2705 + return (pow(n, 3) + 2) / 2; 1.2706 + }, 1.2707 + backIn: function (n) { 1.2708 + var s = 1.70158; 1.2709 + return n * n * ((s + 1) * n - s); 1.2710 + }, 1.2711 + backOut: function (n) { 1.2712 + n = n - 1; 1.2713 + var s = 1.70158; 1.2714 + return n * n * ((s + 1) * n + s) + 1; 1.2715 + }, 1.2716 + elastic: function (n) { 1.2717 + if (n == 0 || n == 1) { 1.2718 + return n; 1.2719 + } 1.2720 + var p = .3, 1.2721 + s = p / 4; 1.2722 + return pow(2, -10 * n) * math.sin((n - s) * (2 * math.PI) / p) + 1; 1.2723 + }, 1.2724 + bounce: function (n) { 1.2725 + var s = 7.5625, 1.2726 + p = 2.75, 1.2727 + l; 1.2728 + if (n < (1 / p)) { 1.2729 + l = s * n * n; 1.2730 + } else { 1.2731 + if (n < (2 / p)) { 1.2732 + n -= (1.5 / p); 1.2733 + l = s * n * n + .75; 1.2734 + } else { 1.2735 + if (n < (2.5 / p)) { 1.2736 + n -= (2.25 / p); 1.2737 + l = s * n * n + .9375; 1.2738 + } else { 1.2739 + n -= (2.625 / p); 1.2740 + l = s * n * n + .984375; 1.2741 + } 1.2742 + } 1.2743 + } 1.2744 + return l; 1.2745 + } 1.2746 + }; 1.2747 + 1.2748 + var animationElements = {length : 0}, 1.2749 + animation = function () { 1.2750 + var Now = +new Date; 1.2751 + for (var l in animationElements) if (l != "length" && animationElements[has](l)) { 1.2752 + var e = animationElements[l]; 1.2753 + if (e.stop) { 1.2754 + delete animationElements[l]; 1.2755 + animationElements[length]--; 1.2756 + continue; 1.2757 + } 1.2758 + var time = Now - e.start, 1.2759 + ms = e.ms, 1.2760 + easing = e.easing, 1.2761 + from = e.from, 1.2762 + diff = e.diff, 1.2763 + to = e.to, 1.2764 + t = e.t, 1.2765 + prev = e.prev || 0, 1.2766 + that = e.el, 1.2767 + callback = e.callback, 1.2768 + set = {}, 1.2769 + now; 1.2770 + if (time < ms) { 1.2771 + var pos = R.easing_formulas[easing] ? R.easing_formulas[easing](time / ms) : time / ms; 1.2772 + for (var attr in from) if (from[has](attr)) { 1.2773 + switch (availableAnimAttrs[attr]) { 1.2774 + case "along": 1.2775 + now = pos * ms * diff[attr]; 1.2776 + to.back && (now = to.len - now); 1.2777 + var point = getPointAtLength(to[attr], now); 1.2778 + that.translate(diff.sx - diff.x || 0, diff.sy - diff.y || 0); 1.2779 + diff.x = point.x; 1.2780 + diff.y = point.y; 1.2781 + that.translate(point.x - diff.sx, point.y - diff.sy); 1.2782 + to.rot && that.rotate(diff.r + point.alpha, point.x, point.y); 1.2783 + break; 1.2784 + case "number": 1.2785 + now = +from[attr] + pos * ms * diff[attr]; 1.2786 + break; 1.2787 + case "colour": 1.2788 + now = "rgb(" + [ 1.2789 + upto255(round(from[attr].r + pos * ms * diff[attr].r)), 1.2790 + upto255(round(from[attr].g + pos * ms * diff[attr].g)), 1.2791 + upto255(round(from[attr].b + pos * ms * diff[attr].b)) 1.2792 + ][join](",") + ")"; 1.2793 + break; 1.2794 + case "path": 1.2795 + now = []; 1.2796 + for (var i = 0, ii = from[attr][length]; i < ii; i++) { 1.2797 + now[i] = [from[attr][i][0]]; 1.2798 + for (var j = 1, jj = from[attr][i][length]; j < jj; j++) { 1.2799 + now[i][j] = +from[attr][i][j] + pos * ms * diff[attr][i][j]; 1.2800 + } 1.2801 + now[i] = now[i][join](S); 1.2802 + } 1.2803 + now = now[join](S); 1.2804 + break; 1.2805 + case "csv": 1.2806 + switch (attr) { 1.2807 + case "translation": 1.2808 + var x = diff[attr][0] * (time - prev), 1.2809 + y = diff[attr][1] * (time - prev); 1.2810 + t.x += x; 1.2811 + t.y += y; 1.2812 + now = x + S + y; 1.2813 + break; 1.2814 + case "rotation": 1.2815 + now = +from[attr][0] + pos * ms * diff[attr][0]; 1.2816 + from[attr][1] && (now += "," + from[attr][1] + "," + from[attr][2]); 1.2817 + break; 1.2818 + case "scale": 1.2819 + now = [+from[attr][0] + pos * ms * diff[attr][0], +from[attr][1] + pos * ms * diff[attr][1], (2 in to[attr] ? to[attr][2] : E), (3 in to[attr] ? to[attr][3] : E)][join](S); 1.2820 + break; 1.2821 + case "clip-rect": 1.2822 + now = []; 1.2823 + var i = 4; 1.2824 + while (i--) { 1.2825 + now[i] = +from[attr][i] + pos * ms * diff[attr][i]; 1.2826 + } 1.2827 + break; 1.2828 + } 1.2829 + break; 1.2830 + } 1.2831 + set[attr] = now; 1.2832 + } 1.2833 + that.attr(set); 1.2834 + that._run && that._run.call(that); 1.2835 + } else { 1.2836 + if (to.along) { 1.2837 + var point = getPointAtLength(to.along, to.len * !to.back); 1.2838 + that.translate(diff.sx - (diff.x || 0) + point.x - diff.sx, diff.sy - (diff.y || 0) + point.y - diff.sy); 1.2839 + to.rot && that.rotate(diff.r + point.alpha, point.x, point.y); 1.2840 + } 1.2841 + (t.x || t.y) && that.translate(-t.x, -t.y); 1.2842 + to.scale && (to.scale = to.scale + E); 1.2843 + that.attr(to); 1.2844 + delete animationElements[l]; 1.2845 + animationElements[length]--; 1.2846 + that.in_animation = null; 1.2847 + R.is(callback, "function") && callback.call(that); 1.2848 + } 1.2849 + e.prev = time; 1.2850 + } 1.2851 + R.svg && that && that.paper.safari(); 1.2852 + animationElements[length] && setTimeout(animation); 1.2853 + }, 1.2854 + upto255 = function (color) { 1.2855 + return color > 255 ? 255 : (color < 0 ? 0 : color); 1.2856 + }, 1.2857 + translate = function (x, y) { 1.2858 + if (x == null) { 1.2859 + return {x: this._.tx, y: this._.ty, toString: x_y}; 1.2860 + } 1.2861 + this._.tx += +x; 1.2862 + this._.ty += +y; 1.2863 + switch (this.type) { 1.2864 + case "circle": 1.2865 + case "ellipse": 1.2866 + this.attr({cx: +x + this.attrs.cx, cy: +y + this.attrs.cy}); 1.2867 + break; 1.2868 + case "rect": 1.2869 + case "image": 1.2870 + case "text": 1.2871 + this.attr({x: +x + this.attrs.x, y: +y + this.attrs.y}); 1.2872 + break; 1.2873 + case "path": 1.2874 + var path = pathToRelative(this.attrs.path); 1.2875 + path[0][1] += +x; 1.2876 + path[0][2] += +y; 1.2877 + this.attr({path: path}); 1.2878 + break; 1.2879 + } 1.2880 + return this; 1.2881 + }; 1.2882 + Element[proto].animateWith = function (element, params, ms, easing, callback) { 1.2883 + animationElements[element.id] && (params.start = animationElements[element.id].start); 1.2884 + return this.animate(params, ms, easing, callback); 1.2885 + }; 1.2886 + Element[proto].animateAlong = along(); 1.2887 + Element[proto].animateAlongBack = along(1); 1.2888 + function along(isBack) { 1.2889 + return function (path, ms, rotate, callback) { 1.2890 + var params = {back: isBack}; 1.2891 + R.is(rotate, "function") ? (callback = rotate) : (params.rot = rotate); 1.2892 + path && path.constructor == Element && (path = path.attrs.path); 1.2893 + path && (params.along = path); 1.2894 + return this.animate(params, ms, callback); 1.2895 + }; 1.2896 + } 1.2897 + Element[proto].onAnimation = function (f) { 1.2898 + this._run = f || 0; 1.2899 + return this; 1.2900 + }; 1.2901 + Element[proto].animate = function (params, ms, easing, callback) { 1.2902 + if (R.is(easing, "function") || !easing) { 1.2903 + callback = easing || null; 1.2904 + } 1.2905 + var from = {}, 1.2906 + to = {}, 1.2907 + diff = {}; 1.2908 + for (var attr in params) if (params[has](attr)) { 1.2909 + if (availableAnimAttrs[has](attr)) { 1.2910 + from[attr] = this.attr(attr); 1.2911 + (from[attr] == null) && (from[attr] = availableAttrs[attr]); 1.2912 + to[attr] = params[attr]; 1.2913 + switch (availableAnimAttrs[attr]) { 1.2914 + case "along": 1.2915 + var len = getTotalLength(params[attr]), 1.2916 + point = getPointAtLength(params[attr], len * !!params.back), 1.2917 + bb = this.getBBox(); 1.2918 + diff[attr] = len / ms; 1.2919 + diff.tx = bb.x; 1.2920 + diff.ty = bb.y; 1.2921 + diff.sx = point.x; 1.2922 + diff.sy = point.y; 1.2923 + to.rot = params.rot; 1.2924 + to.back = params.back; 1.2925 + to.len = len; 1.2926 + params.rot && (diff.r = toFloat(this.rotate()) || 0); 1.2927 + break; 1.2928 + case "number": 1.2929 + diff[attr] = (to[attr] - from[attr]) / ms; 1.2930 + break; 1.2931 + case "colour": 1.2932 + from[attr] = R.getRGB(from[attr]); 1.2933 + var toColour = R.getRGB(to[attr]); 1.2934 + diff[attr] = { 1.2935 + r: (toColour.r - from[attr].r) / ms, 1.2936 + g: (toColour.g - from[attr].g) / ms, 1.2937 + b: (toColour.b - from[attr].b) / ms 1.2938 + }; 1.2939 + break; 1.2940 + case "path": 1.2941 + var pathes = path2curve(from[attr], to[attr]); 1.2942 + from[attr] = pathes[0]; 1.2943 + var toPath = pathes[1]; 1.2944 + diff[attr] = []; 1.2945 + for (var i = 0, ii = from[attr][length]; i < ii; i++) { 1.2946 + diff[attr][i] = [0]; 1.2947 + for (var j = 1, jj = from[attr][i][length]; j < jj; j++) { 1.2948 + diff[attr][i][j] = (toPath[i][j] - from[attr][i][j]) / ms; 1.2949 + } 1.2950 + } 1.2951 + break; 1.2952 + case "csv": 1.2953 + var values = (params[attr] + E)[split](separator), 1.2954 + from2 = (from[attr] + E)[split](separator); 1.2955 + switch (attr) { 1.2956 + case "translation": 1.2957 + from[attr] = [0, 0]; 1.2958 + diff[attr] = [values[0] / ms, values[1] / ms]; 1.2959 + break; 1.2960 + case "rotation": 1.2961 + from[attr] = (from2[1] == values[1] && from2[2] == values[2]) ? from2 : [0, values[1], values[2]]; 1.2962 + diff[attr] = [(values[0] - from[attr][0]) / ms, 0, 0]; 1.2963 + break; 1.2964 + case "scale": 1.2965 + params[attr] = values; 1.2966 + from[attr] = (from[attr] + E)[split](separator); 1.2967 + diff[attr] = [(values[0] - from[attr][0]) / ms, (values[1] - from[attr][1]) / ms, 0, 0]; 1.2968 + break; 1.2969 + case "clip-rect": 1.2970 + from[attr] = (from[attr] + E)[split](separator); 1.2971 + diff[attr] = []; 1.2972 + var i = 4; 1.2973 + while (i--) { 1.2974 + diff[attr][i] = (values[i] - from[attr][i]) / ms; 1.2975 + } 1.2976 + break; 1.2977 + } 1.2978 + to[attr] = values; 1.2979 + } 1.2980 + } 1.2981 + } 1.2982 + this.stop(); 1.2983 + this.in_animation = 1; 1.2984 + animationElements[this.id] = { 1.2985 + start: params.start || +new Date, 1.2986 + ms: ms, 1.2987 + easing: easing, 1.2988 + from: from, 1.2989 + diff: diff, 1.2990 + to: to, 1.2991 + el: this, 1.2992 + callback: callback, 1.2993 + t: {x: 0, y: 0} 1.2994 + }; 1.2995 + ++animationElements[length] == 1 && animation(); 1.2996 + return this; 1.2997 + }; 1.2998 + Element[proto].stop = function () { 1.2999 + animationElements[this.id] && animationElements[length]--; 1.3000 + delete animationElements[this.id]; 1.3001 + return this; 1.3002 + }; 1.3003 + Element[proto].translate = function (x, y) { 1.3004 + return this.attr({translation: x + " " + y}); 1.3005 + }; 1.3006 + Element[proto][toString] = function () { 1.3007 + return "Rapha\xebl\u2019s object"; 1.3008 + }; 1.3009 + R.ae = animationElements; 1.3010 + 1.3011 + // Set 1.3012 + var Set = function (items) { 1.3013 + this.items = []; 1.3014 + this[length] = 0; 1.3015 + if (items) { 1.3016 + for (var i = 0, ii = items[length]; i < ii; i++) { 1.3017 + if (items[i] && (items[i].constructor == Element || items[i].constructor == Set)) { 1.3018 + this[this.items[length]] = this.items[this.items[length]] = items[i]; 1.3019 + this[length]++; 1.3020 + } 1.3021 + } 1.3022 + } 1.3023 + }; 1.3024 + Set[proto][push] = function () { 1.3025 + var item, 1.3026 + len; 1.3027 + for (var i = 0, ii = arguments[length]; i < ii; i++) { 1.3028 + item = arguments[i]; 1.3029 + if (item && (item.constructor == Element || item.constructor == Set)) { 1.3030 + len = this.items[length]; 1.3031 + this[len] = this.items[len] = item; 1.3032 + this[length]++; 1.3033 + } 1.3034 + } 1.3035 + return this; 1.3036 + }; 1.3037 + Set[proto].pop = function () { 1.3038 + delete this[this[length]--]; 1.3039 + return this.items.pop(); 1.3040 + }; 1.3041 + for (var method in Element[proto]) if (Element[proto][has](method)) { 1.3042 + Set[proto][method] = (function (methodname) { 1.3043 + return function () { 1.3044 + for (var i = 0, ii = this.items[length]; i < ii; i++) { 1.3045 + this.items[i][methodname][apply](this.items[i], arguments); 1.3046 + } 1.3047 + return this; 1.3048 + }; 1.3049 + })(method); 1.3050 + } 1.3051 + Set[proto].attr = function (name, value) { 1.3052 + if (name && R.is(name, "array") && R.is(name[0], "object")) { 1.3053 + for (var j = 0, jj = name[length]; j < jj; j++) { 1.3054 + this.items[j].attr(name[j]); 1.3055 + } 1.3056 + } else { 1.3057 + for (var i = 0, ii = this.items[length]; i < ii; i++) { 1.3058 + this.items[i].attr[apply](this.items[i], arguments); 1.3059 + } 1.3060 + } 1.3061 + return this; 1.3062 + }; 1.3063 + Set[proto].animate = function (params, ms, easing, callback) { 1.3064 + (R.is(easing, "function") || !easing) && (callback = easing || null); 1.3065 + var len = this.items[length], 1.3066 + i = len, 1.3067 + set = this, 1.3068 + collector; 1.3069 + callback && (collector = function () { 1.3070 + !--len && callback.call(set); 1.3071 + }); 1.3072 + this.items[--i].animate(params, ms, easing || collector, collector); 1.3073 + while (i--) { 1.3074 + this.items[i].animateWith(this.items[len - 1], params, ms, easing || collector, collector); 1.3075 + } 1.3076 + return this; 1.3077 + }; 1.3078 + Set[proto].insertAfter = function (el) { 1.3079 + var i = this.items[length]; 1.3080 + while (i--) { 1.3081 + this.items[i].insertAfter(el); 1.3082 + } 1.3083 + return this; 1.3084 + }; 1.3085 + Set[proto].getBBox = function () { 1.3086 + var x = [], 1.3087 + y = [], 1.3088 + w = [], 1.3089 + h = []; 1.3090 + for (var i = this.items[length]; i--;) { 1.3091 + var box = this.items[i].getBBox(); 1.3092 + x[push](box.x); 1.3093 + y[push](box.y); 1.3094 + w[push](box.x + box.width); 1.3095 + h[push](box.y + box.height); 1.3096 + } 1.3097 + x = mmin[apply](0, x); 1.3098 + y = mmin[apply](0, y); 1.3099 + return { 1.3100 + x: x, 1.3101 + y: y, 1.3102 + width: mmax[apply](0, w) - x, 1.3103 + height: mmax[apply](0, h) - y 1.3104 + }; 1.3105 + }; 1.3106 + 1.3107 + R.registerFont = function (font) { 1.3108 + if (!font.face) { 1.3109 + return font; 1.3110 + } 1.3111 + this.fonts = this.fonts || {}; 1.3112 + var fontcopy = { 1.3113 + w: font.w, 1.3114 + face: {}, 1.3115 + glyphs: {} 1.3116 + }, 1.3117 + family = font.face["font-family"]; 1.3118 + for (var prop in font.face) if (font.face[has](prop)) { 1.3119 + fontcopy.face[prop] = font.face[prop]; 1.3120 + } 1.3121 + if (this.fonts[family]) { 1.3122 + this.fonts[family][push](fontcopy); 1.3123 + } else { 1.3124 + this.fonts[family] = [fontcopy]; 1.3125 + } 1.3126 + if (!font.svg) { 1.3127 + fontcopy.face["units-per-em"] = toInt(font.face["units-per-em"], 10); 1.3128 + for (var glyph in font.glyphs) if (font.glyphs[has](glyph)) { 1.3129 + var path = font.glyphs[glyph]; 1.3130 + fontcopy.glyphs[glyph] = { 1.3131 + w: path.w, 1.3132 + k: {}, 1.3133 + d: path.d && "M" + path.d[rp](/[mlcxtrv]/g, function (command) { 1.3134 + return {l: "L", c: "C", x: "z", t: "m", r: "l", v: "c"}[command] || "M"; 1.3135 + }) + "z" 1.3136 + }; 1.3137 + if (path.k) { 1.3138 + for (var k in path.k) if (path[has](k)) { 1.3139 + fontcopy.glyphs[glyph].k[k] = path.k[k]; 1.3140 + } 1.3141 + } 1.3142 + } 1.3143 + } 1.3144 + return font; 1.3145 + }; 1.3146 + Paper[proto].getFont = function (family, weight, style, stretch) { 1.3147 + stretch = stretch || "normal"; 1.3148 + style = style || "normal"; 1.3149 + weight = +weight || {normal: 400, bold: 700, lighter: 300, bolder: 800}[weight] || 400; 1.3150 + var font = R.fonts[family]; 1.3151 + if (!font) { 1.3152 + var name = new RegExp("(^|\\s)" + family[rp](/[^\w\d\s+!~.:_-]/g, E) + "(\\s|$)", "i"); 1.3153 + for (var fontName in R.fonts) if (R.fonts[has](fontName)) { 1.3154 + if (name.test(fontName)) { 1.3155 + font = R.fonts[fontName]; 1.3156 + break; 1.3157 + } 1.3158 + } 1.3159 + } 1.3160 + var thefont; 1.3161 + if (font) { 1.3162 + for (var i = 0, ii = font[length]; i < ii; i++) { 1.3163 + thefont = font[i]; 1.3164 + if (thefont.face["font-weight"] == weight && (thefont.face["font-style"] == style || !thefont.face["font-style"]) && thefont.face["font-stretch"] == stretch) { 1.3165 + break; 1.3166 + } 1.3167 + } 1.3168 + } 1.3169 + return thefont; 1.3170 + }; 1.3171 + Paper[proto].print = function (x, y, string, font, size, origin) { 1.3172 + origin = origin || "middle"; // baseline|middle 1.3173 + var out = this.set(), 1.3174 + letters = (string + E)[split](E), 1.3175 + shift = 0, 1.3176 + path = E, 1.3177 + scale; 1.3178 + R.is(font, "string") && (font = this.getFont(font)); 1.3179 + if (font) { 1.3180 + scale = (size || 16) / font.face["units-per-em"]; 1.3181 + var bb = font.face.bbox.split(separator), 1.3182 + top = +bb[0], 1.3183 + height = +bb[1] + (origin == "baseline" ? bb[3] - bb[1] + (+font.face.descent) : (bb[3] - bb[1]) / 2); 1.3184 + for (var i = 0, ii = letters[length]; i < ii; i++) { 1.3185 + var prev = i && font.glyphs[letters[i - 1]] || {}, 1.3186 + curr = font.glyphs[letters[i]]; 1.3187 + shift += i ? (prev.w || font.w) + (prev.k && prev.k[letters[i]] || 0) : 0; 1.3188 + curr && curr.d && out[push](this.path(curr.d).attr({fill: "#000", stroke: "none", translation: [shift, 0]})); 1.3189 + } 1.3190 + out.scale(scale, scale, top, height).translate(x - top, y - height); 1.3191 + } 1.3192 + return out; 1.3193 + }; 1.3194 + 1.3195 + R.format = function (token) { 1.3196 + var args = R.is(arguments[1], "array") ? [0][concat](arguments[1]) : arguments, 1.3197 + rg = /\{(\d+)\}/g; 1.3198 + token && R.is(token, "string") && args[length] - 1 && (token = token[rp](rg, function (str, i) { 1.3199 + return args[++i] == null ? E : args[i]; 1.3200 + })); 1.3201 + return token || E; 1.3202 + }; 1.3203 + R.ninja = function () { 1.3204 + var r = win.Raphael, u; 1.3205 + if (oldRaphael.was) { 1.3206 + win.Raphael = oldRaphael.is; 1.3207 + } else { 1.3208 + try { 1.3209 + delete win.Raphael; 1.3210 + } catch (e) { 1.3211 + win.Raphael = u; 1.3212 + } 1.3213 + } 1.3214 + return r; 1.3215 + }; 1.3216 + R.el = Element[proto]; 1.3217 + return R; 1.3218 +})();