LaravelTest
8438 строк · 303.3 Кб
1// ┌───────────────────────────────────────────────────────────────────────────────────────────────────────┐ \\
2// │ Raphaël 2.3.0 - JavaScript Vector Library │ \\
3// ├───────────────────────────────────────────────────────────────────────────────────────────────────────┤ \\
4// │ Copyright © 2008-2016 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
5// │ Copyright © 2008-2016 Sencha Labs (http://sencha.com) │ \\
6// ├───────────────────────────────────────────────────────────────────────────────────────────────────────┤ \\
7// │ Licensed under the MIT (https://github.com/DmitryBaranovskiy/raphael/blob/master/license.txt) license.│ \\
8// └───────────────────────────────────────────────────────────────────────────────────────────────────────┘ \\
9
10(function webpackUniversalModuleDefinition(root, factory) {11if(typeof exports === 'object' && typeof module === 'object')12module.exports = factory();13else if(typeof define === 'function' && define.amd)14define([], factory);15else if(typeof exports === 'object')16exports["Raphael"] = factory();17else18root["Raphael"] = factory();19})(window, function() {20return /******/ (function(modules) { // webpackBootstrap21/******/ // The module cache22/******/ var installedModules = {};23/******/
24/******/ // The require function25/******/ function __webpack_require__(moduleId) {26/******/
27/******/ // Check if module is in cache28/******/ if(installedModules[moduleId]) {29/******/ return installedModules[moduleId].exports;30/******/ }31/******/ // Create a new module (and put it into the cache)32/******/ var module = installedModules[moduleId] = {33/******/ i: moduleId,34/******/ l: false,35/******/ exports: {}36/******/ };37/******/
38/******/ // Execute the module function39/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);40/******/
41/******/ // Flag the module as loaded42/******/ module.l = true;43/******/
44/******/ // Return the exports of the module45/******/ return module.exports;46/******/ }47/******/
48/******/
49/******/ // expose the modules object (__webpack_modules__)50/******/ __webpack_require__.m = modules;51/******/
52/******/ // expose the module cache53/******/ __webpack_require__.c = installedModules;54/******/
55/******/ // define getter function for harmony exports56/******/ __webpack_require__.d = function(exports, name, getter) {57/******/ if(!__webpack_require__.o(exports, name)) {58/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });59/******/ }60/******/ };61/******/
62/******/ // define __esModule on exports63/******/ __webpack_require__.r = function(exports) {64/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {65/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });66/******/ }67/******/ Object.defineProperty(exports, '__esModule', { value: true });68/******/ };69/******/
70/******/ // create a fake namespace object71/******/ // mode & 1: value is a module id, require it72/******/ // mode & 2: merge all properties of value into the ns73/******/ // mode & 4: return value when already ns object74/******/ // mode & 8|1: behave like require75/******/ __webpack_require__.t = function(value, mode) {76/******/ if(mode & 1) value = __webpack_require__(value);77/******/ if(mode & 8) return value;78/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;79/******/ var ns = Object.create(null);80/******/ __webpack_require__.r(ns);81/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });82/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));83/******/ return ns;84/******/ };85/******/
86/******/ // getDefaultExport function for compatibility with non-harmony modules87/******/ __webpack_require__.n = function(module) {88/******/ var getter = module && module.__esModule ?89/******/ function getDefault() { return module['default']; } :90/******/ function getModuleExports() { return module; };91/******/ __webpack_require__.d(getter, 'a', getter);92/******/ return getter;93/******/ };94/******/
95/******/ // Object.prototype.hasOwnProperty.call96/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };97/******/
98/******/ // __webpack_public_path__99/******/ __webpack_require__.p = "";100/******/
101/******/
102/******/ // Load entry module and return exports103/******/ return __webpack_require__(__webpack_require__.s = "./dev/raphael.amd.js");104/******/ })105/************************************************************************/
106/******/ ({107
108/***/ "./dev/raphael.amd.js":109/*!****************************!*\
110!*** ./dev/raphael.amd.js ***!
111\****************************/
112/*! no static exports found */
113/***/ (function(module, exports, __webpack_require__) {114
115var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./raphael.core */ "./dev/raphael.core.js"), __webpack_require__(/*! ./raphael.svg */ "./dev/raphael.svg.js"), __webpack_require__(/*! ./raphael.vml */ "./dev/raphael.vml.js")], __WEBPACK_AMD_DEFINE_RESULT__ = (function(R) {116
117return R;118
119}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),120__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));121
122/***/ }),123
124/***/ "./dev/raphael.core.js":125/*!*****************************!*\
126!*** ./dev/raphael.core.js ***!
127\*****************************/
128/*! no static exports found */
129/***/ (function(module, exports, __webpack_require__) {130
131var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! eve */ "./node_modules/eve-raphael/eve.js")], __WEBPACK_AMD_DEFINE_RESULT__ = (function(eve) {132
133/*\134* Raphael
135[ method ]
136**
137* Creates a canvas object on which to draw.
138* You must do this first, as all future calls to drawing methods
139* from this instance will be bound to this canvas.
140> Parameters
141**
142- container (HTMLElement|string) DOM element or its ID which is going to be a parent for drawing surface
143- width (number)
144- height (number)
145- callback (function) #optional callback function which is going to be executed in the context of newly created paper
146* or
147- x (number)
148- y (number)
149- width (number)
150- height (number)
151- callback (function) #optional callback function which is going to be executed in the context of newly created paper
152* or
153- all (array) (first 3 or 4 elements in the array are equal to [containerID, width, height] or [x, y, width, height]. The rest are element descriptions in format {type: type, <attributes>}). See @Paper.add.
154- callback (function) #optional callback function which is going to be executed in the context of newly created paper
155* or
156- onReadyCallback (function) function that is going to be called on DOM ready event. You can also subscribe to this event via Eve’s “DOMLoad” event. In this case method returns `undefined`.
157= (object) @Paper
158> Usage
159| // Each of the following examples create a canvas
160| // that is 320px wide by 200px high.
161| // Canvas is created at the viewport’s 10,50 coordinate.
162| var paper = Raphael(10, 50, 320, 200);
163| // Canvas is created at the top left corner of the #notepad element
164| // (or its top right corner in dir="rtl" elements)
165| var paper = Raphael(document.getElementById("notepad"), 320, 200);
166| // Same as above
167| var paper = Raphael("notepad", 320, 200);
168| // Image dump
169| var set = Raphael(["notepad", 320, 200, {
170| type: "rect",
171| x: 10,
172| y: 10,
173| width: 25,
174| height: 25,
175| stroke: "#f00"
176| }, {
177| type: "text",
178| x: 30,
179| y: 40,
180| text: "Dump"
181| }]);
182\*/
183function R(first) {184if (R.is(first, "function")) {185return loaded ? first() : eve.on("raphael.DOMload", first);186} else if (R.is(first, array)) {187return R._engine.create[apply](R, first.splice(0, 3 + R.is(first[0], nu))).add(first);188} else {189var args = Array.prototype.slice.call(arguments, 0);190if (R.is(args[args.length - 1], "function")) {191var f = args.pop();192return loaded ? f.call(R._engine.create[apply](R, args)) : eve.on("raphael.DOMload", function () {193f.call(R._engine.create[apply](R, args));194});195} else {196return R._engine.create[apply](R, arguments);197}198}199}200R.version = "2.3.0";201R.eve = eve;202var loaded,203separator = /[, ]+/,204elements = {circle: 1, rect: 1, path: 1, ellipse: 1, text: 1, image: 1},205formatrg = /\{(\d+)\}/g,206proto = "prototype",207has = "hasOwnProperty",208g = {209doc: document,210win: window211},212oldRaphael = {213was: Object.prototype[has].call(g.win, "Raphael"),214is: g.win.Raphael215},216Paper = function () {217/*\218* Paper.ca
219[ property (object) ]
220**
221* Shortcut for @Paper.customAttributes
222\*/
223/*\224* Paper.customAttributes
225[ property (object) ]
226**
227* If you have a set of attributes that you would like to represent
228* as a function of some number you can do it easily with custom attributes:
229> Usage
230| paper.customAttributes.hue = function (num) {
231| num = num % 1;
232| return {fill: "hsb(" + num + ", 0.75, 1)"};
233| };
234| // Custom attribute “hue” will change fill
235| // to be given hue with fixed saturation and brightness.
236| // Now you can use it like this:
237| var c = paper.circle(10, 10, 10).attr({hue: .45});
238| // or even like this:
239| c.animate({hue: 1}, 1e3);
240|
241| // You could also create custom attribute
242| // with multiple parameters:
243| paper.customAttributes.hsb = function (h, s, b) {
244| return {fill: "hsb(" + [h, s, b].join(",") + ")"};
245| };
246| c.attr({hsb: "0.5 .8 1"});
247| c.animate({hsb: [1, 0, 0.5]}, 1e3);
248\*/
249this.ca = this.customAttributes = {};250},251paperproto,252appendChild = "appendChild",253apply = "apply",254concat = "concat",255//taken from Modernizr touch test: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js#L40256supportsTouch = ('ontouchstart' in window) || window.TouchEvent || window.DocumentTouch && document instanceof DocumentTouch,257E = "",258S = " ",259Str = String,260split = "split",261events = "click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend touchcancel"[split](S),262touchMap = {263mousedown: "touchstart",264mousemove: "touchmove",265mouseup: "touchend"266},267lowerCase = Str.prototype.toLowerCase,268math = Math,269mmax = math.max,270mmin = math.min,271abs = math.abs,272pow = math.pow,273PI = math.PI,274nu = "number",275string = "string",276array = "array",277toString = "toString",278fillString = "fill",279objectToString = Object.prototype.toString,280paper = {},281push = "push",282ISURL = R._ISURL = /^url\(['"]?(.+?)['"]?\)$/i,283colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,284isnan = {"NaN": 1, "Infinity": 1, "-Infinity": 1},285bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,286round = math.round,287setAttribute = "setAttribute",288toFloat = parseFloat,289toInt = parseInt,290upperCase = Str.prototype.toUpperCase,291availableAttrs = R._availableAttrs = {292"arrow-end": "none",293"arrow-start": "none",294blur: 0,295"clip-rect": "0 0 1e9 1e9",296cursor: "default",297cx: 0,298cy: 0,299fill: "#fff",300"fill-opacity": 1,301font: '10px "Arial"',302"font-family": '"Arial"',303"font-size": "10",304"font-style": "normal",305"font-weight": 400,306gradient: 0,307height: 0,308href: "http://raphaeljs.com/",309"letter-spacing": 0,310opacity: 1,311path: "M0,0",312r: 0,313rx: 0,314ry: 0,315src: "",316stroke: "#000",317"stroke-dasharray": "",318"stroke-linecap": "butt",319"stroke-linejoin": "butt",320"stroke-miterlimit": 0,321"stroke-opacity": 1,322"stroke-width": 1,323target: "_blank",324"text-anchor": "middle",325title: "Raphael",326transform: "",327width: 0,328x: 0,329y: 0,330"class": ""331},332availableAnimAttrs = R._availableAnimAttrs = {333blur: nu,334"clip-rect": "csv",335cx: nu,336cy: nu,337fill: "colour",338"fill-opacity": nu,339"font-size": nu,340height: nu,341opacity: nu,342path: "path",343r: nu,344rx: nu,345ry: nu,346stroke: "colour",347"stroke-opacity": nu,348"stroke-width": nu,349transform: "transform",350width: nu,351x: nu,352y: nu353},354whitespace = /[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]/g,355commaSpaces = /[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/,356hsrg = {hs: 1, rg: 1},357p2s = /,?([achlmqrstvxz]),?/gi,358pathCommand = /([achlmrqstvz])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/ig,359tCommand = /([rstm])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/ig,360pathValues = /(-?\d*\.?\d*(?:e[\-+]?\d+)?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/ig,361radial_gradient = R._radial_gradient = /^r(?:\(([^,]+?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*([^\)]+?)\))?/,362eldata = {},363sortByKey = function (a, b) {364return a.key - b.key;365},366sortByNumber = function (a, b) {367return toFloat(a) - toFloat(b);368},369fun = function () {},370pipe = function (x) {371return x;372},373rectPath = R._rectPath = function (x, y, w, h, r) {374if (r) {375return [["M", x + r, y], ["l", w - r * 2, 0], ["a", r, r, 0, 0, 1, r, r], ["l", 0, h - r * 2], ["a", r, r, 0, 0, 1, -r, r], ["l", r * 2 - w, 0], ["a", r, r, 0, 0, 1, -r, -r], ["l", 0, r * 2 - h], ["a", r, r, 0, 0, 1, r, -r], ["z"]];376}377return [["M", x, y], ["l", w, 0], ["l", 0, h], ["l", -w, 0], ["z"]];378},379ellipsePath = function (x, y, rx, ry) {380if (ry == null) {381ry = rx;382}383return [["M", x, y], ["m", 0, -ry], ["a", rx, ry, 0, 1, 1, 0, 2 * ry], ["a", rx, ry, 0, 1, 1, 0, -2 * ry], ["z"]];384},385getPath = R._getPath = {386path: function (el) {387return el.attr("path");388},389circle: function (el) {390var a = el.attrs;391return ellipsePath(a.cx, a.cy, a.r);392},393ellipse: function (el) {394var a = el.attrs;395return ellipsePath(a.cx, a.cy, a.rx, a.ry);396},397rect: function (el) {398var a = el.attrs;399return rectPath(a.x, a.y, a.width, a.height, a.r);400},401image: function (el) {402var a = el.attrs;403return rectPath(a.x, a.y, a.width, a.height);404},405text: function (el) {406var bbox = el._getBBox();407return rectPath(bbox.x, bbox.y, bbox.width, bbox.height);408},409set : function(el) {410var bbox = el._getBBox();411return rectPath(bbox.x, bbox.y, bbox.width, bbox.height);412}413},414/*\415* Raphael.mapPath
416[ method ]
417**
418* Transform the path string with given matrix.
419> Parameters
420- path (string) path string
421- matrix (object) see @Matrix
422= (string) transformed path string
423\*/
424mapPath = R.mapPath = function (path, matrix) {425if (!matrix) {426return path;427}428var x, y, i, j, ii, jj, pathi;429path = path2curve(path);430for (i = 0, ii = path.length; i < ii; i++) {431pathi = path[i];432for (j = 1, jj = pathi.length; j < jj; j += 2) {433x = matrix.x(pathi[j], pathi[j + 1]);434y = matrix.y(pathi[j], pathi[j + 1]);435pathi[j] = x;436pathi[j + 1] = y;437}438}439return path;440};441
442R._g = g;443/*\444* Raphael.type
445[ property (string) ]
446**
447* Can be “SVG”, “VML” or empty, depending on browser support.
448\*/
449R.type = (g.win.SVGAngle || g.doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML");450if (R.type == "VML") {451var d = g.doc.createElement("div"),452b;453d.innerHTML = '<v:shape adj="1"/>';454b = d.firstChild;455b.style.behavior = "url(#default#VML)";456if (!(b && typeof b.adj == "object")) {457return (R.type = E);458}459d = null;460}461/*\462* Raphael.svg
463[ property (boolean) ]
464**
465* `true` if browser supports SVG.
466\*/
467/*\468* Raphael.vml
469[ property (boolean) ]
470**
471* `true` if browser supports VML.
472\*/
473R.svg = !(R.vml = R.type == "VML");474R._Paper = Paper;475/*\476* Raphael.fn
477[ property (object) ]
478**
479* You can add your own method to the canvas. For example if you want to draw a pie chart,
480* you can create your own pie chart function and ship it as a Raphaël plugin. To do this
481* you need to extend the `Raphael.fn` object. You should modify the `fn` object before a
482* Raphaël instance is created, otherwise it will take no effect. Please note that the
483* ability for namespaced plugins was removed in Raphael 2.0. It is up to the plugin to
484* ensure any namespacing ensures proper context.
485> Usage
486| Raphael.fn.arrow = function (x1, y1, x2, y2, size) {
487| return this.path( ... );
488| };
489| // or create namespace
490| Raphael.fn.mystuff = {
491| arrow: function () {…},
492| star: function () {…},
493| // etc…
494| };
495| var paper = Raphael(10, 10, 630, 480);
496| // then use it
497| paper.arrow(10, 10, 30, 30, 5).attr({fill: "#f00"});
498| paper.mystuff.arrow();
499| paper.mystuff.star();
500\*/
501R.fn = paperproto = Paper.prototype = R.prototype;502R._id = 0;503/*\504* Raphael.is
505[ method ]
506**
507* Handful of replacements for `typeof` operator.
508> Parameters
509- o (…) any object or primitive
510- type (string) name of the type, i.e. “string”, “function”, “number”, etc.
511= (boolean) is given value is of given type
512\*/
513R.is = function (o, type) {514type = lowerCase.call(type);515if (type == "finite") {516return !isnan[has](+o);517}518if (type == "array") {519return o instanceof Array;520}521return (type == "null" && o === null) ||522(type == typeof o && o !== null) ||523(type == "object" && o === Object(o)) ||524(type == "array" && Array.isArray && Array.isArray(o)) ||525objectToString.call(o).slice(8, -1).toLowerCase() == type;526};527
528function clone(obj) {529if (typeof obj == "function" || Object(obj) !== obj) {530return obj;531}532var res = new obj.constructor;533for (var key in obj) if (obj[has](key)) {534res[key] = clone(obj[key]);535}536return res;537}538
539/*\540* Raphael.angle
541[ method ]
542**
543* Returns angle between two or three points
544> Parameters
545- x1 (number) x coord of first point
546- y1 (number) y coord of first point
547- x2 (number) x coord of second point
548- y2 (number) y coord of second point
549- x3 (number) #optional x coord of third point
550- y3 (number) #optional y coord of third point
551= (number) angle in degrees.
552\*/
553R.angle = function (x1, y1, x2, y2, x3, y3) {554if (x3 == null) {555var x = x1 - x2,556y = y1 - y2;557if (!x && !y) {558return 0;559}560return (180 + math.atan2(-y, -x) * 180 / PI + 360) % 360;561} else {562return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3);563}564};565/*\566* Raphael.rad
567[ method ]
568**
569* Transform angle to radians
570> Parameters
571- deg (number) angle in degrees
572= (number) angle in radians.
573\*/
574R.rad = function (deg) {575return deg % 360 * PI / 180;576};577/*\578* Raphael.deg
579[ method ]
580**
581* Transform angle to degrees
582> Parameters
583- rad (number) angle in radians
584= (number) angle in degrees.
585\*/
586R.deg = function (rad) {587return Math.round ((rad * 180 / PI% 360)* 1000) / 1000;588};589/*\590* Raphael.snapTo
591[ method ]
592**
593* Snaps given value to given grid.
594> Parameters
595- values (array|number) given array of values or step of the grid
596- value (number) value to adjust
597- tolerance (number) #optional tolerance for snapping. Default is `10`.
598= (number) adjusted value.
599\*/
600R.snapTo = function (values, value, tolerance) {601tolerance = R.is(tolerance, "finite") ? tolerance : 10;602if (R.is(values, array)) {603var i = values.length;604while (i--) if (abs(values[i] - value) <= tolerance) {605return values[i];606}607} else {608values = +values;609var rem = value % values;610if (rem < tolerance) {611return value - rem;612}613if (rem > values - tolerance) {614return value - rem + values;615}616}617return value;618};619
620/*\621* Raphael.createUUID
622[ method ]
623**
624* Returns RFC4122, version 4 ID
625\*/
626var createUUID = R.createUUID = (function (uuidRegEx, uuidReplacer) {627return function () {628return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx, uuidReplacer).toUpperCase();629};630})(/[xy]/g, function (c) {631var r = math.random() * 16 | 0,632v = c == "x" ? r : (r & 3 | 8);633return v.toString(16);634});635
636/*\637* Raphael.setWindow
638[ method ]
639**
640* Used when you need to draw in `<iframe>`. Switched window to the iframe one.
641> Parameters
642- newwin (window) new window object
643\*/
644R.setWindow = function (newwin) {645eve("raphael.setWindow", R, g.win, newwin);646g.win = newwin;647g.doc = g.win.document;648if (R._engine.initWin) {649R._engine.initWin(g.win);650}651};652var toHex = function (color) {653if (R.vml) {654// http://dean.edwards.name/weblog/2009/10/convert-any-colour-value-to-hex-in-msie/655var trim = /^\s+|\s+$/g;656var bod;657try {658var docum = new ActiveXObject("htmlfile");659docum.write("<body>");660docum.close();661bod = docum.body;662} catch(e) {663bod = createPopup().document.body;664}665var range = bod.createTextRange();666toHex = cacher(function (color) {667try {668bod.style.color = Str(color).replace(trim, E);669var value = range.queryCommandValue("ForeColor");670value = ((value & 255) << 16) | (value & 65280) | ((value & 16711680) >>> 16);671return "#" + ("000000" + value.toString(16)).slice(-6);672} catch(e) {673return "none";674}675});676} else {677var i = g.doc.createElement("i");678i.title = "Rapha\xebl Colour Picker";679i.style.display = "none";680g.doc.body.appendChild(i);681toHex = cacher(function (color) {682i.style.color = color;683return g.doc.defaultView.getComputedStyle(i, E).getPropertyValue("color");684});685}686return toHex(color);687},688hsbtoString = function () {689return "hsb(" + [this.h, this.s, this.b] + ")";690},691hsltoString = function () {692return "hsl(" + [this.h, this.s, this.l] + ")";693},694rgbtoString = function () {695return this.hex;696},697prepareRGB = function (r, g, b) {698if (g == null && R.is(r, "object") && "r" in r && "g" in r && "b" in r) {699b = r.b;700g = r.g;701r = r.r;702}703if (g == null && R.is(r, string)) {704var clr = R.getRGB(r);705r = clr.r;706g = clr.g;707b = clr.b;708}709if (r > 1 || g > 1 || b > 1) {710r /= 255;711g /= 255;712b /= 255;713}714
715return [r, g, b];716},717packageRGB = function (r, g, b, o) {718r *= 255;719g *= 255;720b *= 255;721var rgb = {722r: r,723g: g,724b: b,725hex: R.rgb(r, g, b),726toString: rgbtoString727};728R.is(o, "finite") && (rgb.opacity = o);729return rgb;730};731
732/*\733* Raphael.color
734[ method ]
735**
736* Parses the color string and returns object with all values for the given color.
737> Parameters
738- clr (string) color string in one of the supported formats (see @Raphael.getRGB)
739= (object) Combined RGB & HSB object in format:
740o {
741o r (number) red,
742o g (number) green,
743o b (number) blue,
744o hex (string) color in HTML/CSS format: #••••••,
745o error (boolean) `true` if string can’t be parsed,
746o h (number) hue,
747o s (number) saturation,
748o v (number) value (brightness),
749o l (number) lightness
750o }
751\*/
752R.color = function (clr) {753var rgb;754if (R.is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) {755rgb = R.hsb2rgb(clr);756clr.r = rgb.r;757clr.g = rgb.g;758clr.b = rgb.b;759clr.hex = rgb.hex;760} else if (R.is(clr, "object") && "h" in clr && "s" in clr && "l" in clr) {761rgb = R.hsl2rgb(clr);762clr.r = rgb.r;763clr.g = rgb.g;764clr.b = rgb.b;765clr.hex = rgb.hex;766} else {767if (R.is(clr, "string")) {768clr = R.getRGB(clr);769}770if (R.is(clr, "object") && "r" in clr && "g" in clr && "b" in clr) {771rgb = R.rgb2hsl(clr);772clr.h = rgb.h;773clr.s = rgb.s;774clr.l = rgb.l;775rgb = R.rgb2hsb(clr);776clr.v = rgb.b;777} else {778clr = {hex: "none"};779clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1;780}781}782clr.toString = rgbtoString;783return clr;784};785/*\786* Raphael.hsb2rgb
787[ method ]
788**
789* Converts HSB values to RGB object.
790> Parameters
791- h (number) hue
792- s (number) saturation
793- v (number) value or brightness
794= (object) RGB object in format:
795o {
796o r (number) red,
797o g (number) green,
798o b (number) blue,
799o hex (string) color in HTML/CSS format: #••••••
800o }
801\*/
802R.hsb2rgb = function (h, s, v, o) {803if (this.is(h, "object") && "h" in h && "s" in h && "b" in h) {804v = h.b;805s = h.s;806o = h.o;807h = h.h;808}809h *= 360;810var R, G, B, X, C;811h = (h % 360) / 60;812C = v * s;813X = C * (1 - abs(h % 2 - 1));814R = G = B = v - C;815
816h = ~~h;817R += [C, X, 0, 0, X, C][h];818G += [X, C, C, X, 0, 0][h];819B += [0, 0, X, C, C, X][h];820return packageRGB(R, G, B, o);821};822/*\823* Raphael.hsl2rgb
824[ method ]
825**
826* Converts HSL values to RGB object.
827> Parameters
828- h (number) hue
829- s (number) saturation
830- l (number) luminosity
831= (object) RGB object in format:
832o {
833o r (number) red,
834o g (number) green,
835o b (number) blue,
836o hex (string) color in HTML/CSS format: #••••••
837o }
838\*/
839R.hsl2rgb = function (h, s, l, o) {840if (this.is(h, "object") && "h" in h && "s" in h && "l" in h) {841l = h.l;842s = h.s;843h = h.h;844}845if (h > 1 || s > 1 || l > 1) {846h /= 360;847s /= 100;848l /= 100;849}850h *= 360;851var R, G, B, X, C;852h = (h % 360) / 60;853C = 2 * s * (l < .5 ? l : 1 - l);854X = C * (1 - abs(h % 2 - 1));855R = G = B = l - C / 2;856
857h = ~~h;858R += [C, X, 0, 0, X, C][h];859G += [X, C, C, X, 0, 0][h];860B += [0, 0, X, C, C, X][h];861return packageRGB(R, G, B, o);862};863/*\864* Raphael.rgb2hsb
865[ method ]
866**
867* Converts RGB values to HSB object.
868> Parameters
869- r (number) red
870- g (number) green
871- b (number) blue
872= (object) HSB object in format:
873o {
874o h (number) hue
875o s (number) saturation
876o b (number) brightness
877o }
878\*/
879R.rgb2hsb = function (r, g, b) {880b = prepareRGB(r, g, b);881r = b[0];882g = b[1];883b = b[2];884
885var H, S, V, C;886V = mmax(r, g, b);887C = V - mmin(r, g, b);888H = (C == 0 ? null :889V == r ? (g - b) / C :890V == g ? (b - r) / C + 2 :891(r - g) / C + 4892);893H = ((H + 360) % 6) * 60 / 360;894S = C == 0 ? 0 : C / V;895return {h: H, s: S, b: V, toString: hsbtoString};896};897/*\898* Raphael.rgb2hsl
899[ method ]
900**
901* Converts RGB values to HSL object.
902> Parameters
903- r (number) red
904- g (number) green
905- b (number) blue
906= (object) HSL object in format:
907o {
908o h (number) hue
909o s (number) saturation
910o l (number) luminosity
911o }
912\*/
913R.rgb2hsl = function (r, g, b) {914b = prepareRGB(r, g, b);915r = b[0];916g = b[1];917b = b[2];918
919var H, S, L, M, m, C;920M = mmax(r, g, b);921m = mmin(r, g, b);922C = M - m;923H = (C == 0 ? null :924M == r ? (g - b) / C :925M == g ? (b - r) / C + 2 :926(r - g) / C + 4);927H = ((H + 360) % 6) * 60 / 360;928L = (M + m) / 2;929S = (C == 0 ? 0 :930L < .5 ? C / (2 * L) :931C / (2 - 2 * L));932return {h: H, s: S, l: L, toString: hsltoString};933};934R._path2string = function () {935return this.join(",").replace(p2s, "$1");936};937function repush(array, item) {938for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) {939return array.push(array.splice(i, 1)[0]);940}941}942function cacher(f, scope, postprocessor) {943function newf() {944var arg = Array.prototype.slice.call(arguments, 0),945args = arg.join("\u2400"),946cache = newf.cache = newf.cache || {},947count = newf.count = newf.count || [];948if (cache[has](args)) {949repush(count, args);950return postprocessor ? postprocessor(cache[args]) : cache[args];951}952count.length >= 1e3 && delete cache[count.shift()];953count.push(args);954cache[args] = f[apply](scope, arg);955return postprocessor ? postprocessor(cache[args]) : cache[args];956}957return newf;958}959
960var preload = R._preload = function (src, f) {961var img = g.doc.createElement("img");962img.style.cssText = "position:absolute;left:-9999em;top:-9999em";963img.onload = function () {964f.call(this);965this.onload = null;966g.doc.body.removeChild(this);967};968img.onerror = function () {969g.doc.body.removeChild(this);970};971g.doc.body.appendChild(img);972img.src = src;973};974
975function clrToString() {976return this.hex;977}978
979/*\980* Raphael.getRGB
981[ method ]
982**
983* Parses colour string as RGB object
984> Parameters
985- colour (string) colour string in one of formats:
986# <ul>
987# <li>Colour name (“<code>red</code>”, “<code>green</code>”, “<code>cornflowerblue</code>”, etc)</li>
988# <li>#••• — shortened HTML colour: (“<code>#000</code>”, “<code>#fc0</code>”, etc)</li>
989# <li>#•••••• — full length HTML colour: (“<code>#000000</code>”, “<code>#bd2300</code>”)</li>
990# <li>rgb(•••, •••, •••) — red, green and blue channels’ values: (“<code>rgb(200, 100, 0)</code>”)</li>
991# <li>rgb(•••%, •••%, •••%) — same as above, but in %: (“<code>rgb(100%, 175%, 0%)</code>”)</li>
992# <li>hsb(•••, •••, •••) — hue, saturation and brightness values: (“<code>hsb(0.5, 0.25, 1)</code>”)</li>
993# <li>hsb(•••%, •••%, •••%) — same as above, but in %</li>
994# <li>hsl(•••, •••, •••) — same as hsb</li>
995# <li>hsl(•••%, •••%, •••%) — same as hsb</li>
996# </ul>
997= (object) RGB object in format:
998o {
999o r (number) red,
1000o g (number) green,
1001o b (number) blue
1002o hex (string) color in HTML/CSS format: #••••••,
1003o error (boolean) true if string can’t be parsed
1004o }
1005\*/
1006R.getRGB = cacher(function (colour) {1007if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) {1008return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString};1009}1010if (colour == "none") {1011return {r: -1, g: -1, b: -1, hex: "none", toString: clrToString};1012}1013!(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() == "#") && (colour = toHex(colour));1014var res,1015red,1016green,1017blue,1018opacity,1019t,1020values,1021rgb = colour.match(colourRegExp);1022if (rgb) {1023if (rgb[2]) {1024blue = toInt(rgb[2].substring(5), 16);1025green = toInt(rgb[2].substring(3, 5), 16);1026red = toInt(rgb[2].substring(1, 3), 16);1027}1028if (rgb[3]) {1029blue = toInt((t = rgb[3].charAt(3)) + t, 16);1030green = toInt((t = rgb[3].charAt(2)) + t, 16);1031red = toInt((t = rgb[3].charAt(1)) + t, 16);1032}1033if (rgb[4]) {1034values = rgb[4][split](commaSpaces);1035red = toFloat(values[0]);1036values[0].slice(-1) == "%" && (red *= 2.55);1037green = toFloat(values[1]);1038values[1].slice(-1) == "%" && (green *= 2.55);1039blue = toFloat(values[2]);1040values[2].slice(-1) == "%" && (blue *= 2.55);1041rgb[1].toLowerCase().slice(0, 4) == "rgba" && (opacity = toFloat(values[3]));1042values[3] && values[3].slice(-1) == "%" && (opacity /= 100);1043}1044if (rgb[5]) {1045values = rgb[5][split](commaSpaces);1046red = toFloat(values[0]);1047values[0].slice(-1) == "%" && (red *= 2.55);1048green = toFloat(values[1]);1049values[1].slice(-1) == "%" && (green *= 2.55);1050blue = toFloat(values[2]);1051values[2].slice(-1) == "%" && (blue *= 2.55);1052(values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);1053rgb[1].toLowerCase().slice(0, 4) == "hsba" && (opacity = toFloat(values[3]));1054values[3] && values[3].slice(-1) == "%" && (opacity /= 100);1055return R.hsb2rgb(red, green, blue, opacity);1056}1057if (rgb[6]) {1058values = rgb[6][split](commaSpaces);1059red = toFloat(values[0]);1060values[0].slice(-1) == "%" && (red *= 2.55);1061green = toFloat(values[1]);1062values[1].slice(-1) == "%" && (green *= 2.55);1063blue = toFloat(values[2]);1064values[2].slice(-1) == "%" && (blue *= 2.55);1065(values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);1066rgb[1].toLowerCase().slice(0, 4) == "hsla" && (opacity = toFloat(values[3]));1067values[3] && values[3].slice(-1) == "%" && (opacity /= 100);1068return R.hsl2rgb(red, green, blue, opacity);1069}1070rgb = {r: red, g: green, b: blue, toString: clrToString};1071rgb.hex = "#" + (16777216 | blue | (green << 8) | (red << 16)).toString(16).slice(1);1072R.is(opacity, "finite") && (rgb.opacity = opacity);1073return rgb;1074}1075return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString};1076}, R);1077/*\1078* Raphael.hsb
1079[ method ]
1080**
1081* Converts HSB values to hex representation of the colour.
1082> Parameters
1083- h (number) hue
1084- s (number) saturation
1085- b (number) value or brightness
1086= (string) hex representation of the colour.
1087\*/
1088R.hsb = cacher(function (h, s, b) {1089return R.hsb2rgb(h, s, b).hex;1090});1091/*\1092* Raphael.hsl
1093[ method ]
1094**
1095* Converts HSL values to hex representation of the colour.
1096> Parameters
1097- h (number) hue
1098- s (number) saturation
1099- l (number) luminosity
1100= (string) hex representation of the colour.
1101\*/
1102R.hsl = cacher(function (h, s, l) {1103return R.hsl2rgb(h, s, l).hex;1104});1105/*\1106* Raphael.rgb
1107[ method ]
1108**
1109* Converts RGB values to hex representation of the colour.
1110> Parameters
1111- r (number) red
1112- g (number) green
1113- b (number) blue
1114= (string) hex representation of the colour.
1115\*/
1116R.rgb = cacher(function (r, g, b) {1117function round(x) { return (x + 0.5) | 0; }1118return "#" + (16777216 | round(b) | (round(g) << 8) | (round(r) << 16)).toString(16).slice(1);1119});1120/*\1121* Raphael.getColor
1122[ method ]
1123**
1124* On each call returns next colour in the spectrum. To reset it back to red call @Raphael.getColor.reset
1125> Parameters
1126- value (number) #optional brightness, default is `0.75`
1127= (string) hex representation of the colour.
1128\*/
1129R.getColor = function (value) {1130var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75},1131rgb = this.hsb2rgb(start.h, start.s, start.b);1132start.h += .075;1133if (start.h > 1) {1134start.h = 0;1135start.s -= .2;1136start.s <= 0 && (this.getColor.start = {h: 0, s: 1, b: start.b});1137}1138return rgb.hex;1139};1140/*\1141* Raphael.getColor.reset
1142[ method ]
1143**
1144* Resets spectrum position for @Raphael.getColor back to red.
1145\*/
1146R.getColor.reset = function () {1147delete this.start;1148};1149
1150// http://schepers.cc/getting-to-the-point1151function catmullRom2bezier(crp, z) {1152var d = [];1153for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {1154var p = [1155{x: +crp[i - 2], y: +crp[i - 1]},1156{x: +crp[i], y: +crp[i + 1]},1157{x: +crp[i + 2], y: +crp[i + 3]},1158{x: +crp[i + 4], y: +crp[i + 5]}1159];1160if (z) {1161if (!i) {1162p[0] = {x: +crp[iLen - 2], y: +crp[iLen - 1]};1163} else if (iLen - 4 == i) {1164p[3] = {x: +crp[0], y: +crp[1]};1165} else if (iLen - 2 == i) {1166p[2] = {x: +crp[0], y: +crp[1]};1167p[3] = {x: +crp[2], y: +crp[3]};1168}1169} else {1170if (iLen - 4 == i) {1171p[3] = p[2];1172} else if (!i) {1173p[0] = {x: +crp[i], y: +crp[i + 1]};1174}1175}1176d.push(["C",1177(-p[0].x + 6 * p[1].x + p[2].x) / 6,1178(-p[0].y + 6 * p[1].y + p[2].y) / 6,1179(p[1].x + 6 * p[2].x - p[3].x) / 6,1180(p[1].y + 6*p[2].y - p[3].y) / 6,1181p[2].x,1182p[2].y1183]);1184}1185
1186return d;1187}1188/*\1189* Raphael.parsePathString
1190[ method ]
1191**
1192* Utility method
1193**
1194* Parses given path string into an array of arrays of path segments.
1195> Parameters
1196- pathString (string|array) path string or array of segments (in the last case it will be returned straight away)
1197= (array) array of segments.
1198\*/
1199R.parsePathString = function (pathString) {1200if (!pathString) {1201return null;1202}1203var pth = paths(pathString);1204if (pth.arr) {1205return pathClone(pth.arr);1206}1207
1208var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0},1209data = [];1210if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption1211data = pathClone(pathString);1212}1213if (!data.length) {1214Str(pathString).replace(pathCommand, function (a, b, c) {1215var params = [],1216name = b.toLowerCase();1217c.replace(pathValues, function (a, b) {1218b && params.push(+b);1219});1220if (name == "m" && params.length > 2) {1221data.push([b][concat](params.splice(0, 2)));1222name = "l";1223b = b == "m" ? "l" : "L";1224}1225if (name == "r") {1226data.push([b][concat](params));1227} else while (params.length >= paramCounts[name]) {1228data.push([b][concat](params.splice(0, paramCounts[name])));1229if (!paramCounts[name]) {1230break;1231}1232}1233});1234}1235data.toString = R._path2string;1236pth.arr = pathClone(data);1237return data;1238};1239/*\1240* Raphael.parseTransformString
1241[ method ]
1242**
1243* Utility method
1244**
1245* Parses given path string into an array of transformations.
1246> Parameters
1247- TString (string|array) transform string or array of transformations (in the last case it will be returned straight away)
1248= (array) array of transformations.
1249\*/
1250R.parseTransformString = cacher(function (TString) {1251if (!TString) {1252return null;1253}1254var paramCounts = {r: 3, s: 4, t: 2, m: 6},1255data = [];1256if (R.is(TString, array) && R.is(TString[0], array)) { // rough assumption1257data = pathClone(TString);1258}1259if (!data.length) {1260Str(TString).replace(tCommand, function (a, b, c) {1261var params = [],1262name = lowerCase.call(b);1263c.replace(pathValues, function (a, b) {1264b && params.push(+b);1265});1266data.push([b][concat](params));1267});1268}1269data.toString = R._path2string;1270return data;1271}, this, function(elem) {1272if (!elem) return elem;1273var newData = [];1274for (var i = 0; i < elem.length; i++) {1275var newLevel = [];1276for (var j = 0; j < elem[i].length; j++) {1277newLevel.push(elem[i][j]);1278}1279newData.push(newLevel);1280}1281return newData; } );1282// PATHS1283var paths = function (ps) {1284var p = paths.ps = paths.ps || {};1285if (p[ps]) {1286p[ps].sleep = 100;1287} else {1288p[ps] = {1289sleep: 1001290};1291}1292setTimeout(function () {1293for (var key in p) if (p[has](key) && key != ps) {1294p[key].sleep--;1295!p[key].sleep && delete p[key];1296}1297});1298return p[ps];1299};1300/*\1301* Raphael.findDotsAtSegment
1302[ method ]
1303**
1304* Utility method
1305**
1306* Find dot coordinates on the given cubic bezier curve at the given t.
1307> Parameters
1308- p1x (number) x of the first point of the curve
1309- p1y (number) y of the first point of the curve
1310- c1x (number) x of the first anchor of the curve
1311- c1y (number) y of the first anchor of the curve
1312- c2x (number) x of the second anchor of the curve
1313- c2y (number) y of the second anchor of the curve
1314- p2x (number) x of the second point of the curve
1315- p2y (number) y of the second point of the curve
1316- t (number) position on the curve (0..1)
1317= (object) point information in format:
1318o {
1319o x: (number) x coordinate of the point
1320o y: (number) y coordinate of the point
1321o m: {
1322o x: (number) x coordinate of the left anchor
1323o y: (number) y coordinate of the left anchor
1324o }
1325o n: {
1326o x: (number) x coordinate of the right anchor
1327o y: (number) y coordinate of the right anchor
1328o }
1329o start: {
1330o x: (number) x coordinate of the start of the curve
1331o y: (number) y coordinate of the start of the curve
1332o }
1333o end: {
1334o x: (number) x coordinate of the end of the curve
1335o y: (number) y coordinate of the end of the curve
1336o }
1337o alpha: (number) angle of the curve derivative at the point
1338o }
1339\*/
1340R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {1341var t1 = 1 - t,1342t13 = pow(t1, 3),1343t12 = pow(t1, 2),1344t2 = t * t,1345t3 = t2 * t,1346x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x,1347y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y,1348mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x),1349my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y),1350nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x),1351ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y),1352ax = t1 * p1x + t * c1x,1353ay = t1 * p1y + t * c1y,1354cx = t1 * c2x + t * p2x,1355cy = t1 * c2y + t * p2y,1356alpha = (90 - math.atan2(mx - nx, my - ny) * 180 / PI);1357(mx > nx || my < ny) && (alpha += 180);1358return {1359x: x,1360y: y,1361m: {x: mx, y: my},1362n: {x: nx, y: ny},1363start: {x: ax, y: ay},1364end: {x: cx, y: cy},1365alpha: alpha1366};1367};1368/*\1369* Raphael.bezierBBox
1370[ method ]
1371**
1372* Utility method
1373**
1374* Return bounding box of a given cubic bezier curve
1375> Parameters
1376- p1x (number) x of the first point of the curve
1377- p1y (number) y of the first point of the curve
1378- c1x (number) x of the first anchor of the curve
1379- c1y (number) y of the first anchor of the curve
1380- c2x (number) x of the second anchor of the curve
1381- c2y (number) y of the second anchor of the curve
1382- p2x (number) x of the second point of the curve
1383- p2y (number) y of the second point of the curve
1384* or
1385- bez (array) array of six points for bezier curve
1386= (object) point information in format:
1387o {
1388o min: {
1389o x: (number) x coordinate of the left point
1390o y: (number) y coordinate of the top point
1391o }
1392o max: {
1393o x: (number) x coordinate of the right point
1394o y: (number) y coordinate of the bottom point
1395o }
1396o }
1397\*/
1398R.bezierBBox = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {1399if (!R.is(p1x, "array")) {1400p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];1401}1402var bbox = curveDim.apply(null, p1x);1403return {1404x: bbox.min.x,1405y: bbox.min.y,1406x2: bbox.max.x,1407y2: bbox.max.y,1408width: bbox.max.x - bbox.min.x,1409height: bbox.max.y - bbox.min.y1410};1411};1412/*\1413* Raphael.isPointInsideBBox
1414[ method ]
1415**
1416* Utility method
1417**
1418* Returns `true` if given point is inside bounding boxes.
1419> Parameters
1420- bbox (string) bounding box
1421- x (string) x coordinate of the point
1422- y (string) y coordinate of the point
1423= (boolean) `true` if point inside
1424\*/
1425R.isPointInsideBBox = function (bbox, x, y) {1426return x >= bbox.x && x <= bbox.x2 && y >= bbox.y && y <= bbox.y2;1427};1428/*\1429* Raphael.isBBoxIntersect
1430[ method ]
1431**
1432* Utility method
1433**
1434* Returns `true` if two bounding boxes intersect
1435> Parameters
1436- bbox1 (string) first bounding box
1437- bbox2 (string) second bounding box
1438= (boolean) `true` if they intersect
1439\*/
1440R.isBBoxIntersect = function (bbox1, bbox2) {1441var i = R.isPointInsideBBox;1442return i(bbox2, bbox1.x, bbox1.y)1443|| i(bbox2, bbox1.x2, bbox1.y)1444|| i(bbox2, bbox1.x, bbox1.y2)1445|| i(bbox2, bbox1.x2, bbox1.y2)1446|| i(bbox1, bbox2.x, bbox2.y)1447|| i(bbox1, bbox2.x2, bbox2.y)1448|| i(bbox1, bbox2.x, bbox2.y2)1449|| i(bbox1, bbox2.x2, bbox2.y2)1450|| (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x)1451&& (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);1452};1453function base3(t, p1, p2, p3, p4) {1454var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4,1455t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;1456return t * t2 - 3 * p1 + 3 * p2;1457}1458function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {1459if (z == null) {1460z = 1;1461}1462z = z > 1 ? 1 : z < 0 ? 0 : z;1463var z2 = z / 2,1464n = 12,1465Tvalues = [-0.1252,0.1252,-0.3678,0.3678,-0.5873,0.5873,-0.7699,0.7699,-0.9041,0.9041,-0.9816,0.9816],1466Cvalues = [0.2491,0.2491,0.2335,0.2335,0.2032,0.2032,0.1601,0.1601,0.1069,0.1069,0.0472,0.0472],1467sum = 0;1468for (var i = 0; i < n; i++) {1469var ct = z2 * Tvalues[i] + z2,1470xbase = base3(ct, x1, x2, x3, x4),1471ybase = base3(ct, y1, y2, y3, y4),1472comb = xbase * xbase + ybase * ybase;1473sum += Cvalues[i] * math.sqrt(comb);1474}1475return z2 * sum;1476}1477function getTatLen(x1, y1, x2, y2, x3, y3, x4, y4, ll) {1478if (ll < 0 || bezlen(x1, y1, x2, y2, x3, y3, x4, y4) < ll) {1479return;1480}1481var t = 1,1482step = t / 2,1483t2 = t - step,1484l,1485e = .01;1486l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);1487while (abs(l - ll) > e) {1488step /= 2;1489t2 += (l < ll ? 1 : -1) * step;1490l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);1491}1492return t2;1493}1494function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {1495if (1496mmax(x1, x2) < mmin(x3, x4) ||1497mmin(x1, x2) > mmax(x3, x4) ||1498mmax(y1, y2) < mmin(y3, y4) ||1499mmin(y1, y2) > mmax(y3, y4)1500) {1501return;1502}1503var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4),1504ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4),1505denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);1506
1507if (!denominator) {1508return;1509}1510var px = nx / denominator,1511py = ny / denominator,1512px2 = +px.toFixed(2),1513py2 = +py.toFixed(2);1514if (1515px2 < +mmin(x1, x2).toFixed(2) ||1516px2 > +mmax(x1, x2).toFixed(2) ||1517px2 < +mmin(x3, x4).toFixed(2) ||1518px2 > +mmax(x3, x4).toFixed(2) ||1519py2 < +mmin(y1, y2).toFixed(2) ||1520py2 > +mmax(y1, y2).toFixed(2) ||1521py2 < +mmin(y3, y4).toFixed(2) ||1522py2 > +mmax(y3, y4).toFixed(2)1523) {1524return;1525}1526return {x: px, y: py};1527}1528function inter(bez1, bez2) {1529return interHelper(bez1, bez2);1530}1531function interCount(bez1, bez2) {1532return interHelper(bez1, bez2, 1);1533}1534function interHelper(bez1, bez2, justCount) {1535var bbox1 = R.bezierBBox(bez1),1536bbox2 = R.bezierBBox(bez2);1537if (!R.isBBoxIntersect(bbox1, bbox2)) {1538return justCount ? 0 : [];1539}1540var l1 = bezlen.apply(0, bez1),1541l2 = bezlen.apply(0, bez2),1542n1 = mmax(~~(l1 / 5), 1),1543n2 = mmax(~~(l2 / 5), 1),1544dots1 = [],1545dots2 = [],1546xy = {},1547res = justCount ? 0 : [];1548for (var i = 0; i < n1 + 1; i++) {1549var p = R.findDotsAtSegment.apply(R, bez1.concat(i / n1));1550dots1.push({x: p.x, y: p.y, t: i / n1});1551}1552for (i = 0; i < n2 + 1; i++) {1553p = R.findDotsAtSegment.apply(R, bez2.concat(i / n2));1554dots2.push({x: p.x, y: p.y, t: i / n2});1555}1556for (i = 0; i < n1; i++) {1557for (var j = 0; j < n2; j++) {1558var di = dots1[i],1559di1 = dots1[i + 1],1560dj = dots2[j],1561dj1 = dots2[j + 1],1562ci = abs(di1.x - di.x) < .001 ? "y" : "x",1563cj = abs(dj1.x - dj.x) < .001 ? "y" : "x",1564is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);1565if (is) {1566if (xy[is.x.toFixed(4)] == is.y.toFixed(4)) {1567continue;1568}1569xy[is.x.toFixed(4)] = is.y.toFixed(4);1570var t1 = di.t + abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t),1571t2 = dj.t + abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);1572if (t1 >= 0 && t1 <= 1.001 && t2 >= 0 && t2 <= 1.001) {1573if (justCount) {1574res++;1575} else {1576res.push({1577x: is.x,1578y: is.y,1579t1: mmin(t1, 1),1580t2: mmin(t2, 1)1581});1582}1583}1584}1585}1586}1587return res;1588}1589/*\1590* Raphael.pathIntersection
1591[ method ]
1592**
1593* Utility method
1594**
1595* Finds intersections of two paths
1596> Parameters
1597- path1 (string) path string
1598- path2 (string) path string
1599= (array) dots of intersection
1600o [
1601o {
1602o x: (number) x coordinate of the point
1603o y: (number) y coordinate of the point
1604o t1: (number) t value for segment of path1
1605o t2: (number) t value for segment of path2
1606o segment1: (number) order number for segment of path1
1607o segment2: (number) order number for segment of path2
1608o bez1: (array) eight coordinates representing beziér curve for the segment of path1
1609o bez2: (array) eight coordinates representing beziér curve for the segment of path2
1610o }
1611o ]
1612\*/
1613R.pathIntersection = function (path1, path2) {1614return interPathHelper(path1, path2);1615};1616R.pathIntersectionNumber = function (path1, path2) {1617return interPathHelper(path1, path2, 1);1618};1619function interPathHelper(path1, path2, justCount) {1620path1 = R._path2curve(path1);1621path2 = R._path2curve(path2);1622var x1, y1, x2, y2, x1m, y1m, x2m, y2m, bez1, bez2,1623res = justCount ? 0 : [];1624for (var i = 0, ii = path1.length; i < ii; i++) {1625var pi = path1[i];1626if (pi[0] == "M") {1627x1 = x1m = pi[1];1628y1 = y1m = pi[2];1629} else {1630if (pi[0] == "C") {1631bez1 = [x1, y1].concat(pi.slice(1));1632x1 = bez1[6];1633y1 = bez1[7];1634} else {1635bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];1636x1 = x1m;1637y1 = y1m;1638}1639for (var j = 0, jj = path2.length; j < jj; j++) {1640var pj = path2[j];1641if (pj[0] == "M") {1642x2 = x2m = pj[1];1643y2 = y2m = pj[2];1644} else {1645if (pj[0] == "C") {1646bez2 = [x2, y2].concat(pj.slice(1));1647x2 = bez2[6];1648y2 = bez2[7];1649} else {1650bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];1651x2 = x2m;1652y2 = y2m;1653}1654var intr = interHelper(bez1, bez2, justCount);1655if (justCount) {1656res += intr;1657} else {1658for (var k = 0, kk = intr.length; k < kk; k++) {1659intr[k].segment1 = i;1660intr[k].segment2 = j;1661intr[k].bez1 = bez1;1662intr[k].bez2 = bez2;1663}1664res = res.concat(intr);1665}1666}1667}1668}1669}1670return res;1671}1672/*\1673* Raphael.isPointInsidePath
1674[ method ]
1675**
1676* Utility method
1677**
1678* Returns `true` if given point is inside a given closed path.
1679> Parameters
1680- path (string) path string
1681- x (number) x of the point
1682- y (number) y of the point
1683= (boolean) true, if point is inside the path
1684\*/
1685R.isPointInsidePath = function (path, x, y) {1686var bbox = R.pathBBox(path);1687return R.isPointInsideBBox(bbox, x, y) &&1688interPathHelper(path, [["M", x, y], ["H", bbox.x2 + 10]], 1) % 2 == 1;1689};1690R._removedFactory = function (methodname) {1691return function () {1692eve("raphael.log", null, "Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object", methodname);1693};1694};1695/*\1696* Raphael.pathBBox
1697[ method ]
1698**
1699* Utility method
1700**
1701* Return bounding box of a given path
1702> Parameters
1703- path (string) path string
1704= (object) bounding box
1705o {
1706o x: (number) x coordinate of the left top point of the box
1707o y: (number) y coordinate of the left top point of the box
1708o x2: (number) x coordinate of the right bottom point of the box
1709o y2: (number) y coordinate of the right bottom point of the box
1710o width: (number) width of the box
1711o height: (number) height of the box
1712o cx: (number) x coordinate of the center of the box
1713o cy: (number) y coordinate of the center of the box
1714o }
1715\*/
1716var pathDimensions = R.pathBBox = function (path) {1717var pth = paths(path);1718if (pth.bbox) {1719return clone(pth.bbox);1720}1721if (!path) {1722return {x: 0, y: 0, width: 0, height: 0, x2: 0, y2: 0};1723}1724path = path2curve(path);1725var x = 0,1726y = 0,1727X = [],1728Y = [],1729p;1730for (var i = 0, ii = path.length; i < ii; i++) {1731p = path[i];1732if (p[0] == "M") {1733x = p[1];1734y = p[2];1735X.push(x);1736Y.push(y);1737} else {1738var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);1739X = X[concat](dim.min.x, dim.max.x);1740Y = Y[concat](dim.min.y, dim.max.y);1741x = p[5];1742y = p[6];1743}1744}1745var xmin = mmin[apply](0, X),1746ymin = mmin[apply](0, Y),1747xmax = mmax[apply](0, X),1748ymax = mmax[apply](0, Y),1749width = xmax - xmin,1750height = ymax - ymin,1751bb = {1752x: xmin,1753y: ymin,1754x2: xmax,1755y2: ymax,1756width: width,1757height: height,1758cx: xmin + width / 2,1759cy: ymin + height / 21760};1761pth.bbox = clone(bb);1762return bb;1763},1764pathClone = function (pathArray) {1765var res = clone(pathArray);1766res.toString = R._path2string;1767return res;1768},1769pathToRelative = R._pathToRelative = function (pathArray) {1770var pth = paths(pathArray);1771if (pth.rel) {1772return pathClone(pth.rel);1773}1774if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption1775pathArray = R.parsePathString(pathArray);1776}1777var res = [],1778x = 0,1779y = 0,1780mx = 0,1781my = 0,1782start = 0;1783if (pathArray[0][0] == "M") {1784x = pathArray[0][1];1785y = pathArray[0][2];1786mx = x;1787my = y;1788start++;1789res.push(["M", x, y]);1790}1791for (var i = start, ii = pathArray.length; i < ii; i++) {1792var r = res[i] = [],1793pa = pathArray[i];1794if (pa[0] != lowerCase.call(pa[0])) {1795r[0] = lowerCase.call(pa[0]);1796switch (r[0]) {1797case "a":1798r[1] = pa[1];1799r[2] = pa[2];1800r[3] = pa[3];1801r[4] = pa[4];1802r[5] = pa[5];1803r[6] = +(pa[6] - x).toFixed(3);1804r[7] = +(pa[7] - y).toFixed(3);1805break;1806case "v":1807r[1] = +(pa[1] - y).toFixed(3);1808break;1809case "m":1810mx = pa[1];1811my = pa[2];1812default:1813for (var j = 1, jj = pa.length; j < jj; j++) {1814r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3);1815}1816}1817} else {1818r = res[i] = [];1819if (pa[0] == "m") {1820mx = pa[1] + x;1821my = pa[2] + y;1822}1823for (var k = 0, kk = pa.length; k < kk; k++) {1824res[i][k] = pa[k];1825}1826}1827var len = res[i].length;1828switch (res[i][0]) {1829case "z":1830x = mx;1831y = my;1832break;1833case "h":1834x += +res[i][len - 1];1835break;1836case "v":1837y += +res[i][len - 1];1838break;1839default:1840x += +res[i][len - 2];1841y += +res[i][len - 1];1842}1843}1844res.toString = R._path2string;1845pth.rel = pathClone(res);1846return res;1847},1848pathToAbsolute = R._pathToAbsolute = function (pathArray) {1849var pth = paths(pathArray);1850if (pth.abs) {1851return pathClone(pth.abs);1852}1853if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption1854pathArray = R.parsePathString(pathArray);1855}1856if (!pathArray || !pathArray.length) {1857return [["M", 0, 0]];1858}1859var res = [],1860x = 0,1861y = 0,1862mx = 0,1863my = 0,1864start = 0;1865if (pathArray[0][0] == "M") {1866x = +pathArray[0][1];1867y = +pathArray[0][2];1868mx = x;1869my = y;1870start++;1871res[0] = ["M", x, y];1872}1873var crz = pathArray.length == 3 && pathArray[0][0] == "M" && pathArray[1][0].toUpperCase() == "R" && pathArray[2][0].toUpperCase() == "Z";1874for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {1875res.push(r = []);1876pa = pathArray[i];1877if (pa[0] != upperCase.call(pa[0])) {1878r[0] = upperCase.call(pa[0]);1879switch (r[0]) {1880case "A":1881r[1] = pa[1];1882r[2] = pa[2];1883r[3] = pa[3];1884r[4] = pa[4];1885r[5] = pa[5];1886r[6] = +(pa[6] + x);1887r[7] = +(pa[7] + y);1888break;1889case "V":1890r[1] = +pa[1] + y;1891break;1892case "H":1893r[1] = +pa[1] + x;1894break;1895case "R":1896var dots = [x, y][concat](pa.slice(1));1897for (var j = 2, jj = dots.length; j < jj; j++) {1898dots[j] = +dots[j] + x;1899dots[++j] = +dots[j] + y;1900}1901res.pop();1902res = res[concat](catmullRom2bezier(dots, crz));1903break;1904case "M":1905mx = +pa[1] + x;1906my = +pa[2] + y;1907default:1908for (j = 1, jj = pa.length; j < jj; j++) {1909r[j] = +pa[j] + ((j % 2) ? x : y);1910}1911}1912} else if (pa[0] == "R") {1913dots = [x, y][concat](pa.slice(1));1914res.pop();1915res = res[concat](catmullRom2bezier(dots, crz));1916r = ["R"][concat](pa.slice(-2));1917} else {1918for (var k = 0, kk = pa.length; k < kk; k++) {1919r[k] = pa[k];1920}1921}1922switch (r[0]) {1923case "Z":1924x = mx;1925y = my;1926break;1927case "H":1928x = r[1];1929break;1930case "V":1931y = r[1];1932break;1933case "M":1934mx = r[r.length - 2];1935my = r[r.length - 1];1936default:1937x = r[r.length - 2];1938y = r[r.length - 1];1939}1940}1941res.toString = R._path2string;1942pth.abs = pathClone(res);1943return res;1944},1945l2c = function (x1, y1, x2, y2) {1946return [x1, y1, x2, y2, x2, y2];1947},1948q2c = function (x1, y1, ax, ay, x2, y2) {1949var _13 = 1 / 3,1950_23 = 2 / 3;1951return [1952_13 * x1 + _23 * ax,1953_13 * y1 + _23 * ay,1954_13 * x2 + _23 * ax,1955_13 * y2 + _23 * ay,1956x2,1957y2
1958];1959},1960a2c = function (x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {1961// for more information of where this math came from visit:1962// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes1963var _120 = PI * 120 / 180,1964rad = PI / 180 * (+angle || 0),1965res = [],1966xy,1967rotate = cacher(function (x, y, rad) {1968var X = x * math.cos(rad) - y * math.sin(rad),1969Y = x * math.sin(rad) + y * math.cos(rad);1970return {x: X, y: Y};1971});1972if (!recursive) {1973xy = rotate(x1, y1, -rad);1974x1 = xy.x;1975y1 = xy.y;1976xy = rotate(x2, y2, -rad);1977x2 = xy.x;1978y2 = xy.y;1979var cos = math.cos(PI / 180 * angle),1980sin = math.sin(PI / 180 * angle),1981x = (x1 - x2) / 2,1982y = (y1 - y2) / 2;1983var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);1984if (h > 1) {1985h = math.sqrt(h);1986rx = h * rx;1987ry = h * ry;1988}1989var rx2 = rx * rx,1990ry2 = ry * ry,1991k = (large_arc_flag == sweep_flag ? -1 : 1) *1992math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))),1993cx = k * rx * y / ry + (x1 + x2) / 2,1994cy = k * -ry * x / rx + (y1 + y2) / 2,1995f1 = math.asin(((y1 - cy) / ry).toFixed(9)),1996f2 = math.asin(((y2 - cy) / ry).toFixed(9));1997
1998f1 = x1 < cx ? PI - f1 : f1;1999f2 = x2 < cx ? PI - f2 : f2;2000f1 < 0 && (f1 = PI * 2 + f1);2001f2 < 0 && (f2 = PI * 2 + f2);2002if (sweep_flag && f1 > f2) {2003f1 = f1 - PI * 2;2004}2005if (!sweep_flag && f2 > f1) {2006f2 = f2 - PI * 2;2007}2008} else {2009f1 = recursive[0];2010f2 = recursive[1];2011cx = recursive[2];2012cy = recursive[3];2013}2014var df = f2 - f1;2015if (abs(df) > _120) {2016var f2old = f2,2017x2old = x2,2018y2old = y2;2019f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);2020x2 = cx + rx * math.cos(f2);2021y2 = cy + ry * math.sin(f2);2022res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);2023}2024df = f2 - f1;2025var c1 = math.cos(f1),2026s1 = math.sin(f1),2027c2 = math.cos(f2),2028s2 = math.sin(f2),2029t = math.tan(df / 4),2030hx = 4 / 3 * rx * t,2031hy = 4 / 3 * ry * t,2032m1 = [x1, y1],2033m2 = [x1 + hx * s1, y1 - hy * c1],2034m3 = [x2 + hx * s2, y2 - hy * c2],2035m4 = [x2, y2];2036m2[0] = 2 * m1[0] - m2[0];2037m2[1] = 2 * m1[1] - m2[1];2038if (recursive) {2039return [m2, m3, m4][concat](res);2040} else {2041res = [m2, m3, m4][concat](res).join()[split](",");2042var newres = [];2043for (var i = 0, ii = res.length; i < ii; i++) {2044newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;2045}2046return newres;2047}2048},2049findDotAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {2050var t1 = 1 - t;2051return {2052x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x,2053y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y2054};2055},2056curveDim = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {2057var a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x),2058b = 2 * (c1x - p1x) - 2 * (c2x - c1x),2059c = p1x - c1x,2060t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a,2061t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a,2062y = [p1y, p2y],2063x = [p1x, p2x],2064dot;2065abs(t1) > "1e12" && (t1 = .5);2066abs(t2) > "1e12" && (t2 = .5);2067if (t1 > 0 && t1 < 1) {2068dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);2069x.push(dot.x);2070y.push(dot.y);2071}2072if (t2 > 0 && t2 < 1) {2073dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);2074x.push(dot.x);2075y.push(dot.y);2076}2077a = (c2y - 2 * c1y + p1y) - (p2y - 2 * c2y + c1y);2078b = 2 * (c1y - p1y) - 2 * (c2y - c1y);2079c = p1y - c1y;2080t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a;2081t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a;2082abs(t1) > "1e12" && (t1 = .5);2083abs(t2) > "1e12" && (t2 = .5);2084if (t1 > 0 && t1 < 1) {2085dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);2086x.push(dot.x);2087y.push(dot.y);2088}2089if (t2 > 0 && t2 < 1) {2090dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);2091x.push(dot.x);2092y.push(dot.y);2093}2094return {2095min: {x: mmin[apply](0, x), y: mmin[apply](0, y)},2096max: {x: mmax[apply](0, x), y: mmax[apply](0, y)}2097};2098}),2099path2curve = R._path2curve = cacher(function (path, path2) {2100var pth = !path2 && paths(path);2101if (!path2 && pth.curve) {2102return pathClone(pth.curve);2103}2104var p = pathToAbsolute(path),2105p2 = path2 && pathToAbsolute(path2),2106attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},2107attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},2108processPath = function (path, d, pcom) {2109var nx, ny, tq = {T:1, Q:1};2110if (!path) {2111return ["C", d.x, d.y, d.x, d.y, d.x, d.y];2112}2113!(path[0] in tq) && (d.qx = d.qy = null);2114switch (path[0]) {2115case "M":2116d.X = path[1];2117d.Y = path[2];2118break;2119case "A":2120path = ["C"][concat](a2c[apply](0, [d.x, d.y][concat](path.slice(1))));2121break;2122case "S":2123if (pcom == "C" || pcom == "S") { // In "S" case we have to take into account, if the previous command is C/S.2124nx = d.x * 2 - d.bx; // And reflect the previous2125ny = d.y * 2 - d.by; // command's control point relative to the current point.2126}2127else { // or some else or nothing2128nx = d.x;2129ny = d.y;2130}2131path = ["C", nx, ny][concat](path.slice(1));2132break;2133case "T":2134if (pcom == "Q" || pcom == "T") { // In "T" case we have to take into account, if the previous command is Q/T.2135d.qx = d.x * 2 - d.qx; // And make a reflection similar2136d.qy = d.y * 2 - d.qy; // to case "S".2137}2138else { // or something else or nothing2139d.qx = d.x;2140d.qy = d.y;2141}2142path = ["C"][concat](q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));2143break;2144case "Q":2145d.qx = path[1];2146d.qy = path[2];2147path = ["C"][concat](q2c(d.x, d.y, path[1], path[2], path[3], path[4]));2148break;2149case "L":2150path = ["C"][concat](l2c(d.x, d.y, path[1], path[2]));2151break;2152case "H":2153path = ["C"][concat](l2c(d.x, d.y, path[1], d.y));2154break;2155case "V":2156path = ["C"][concat](l2c(d.x, d.y, d.x, path[1]));2157break;2158case "Z":2159path = ["C"][concat](l2c(d.x, d.y, d.X, d.Y));2160break;2161}2162return path;2163},2164fixArc = function (pp, i) {2165if (pp[i].length > 7) {2166pp[i].shift();2167var pi = pp[i];2168while (pi.length) {2169pcoms1[i]="A"; // if created multiple C:s, their original seg is saved2170p2 && (pcoms2[i]="A"); // the same as above2171pp.splice(i++, 0, ["C"][concat](pi.splice(0, 6)));2172}2173pp.splice(i, 1);2174ii = mmax(p.length, p2 && p2.length || 0);2175}2176},2177fixM = function (path1, path2, a1, a2, i) {2178if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M") {2179path2.splice(i, 0, ["M", a2.x, a2.y]);2180a1.bx = 0;2181a1.by = 0;2182a1.x = path1[i][1];2183a1.y = path1[i][2];2184ii = mmax(p.length, p2 && p2.length || 0);2185}2186},2187pcoms1 = [], // path commands of original path p2188pcoms2 = [], // path commands of original path p22189pfirst = "", // temporary holder for original path command2190pcom = ""; // holder for previous path command of original path2191for (var i = 0, ii = mmax(p.length, p2 && p2.length || 0); i < ii; i++) {2192p[i] && (pfirst = p[i][0]); // save current path command2193
2194if (pfirst != "C") // C is not saved yet, because it may be result of conversion2195{2196pcoms1[i] = pfirst; // Save current path command2197i && ( pcom = pcoms1[i-1]); // Get previous path command pcom2198}2199p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath2200
2201if (pcoms1[i] != "A" && pfirst == "C") pcoms1[i] = "C"; // A is the only command2202// which may produce multiple C:s2203// so we have to make sure that C is also C in original path2204
2205fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms12206
2207if (p2) { // the same procedures is done to p22208p2[i] && (pfirst = p2[i][0]);2209if (pfirst != "C")2210{2211pcoms2[i] = pfirst;2212i && (pcom = pcoms2[i-1]);2213}2214p2[i] = processPath(p2[i], attrs2, pcom);2215
2216if (pcoms2[i]!="A" && pfirst=="C") pcoms2[i]="C";2217
2218fixArc(p2, i);2219}2220fixM(p, p2, attrs, attrs2, i);2221fixM(p2, p, attrs2, attrs, i);2222var seg = p[i],2223seg2 = p2 && p2[i],2224seglen = seg.length,2225seg2len = p2 && seg2.length;2226attrs.x = seg[seglen - 2];2227attrs.y = seg[seglen - 1];2228attrs.bx = toFloat(seg[seglen - 4]) || attrs.x;2229attrs.by = toFloat(seg[seglen - 3]) || attrs.y;2230attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x);2231attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y);2232attrs2.x = p2 && seg2[seg2len - 2];2233attrs2.y = p2 && seg2[seg2len - 1];2234}2235if (!p2) {2236pth.curve = pathClone(p);2237}2238return p2 ? [p, p2] : p;2239}, null, pathClone),2240parseDots = R._parseDots = cacher(function (gradient) {2241var dots = [];2242for (var i = 0, ii = gradient.length; i < ii; i++) {2243var dot = {},2244par = gradient[i].match(/^([^:]*):?([\d\.]*)/);2245dot.color = R.getRGB(par[1]);2246if (dot.color.error) {2247return null;2248}2249dot.opacity = dot.color.opacity;2250dot.color = dot.color.hex;2251par[2] && (dot.offset = par[2] + "%");2252dots.push(dot);2253}2254for (i = 1, ii = dots.length - 1; i < ii; i++) {2255if (!dots[i].offset) {2256var start = toFloat(dots[i - 1].offset || 0),2257end = 0;2258for (var j = i + 1; j < ii; j++) {2259if (dots[j].offset) {2260end = dots[j].offset;2261break;2262}2263}2264if (!end) {2265end = 100;2266j = ii;2267}2268end = toFloat(end);2269var d = (end - start) / (j - i + 1);2270for (; i < j; i++) {2271start += d;2272dots[i].offset = start + "%";2273}2274}2275}2276return dots;2277}),2278tear = R._tear = function (el, paper) {2279el == paper.top && (paper.top = el.prev);2280el == paper.bottom && (paper.bottom = el.next);2281el.next && (el.next.prev = el.prev);2282el.prev && (el.prev.next = el.next);2283},2284tofront = R._tofront = function (el, paper) {2285if (paper.top === el) {2286return;2287}2288tear(el, paper);2289el.next = null;2290el.prev = paper.top;2291paper.top.next = el;2292paper.top = el;2293},2294toback = R._toback = function (el, paper) {2295if (paper.bottom === el) {2296return;2297}2298tear(el, paper);2299el.next = paper.bottom;2300el.prev = null;2301paper.bottom.prev = el;2302paper.bottom = el;2303},2304insertafter = R._insertafter = function (el, el2, paper) {2305tear(el, paper);2306el2 == paper.top && (paper.top = el);2307el2.next && (el2.next.prev = el);2308el.next = el2.next;2309el.prev = el2;2310el2.next = el;2311},2312insertbefore = R._insertbefore = function (el, el2, paper) {2313tear(el, paper);2314el2 == paper.bottom && (paper.bottom = el);2315el2.prev && (el2.prev.next = el);2316el.prev = el2.prev;2317el2.prev = el;2318el.next = el2;2319},2320/*\2321* Raphael.toMatrix
2322[ method ]
2323**
2324* Utility method
2325**
2326* Returns matrix of transformations applied to a given path
2327> Parameters
2328- path (string) path string
2329- transform (string|array) transformation string
2330= (object) @Matrix
2331\*/
2332toMatrix = R.toMatrix = function (path, transform) {2333var bb = pathDimensions(path),2334el = {2335_: {2336transform: E2337},2338getBBox: function () {2339return bb;2340}2341};2342extractTransform(el, transform);2343return el.matrix;2344},2345/*\2346* Raphael.transformPath
2347[ method ]
2348**
2349* Utility method
2350**
2351* Returns path transformed by a given transformation
2352> Parameters
2353- path (string) path string
2354- transform (string|array) transformation string
2355= (string) path
2356\*/
2357transformPath = R.transformPath = function (path, transform) {2358return mapPath(path, toMatrix(path, transform));2359},2360extractTransform = R._extractTransform = function (el, tstr) {2361if (tstr == null) {2362return el._.transform;2363}2364tstr = Str(tstr).replace(/\.{3}|\u2026/g, el._.transform || E);2365var tdata = R.parseTransformString(tstr),2366deg = 0,2367dx = 0,2368dy = 0,2369sx = 1,2370sy = 1,2371_ = el._,2372m = new Matrix;2373_.transform = tdata || [];2374if (tdata) {2375for (var i = 0, ii = tdata.length; i < ii; i++) {2376var t = tdata[i],2377tlen = t.length,2378command = Str(t[0]).toLowerCase(),2379absolute = t[0] != command,2380inver = absolute ? m.invert() : 0,2381x1,2382y1,2383x2,2384y2,2385bb;2386if (command == "t" && tlen == 3) {2387if (absolute) {2388x1 = inver.x(0, 0);2389y1 = inver.y(0, 0);2390x2 = inver.x(t[1], t[2]);2391y2 = inver.y(t[1], t[2]);2392m.translate(x2 - x1, y2 - y1);2393} else {2394m.translate(t[1], t[2]);2395}2396} else if (command == "r") {2397if (tlen == 2) {2398bb = bb || el.getBBox(1);2399m.rotate(t[1], bb.x + bb.width / 2, bb.y + bb.height / 2);2400deg += t[1];2401} else if (tlen == 4) {2402if (absolute) {2403x2 = inver.x(t[2], t[3]);2404y2 = inver.y(t[2], t[3]);2405m.rotate(t[1], x2, y2);2406} else {2407m.rotate(t[1], t[2], t[3]);2408}2409deg += t[1];2410}2411} else if (command == "s") {2412if (tlen == 2 || tlen == 3) {2413bb = bb || el.getBBox(1);2414m.scale(t[1], t[tlen - 1], bb.x + bb.width / 2, bb.y + bb.height / 2);2415sx *= t[1];2416sy *= t[tlen - 1];2417} else if (tlen == 5) {2418if (absolute) {2419x2 = inver.x(t[3], t[4]);2420y2 = inver.y(t[3], t[4]);2421m.scale(t[1], t[2], x2, y2);2422} else {2423m.scale(t[1], t[2], t[3], t[4]);2424}2425sx *= t[1];2426sy *= t[2];2427}2428} else if (command == "m" && tlen == 7) {2429m.add(t[1], t[2], t[3], t[4], t[5], t[6]);2430}2431_.dirtyT = 1;2432el.matrix = m;2433}2434}2435
2436/*\2437* Element.matrix
2438[ property (object) ]
2439**
2440* Keeps @Matrix object, which represents element transformation
2441\*/
2442el.matrix = m;2443
2444_.sx = sx;2445_.sy = sy;2446_.deg = deg;2447_.dx = dx = m.e;2448_.dy = dy = m.f;2449
2450if (sx == 1 && sy == 1 && !deg && _.bbox) {2451_.bbox.x += +dx;2452_.bbox.y += +dy;2453} else {2454_.dirtyT = 1;2455}2456},2457getEmpty = function (item) {2458var l = item[0];2459switch (l.toLowerCase()) {2460case "t": return [l, 0, 0];2461case "m": return [l, 1, 0, 0, 1, 0, 0];2462case "r": if (item.length == 4) {2463return [l, 0, item[2], item[3]];2464} else {2465return [l, 0];2466}2467case "s": if (item.length == 5) {2468return [l, 1, 1, item[3], item[4]];2469} else if (item.length == 3) {2470return [l, 1, 1];2471} else {2472return [l, 1];2473}2474}2475},2476equaliseTransform = R._equaliseTransform = function (t1, t2) {2477t2 = Str(t2).replace(/\.{3}|\u2026/g, t1);2478t1 = R.parseTransformString(t1) || [];2479t2 = R.parseTransformString(t2) || [];2480var maxlength = mmax(t1.length, t2.length),2481from = [],2482to = [],2483i = 0, j, jj,2484tt1, tt2;2485for (; i < maxlength; i++) {2486tt1 = t1[i] || getEmpty(t2[i]);2487tt2 = t2[i] || getEmpty(tt1);2488if ((tt1[0] != tt2[0]) ||2489(tt1[0].toLowerCase() == "r" && (tt1[2] != tt2[2] || tt1[3] != tt2[3])) ||2490(tt1[0].toLowerCase() == "s" && (tt1[3] != tt2[3] || tt1[4] != tt2[4]))2491) {2492return;2493}2494from[i] = [];2495to[i] = [];2496for (j = 0, jj = mmax(tt1.length, tt2.length); j < jj; j++) {2497j in tt1 && (from[i][j] = tt1[j]);2498j in tt2 && (to[i][j] = tt2[j]);2499}2500}2501return {2502from: from,2503to: to2504};2505};2506R._getContainer = function (x, y, w, h) {2507var container;2508container = h == null && !R.is(x, "object") ? g.doc.getElementById(x) : x;2509if (container == null) {2510return;2511}2512if (container.tagName) {2513if (y == null) {2514return {2515container: container,2516width: container.style.pixelWidth || container.offsetWidth,2517height: container.style.pixelHeight || container.offsetHeight2518};2519} else {2520return {2521container: container,2522width: y,2523height: w2524};2525}2526}2527return {2528container: 1,2529x: x,2530y: y,2531width: w,2532height: h2533};2534};2535/*\2536* Raphael.pathToRelative
2537[ method ]
2538**
2539* Utility method
2540**
2541* Converts path to relative form
2542> Parameters
2543- pathString (string|array) path string or array of segments
2544= (array) array of segments.
2545\*/
2546R.pathToRelative = pathToRelative;2547R._engine = {};2548/*\2549* Raphael.path2curve
2550[ method ]
2551**
2552* Utility method
2553**
2554* Converts path to a new path where all segments are cubic bezier curves.
2555> Parameters
2556- pathString (string|array) path string or array of segments
2557= (array) array of segments.
2558\*/
2559R.path2curve = path2curve;2560/*\2561* Raphael.matrix
2562[ method ]
2563**
2564* Utility method
2565**
2566* Returns matrix based on given parameters.
2567> Parameters
2568- a (number)
2569- b (number)
2570- c (number)
2571- d (number)
2572- e (number)
2573- f (number)
2574= (object) @Matrix
2575\*/
2576R.matrix = function (a, b, c, d, e, f) {2577return new Matrix(a, b, c, d, e, f);2578};2579function Matrix(a, b, c, d, e, f) {2580if (a != null) {2581this.a = +a;2582this.b = +b;2583this.c = +c;2584this.d = +d;2585this.e = +e;2586this.f = +f;2587} else {2588this.a = 1;2589this.b = 0;2590this.c = 0;2591this.d = 1;2592this.e = 0;2593this.f = 0;2594}2595}2596(function (matrixproto) {2597/*\2598* Matrix.add
2599[ method ]
2600**
2601* Adds given matrix to existing one.
2602> Parameters
2603- a (number)
2604- b (number)
2605- c (number)
2606- d (number)
2607- e (number)
2608- f (number)
2609or
2610- matrix (object) @Matrix
2611\*/
2612matrixproto.add = function (a, b, c, d, e, f) {2613var out = [[], [], []],2614m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]],2615matrix = [[a, c, e], [b, d, f], [0, 0, 1]],2616x, y, z, res;2617
2618if (a && a instanceof Matrix) {2619matrix = [[a.a, a.c, a.e], [a.b, a.d, a.f], [0, 0, 1]];2620}2621
2622for (x = 0; x < 3; x++) {2623for (y = 0; y < 3; y++) {2624res = 0;2625for (z = 0; z < 3; z++) {2626res += m[x][z] * matrix[z][y];2627}2628out[x][y] = res;2629}2630}2631this.a = out[0][0];2632this.b = out[1][0];2633this.c = out[0][1];2634this.d = out[1][1];2635this.e = out[0][2];2636this.f = out[1][2];2637};2638/*\2639* Matrix.invert
2640[ method ]
2641**
2642* Returns inverted version of the matrix
2643= (object) @Matrix
2644\*/
2645matrixproto.invert = function () {2646var me = this,2647x = me.a * me.d - me.b * me.c;2648return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x);2649};2650/*\2651* Matrix.clone
2652[ method ]
2653**
2654* Returns copy of the matrix
2655= (object) @Matrix
2656\*/
2657matrixproto.clone = function () {2658return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f);2659};2660/*\2661* Matrix.translate
2662[ method ]
2663**
2664* Translate the matrix
2665> Parameters
2666- x (number)
2667- y (number)
2668\*/
2669matrixproto.translate = function (x, y) {2670this.add(1, 0, 0, 1, x, y);2671};2672/*\2673* Matrix.scale
2674[ method ]
2675**
2676* Scales the matrix
2677> Parameters
2678- x (number)
2679- y (number) #optional
2680- cx (number) #optional
2681- cy (number) #optional
2682\*/
2683matrixproto.scale = function (x, y, cx, cy) {2684y == null && (y = x);2685(cx || cy) && this.add(1, 0, 0, 1, cx, cy);2686this.add(x, 0, 0, y, 0, 0);2687(cx || cy) && this.add(1, 0, 0, 1, -cx, -cy);2688};2689/*\2690* Matrix.rotate
2691[ method ]
2692**
2693* Rotates the matrix
2694> Parameters
2695- a (number)
2696- x (number)
2697- y (number)
2698\*/
2699matrixproto.rotate = function (a, x, y) {2700a = R.rad(a);2701x = x || 0;2702y = y || 0;2703var cos = +math.cos(a).toFixed(9),2704sin = +math.sin(a).toFixed(9);2705this.add(cos, sin, -sin, cos, x, y);2706this.add(1, 0, 0, 1, -x, -y);2707};2708/*\2709* Matrix.x
2710[ method ]
2711**
2712* Return x coordinate for given point after transformation described by the matrix. See also @Matrix.y
2713> Parameters
2714- x (number)
2715- y (number)
2716= (number) x
2717\*/
2718matrixproto.x = function (x, y) {2719return x * this.a + y * this.c + this.e;2720};2721/*\2722* Matrix.y
2723[ method ]
2724**
2725* Return y coordinate for given point after transformation described by the matrix. See also @Matrix.x
2726> Parameters
2727- x (number)
2728- y (number)
2729= (number) y
2730\*/
2731matrixproto.y = function (x, y) {2732return x * this.b + y * this.d + this.f;2733};2734matrixproto.get = function (i) {2735return +this[Str.fromCharCode(97 + i)].toFixed(4);2736};2737matrixproto.toString = function () {2738return R.svg ?2739"matrix(" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)].join() + ")" :2740[this.get(0), this.get(2), this.get(1), this.get(3), 0, 0].join();2741};2742matrixproto.toFilter = function () {2743return "progid:DXImageTransform.Microsoft.Matrix(M11=" + this.get(0) +2744", M12=" + this.get(2) + ", M21=" + this.get(1) + ", M22=" + this.get(3) +2745", Dx=" + this.get(4) + ", Dy=" + this.get(5) + ", sizingmethod='auto expand')";2746};2747matrixproto.offset = function () {2748return [this.e.toFixed(4), this.f.toFixed(4)];2749};2750function norm(a) {2751return a[0] * a[0] + a[1] * a[1];2752}2753function normalize(a) {2754var mag = math.sqrt(norm(a));2755a[0] && (a[0] /= mag);2756a[1] && (a[1] /= mag);2757}2758/*\2759* Matrix.split
2760[ method ]
2761**
2762* Splits matrix into primitive transformations
2763= (object) in format:
2764o dx (number) translation by x
2765o dy (number) translation by y
2766o scalex (number) scale by x
2767o scaley (number) scale by y
2768o shear (number) shear
2769o rotate (number) rotation in deg
2770o isSimple (boolean) could it be represented via simple transformations
2771\*/
2772matrixproto.split = function () {2773var out = {};2774// translation2775out.dx = this.e;2776out.dy = this.f;2777
2778// scale and shear2779var row = [[this.a, this.c], [this.b, this.d]];2780out.scalex = math.sqrt(norm(row[0]));2781normalize(row[0]);2782
2783out.shear = row[0][0] * row[1][0] + row[0][1] * row[1][1];2784row[1] = [row[1][0] - row[0][0] * out.shear, row[1][1] - row[0][1] * out.shear];2785
2786out.scaley = math.sqrt(norm(row[1]));2787normalize(row[1]);2788out.shear /= out.scaley;2789
2790// rotation2791var sin = -row[0][1],2792cos = row[1][1];2793if (cos < 0) {2794out.rotate = R.deg(math.acos(cos));2795if (sin < 0) {2796out.rotate = 360 - out.rotate;2797}2798} else {2799out.rotate = R.deg(math.asin(sin));2800}2801
2802out.isSimple = !+out.shear.toFixed(9) && (out.scalex.toFixed(9) == out.scaley.toFixed(9) || !out.rotate);2803out.isSuperSimple = !+out.shear.toFixed(9) && out.scalex.toFixed(9) == out.scaley.toFixed(9) && !out.rotate;2804out.noRotation = !+out.shear.toFixed(9) && !out.rotate;2805return out;2806};2807/*\2808* Matrix.toTransformString
2809[ method ]
2810**
2811* Return transform string that represents given matrix
2812= (string) transform string
2813\*/
2814matrixproto.toTransformString = function (shorter) {2815var s = shorter || this[split]();2816if (s.isSimple) {2817s.scalex = +s.scalex.toFixed(4);2818s.scaley = +s.scaley.toFixed(4);2819s.rotate = +s.rotate.toFixed(4);2820return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) +2821(s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) +2822(s.rotate ? "r" + [s.rotate, 0, 0] : E);2823} else {2824return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];2825}2826};2827})(Matrix.prototype);2828
2829var preventDefault = function () {2830this.returnValue = false;2831},2832preventTouch = function () {2833return this.originalEvent.preventDefault();2834},2835stopPropagation = function () {2836this.cancelBubble = true;2837},2838stopTouch = function () {2839return this.originalEvent.stopPropagation();2840},2841getEventPosition = function (e) {2842var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,2843scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft;2844
2845return {2846x: e.clientX + scrollX,2847y: e.clientY + scrollY2848};2849},2850addEvent = (function () {2851if (g.doc.addEventListener) {2852return function (obj, type, fn, element) {2853var f = function (e) {2854var pos = getEventPosition(e);2855return fn.call(element, e, pos.x, pos.y);2856};2857obj.addEventListener(type, f, false);2858
2859if (supportsTouch && touchMap[type]) {2860var _f = function (e) {2861var pos = getEventPosition(e),2862olde = e;2863
2864for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) {2865if (e.targetTouches[i].target == obj) {2866e = e.targetTouches[i];2867e.originalEvent = olde;2868e.preventDefault = preventTouch;2869e.stopPropagation = stopTouch;2870break;2871}2872}2873
2874return fn.call(element, e, pos.x, pos.y);2875};2876obj.addEventListener(touchMap[type], _f, false);2877}2878
2879return function () {2880obj.removeEventListener(type, f, false);2881
2882if (supportsTouch && touchMap[type])2883obj.removeEventListener(touchMap[type], _f, false);2884
2885return true;2886};2887};2888} else if (g.doc.attachEvent) {2889return function (obj, type, fn, element) {2890var f = function (e) {2891e = e || g.win.event;2892var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,2893scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,2894x = e.clientX + scrollX,2895y = e.clientY + scrollY;2896e.preventDefault = e.preventDefault || preventDefault;2897e.stopPropagation = e.stopPropagation || stopPropagation;2898return fn.call(element, e, x, y);2899};2900obj.attachEvent("on" + type, f);2901var detacher = function () {2902obj.detachEvent("on" + type, f);2903return true;2904};2905return detacher;2906};2907}2908})(),2909drag = [],2910dragMove = function (e) {2911var x = e.clientX,2912y = e.clientY,2913scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,2914scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,2915dragi,2916j = drag.length;2917while (j--) {2918dragi = drag[j];2919if (supportsTouch && e.touches) {2920var i = e.touches.length,2921touch;2922while (i--) {2923touch = e.touches[i];2924if (touch.identifier == dragi.el._drag.id) {2925x = touch.clientX;2926y = touch.clientY;2927(e.originalEvent ? e.originalEvent : e).preventDefault();2928break;2929}2930}2931} else {2932e.preventDefault();2933}2934var node = dragi.el.node,2935o,2936next = node.nextSibling,2937parent = node.parentNode,2938display = node.style.display;2939g.win.opera && parent.removeChild(node);2940node.style.display = "none";2941o = dragi.el.paper.getElementByPoint(x, y);2942node.style.display = display;2943g.win.opera && (next ? parent.insertBefore(node, next) : parent.appendChild(node));2944o && eve("raphael.drag.over." + dragi.el.id, dragi.el, o);2945x += scrollX;2946y += scrollY;2947eve("raphael.drag.move." + dragi.el.id, dragi.move_scope || dragi.el, x - dragi.el._drag.x, y - dragi.el._drag.y, x, y, e);2948}2949},2950dragUp = function (e) {2951R.unmousemove(dragMove).unmouseup(dragUp);2952var i = drag.length,2953dragi;2954while (i--) {2955dragi = drag[i];2956dragi.el._drag = {};2957eve("raphael.drag.end." + dragi.el.id, dragi.end_scope || dragi.start_scope || dragi.move_scope || dragi.el, e);2958}2959drag = [];2960},2961/*\2962* Raphael.el
2963[ property (object) ]
2964**
2965* You can add your own method to elements. This is useful when you want to hack default functionality or
2966* want to wrap some common transformation or attributes in one method. In difference to canvas methods,
2967* you can redefine element method at any time. Expending element methods wouldn’t affect set.
2968> Usage
2969| Raphael.el.red = function () {
2970| this.attr({fill: "#f00"});
2971| };
2972| // then use it
2973| paper.circle(100, 100, 20).red();
2974\*/
2975elproto = R.el = {};2976/*\2977* Element.click
2978[ method ]
2979**
2980* Adds event handler for click for the element.
2981> Parameters
2982- handler (function) handler for the event
2983= (object) @Element
2984\*/
2985/*\2986* Element.unclick
2987[ method ]
2988**
2989* Removes event handler for click for the element.
2990> Parameters
2991- handler (function) #optional handler for the event
2992= (object) @Element
2993\*/
2994
2995/*\2996* Element.dblclick
2997[ method ]
2998**
2999* Adds event handler for double click for the element.
3000> Parameters
3001- handler (function) handler for the event
3002= (object) @Element
3003\*/
3004/*\3005* Element.undblclick
3006[ method ]
3007**
3008* Removes event handler for double click for the element.
3009> Parameters
3010- handler (function) #optional handler for the event
3011= (object) @Element
3012\*/
3013
3014/*\3015* Element.mousedown
3016[ method ]
3017**
3018* Adds event handler for mousedown for the element.
3019> Parameters
3020- handler (function) handler for the event
3021= (object) @Element
3022\*/
3023/*\3024* Element.unmousedown
3025[ method ]
3026**
3027* Removes event handler for mousedown for the element.
3028> Parameters
3029- handler (function) #optional handler for the event
3030= (object) @Element
3031\*/
3032
3033/*\3034* Element.mousemove
3035[ method ]
3036**
3037* Adds event handler for mousemove for the element.
3038> Parameters
3039- handler (function) handler for the event
3040= (object) @Element
3041\*/
3042/*\3043* Element.unmousemove
3044[ method ]
3045**
3046* Removes event handler for mousemove for the element.
3047> Parameters
3048- handler (function) #optional handler for the event
3049= (object) @Element
3050\*/
3051
3052/*\3053* Element.mouseout
3054[ method ]
3055**
3056* Adds event handler for mouseout for the element.
3057> Parameters
3058- handler (function) handler for the event
3059= (object) @Element
3060\*/
3061/*\3062* Element.unmouseout
3063[ method ]
3064**
3065* Removes event handler for mouseout for the element.
3066> Parameters
3067- handler (function) #optional handler for the event
3068= (object) @Element
3069\*/
3070
3071/*\3072* Element.mouseover
3073[ method ]
3074**
3075* Adds event handler for mouseover for the element.
3076> Parameters
3077- handler (function) handler for the event
3078= (object) @Element
3079\*/
3080/*\3081* Element.unmouseover
3082[ method ]
3083**
3084* Removes event handler for mouseover for the element.
3085> Parameters
3086- handler (function) #optional handler for the event
3087= (object) @Element
3088\*/
3089
3090/*\3091* Element.mouseup
3092[ method ]
3093**
3094* Adds event handler for mouseup for the element.
3095> Parameters
3096- handler (function) handler for the event
3097= (object) @Element
3098\*/
3099/*\3100* Element.unmouseup
3101[ method ]
3102**
3103* Removes event handler for mouseup for the element.
3104> Parameters
3105- handler (function) #optional handler for the event
3106= (object) @Element
3107\*/
3108
3109/*\3110* Element.touchstart
3111[ method ]
3112**
3113* Adds event handler for touchstart for the element.
3114> Parameters
3115- handler (function) handler for the event
3116= (object) @Element
3117\*/
3118/*\3119* Element.untouchstart
3120[ method ]
3121**
3122* Removes event handler for touchstart for the element.
3123> Parameters
3124- handler (function) #optional handler for the event
3125= (object) @Element
3126\*/
3127
3128/*\3129* Element.touchmove
3130[ method ]
3131**
3132* Adds event handler for touchmove for the element.
3133> Parameters
3134- handler (function) handler for the event
3135= (object) @Element
3136\*/
3137/*\3138* Element.untouchmove
3139[ method ]
3140**
3141* Removes event handler for touchmove for the element.
3142> Parameters
3143- handler (function) #optional handler for the event
3144= (object) @Element
3145\*/
3146
3147/*\3148* Element.touchend
3149[ method ]
3150**
3151* Adds event handler for touchend for the element.
3152> Parameters
3153- handler (function) handler for the event
3154= (object) @Element
3155\*/
3156/*\3157* Element.untouchend
3158[ method ]
3159**
3160* Removes event handler for touchend for the element.
3161> Parameters
3162- handler (function) #optional handler for the event
3163= (object) @Element
3164\*/
3165
3166/*\3167* Element.touchcancel
3168[ method ]
3169**
3170* Adds event handler for touchcancel for the element.
3171> Parameters
3172- handler (function) handler for the event
3173= (object) @Element
3174\*/
3175/*\3176* Element.untouchcancel
3177[ method ]
3178**
3179* Removes event handler for touchcancel for the element.
3180> Parameters
3181- handler (function) #optional handler for the event
3182= (object) @Element
3183\*/
3184for (var i = events.length; i--;) {3185(function (eventName) {3186R[eventName] = elproto[eventName] = function (fn, scope) {3187if (R.is(fn, "function")) {3188this.events = this.events || [];3189this.events.push({name: eventName, f: fn, unbind: addEvent(this.shape || this.node || g.doc, eventName, fn, scope || this)});3190}3191return this;3192};3193R["un" + eventName] = elproto["un" + eventName] = function (fn) {3194var events = this.events || [],3195l = events.length;3196while (l--){3197if (events[l].name == eventName && (R.is(fn, "undefined") || events[l].f == fn)) {3198events[l].unbind();3199events.splice(l, 1);3200!events.length && delete this.events;3201}3202}3203return this;3204};3205})(events[i]);3206}3207
3208/*\3209* Element.data
3210[ method ]
3211**
3212* Adds or retrieves given value associated with given key.
3213**
3214* See also @Element.removeData
3215> Parameters
3216- key (string) key to store data
3217- value (any) #optional value to store
3218= (object) @Element
3219* or, if value is not specified:
3220= (any) value
3221* or, if key and value are not specified:
3222= (object) Key/value pairs for all the data associated with the element.
3223> Usage
3224| for (var i = 0, i < 5, i++) {
3225| paper.circle(10 + 15 * i, 10, 10)
3226| .attr({fill: "#000"})
3227| .data("i", i)
3228| .click(function () {
3229| alert(this.data("i"));
3230| });
3231| }
3232\*/
3233elproto.data = function (key, value) {3234var data = eldata[this.id] = eldata[this.id] || {};3235if (arguments.length == 0) {3236return data;3237}3238if (arguments.length == 1) {3239if (R.is(key, "object")) {3240for (var i in key) if (key[has](i)) {3241this.data(i, key[i]);3242}3243return this;3244}3245eve("raphael.data.get." + this.id, this, data[key], key);3246return data[key];3247}3248data[key] = value;3249eve("raphael.data.set." + this.id, this, value, key);3250return this;3251};3252/*\3253* Element.removeData
3254[ method ]
3255**
3256* Removes value associated with an element by given key.
3257* If key is not provided, removes all the data of the element.
3258> Parameters
3259- key (string) #optional key
3260= (object) @Element
3261\*/
3262elproto.removeData = function (key) {3263if (key == null) {3264delete eldata[this.id];3265} else {3266eldata[this.id] && delete eldata[this.id][key];3267}3268return this;3269};3270/*\3271* Element.getData
3272[ method ]
3273**
3274* Retrieves the element data
3275= (object) data
3276\*/
3277elproto.getData = function () {3278return clone(eldata[this.id] || {});3279};3280/*\3281* Element.hover
3282[ method ]
3283**
3284* Adds event handlers for hover for the element.
3285> Parameters
3286- f_in (function) handler for hover in
3287- f_out (function) handler for hover out
3288- icontext (object) #optional context for hover in handler
3289- ocontext (object) #optional context for hover out handler
3290= (object) @Element
3291\*/
3292elproto.hover = function (f_in, f_out, scope_in, scope_out) {3293return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in);3294};3295/*\3296* Element.unhover
3297[ method ]
3298**
3299* Removes event handlers for hover for the element.
3300> Parameters
3301- f_in (function) handler for hover in
3302- f_out (function) handler for hover out
3303= (object) @Element
3304\*/
3305elproto.unhover = function (f_in, f_out) {3306return this.unmouseover(f_in).unmouseout(f_out);3307};3308var draggable = [];3309/*\3310* Element.drag
3311[ method ]
3312**
3313* Adds event handlers for drag of the element.
3314> Parameters
3315- onmove (function) handler for moving
3316- onstart (function) handler for drag start
3317- onend (function) handler for drag end
3318- mcontext (object) #optional context for moving handler
3319- scontext (object) #optional context for drag start handler
3320- econtext (object) #optional context for drag end handler
3321* Additionally following `drag` events will be triggered: `drag.start.<id>` on start,
3322* `drag.end.<id>` on end and `drag.move.<id>` on every move. When element will be dragged over another element
3323* `drag.over.<id>` will be fired as well.
3324*
3325* Start event and start handler will be called in specified context or in context of the element with following parameters:
3326o x (number) x position of the mouse
3327o y (number) y position of the mouse
3328o event (object) DOM event object
3329* Move event and move handler will be called in specified context or in context of the element with following parameters:
3330o dx (number) shift by x from the start point
3331o dy (number) shift by y from the start point
3332o x (number) x position of the mouse
3333o y (number) y position of the mouse
3334o event (object) DOM event object
3335* End event and end handler will be called in specified context or in context of the element with following parameters:
3336o event (object) DOM event object
3337= (object) @Element
3338\*/
3339elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) {3340function start(e) {3341(e.originalEvent || e).preventDefault();3342var x = e.clientX,3343y = e.clientY,3344scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,3345scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft;3346this._drag.id = e.identifier;3347if (supportsTouch && e.touches) {3348var i = e.touches.length, touch;3349while (i--) {3350touch = e.touches[i];3351this._drag.id = touch.identifier;3352if (touch.identifier == this._drag.id) {3353x = touch.clientX;3354y = touch.clientY;3355break;3356}3357}3358}3359this._drag.x = x + scrollX;3360this._drag.y = y + scrollY;3361!drag.length && R.mousemove(dragMove).mouseup(dragUp);3362drag.push({el: this, move_scope: move_scope, start_scope: start_scope, end_scope: end_scope});3363onstart && eve.on("raphael.drag.start." + this.id, onstart);3364onmove && eve.on("raphael.drag.move." + this.id, onmove);3365onend && eve.on("raphael.drag.end." + this.id, onend);3366eve("raphael.drag.start." + this.id, start_scope || move_scope || this, this._drag.x, this._drag.y, e);3367}3368this._drag = {};3369draggable.push({el: this, start: start});3370this.mousedown(start);3371return this;3372};3373/*\3374* Element.onDragOver
3375[ method ]
3376**
3377* Shortcut for assigning event handler for `drag.over.<id>` event, where id is id of the element (see @Element.id).
3378> Parameters
3379- f (function) handler for event, first argument would be the element you are dragging over
3380\*/
3381elproto.onDragOver = function (f) {3382f ? eve.on("raphael.drag.over." + this.id, f) : eve.unbind("raphael.drag.over." + this.id);3383};3384/*\3385* Element.undrag
3386[ method ]
3387**
3388* Removes all drag event handlers from given element.
3389\*/
3390elproto.undrag = function () {3391var i = draggable.length;3392while (i--) if (draggable[i].el == this) {3393this.unmousedown(draggable[i].start);3394draggable.splice(i, 1);3395eve.unbind("raphael.drag.*." + this.id);3396}3397!draggable.length && R.unmousemove(dragMove).unmouseup(dragUp);3398drag = [];3399};3400/*\3401* Paper.circle
3402[ method ]
3403**
3404* Draws a circle.
3405**
3406> Parameters
3407**
3408- x (number) x coordinate of the centre
3409- y (number) y coordinate of the centre
3410- r (number) radius
3411= (object) Raphaël element object with type “circle”
3412**
3413> Usage
3414| var c = paper.circle(50, 50, 40);
3415\*/
3416paperproto.circle = function (x, y, r) {3417var out = R._engine.circle(this, x || 0, y || 0, r || 0);3418this.__set__ && this.__set__.push(out);3419return out;3420};3421/*\3422* Paper.rect
3423[ method ]
3424*
3425* Draws a rectangle.
3426**
3427> Parameters
3428**
3429- x (number) x coordinate of the top left corner
3430- y (number) y coordinate of the top left corner
3431- width (number) width
3432- height (number) height
3433- r (number) #optional radius for rounded corners, default is 0
3434= (object) Raphaël element object with type “rect”
3435**
3436> Usage
3437| // regular rectangle
3438| var c = paper.rect(10, 10, 50, 50);
3439| // rectangle with rounded corners
3440| var c = paper.rect(40, 40, 50, 50, 10);
3441\*/
3442paperproto.rect = function (x, y, w, h, r) {3443var out = R._engine.rect(this, x || 0, y || 0, w || 0, h || 0, r || 0);3444this.__set__ && this.__set__.push(out);3445return out;3446};3447/*\3448* Paper.ellipse
3449[ method ]
3450**
3451* Draws an ellipse.
3452**
3453> Parameters
3454**
3455- x (number) x coordinate of the centre
3456- y (number) y coordinate of the centre
3457- rx (number) horizontal radius
3458- ry (number) vertical radius
3459= (object) Raphaël element object with type “ellipse”
3460**
3461> Usage
3462| var c = paper.ellipse(50, 50, 40, 20);
3463\*/
3464paperproto.ellipse = function (x, y, rx, ry) {3465var out = R._engine.ellipse(this, x || 0, y || 0, rx || 0, ry || 0);3466this.__set__ && this.__set__.push(out);3467return out;3468};3469/*\3470* Paper.path
3471[ method ]
3472**
3473* Creates a path element by given path data string.
3474> Parameters
3475- pathString (string) #optional path string in SVG format.
3476* Path string consists of one-letter commands, followed by comma seprarated arguments in numercal form. Example:
3477| "M10,20L30,40"
3478* Here we can see two commands: “M”, with arguments `(10, 20)` and “L” with arguments `(30, 40)`. Upper case letter mean command is absolute, lower case—relative.
3479*
3480# <p>Here is short list of commands available, for more details see <a href="http://www.w3.org/TR/SVG/paths.html#PathData" title="Details of a path's data attribute's format are described in the SVG specification.">SVG path string format</a>.</p>
3481# <table><thead><tr><th>Command</th><th>Name</th><th>Parameters</th></tr></thead><tbody>
3482# <tr><td>M</td><td>moveto</td><td>(x y)+</td></tr>
3483# <tr><td>Z</td><td>closepath</td><td>(none)</td></tr>
3484# <tr><td>L</td><td>lineto</td><td>(x y)+</td></tr>
3485# <tr><td>H</td><td>horizontal lineto</td><td>x+</td></tr>
3486# <tr><td>V</td><td>vertical lineto</td><td>y+</td></tr>
3487# <tr><td>C</td><td>curveto</td><td>(x1 y1 x2 y2 x y)+</td></tr>
3488# <tr><td>S</td><td>smooth curveto</td><td>(x2 y2 x y)+</td></tr>
3489# <tr><td>Q</td><td>quadratic Bézier curveto</td><td>(x1 y1 x y)+</td></tr>
3490# <tr><td>T</td><td>smooth quadratic Bézier curveto</td><td>(x y)+</td></tr>
3491# <tr><td>A</td><td>elliptical arc</td><td>(rx ry x-axis-rotation large-arc-flag sweep-flag x y)+</td></tr>
3492# <tr><td>R</td><td><a href="http://en.wikipedia.org/wiki/Catmull–Rom_spline#Catmull.E2.80.93Rom_spline">Catmull-Rom curveto</a>*</td><td>x1 y1 (x y)+</td></tr></tbody></table>
3493* * “Catmull-Rom curveto” is a not standard SVG command and added in 2.0 to make life easier.
3494* Note: there is a special case when path consist of just three commands: “M10,10R…z”. In this case path will smoothly connects to its beginning.
3495> Usage
3496| var c = paper.path("M10 10L90 90");
3497| // draw a diagonal line:
3498| // move to 10,10, line to 90,90
3499* For example of path strings, check out these icons: http://raphaeljs.com/icons/
3500\*/
3501paperproto.path = function (pathString) {3502pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E);3503var out = R._engine.path(R.format[apply](R, arguments), this);3504this.__set__ && this.__set__.push(out);3505return out;3506};3507/*\3508* Paper.image
3509[ method ]
3510**
3511* Embeds an image into the surface.
3512**
3513> Parameters
3514**
3515- src (string) URI of the source image
3516- x (number) x coordinate position
3517- y (number) y coordinate position
3518- width (number) width of the image
3519- height (number) height of the image
3520= (object) Raphaël element object with type “image”
3521**
3522> Usage
3523| var c = paper.image("apple.png", 10, 10, 80, 80);
3524\*/
3525paperproto.image = function (src, x, y, w, h) {3526var out = R._engine.image(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0);3527this.__set__ && this.__set__.push(out);3528return out;3529};3530/*\3531* Paper.text
3532[ method ]
3533**
3534* Draws a text string. If you need line breaks, put “\n” in the string.
3535**
3536> Parameters
3537**
3538- x (number) x coordinate position
3539- y (number) y coordinate position
3540- text (string) The text string to draw
3541= (object) Raphaël element object with type “text”
3542**
3543> Usage
3544| var t = paper.text(50, 50, "Raphaël\nkicks\nbutt!");
3545\*/
3546paperproto.text = function (x, y, text) {3547var out = R._engine.text(this, x || 0, y || 0, Str(text));3548this.__set__ && this.__set__.push(out);3549return out;3550};3551/*\3552* Paper.set
3553[ method ]
3554**
3555* Creates array-like object to keep and operate several elements at once.
3556* Warning: it doesn’t create any elements for itself in the page, it just groups existing elements.
3557* Sets act as pseudo elements — all methods available to an element can be used on a set.
3558= (object) array-like object that represents set of elements
3559**
3560> Usage
3561| var st = paper.set();
3562| st.push(
3563| paper.circle(10, 10, 5),
3564| paper.circle(30, 10, 5)
3565| );
3566| st.attr({fill: "red"}); // changes the fill of both circles
3567\*/
3568paperproto.set = function (itemsArray) {3569!R.is(itemsArray, "array") && (itemsArray = Array.prototype.splice.call(arguments, 0, arguments.length));3570var out = new Set(itemsArray);3571this.__set__ && this.__set__.push(out);3572out["paper"] = this;3573out["type"] = "set";3574return out;3575};3576/*\3577* Paper.setStart
3578[ method ]
3579**
3580* Creates @Paper.set. All elements that will be created after calling this method and before calling
3581* @Paper.setFinish will be added to the set.
3582**
3583> Usage
3584| paper.setStart();
3585| paper.circle(10, 10, 5),
3586| paper.circle(30, 10, 5)
3587| var st = paper.setFinish();
3588| st.attr({fill: "red"}); // changes the fill of both circles
3589\*/
3590paperproto.setStart = function (set) {3591this.__set__ = set || this.set();3592};3593/*\3594* Paper.setFinish
3595[ method ]
3596**
3597* See @Paper.setStart. This method finishes catching and returns resulting set.
3598**
3599= (object) set
3600\*/
3601paperproto.setFinish = function (set) {3602var out = this.__set__;3603delete this.__set__;3604return out;3605};3606/*\3607* Paper.getSize
3608[ method ]
3609**
3610* Obtains current paper actual size.
3611**
3612= (object)
3613\*/
3614paperproto.getSize = function () {3615var container = this.canvas.parentNode;3616return {3617width: container.offsetWidth,3618height: container.offsetHeight3619};3620};3621/*\3622* Paper.setSize
3623[ method ]
3624**
3625* If you need to change dimensions of the canvas call this method
3626**
3627> Parameters
3628**
3629- width (number) new width of the canvas
3630- height (number) new height of the canvas
3631\*/
3632paperproto.setSize = function (width, height) {3633return R._engine.setSize.call(this, width, height);3634};3635/*\3636* Paper.setViewBox
3637[ method ]
3638**
3639* Sets the view box of the paper. Practically it gives you ability to zoom and pan whole paper surface by
3640* specifying new boundaries.
3641**
3642> Parameters
3643**
3644- x (number) new x position, default is `0`
3645- y (number) new y position, default is `0`
3646- w (number) new width of the canvas
3647- h (number) new height of the canvas
3648- fit (boolean) `true` if you want graphics to fit into new boundary box
3649\*/
3650paperproto.setViewBox = function (x, y, w, h, fit) {3651return R._engine.setViewBox.call(this, x, y, w, h, fit);3652};3653/*\3654* Paper.top
3655[ property ]
3656**
3657* Points to the topmost element on the paper
3658\*/
3659/*\3660* Paper.bottom
3661[ property ]
3662**
3663* Points to the bottom element on the paper
3664\*/
3665paperproto.top = paperproto.bottom = null;3666/*\3667* Paper.raphael
3668[ property ]
3669**
3670* Points to the @Raphael object/function
3671\*/
3672paperproto.raphael = R;3673var getOffset = function (elem) {3674var box = elem.getBoundingClientRect(),3675doc = elem.ownerDocument,3676body = doc.body,3677docElem = doc.documentElement,3678clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,3679top = box.top + (g.win.pageYOffset || docElem.scrollTop || body.scrollTop ) - clientTop,3680left = box.left + (g.win.pageXOffset || docElem.scrollLeft || body.scrollLeft) - clientLeft;3681return {3682y: top,3683x: left3684};3685};3686/*\3687* Paper.getElementByPoint
3688[ method ]
3689**
3690* Returns you topmost element under given point.
3691**
3692= (object) Raphaël element object
3693> Parameters
3694**
3695- x (number) x coordinate from the top left corner of the window
3696- y (number) y coordinate from the top left corner of the window
3697> Usage
3698| paper.getElementByPoint(mouseX, mouseY).attr({stroke: "#f00"});
3699\*/
3700paperproto.getElementByPoint = function (x, y) {3701var paper = this,3702svg = paper.canvas,3703target = g.doc.elementFromPoint(x, y);3704if (g.win.opera && target.tagName == "svg") {3705var so = getOffset(svg),3706sr = svg.createSVGRect();3707sr.x = x - so.x;3708sr.y = y - so.y;3709sr.width = sr.height = 1;3710var hits = svg.getIntersectionList(sr, null);3711if (hits.length) {3712target = hits[hits.length - 1];3713}3714}3715if (!target) {3716return null;3717}3718while (target.parentNode && target != svg.parentNode && !target.raphael) {3719target = target.parentNode;3720}3721target == paper.canvas.parentNode && (target = svg);3722target = target && target.raphael ? paper.getById(target.raphaelid) : null;3723return target;3724};3725
3726/*\3727* Paper.getElementsByBBox
3728[ method ]
3729**
3730* Returns set of elements that have an intersecting bounding box
3731**
3732> Parameters
3733**
3734- bbox (object) bbox to check with
3735= (object) @Set
3736\*/
3737paperproto.getElementsByBBox = function (bbox) {3738var set = this.set();3739this.forEach(function (el) {3740if (R.isBBoxIntersect(el.getBBox(), bbox)) {3741set.push(el);3742}3743});3744return set;3745};3746
3747/*\3748* Paper.getById
3749[ method ]
3750**
3751* Returns you element by its internal ID.
3752**
3753> Parameters
3754**
3755- id (number) id
3756= (object) Raphaël element object
3757\*/
3758paperproto.getById = function (id) {3759var bot = this.bottom;3760while (bot) {3761if (bot.id == id) {3762return bot;3763}3764bot = bot.next;3765}3766return null;3767};3768/*\3769* Paper.forEach
3770[ method ]
3771**
3772* Executes given function for each element on the paper
3773*
3774* If callback function returns `false` it will stop loop running.
3775**
3776> Parameters
3777**
3778- callback (function) function to run
3779- thisArg (object) context object for the callback
3780= (object) Paper object
3781> Usage
3782| paper.forEach(function (el) {
3783| el.attr({ stroke: "blue" });
3784| });
3785\*/
3786paperproto.forEach = function (callback, thisArg) {3787var bot = this.bottom;3788while (bot) {3789if (callback.call(thisArg, bot) === false) {3790return this;3791}3792bot = bot.next;3793}3794return this;3795};3796/*\3797* Paper.getElementsByPoint
3798[ method ]
3799**
3800* Returns set of elements that have common point inside
3801**
3802> Parameters
3803**
3804- x (number) x coordinate of the point
3805- y (number) y coordinate of the point
3806= (object) @Set
3807\*/
3808paperproto.getElementsByPoint = function (x, y) {3809var set = this.set();3810this.forEach(function (el) {3811if (el.isPointInside(x, y)) {3812set.push(el);3813}3814});3815return set;3816};3817function x_y() {3818return this.x + S + this.y;3819}3820function x_y_w_h() {3821return this.x + S + this.y + S + this.width + " \xd7 " + this.height;3822}3823/*\3824* Element.isPointInside
3825[ method ]
3826**
3827* Determine if given point is inside this element’s shape
3828**
3829> Parameters
3830**
3831- x (number) x coordinate of the point
3832- y (number) y coordinate of the point
3833= (boolean) `true` if point inside the shape
3834\*/
3835elproto.isPointInside = function (x, y) {3836var rp = this.realPath = getPath[this.type](this);3837if (this.attr('transform') && this.attr('transform').length) {3838rp = R.transformPath(rp, this.attr('transform'));3839}3840return R.isPointInsidePath(rp, x, y);3841};3842/*\3843* Element.getBBox
3844[ method ]
3845**
3846* Return bounding box for a given element
3847**
3848> Parameters
3849**
3850- isWithoutTransform (boolean) flag, `true` if you want to have bounding box before transformations. Default is `false`.
3851= (object) Bounding box object:
3852o {
3853o x: (number) top left corner x
3854o y: (number) top left corner y
3855o x2: (number) bottom right corner x
3856o y2: (number) bottom right corner y
3857o width: (number) width
3858o height: (number) height
3859o }
3860\*/
3861elproto.getBBox = function (isWithoutTransform) {3862if (this.removed) {3863return {};3864}3865var _ = this._;3866if (isWithoutTransform) {3867if (_.dirty || !_.bboxwt) {3868this.realPath = getPath[this.type](this);3869_.bboxwt = pathDimensions(this.realPath);3870_.bboxwt.toString = x_y_w_h;3871_.dirty = 0;3872}3873return _.bboxwt;3874}3875if (_.dirty || _.dirtyT || !_.bbox) {3876if (_.dirty || !this.realPath) {3877_.bboxwt = 0;3878this.realPath = getPath[this.type](this);3879}3880_.bbox = pathDimensions(mapPath(this.realPath, this.matrix));3881_.bbox.toString = x_y_w_h;3882_.dirty = _.dirtyT = 0;3883}3884return _.bbox;3885};3886/*\3887* Element.clone
3888[ method ]
3889**
3890= (object) clone of a given element
3891**
3892\*/
3893elproto.clone = function () {3894if (this.removed) {3895return null;3896}3897var out = this.paper[this.type]().attr(this.attr());3898this.__set__ && this.__set__.push(out);3899return out;3900};3901/*\3902* Element.glow
3903[ method ]
3904**
3905* Return set of elements that create glow-like effect around given element. See @Paper.set.
3906*
3907* Note: Glow is not connected to the element. If you change element attributes it won’t adjust itself.
3908**
3909> Parameters
3910**
3911- glow (object) #optional parameters object with all properties optional:
3912o {
3913o width (number) size of the glow, default is `10`
3914o fill (boolean) will it be filled, default is `false`
3915o opacity (number) opacity, default is `0.5`
3916o offsetx (number) horizontal offset, default is `0`
3917o offsety (number) vertical offset, default is `0`
3918o color (string) glow colour, default is `black`
3919o }
3920= (object) @Paper.set of elements that represents glow
3921\*/
3922elproto.glow = function (glow) {3923if (this.type == "text") {3924return null;3925}3926glow = glow || {};3927var s = {3928width: (glow.width || 10) + (+this.attr("stroke-width") || 1),3929fill: glow.fill || false,3930opacity: glow.opacity == null ? .5 : glow.opacity,3931offsetx: glow.offsetx || 0,3932offsety: glow.offsety || 0,3933color: glow.color || "#000"3934},3935c = s.width / 2,3936r = this.paper,3937out = r.set(),3938path = this.realPath || getPath[this.type](this);3939path = this.matrix ? mapPath(path, this.matrix) : path;3940for (var i = 1; i < c + 1; i++) {3941out.push(r.path(path).attr({3942stroke: s.color,3943fill: s.fill ? s.color : "none",3944"stroke-linejoin": "round",3945"stroke-linecap": "round",3946"stroke-width": +(s.width / c * i).toFixed(3),3947opacity: +(s.opacity / c).toFixed(3)3948}));3949}3950return out.insertBefore(this).translate(s.offsetx, s.offsety);3951};3952var curveslengths = {},3953getPointAtSegmentLength = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) {3954if (length == null) {3955return bezlen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);3956} else {3957return R.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, getTatLen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length));3958}3959},3960getLengthFactory = function (istotal, subpath) {3961return function (path, length, onlystart) {3962path = path2curve(path);3963var x, y, p, l, sp = "", subpaths = {}, point,3964len = 0;3965for (var i = 0, ii = path.length; i < ii; i++) {3966p = path[i];3967if (p[0] == "M") {3968x = +p[1];3969y = +p[2];3970} else {3971l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);3972if (len + l > length) {3973if (subpath && !subpaths.start) {3974point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);3975sp += ["C" + point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y];3976if (onlystart) {return sp;}3977subpaths.start = sp;3978sp = ["M" + point.x, point.y + "C" + point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]].join();3979len += l;3980x = +p[5];3981y = +p[6];3982continue;3983}3984if (!istotal && !subpath) {3985point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);3986return {x: point.x, y: point.y, alpha: point.alpha};3987}3988}3989len += l;3990x = +p[5];3991y = +p[6];3992}3993sp += p.shift() + p;3994}3995subpaths.end = sp;3996point = istotal ? len : subpath ? subpaths : R.findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1);3997point.alpha && (point = {x: point.x, y: point.y, alpha: point.alpha});3998return point;3999};4000};4001var getTotalLength = getLengthFactory(1),4002getPointAtLength = getLengthFactory(),4003getSubpathsAtLength = getLengthFactory(0, 1);4004/*\4005* Raphael.getTotalLength
4006[ method ]
4007**
4008* Returns length of the given path in pixels.
4009**
4010> Parameters
4011**
4012- path (string) SVG path string.
4013**
4014= (number) length.
4015\*/
4016R.getTotalLength = getTotalLength;4017/*\4018* Raphael.getPointAtLength
4019[ method ]
4020**
4021* Return coordinates of the point located at the given length on the given path.
4022**
4023> Parameters
4024**
4025- path (string) SVG path string
4026- length (number)
4027**
4028= (object) representation of the point:
4029o {
4030o x: (number) x coordinate
4031o y: (number) y coordinate
4032o alpha: (number) angle of derivative
4033o }
4034\*/
4035R.getPointAtLength = getPointAtLength;4036/*\4037* Raphael.getSubpath
4038[ method ]
4039**
4040* Return subpath of a given path from given length to given length.
4041**
4042> Parameters
4043**
4044- path (string) SVG path string
4045- from (number) position of the start of the segment
4046- to (number) position of the end of the segment
4047**
4048= (string) pathstring for the segment
4049\*/
4050R.getSubpath = function (path, from, to) {4051if (this.getTotalLength(path) - to < 1e-6) {4052return getSubpathsAtLength(path, from).end;4053}4054var a = getSubpathsAtLength(path, to, 1);4055return from ? getSubpathsAtLength(a, from).end : a;4056};4057/*\4058* Element.getTotalLength
4059[ method ]
4060**
4061* Returns length of the path in pixels. Only works for element of “path” type.
4062= (number) length.
4063\*/
4064elproto.getTotalLength = function () {4065var path = this.getPath();4066if (!path) {4067return;4068}4069
4070if (this.node.getTotalLength) {4071return this.node.getTotalLength();4072}4073
4074return getTotalLength(path);4075};4076/*\4077* Element.getPointAtLength
4078[ method ]
4079**
4080* Return coordinates of the point located at the given length on the given path. Only works for element of “path” type.
4081**
4082> Parameters
4083**
4084- length (number)
4085**
4086= (object) representation of the point:
4087o {
4088o x: (number) x coordinate
4089o y: (number) y coordinate
4090o alpha: (number) angle of derivative
4091o }
4092\*/
4093elproto.getPointAtLength = function (length) {4094var path = this.getPath();4095if (!path) {4096return;4097}4098
4099return getPointAtLength(path, length);4100};4101/*\4102* Element.getPath
4103[ method ]
4104**
4105* Returns path of the element. Only works for elements of “path” type and simple elements like circle.
4106= (object) path
4107**
4108\*/
4109elproto.getPath = function () {4110var path,4111getPath = R._getPath[this.type];4112
4113if (this.type == "text" || this.type == "set") {4114return;4115}4116
4117if (getPath) {4118path = getPath(this);4119}4120
4121return path;4122};4123/*\4124* Element.getSubpath
4125[ method ]
4126**
4127* Return subpath of a given element from given length to given length. Only works for element of “path” type.
4128**
4129> Parameters
4130**
4131- from (number) position of the start of the segment
4132- to (number) position of the end of the segment
4133**
4134= (string) pathstring for the segment
4135\*/
4136elproto.getSubpath = function (from, to) {4137var path = this.getPath();4138if (!path) {4139return;4140}4141
4142return R.getSubpath(path, from, to);4143};4144/*\4145* Raphael.easing_formulas
4146[ property ]
4147**
4148* Object that contains easing formulas for animation. You could extend it with your own. By default it has following list of easing:
4149# <ul>
4150# <li>“linear”</li>
4151# <li>“<” or “easeIn” or “ease-in”</li>
4152# <li>“>” or “easeOut” or “ease-out”</li>
4153# <li>“<>” or “easeInOut” or “ease-in-out”</li>
4154# <li>“backIn” or “back-in”</li>
4155# <li>“backOut” or “back-out”</li>
4156# <li>“elastic”</li>
4157# <li>“bounce”</li>
4158# </ul>
4159# <p>See also <a href="http://raphaeljs.com/easing.html">Easing demo</a>.</p>
4160\*/
4161var ef = R.easing_formulas = {4162linear: function (n) {4163return n;4164},4165"<": function (n) {4166return pow(n, 1.7);4167},4168">": function (n) {4169return pow(n, .48);4170},4171"<>": function (n) {4172var q = .48 - n / 1.04,4173Q = math.sqrt(.1734 + q * q),4174x = Q - q,4175X = pow(abs(x), 1 / 3) * (x < 0 ? -1 : 1),4176y = -Q - q,4177Y = pow(abs(y), 1 / 3) * (y < 0 ? -1 : 1),4178t = X + Y + .5;4179return (1 - t) * 3 * t * t + t * t * t;4180},4181backIn: function (n) {4182var s = 1.70158;4183return n * n * ((s + 1) * n - s);4184},4185backOut: function (n) {4186n = n - 1;4187var s = 1.70158;4188return n * n * ((s + 1) * n + s) + 1;4189},4190elastic: function (n) {4191if (n == !!n) {4192return n;4193}4194return pow(2, -10 * n) * math.sin((n - .075) * (2 * PI) / .3) + 1;4195},4196bounce: function (n) {4197var s = 7.5625,4198p = 2.75,4199l;4200if (n < (1 / p)) {4201l = s * n * n;4202} else {4203if (n < (2 / p)) {4204n -= (1.5 / p);4205l = s * n * n + .75;4206} else {4207if (n < (2.5 / p)) {4208n -= (2.25 / p);4209l = s * n * n + .9375;4210} else {4211n -= (2.625 / p);4212l = s * n * n + .984375;4213}4214}4215}4216return l;4217}4218};4219ef.easeIn = ef["ease-in"] = ef["<"];4220ef.easeOut = ef["ease-out"] = ef[">"];4221ef.easeInOut = ef["ease-in-out"] = ef["<>"];4222ef["back-in"] = ef.backIn;4223ef["back-out"] = ef.backOut;4224
4225var animationElements = [],4226requestAnimFrame = window.requestAnimationFrame ||4227window.webkitRequestAnimationFrame ||4228window.mozRequestAnimationFrame ||4229window.oRequestAnimationFrame ||4230window.msRequestAnimationFrame ||4231function (callback) {4232setTimeout(callback, 16);4233},4234animation = function () {4235var Now = +new Date,4236l = 0;4237for (; l < animationElements.length; l++) {4238var e = animationElements[l];4239if (e.el.removed || e.paused) {4240continue;4241}4242var time = Now - e.start,4243ms = e.ms,4244easing = e.easing,4245from = e.from,4246diff = e.diff,4247to = e.to,4248t = e.t,4249that = e.el,4250set = {},4251now,4252init = {},4253key;4254if (e.initstatus) {4255time = (e.initstatus * e.anim.top - e.prev) / (e.percent - e.prev) * ms;4256e.status = e.initstatus;4257delete e.initstatus;4258e.stop && animationElements.splice(l--, 1);4259} else {4260e.status = (e.prev + (e.percent - e.prev) * (time / ms)) / e.anim.top;4261}4262if (time < 0) {4263continue;4264}4265if (time < ms) {4266var pos = easing(time / ms);4267for (var attr in from) if (from[has](attr)) {4268switch (availableAnimAttrs[attr]) {4269case nu:4270now = +from[attr] + pos * ms * diff[attr];4271break;4272case "colour":4273now = "rgb(" + [4274upto255(round(from[attr].r + pos * ms * diff[attr].r)),4275upto255(round(from[attr].g + pos * ms * diff[attr].g)),4276upto255(round(from[attr].b + pos * ms * diff[attr].b))4277].join(",") + ")";4278break;4279case "path":4280now = [];4281for (var i = 0, ii = from[attr].length; i < ii; i++) {4282now[i] = [from[attr][i][0]];4283for (var j = 1, jj = from[attr][i].length; j < jj; j++) {4284now[i][j] = +from[attr][i][j] + pos * ms * diff[attr][i][j];4285}4286now[i] = now[i].join(S);4287}4288now = now.join(S);4289break;4290case "transform":4291if (diff[attr].real) {4292now = [];4293for (i = 0, ii = from[attr].length; i < ii; i++) {4294now[i] = [from[attr][i][0]];4295for (j = 1, jj = from[attr][i].length; j < jj; j++) {4296now[i][j] = from[attr][i][j] + pos * ms * diff[attr][i][j];4297}4298}4299} else {4300var get = function (i) {4301return +from[attr][i] + pos * ms * diff[attr][i];4302};4303// now = [["r", get(2), 0, 0], ["t", get(3), get(4)], ["s", get(0), get(1), 0, 0]];4304now = [["m", get(0), get(1), get(2), get(3), get(4), get(5)]];4305}4306break;4307case "csv":4308if (attr == "clip-rect") {4309now = [];4310i = 4;4311while (i--) {4312now[i] = +from[attr][i] + pos * ms * diff[attr][i];4313}4314}4315break;4316default:4317var from2 = [][concat](from[attr]);4318now = [];4319i = that.paper.customAttributes[attr].length;4320while (i--) {4321now[i] = +from2[i] + pos * ms * diff[attr][i];4322}4323break;4324}4325set[attr] = now;4326}4327that.attr(set);4328(function (id, that, anim) {4329setTimeout(function () {4330eve("raphael.anim.frame." + id, that, anim);4331});4332})(that.id, that, e.anim);4333} else {4334(function(f, el, a) {4335setTimeout(function() {4336eve("raphael.anim.frame." + el.id, el, a);4337eve("raphael.anim.finish." + el.id, el, a);4338R.is(f, "function") && f.call(el);4339});4340})(e.callback, that, e.anim);4341that.attr(to);4342animationElements.splice(l--, 1);4343if (e.repeat > 1 && !e.next) {4344for (key in to) if (to[has](key)) {4345init[key] = e.totalOrigin[key];4346}4347e.el.attr(init);4348runAnimation(e.anim, e.el, e.anim.percents[0], null, e.totalOrigin, e.repeat - 1);4349}4350if (e.next && !e.stop) {4351runAnimation(e.anim, e.el, e.next, null, e.totalOrigin, e.repeat);4352}4353}4354}4355animationElements.length && requestAnimFrame(animation);4356},4357upto255 = function (color) {4358return color > 255 ? 255 : color < 0 ? 0 : color;4359};4360/*\4361* Element.animateWith
4362[ method ]
4363**
4364* Acts similar to @Element.animate, but ensure that given animation runs in sync with another given element.
4365**
4366> Parameters
4367**
4368- el (object) element to sync with
4369- anim (object) animation to sync with
4370- params (object) #optional final attributes for the element, see also @Element.attr
4371- ms (number) #optional number of milliseconds for animation to run
4372- easing (string) #optional easing type. Accept on of @Raphael.easing_formulas or CSS format: `cubic‐bezier(XX, XX, XX, XX)`
4373- callback (function) #optional callback function. Will be called at the end of animation.
4374* or
4375- element (object) element to sync with
4376- anim (object) animation to sync with
4377- animation (object) #optional animation object, see @Raphael.animation
4378**
4379= (object) original element
4380\*/
4381elproto.animateWith = function (el, anim, params, ms, easing, callback) {4382var element = this;4383if (element.removed) {4384callback && callback.call(element);4385return element;4386}4387var a = params instanceof Animation ? params : R.animation(params, ms, easing, callback),4388x, y;4389runAnimation(a, element, a.percents[0], null, element.attr());4390for (var i = 0, ii = animationElements.length; i < ii; i++) {4391if (animationElements[i].anim == anim && animationElements[i].el == el) {4392animationElements[ii - 1].start = animationElements[i].start;4393break;4394}4395}4396return element;4397//4398//4399// var a = params ? R.animation(params, ms, easing, callback) : anim,4400// status = element.status(anim);4401// return this.animate(a).status(a, status * anim.ms / a.ms);4402};4403function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) {4404var cx = 3 * p1x,4405bx = 3 * (p2x - p1x) - cx,4406ax = 1 - cx - bx,4407cy = 3 * p1y,4408by = 3 * (p2y - p1y) - cy,4409ay = 1 - cy - by;4410function sampleCurveX(t) {4411return ((ax * t + bx) * t + cx) * t;4412}4413function solve(x, epsilon) {4414var t = solveCurveX(x, epsilon);4415return ((ay * t + by) * t + cy) * t;4416}4417function solveCurveX(x, epsilon) {4418var t0, t1, t2, x2, d2, i;4419for(t2 = x, i = 0; i < 8; i++) {4420x2 = sampleCurveX(t2) - x;4421if (abs(x2) < epsilon) {4422return t2;4423}4424d2 = (3 * ax * t2 + 2 * bx) * t2 + cx;4425if (abs(d2) < 1e-6) {4426break;4427}4428t2 = t2 - x2 / d2;4429}4430t0 = 0;4431t1 = 1;4432t2 = x;4433if (t2 < t0) {4434return t0;4435}4436if (t2 > t1) {4437return t1;4438}4439while (t0 < t1) {4440x2 = sampleCurveX(t2);4441if (abs(x2 - x) < epsilon) {4442return t2;4443}4444if (x > x2) {4445t0 = t2;4446} else {4447t1 = t2;4448}4449t2 = (t1 - t0) / 2 + t0;4450}4451return t2;4452}4453return solve(t, 1 / (200 * duration));4454}4455elproto.onAnimation = function (f) {4456f ? eve.on("raphael.anim.frame." + this.id, f) : eve.unbind("raphael.anim.frame." + this.id);4457return this;4458};4459function Animation(anim, ms) {4460var percents = [],4461newAnim = {};4462this.ms = ms;4463this.times = 1;4464if (anim) {4465for (var attr in anim) if (anim[has](attr)) {4466newAnim[toFloat(attr)] = anim[attr];4467percents.push(toFloat(attr));4468}4469percents.sort(sortByNumber);4470}4471this.anim = newAnim;4472this.top = percents[percents.length - 1];4473this.percents = percents;4474}4475/*\4476* Animation.delay
4477[ method ]
4478**
4479* Creates a copy of existing animation object with given delay.
4480**
4481> Parameters
4482**
4483- delay (number) number of ms to pass between animation start and actual animation
4484**
4485= (object) new altered Animation object
4486| var anim = Raphael.animation({cx: 10, cy: 20}, 2e3);
4487| circle1.animate(anim); // run the given animation immediately
4488| circle2.animate(anim.delay(500)); // run the given animation after 500 ms
4489\*/
4490Animation.prototype.delay = function (delay) {4491var a = new Animation(this.anim, this.ms);4492a.times = this.times;4493a.del = +delay || 0;4494return a;4495};4496/*\4497* Animation.repeat
4498[ method ]
4499**
4500* Creates a copy of existing animation object with given repetition.
4501**
4502> Parameters
4503**
4504- repeat (number) number iterations of animation. For infinite animation pass `Infinity`
4505**
4506= (object) new altered Animation object
4507\*/
4508Animation.prototype.repeat = function (times) {4509var a = new Animation(this.anim, this.ms);4510a.del = this.del;4511a.times = math.floor(mmax(times, 0)) || 1;4512return a;4513};4514function runAnimation(anim, element, percent, status, totalOrigin, times) {4515percent = toFloat(percent);4516var params,4517isInAnim,4518isInAnimSet,4519percents = [],4520next,4521prev,4522timestamp,4523ms = anim.ms,4524from = {},4525to = {},4526diff = {};4527if (status) {4528for (i = 0, ii = animationElements.length; i < ii; i++) {4529var e = animationElements[i];4530if (e.el.id == element.id && e.anim == anim) {4531if (e.percent != percent) {4532animationElements.splice(i, 1);4533isInAnimSet = 1;4534} else {4535isInAnim = e;4536}4537element.attr(e.totalOrigin);4538break;4539}4540}4541} else {4542status = +to; // NaN4543}4544for (var i = 0, ii = anim.percents.length; i < ii; i++) {4545if (anim.percents[i] == percent || anim.percents[i] > status * anim.top) {4546percent = anim.percents[i];4547prev = anim.percents[i - 1] || 0;4548ms = ms / anim.top * (percent - prev);4549next = anim.percents[i + 1];4550params = anim.anim[percent];4551break;4552} else if (status) {4553element.attr(anim.anim[anim.percents[i]]);4554}4555}4556if (!params) {4557return;4558}4559if (!isInAnim) {4560for (var attr in params) if (params[has](attr)) {4561if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) {4562from[attr] = element.attr(attr);4563(from[attr] == null) && (from[attr] = availableAttrs[attr]);4564to[attr] = params[attr];4565switch (availableAnimAttrs[attr]) {4566case nu:4567diff[attr] = (to[attr] - from[attr]) / ms;4568break;4569case "colour":4570from[attr] = R.getRGB(from[attr]);4571var toColour = R.getRGB(to[attr]);4572diff[attr] = {4573r: (toColour.r - from[attr].r) / ms,4574g: (toColour.g - from[attr].g) / ms,4575b: (toColour.b - from[attr].b) / ms4576};4577break;4578case "path":4579var pathes = path2curve(from[attr], to[attr]),4580toPath = pathes[1];4581from[attr] = pathes[0];4582diff[attr] = [];4583for (i = 0, ii = from[attr].length; i < ii; i++) {4584diff[attr][i] = [0];4585for (var j = 1, jj = from[attr][i].length; j < jj; j++) {4586diff[attr][i][j] = (toPath[i][j] - from[attr][i][j]) / ms;4587}4588}4589break;4590case "transform":4591var _ = element._,4592eq = equaliseTransform(_[attr], to[attr]);4593if (eq) {4594from[attr] = eq.from;4595to[attr] = eq.to;4596diff[attr] = [];4597diff[attr].real = true;4598for (i = 0, ii = from[attr].length; i < ii; i++) {4599diff[attr][i] = [from[attr][i][0]];4600for (j = 1, jj = from[attr][i].length; j < jj; j++) {4601diff[attr][i][j] = (to[attr][i][j] - from[attr][i][j]) / ms;4602}4603}4604} else {4605var m = (element.matrix || new Matrix),4606to2 = {4607_: {transform: _.transform},4608getBBox: function () {4609return element.getBBox(1);4610}4611};4612from[attr] = [4613m.a,4614m.b,4615m.c,4616m.d,4617m.e,4618m.f4619];4620extractTransform(to2, to[attr]);4621to[attr] = to2._.transform;4622diff[attr] = [4623(to2.matrix.a - m.a) / ms,4624(to2.matrix.b - m.b) / ms,4625(to2.matrix.c - m.c) / ms,4626(to2.matrix.d - m.d) / ms,4627(to2.matrix.e - m.e) / ms,4628(to2.matrix.f - m.f) / ms4629];4630// from[attr] = [_.sx, _.sy, _.deg, _.dx, _.dy];4631// var to2 = {_:{}, getBBox: function () { return element.getBBox(); }};4632// extractTransform(to2, to[attr]);4633// diff[attr] = [4634// (to2._.sx - _.sx) / ms,4635// (to2._.sy - _.sy) / ms,4636// (to2._.deg - _.deg) / ms,4637// (to2._.dx - _.dx) / ms,4638// (to2._.dy - _.dy) / ms4639// ];4640}4641break;4642case "csv":4643var values = Str(params[attr])[split](separator),4644from2 = Str(from[attr])[split](separator);4645if (attr == "clip-rect") {4646from[attr] = from2;4647diff[attr] = [];4648i = from2.length;4649while (i--) {4650diff[attr][i] = (values[i] - from[attr][i]) / ms;4651}4652}4653to[attr] = values;4654break;4655default:4656values = [][concat](params[attr]);4657from2 = [][concat](from[attr]);4658diff[attr] = [];4659i = element.paper.customAttributes[attr].length;4660while (i--) {4661diff[attr][i] = ((values[i] || 0) - (from2[i] || 0)) / ms;4662}4663break;4664}4665}4666}4667var easing = params.easing,4668easyeasy = R.easing_formulas[easing];4669if (!easyeasy) {4670easyeasy = Str(easing).match(bezierrg);4671if (easyeasy && easyeasy.length == 5) {4672var curve = easyeasy;4673easyeasy = function (t) {4674return CubicBezierAtTime(t, +curve[1], +curve[2], +curve[3], +curve[4], ms);4675};4676} else {4677easyeasy = pipe;4678}4679}4680timestamp = params.start || anim.start || +new Date;4681e = {4682anim: anim,4683percent: percent,4684timestamp: timestamp,4685start: timestamp + (anim.del || 0),4686status: 0,4687initstatus: status || 0,4688stop: false,4689ms: ms,4690easing: easyeasy,4691from: from,4692diff: diff,4693to: to,4694el: element,4695callback: params.callback,4696prev: prev,4697next: next,4698repeat: times || anim.times,4699origin: element.attr(),4700totalOrigin: totalOrigin4701};4702animationElements.push(e);4703if (status && !isInAnim && !isInAnimSet) {4704e.stop = true;4705e.start = new Date - ms * status;4706if (animationElements.length == 1) {4707return animation();4708}4709}4710if (isInAnimSet) {4711e.start = new Date - e.ms * status;4712}4713animationElements.length == 1 && requestAnimFrame(animation);4714} else {4715isInAnim.initstatus = status;4716isInAnim.start = new Date - isInAnim.ms * status;4717}4718eve("raphael.anim.start." + element.id, element, anim);4719}4720/*\4721* Raphael.animation
4722[ method ]
4723**
4724* Creates an animation object that can be passed to the @Element.animate or @Element.animateWith methods.
4725* See also @Animation.delay and @Animation.repeat methods.
4726**
4727> Parameters
4728**
4729- params (object) final attributes for the element, see also @Element.attr
4730- ms (number) number of milliseconds for animation to run
4731- easing (string) #optional easing type. Accept one of @Raphael.easing_formulas or CSS format: `cubic‐bezier(XX, XX, XX, XX)`
4732- callback (function) #optional callback function. Will be called at the end of animation.
4733**
4734= (object) @Animation
4735\*/
4736R.animation = function (params, ms, easing, callback) {4737if (params instanceof Animation) {4738return params;4739}4740if (R.is(easing, "function") || !easing) {4741callback = callback || easing || null;4742easing = null;4743}4744params = Object(params);4745ms = +ms || 0;4746var p = {},4747json,4748attr;4749for (attr in params) if (params[has](attr) && toFloat(attr) != attr && toFloat(attr) + "%" != attr) {4750json = true;4751p[attr] = params[attr];4752}4753if (!json) {4754// if percent-like syntax is used and end-of-all animation callback used4755if(callback){4756// find the last one4757var lastKey = 0;4758for(var i in params){4759var percent = toInt(i);4760if(params[has](i) && percent > lastKey){4761lastKey = percent;4762}4763}4764lastKey += '%';4765// if already defined callback in the last keyframe, skip4766!params[lastKey].callback && (params[lastKey].callback = callback);4767}4768return new Animation(params, ms);4769} else {4770easing && (p.easing = easing);4771callback && (p.callback = callback);4772return new Animation({100: p}, ms);4773}4774};4775/*\4776* Element.animate
4777[ method ]
4778**
4779* Creates and starts animation for given element.
4780**
4781> Parameters
4782**
4783- params (object) final attributes for the element, see also @Element.attr
4784- ms (number) number of milliseconds for animation to run
4785- easing (string) #optional easing type. Accept one of @Raphael.easing_formulas or CSS format: `cubic‐bezier(XX, XX, XX, XX)`
4786- callback (function) #optional callback function. Will be called at the end of animation.
4787* or
4788- animation (object) animation object, see @Raphael.animation
4789**
4790= (object) original element
4791\*/
4792elproto.animate = function (params, ms, easing, callback) {4793var element = this;4794if (element.removed) {4795callback && callback.call(element);4796return element;4797}4798var anim = params instanceof Animation ? params : R.animation(params, ms, easing, callback);4799runAnimation(anim, element, anim.percents[0], null, element.attr());4800return element;4801};4802/*\4803* Element.setTime
4804[ method ]
4805**
4806* Sets the status of animation of the element in milliseconds. Similar to @Element.status method.
4807**
4808> Parameters
4809**
4810- anim (object) animation object
4811- value (number) number of milliseconds from the beginning of the animation
4812**
4813= (object) original element if `value` is specified
4814* Note, that during animation following events are triggered:
4815*
4816* On each animation frame event `anim.frame.<id>`, on start `anim.start.<id>` and on end `anim.finish.<id>`.
4817\*/
4818elproto.setTime = function (anim, value) {4819if (anim && value != null) {4820this.status(anim, mmin(value, anim.ms) / anim.ms);4821}4822return this;4823};4824/*\4825* Element.status
4826[ method ]
4827**
4828* Gets or sets the status of animation of the element.
4829**
4830> Parameters
4831**
4832- anim (object) #optional animation object
4833- value (number) #optional 0 – 1. If specified, method works like a setter and sets the status of a given animation to the value. This will cause animation to jump to the given position.
4834**
4835= (number) status
4836* or
4837= (array) status if `anim` is not specified. Array of objects in format:
4838o {
4839o anim: (object) animation object
4840o status: (number) status
4841o }
4842* or
4843= (object) original element if `value` is specified
4844\*/
4845elproto.status = function (anim, value) {4846var out = [],4847i = 0,4848len,4849e;4850if (value != null) {4851runAnimation(anim, this, -1, mmin(value, 1));4852return this;4853} else {4854len = animationElements.length;4855for (; i < len; i++) {4856e = animationElements[i];4857if (e.el.id == this.id && (!anim || e.anim == anim)) {4858if (anim) {4859return e.status;4860}4861out.push({4862anim: e.anim,4863status: e.status4864});4865}4866}4867if (anim) {4868return 0;4869}4870return out;4871}4872};4873/*\4874* Element.pause
4875[ method ]
4876**
4877* Stops animation of the element with ability to resume it later on.
4878**
4879> Parameters
4880**
4881- anim (object) #optional animation object
4882**
4883= (object) original element
4884\*/
4885elproto.pause = function (anim) {4886for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {4887if (eve("raphael.anim.pause." + this.id, this, animationElements[i].anim) !== false) {4888animationElements[i].paused = true;4889}4890}4891return this;4892};4893/*\4894* Element.resume
4895[ method ]
4896**
4897* Resumes animation if it was paused with @Element.pause method.
4898**
4899> Parameters
4900**
4901- anim (object) #optional animation object
4902**
4903= (object) original element
4904\*/
4905elproto.resume = function (anim) {4906for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {4907var e = animationElements[i];4908if (eve("raphael.anim.resume." + this.id, this, e.anim) !== false) {4909delete e.paused;4910this.status(e.anim, e.status);4911}4912}4913return this;4914};4915/*\4916* Element.stop
4917[ method ]
4918**
4919* Stops animation of the element.
4920**
4921> Parameters
4922**
4923- anim (object) #optional animation object
4924**
4925= (object) original element
4926\*/
4927elproto.stop = function (anim) {4928for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {4929if (eve("raphael.anim.stop." + this.id, this, animationElements[i].anim) !== false) {4930animationElements.splice(i--, 1);4931}4932}4933return this;4934};4935function stopAnimation(paper) {4936for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.paper == paper) {4937animationElements.splice(i--, 1);4938}4939}4940eve.on("raphael.remove", stopAnimation);4941eve.on("raphael.clear", stopAnimation);4942elproto.toString = function () {4943return "Rapha\xebl\u2019s object";4944};4945
4946// Set4947var Set = function (items) {4948this.items = [];4949this.length = 0;4950this.type = "set";4951if (items) {4952for (var i = 0, ii = items.length; i < ii; i++) {4953if (items[i] && (items[i].constructor == elproto.constructor || items[i].constructor == Set)) {4954this[this.items.length] = this.items[this.items.length] = items[i];4955this.length++;4956}4957}4958}4959},4960setproto = Set.prototype;4961/*\4962* Set.push
4963[ method ]
4964**
4965* Adds each argument to the current set.
4966= (object) original element
4967\*/
4968setproto.push = function () {4969var item,4970len;4971for (var i = 0, ii = arguments.length; i < ii; i++) {4972item = arguments[i];4973if (item && (item.constructor == elproto.constructor || item.constructor == Set)) {4974len = this.items.length;4975this[len] = this.items[len] = item;4976this.length++;4977}4978}4979return this;4980};4981/*\4982* Set.pop
4983[ method ]
4984**
4985* Removes last element and returns it.
4986= (object) element
4987\*/
4988setproto.pop = function () {4989this.length && delete this[this.length--];4990return this.items.pop();4991};4992/*\4993* Set.forEach
4994[ method ]
4995**
4996* Executes given function for each element in the set.
4997*
4998* If function returns `false` it will stop loop running.
4999**
5000> Parameters
5001**
5002- callback (function) function to run
5003- thisArg (object) context object for the callback
5004= (object) Set object
5005\*/
5006setproto.forEach = function (callback, thisArg) {5007for (var i = 0, ii = this.items.length; i < ii; i++) {5008if (callback.call(thisArg, this.items[i], i) === false) {5009return this;5010}5011}5012return this;5013};5014for (var method in elproto) if (elproto[has](method)) {5015setproto[method] = (function (methodname) {5016return function () {5017var arg = arguments;5018return this.forEach(function (el) {5019el[methodname][apply](el, arg);5020});5021};5022})(method);5023}5024setproto.attr = function (name, value) {5025if (name && R.is(name, array) && R.is(name[0], "object")) {5026for (var j = 0, jj = name.length; j < jj; j++) {5027this.items[j].attr(name[j]);5028}5029} else {5030for (var i = 0, ii = this.items.length; i < ii; i++) {5031this.items[i].attr(name, value);5032}5033}5034return this;5035};5036/*\5037* Set.clear
5038[ method ]
5039**
5040* Removes all elements from the set
5041\*/
5042setproto.clear = function () {5043while (this.length) {5044this.pop();5045}5046};5047/*\5048* Set.splice
5049[ method ]
5050**
5051* Removes given element from the set
5052**
5053> Parameters
5054**
5055- index (number) position of the deletion
5056- count (number) number of element to remove
5057- insertion… (object) #optional elements to insert
5058= (object) set elements that were deleted
5059\*/
5060setproto.splice = function (index, count, insertion) {5061index = index < 0 ? mmax(this.length + index, 0) : index;5062count = mmax(0, mmin(this.length - index, count));5063var tail = [],5064todel = [],5065args = [],5066i;5067for (i = 2; i < arguments.length; i++) {5068args.push(arguments[i]);5069}5070for (i = 0; i < count; i++) {5071todel.push(this[index + i]);5072}5073for (; i < this.length - index; i++) {5074tail.push(this[index + i]);5075}5076var arglen = args.length;5077for (i = 0; i < arglen + tail.length; i++) {5078this.items[index + i] = this[index + i] = i < arglen ? args[i] : tail[i - arglen];5079}5080i = this.items.length = this.length -= count - arglen;5081while (this[i]) {5082delete this[i++];5083}5084return new Set(todel);5085};5086/*\5087* Set.exclude
5088[ method ]
5089**
5090* Removes given element from the set
5091**
5092> Parameters
5093**
5094- element (object) element to remove
5095= (boolean) `true` if object was found & removed from the set
5096\*/
5097setproto.exclude = function (el) {5098for (var i = 0, ii = this.length; i < ii; i++) if (this[i] == el) {5099this.splice(i, 1);5100return true;5101}5102};5103setproto.animate = function (params, ms, easing, callback) {5104(R.is(easing, "function") || !easing) && (callback = easing || null);5105var len = this.items.length,5106i = len,5107item,5108set = this,5109collector;5110if (!len) {5111return this;5112}5113callback && (collector = function () {5114!--len && callback.call(set);5115});5116easing = R.is(easing, string) ? easing : collector;5117var anim = R.animation(params, ms, easing, collector);5118item = this.items[--i].animate(anim);5119while (i--) {5120this.items[i] && !this.items[i].removed && this.items[i].animateWith(item, anim, anim);5121(this.items[i] && !this.items[i].removed) || len--;5122}5123return this;5124};5125setproto.insertAfter = function (el) {5126var i = this.items.length;5127while (i--) {5128this.items[i].insertAfter(el);5129}5130return this;5131};5132setproto.getBBox = function () {5133var x = [],5134y = [],5135x2 = [],5136y2 = [];5137for (var i = this.items.length; i--;) if (!this.items[i].removed) {5138var box = this.items[i].getBBox();5139x.push(box.x);5140y.push(box.y);5141x2.push(box.x + box.width);5142y2.push(box.y + box.height);5143}5144x = mmin[apply](0, x);5145y = mmin[apply](0, y);5146x2 = mmax[apply](0, x2);5147y2 = mmax[apply](0, y2);5148return {5149x: x,5150y: y,5151x2: x2,5152y2: y2,5153width: x2 - x,5154height: y2 - y5155};5156};5157setproto.clone = function (s) {5158s = this.paper.set();5159for (var i = 0, ii = this.items.length; i < ii; i++) {5160s.push(this.items[i].clone());5161}5162return s;5163};5164setproto.toString = function () {5165return "Rapha\xebl\u2018s set";5166};5167
5168setproto.glow = function(glowConfig) {5169var ret = this.paper.set();5170this.forEach(function(shape, index){5171var g = shape.glow(glowConfig);5172if(g != null){5173g.forEach(function(shape2, index2){5174ret.push(shape2);5175});5176}5177});5178return ret;5179};5180
5181
5182/*\5183* Set.isPointInside
5184[ method ]
5185**
5186* Determine if given point is inside this set’s elements
5187**
5188> Parameters
5189**
5190- x (number) x coordinate of the point
5191- y (number) y coordinate of the point
5192= (boolean) `true` if point is inside any of the set's elements
5193\*/
5194setproto.isPointInside = function (x, y) {5195var isPointInside = false;5196this.forEach(function (el) {5197if (el.isPointInside(x, y)) {5198isPointInside = true;5199return false; // stop loop5200}5201});5202return isPointInside;5203};5204
5205/*\5206* Raphael.registerFont
5207[ method ]
5208**
5209* Adds given font to the registered set of fonts for Raphaël. Should be used as an internal call from within Cufón’s font file.
5210* Returns original parameter, so it could be used with chaining.
5211# <a href="http://wiki.github.com/sorccu/cufon/about">More about Cufón and how to convert your font form TTF, OTF, etc to JavaScript file.</a>
5212**
5213> Parameters
5214**
5215- font (object) the font to register
5216= (object) the font you passed in
5217> Usage
5218| Cufon.registerFont(Raphael.registerFont({…}));
5219\*/
5220R.registerFont = function (font) {5221if (!font.face) {5222return font;5223}5224this.fonts = this.fonts || {};5225var fontcopy = {5226w: font.w,5227face: {},5228glyphs: {}5229},5230family = font.face["font-family"];5231for (var prop in font.face) if (font.face[has](prop)) {5232fontcopy.face[prop] = font.face[prop];5233}5234if (this.fonts[family]) {5235this.fonts[family].push(fontcopy);5236} else {5237this.fonts[family] = [fontcopy];5238}5239if (!font.svg) {5240fontcopy.face["units-per-em"] = toInt(font.face["units-per-em"], 10);5241for (var glyph in font.glyphs) if (font.glyphs[has](glyph)) {5242var path = font.glyphs[glyph];5243fontcopy.glyphs[glyph] = {5244w: path.w,5245k: {},5246d: path.d && "M" + path.d.replace(/[mlcxtrv]/g, function (command) {5247return {l: "L", c: "C", x: "z", t: "m", r: "l", v: "c"}[command] || "M";5248}) + "z"5249};5250if (path.k) {5251for (var k in path.k) if (path[has](k)) {5252fontcopy.glyphs[glyph].k[k] = path.k[k];5253}5254}5255}5256}5257return font;5258};5259/*\5260* Paper.getFont
5261[ method ]
5262**
5263* Finds font object in the registered fonts by given parameters. You could specify only one word from the font name, like “Myriad” for “Myriad Pro”.
5264**
5265> Parameters
5266**
5267- family (string) font family name or any word from it
5268- weight (string) #optional font weight
5269- style (string) #optional font style
5270- stretch (string) #optional font stretch
5271= (object) the font object
5272> Usage
5273| paper.print(100, 100, "Test string", paper.getFont("Times", 800), 30);
5274\*/
5275paperproto.getFont = function (family, weight, style, stretch) {5276stretch = stretch || "normal";5277style = style || "normal";5278weight = +weight || {normal: 400, bold: 700, lighter: 300, bolder: 800}[weight] || 400;5279if (!R.fonts) {5280return;5281}5282var font = R.fonts[family];5283if (!font) {5284var name = new RegExp("(^|\\s)" + family.replace(/[^\w\d\s+!~.:_-]/g, E) + "(\\s|$)", "i");5285for (var fontName in R.fonts) if (R.fonts[has](fontName)) {5286if (name.test(fontName)) {5287font = R.fonts[fontName];5288break;5289}5290}5291}5292var thefont;5293if (font) {5294for (var i = 0, ii = font.length; i < ii; i++) {5295thefont = font[i];5296if (thefont.face["font-weight"] == weight && (thefont.face["font-style"] == style || !thefont.face["font-style"]) && thefont.face["font-stretch"] == stretch) {5297break;5298}5299}5300}5301return thefont;5302};5303/*\5304* Paper.print
5305[ method ]
5306**
5307* Creates path that represent given text written using given font at given position with given size.
5308* Result of the method is path element that contains whole text as a separate path.
5309**
5310> Parameters
5311**
5312- x (number) x position of the text
5313- y (number) y position of the text
5314- string (string) text to print
5315- font (object) font object, see @Paper.getFont
5316- size (number) #optional size of the font, default is `16`
5317- origin (string) #optional could be `"baseline"` or `"middle"`, default is `"middle"`
5318- letter_spacing (number) #optional number in range `-1..1`, default is `0`
5319- line_spacing (number) #optional number in range `1..3`, default is `1`
5320= (object) resulting path element, which consist of all letters
5321> Usage
5322| var txt = r.print(10, 50, "print", r.getFont("Museo"), 30).attr({fill: "#fff"});
5323\*/
5324paperproto.print = function (x, y, string, font, size, origin, letter_spacing, line_spacing) {5325origin = origin || "middle"; // baseline|middle5326letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1);5327line_spacing = mmax(mmin(line_spacing || 1, 3), 1);5328var letters = Str(string)[split](E),5329shift = 0,5330notfirst = 0,5331path = E,5332scale;5333R.is(font, "string") && (font = this.getFont(font));5334if (font) {5335scale = (size || 16) / font.face["units-per-em"];5336var bb = font.face.bbox[split](separator),5337top = +bb[0],5338lineHeight = bb[3] - bb[1],5339shifty = 0,5340height = +bb[1] + (origin == "baseline" ? lineHeight + (+font.face.descent) : lineHeight / 2);5341for (var i = 0, ii = letters.length; i < ii; i++) {5342if (letters[i] == "\n") {5343shift = 0;5344curr = 0;5345notfirst = 0;5346shifty += lineHeight * line_spacing;5347} else {5348var prev = notfirst && font.glyphs[letters[i - 1]] || {},5349curr = font.glyphs[letters[i]];5350shift += notfirst ? (prev.w || font.w) + (prev.k && prev.k[letters[i]] || 0) + (font.w * letter_spacing) : 0;5351notfirst = 1;5352}5353if (curr && curr.d) {5354path += R.transformPath(curr.d, ["t", shift * scale, shifty * scale, "s", scale, scale, top, height, "t", (x - top) / scale, (y - height) / scale]);5355}5356}5357}5358return this.path(path).attr({5359fill: "#000",5360stroke: "none"5361});5362};5363
5364/*\5365* Paper.add
5366[ method ]
5367**
5368* Imports elements in JSON array in format `{type: type, <attributes>}`
5369**
5370> Parameters
5371**
5372- json (array)
5373= (object) resulting set of imported elements
5374> Usage
5375| paper.add([
5376| {
5377| type: "circle",
5378| cx: 10,
5379| cy: 10,
5380| r: 5
5381| },
5382| {
5383| type: "rect",
5384| x: 10,
5385| y: 10,
5386| width: 10,
5387| height: 10,
5388| fill: "#fc0"
5389| }
5390| ]);
5391\*/
5392paperproto.add = function (json) {5393if (R.is(json, "array")) {5394var res = this.set(),5395i = 0,5396ii = json.length,5397j;5398for (; i < ii; i++) {5399j = json[i] || {};5400elements[has](j.type) && res.push(this[j.type]().attr(j));5401}5402}5403return res;5404};5405
5406/*\5407* Raphael.format
5408[ method ]
5409**
5410* Simple format function. Replaces construction of type “`{<number>}`” to the corresponding argument.
5411**
5412> Parameters
5413**
5414- token (string) string to format
5415- … (string) rest of arguments will be treated as parameters for replacement
5416= (string) formated string
5417> Usage
5418| var x = 10,
5419| y = 20,
5420| width = 40,
5421| height = 50;
5422| // this will draw a rectangular shape equivalent to "M10,20h40v50h-40z"
5423| paper.path(Raphael.format("M{0},{1}h{2}v{3}h{4}z", x, y, width, height, -width));
5424\*/
5425R.format = function (token, params) {5426var args = R.is(params, array) ? [0][concat](params) : arguments;5427token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) {5428return args[++i] == null ? E : args[i];5429}));5430return token || E;5431};5432/*\5433* Raphael.fullfill
5434[ method ]
5435**
5436* A little bit more advanced format function than @Raphael.format. Replaces construction of type “`{<name>}`” to the corresponding argument.
5437**
5438> Parameters
5439**
5440- token (string) string to format
5441- json (object) object which properties will be used as a replacement
5442= (string) formated string
5443> Usage
5444| // this will draw a rectangular shape equivalent to "M10,20h40v50h-40z"
5445| paper.path(Raphael.fullfill("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width']}z", {
5446| x: 10,
5447| y: 20,
5448| dim: {
5449| width: 40,
5450| height: 50,
5451| "negative width": -40
5452| }
5453| }));
5454\*/
5455R.fullfill = (function () {5456var tokenRegex = /\{([^\}]+)\}/g,5457objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties5458replacer = function (all, key, obj) {5459var res = obj;5460key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) {5461name = name || quotedName;5462if (res) {5463if (name in res) {5464res = res[name];5465}5466typeof res == "function" && isFunc && (res = res());5467}5468});5469res = (res == null || res == obj ? all : res) + "";5470return res;5471};5472return function (str, obj) {5473return String(str).replace(tokenRegex, function (all, key) {5474return replacer(all, key, obj);5475});5476};5477})();5478/*\5479* Raphael.ninja
5480[ method ]
5481**
5482* If you want to leave no trace of Raphaël (Well, Raphaël creates only one global variable `Raphael`, but anyway.) You can use `ninja` method.
5483* Beware, that in this case plugins could stop working, because they are depending on global variable existence.
5484**
5485= (object) Raphael object
5486> Usage
5487| (function (local_raphael) {
5488| var paper = local_raphael(10, 10, 320, 200);
5489| …
5490| })(Raphael.ninja());
5491\*/
5492R.ninja = function () {5493if (oldRaphael.was) {5494g.win.Raphael = oldRaphael.is;5495} else {5496// IE8 raises an error when deleting window property5497window.Raphael = undefined;5498try {5499delete window.Raphael;5500} catch(e) {}5501}5502return R;5503};5504/*\5505* Raphael.st
5506[ property (object) ]
5507**
5508* You can add your own method to elements and sets. It is wise to add a set method for each element method
5509* you added, so you will be able to call the same method on sets too.
5510**
5511* See also @Raphael.el.
5512> Usage
5513| Raphael.el.red = function () {
5514| this.attr({fill: "#f00"});
5515| };
5516| Raphael.st.red = function () {
5517| this.forEach(function (el) {
5518| el.red();
5519| });
5520| };
5521| // then use it
5522| paper.set(paper.circle(100, 100, 20), paper.circle(110, 100, 20)).red();
5523\*/
5524R.st = setproto;5525
5526eve.on("raphael.DOMload", function () {5527loaded = true;5528});5529
5530// Firefox <3.6 fix: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html5531(function (doc, loaded, f) {5532if (doc.readyState == null && doc.addEventListener){5533doc.addEventListener(loaded, f = function () {5534doc.removeEventListener(loaded, f, false);5535doc.readyState = "complete";5536}, false);5537doc.readyState = "loading";5538}5539function isLoaded() {5540(/in/).test(doc.readyState) ? setTimeout(isLoaded, 9) : R.eve("raphael.DOMload");5541}5542isLoaded();5543})(document, "DOMContentLoaded");5544
5545return R;5546}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),5547__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));5548
5549
5550/***/ }),5551
5552/***/ "./dev/raphael.svg.js":5553/*!****************************!*\
5554!*** ./dev/raphael.svg.js ***!
5555\****************************/
5556/*! no static exports found */
5557/***/ (function(module, exports, __webpack_require__) {5558
5559var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./raphael.core */ "./dev/raphael.core.js")], __WEBPACK_AMD_DEFINE_RESULT__ = (function(R) {5560if (R && !R.svg) {5561return;5562}5563
5564var has = "hasOwnProperty",5565Str = String,5566toFloat = parseFloat,5567toInt = parseInt,5568math = Math,5569mmax = math.max,5570abs = math.abs,5571pow = math.pow,5572separator = /[, ]+/,5573eve = R.eve,5574E = "",5575S = " ";5576var xlink = "http://www.w3.org/1999/xlink",5577markers = {5578block: "M5,0 0,2.5 5,5z",5579classic: "M5,0 0,2.5 5,5 3.5,3 3.5,2z",5580diamond: "M2.5,0 5,2.5 2.5,5 0,2.5z",5581open: "M6,1 1,3.5 6,6",5582oval: "M2.5,0A2.5,2.5,0,0,1,2.5,5 2.5,2.5,0,0,1,2.5,0z"5583},5584markerCounter = {};5585R.toString = function () {5586return "Your browser supports SVG.\nYou are running Rapha\xebl " + this.version;5587};5588var $ = function (el, attr) {5589if (attr) {5590if (typeof el == "string") {5591el = $(el);5592}5593for (var key in attr) if (attr[has](key)) {5594if (key.substring(0, 6) == "xlink:") {5595el.setAttributeNS(xlink, key.substring(6), Str(attr[key]));5596} else {5597el.setAttribute(key, Str(attr[key]));5598}5599}5600} else {5601el = R._g.doc.createElementNS("http://www.w3.org/2000/svg", el);5602el.style && (el.style.webkitTapHighlightColor = "rgba(0,0,0,0)");5603}5604return el;5605},5606addGradientFill = function (element, gradient) {5607var type = "linear",5608id = element.id + gradient,5609fx = .5, fy = .5,5610o = element.node,5611SVG = element.paper,5612s = o.style,5613el = R._g.doc.getElementById(id);5614if (!el) {5615gradient = Str(gradient).replace(R._radial_gradient, function (all, _fx, _fy) {5616type = "radial";5617if (_fx && _fy) {5618fx = toFloat(_fx);5619fy = toFloat(_fy);5620var dir = ((fy > .5) * 2 - 1);5621pow(fx - .5, 2) + pow(fy - .5, 2) > .25 &&5622(fy = math.sqrt(.25 - pow(fx - .5, 2)) * dir + .5) &&5623fy != .5 &&5624(fy = fy.toFixed(5) - 1e-5 * dir);5625}5626return E;5627});5628gradient = gradient.split(/\s*\-\s*/);5629if (type == "linear") {5630var angle = gradient.shift();5631angle = -toFloat(angle);5632if (isNaN(angle)) {5633return null;5634}5635var vector = [0, 0, math.cos(R.rad(angle)), math.sin(R.rad(angle))],5636max = 1 / (mmax(abs(vector[2]), abs(vector[3])) || 1);5637vector[2] *= max;5638vector[3] *= max;5639if (vector[2] < 0) {5640vector[0] = -vector[2];5641vector[2] = 0;5642}5643if (vector[3] < 0) {5644vector[1] = -vector[3];5645vector[3] = 0;5646}5647}5648var dots = R._parseDots(gradient);5649if (!dots) {5650return null;5651}5652id = id.replace(/[\(\)\s,\xb0#]/g, "_");5653
5654if (element.gradient && id != element.gradient.id) {5655SVG.defs.removeChild(element.gradient);5656delete element.gradient;5657}5658
5659if (!element.gradient) {5660el = $(type + "Gradient", {id: id});5661element.gradient = el;5662$(el, type == "radial" ? {5663fx: fx,5664fy: fy5665} : {5666x1: vector[0],5667y1: vector[1],5668x2: vector[2],5669y2: vector[3],5670gradientTransform: element.matrix.invert()5671});5672SVG.defs.appendChild(el);5673for (var i = 0, ii = dots.length; i < ii; i++) {5674el.appendChild($("stop", {5675offset: dots[i].offset ? dots[i].offset : i ? "100%" : "0%",5676"stop-color": dots[i].color || "#fff",5677"stop-opacity": isFinite(dots[i].opacity) ? dots[i].opacity : 15678}));5679}5680}5681}5682$(o, {5683fill: fillurl(id),5684opacity: 1,5685"fill-opacity": 15686});5687s.fill = E;5688s.opacity = 1;5689s.fillOpacity = 1;5690return 1;5691},5692isIE9or10 = function () {5693var mode = document.documentMode;5694return mode && (mode === 9 || mode === 10);5695},5696fillurl = function (id) {5697if (isIE9or10()) {5698return "url('#" + id + "')";5699}5700var location = document.location;5701var locationString = (5702location.protocol + '//' +5703location.host +5704location.pathname +5705location.search5706);5707return "url('" + locationString + "#" + id + "')";5708},5709updatePosition = function (o) {5710var bbox = o.getBBox(1);5711$(o.pattern, {patternTransform: o.matrix.invert() + " translate(" + bbox.x + "," + bbox.y + ")"});5712},5713addArrow = function (o, value, isEnd) {5714if (o.type == "path") {5715var values = Str(value).toLowerCase().split("-"),5716p = o.paper,5717se = isEnd ? "end" : "start",5718node = o.node,5719attrs = o.attrs,5720stroke = attrs["stroke-width"],5721i = values.length,5722type = "classic",5723from,5724to,5725dx,5726refX,5727attr,5728w = 3,5729h = 3,5730t = 5;5731while (i--) {5732switch (values[i]) {5733case "block":5734case "classic":5735case "oval":5736case "diamond":5737case "open":5738case "none":5739type = values[i];5740break;5741case "wide": h = 5; break;5742case "narrow": h = 2; break;5743case "long": w = 5; break;5744case "short": w = 2; break;5745}5746}5747if (type == "open") {5748w += 2;5749h += 2;5750t += 2;5751dx = 1;5752refX = isEnd ? 4 : 1;5753attr = {5754fill: "none",5755stroke: attrs.stroke5756};5757} else {5758refX = dx = w / 2;5759attr = {5760fill: attrs.stroke,5761stroke: "none"5762};5763}5764if (o._.arrows) {5765if (isEnd) {5766o._.arrows.endPath && markerCounter[o._.arrows.endPath]--;5767o._.arrows.endMarker && markerCounter[o._.arrows.endMarker]--;5768} else {5769o._.arrows.startPath && markerCounter[o._.arrows.startPath]--;5770o._.arrows.startMarker && markerCounter[o._.arrows.startMarker]--;5771}5772} else {5773o._.arrows = {};5774}5775if (type != "none") {5776var pathId = "raphael-marker-" + type,5777markerId = "raphael-marker-" + se + type + w + h + "-obj" + o.id;5778if (!R._g.doc.getElementById(pathId)) {5779p.defs.appendChild($($("path"), {5780"stroke-linecap": "round",5781d: markers[type],5782id: pathId5783}));5784markerCounter[pathId] = 1;5785} else {5786markerCounter[pathId]++;5787}5788var marker = R._g.doc.getElementById(markerId),5789use;5790if (!marker) {5791marker = $($("marker"), {5792id: markerId,5793markerHeight: h,5794markerWidth: w,5795orient: "auto",5796refX: refX,5797refY: h / 25798});5799use = $($("use"), {5800"xlink:href": "#" + pathId,5801transform: (isEnd ? "rotate(180 " + w / 2 + " " + h / 2 + ") " : E) + "scale(" + w / t + "," + h / t + ")",5802"stroke-width": (1 / ((w / t + h / t) / 2)).toFixed(4)5803});5804marker.appendChild(use);5805p.defs.appendChild(marker);5806markerCounter[markerId] = 1;5807} else {5808markerCounter[markerId]++;5809use = marker.getElementsByTagName("use")[0];5810}5811$(use, attr);5812var delta = dx * (type != "diamond" && type != "oval");5813if (isEnd) {5814from = o._.arrows.startdx * stroke || 0;5815to = R.getTotalLength(attrs.path) - delta * stroke;5816} else {5817from = delta * stroke;5818to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0);5819}5820attr = {};5821attr["marker-" + se] = "url(#" + markerId + ")";5822if (to || from) {5823attr.d = R.getSubpath(attrs.path, from, to);5824}5825$(node, attr);5826o._.arrows[se + "Path"] = pathId;5827o._.arrows[se + "Marker"] = markerId;5828o._.arrows[se + "dx"] = delta;5829o._.arrows[se + "Type"] = type;5830o._.arrows[se + "String"] = value;5831} else {5832if (isEnd) {5833from = o._.arrows.startdx * stroke || 0;5834to = R.getTotalLength(attrs.path) - from;5835} else {5836from = 0;5837to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0);5838}5839o._.arrows[se + "Path"] && $(node, {d: R.getSubpath(attrs.path, from, to)});5840delete o._.arrows[se + "Path"];5841delete o._.arrows[se + "Marker"];5842delete o._.arrows[se + "dx"];5843delete o._.arrows[se + "Type"];5844delete o._.arrows[se + "String"];5845}5846for (attr in markerCounter) if (markerCounter[has](attr) && !markerCounter[attr]) {5847var item = R._g.doc.getElementById(attr);5848item && item.parentNode.removeChild(item);5849}5850}5851},5852dasharray = {5853"-": [3, 1],5854".": [1, 1],5855"-.": [3, 1, 1, 1],5856"-..": [3, 1, 1, 1, 1, 1],5857". ": [1, 3],5858"- ": [4, 3],5859"--": [8, 3],5860"- .": [4, 3, 1, 3],5861"--.": [8, 3, 1, 3],5862"--..": [8, 3, 1, 3, 1, 3]5863},5864addDashes = function (o, value, params) {5865value = dasharray[Str(value).toLowerCase()];5866if (value) {5867var width = o.attrs["stroke-width"] || "1",5868butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0,5869dashes = [],5870i = value.length;5871while (i--) {5872dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt;5873}5874$(o.node, {"stroke-dasharray": dashes.join(",")});5875}5876else {5877$(o.node, {"stroke-dasharray": "none"});5878}5879},5880setFillAndStroke = function (o, params) {5881var node = o.node,5882attrs = o.attrs,5883vis = node.style.visibility;5884node.style.visibility = "hidden";5885for (var att in params) {5886if (params[has](att)) {5887if (!R._availableAttrs[has](att)) {5888continue;5889}5890var value = params[att];5891attrs[att] = value;5892switch (att) {5893case "blur":5894o.blur(value);5895break;5896case "title":5897var title = node.getElementsByTagName("title");5898
5899// Use the existing <title>.5900if (title.length && (title = title[0])) {5901title.firstChild.nodeValue = value;5902} else {5903title = $("title");5904var val = R._g.doc.createTextNode(value);5905title.appendChild(val);5906node.appendChild(title);5907}5908break;5909case "href":5910case "target":5911var pn = node.parentNode;5912if (pn.tagName.toLowerCase() != "a") {5913var hl = $("a");5914pn.insertBefore(hl, node);5915hl.appendChild(node);5916pn = hl;5917}5918if (att == "target") {5919pn.setAttributeNS(xlink, "show", value == "blank" ? "new" : value);5920} else {5921pn.setAttributeNS(xlink, att, value);5922}5923break;5924case "cursor":5925node.style.cursor = value;5926break;5927case "transform":5928o.transform(value);5929break;5930case "arrow-start":5931addArrow(o, value);5932break;5933case "arrow-end":5934addArrow(o, value, 1);5935break;5936case "clip-rect":5937var rect = Str(value).split(separator);5938if (rect.length == 4) {5939o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode);5940var el = $("clipPath"),5941rc = $("rect");5942el.id = R.createUUID();5943$(rc, {5944x: rect[0],5945y: rect[1],5946width: rect[2],5947height: rect[3]5948});5949el.appendChild(rc);5950o.paper.defs.appendChild(el);5951$(node, {"clip-path": "url(#" + el.id + ")"});5952o.clip = rc;5953}5954if (!value) {5955var path = node.getAttribute("clip-path");5956if (path) {5957var clip = R._g.doc.getElementById(path.replace(/(^url\(#|\)$)/g, E));5958clip && clip.parentNode.removeChild(clip);5959$(node, {"clip-path": E});5960delete o.clip;5961}5962}5963break;5964case "path":5965if (o.type == "path") {5966$(node, {d: value ? attrs.path = R._pathToAbsolute(value) : "M0,0"});5967o._.dirty = 1;5968if (o._.arrows) {5969"startString" in o._.arrows && addArrow(o, o._.arrows.startString);5970"endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);5971}5972}5973break;5974case "width":5975node.setAttribute(att, value);5976o._.dirty = 1;5977if (attrs.fx) {5978att = "x";5979value = attrs.x;5980} else {5981break;5982}5983case "x":5984if (attrs.fx) {5985value = -attrs.x - (attrs.width || 0);5986}5987case "rx":5988if (att == "rx" && o.type == "rect") {5989break;5990}5991case "cx":5992node.setAttribute(att, value);5993o.pattern && updatePosition(o);5994o._.dirty = 1;5995break;5996case "height":5997node.setAttribute(att, value);5998o._.dirty = 1;5999if (attrs.fy) {6000att = "y";6001value = attrs.y;6002} else {6003break;6004}6005case "y":6006if (attrs.fy) {6007value = -attrs.y - (attrs.height || 0);6008}6009case "ry":6010if (att == "ry" && o.type == "rect") {6011break;6012}6013case "cy":6014node.setAttribute(att, value);6015o.pattern && updatePosition(o);6016o._.dirty = 1;6017break;6018case "r":6019if (o.type == "rect") {6020$(node, {rx: value, ry: value});6021} else {6022node.setAttribute(att, value);6023}6024o._.dirty = 1;6025break;6026case "src":6027if (o.type == "image") {6028node.setAttributeNS(xlink, "href", value);6029}6030break;6031case "stroke-width":6032if (o._.sx != 1 || o._.sy != 1) {6033value /= mmax(abs(o._.sx), abs(o._.sy)) || 1;6034}6035node.setAttribute(att, value);6036if (attrs["stroke-dasharray"]) {6037addDashes(o, attrs["stroke-dasharray"], params);6038}6039if (o._.arrows) {6040"startString" in o._.arrows && addArrow(o, o._.arrows.startString);6041"endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);6042}6043break;6044case "stroke-dasharray":6045addDashes(o, value, params);6046break;6047case "fill":6048var isURL = Str(value).match(R._ISURL);6049if (isURL) {6050el = $("pattern");6051var ig = $("image");6052el.id = R.createUUID();6053$(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse", height: 1, width: 1});6054$(ig, {x: 0, y: 0, "xlink:href": isURL[1]});6055el.appendChild(ig);6056
6057(function (el) {6058R._preload(isURL[1], function () {6059var w = this.offsetWidth,6060h = this.offsetHeight;6061$(el, {width: w, height: h});6062$(ig, {width: w, height: h});6063});6064})(el);6065o.paper.defs.appendChild(el);6066$(node, {fill: "url(#" + el.id + ")"});6067o.pattern = el;6068o.pattern && updatePosition(o);6069break;6070}6071var clr = R.getRGB(value);6072if (!clr.error) {6073delete params.gradient;6074delete attrs.gradient;6075!R.is(attrs.opacity, "undefined") &&6076R.is(params.opacity, "undefined") &&6077$(node, {opacity: attrs.opacity});6078!R.is(attrs["fill-opacity"], "undefined") &&6079R.is(params["fill-opacity"], "undefined") &&6080$(node, {"fill-opacity": attrs["fill-opacity"]});6081} else if ((o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value)) {6082if ("opacity" in attrs || "fill-opacity" in attrs) {6083var gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E));6084if (gradient) {6085var stops = gradient.getElementsByTagName("stop");6086$(stops[stops.length - 1], {"stop-opacity": ("opacity" in attrs ? attrs.opacity : 1) * ("fill-opacity" in attrs ? attrs["fill-opacity"] : 1)});6087}6088}6089attrs.gradient = value;6090attrs.fill = "none";6091break;6092}6093clr[has]("opacity") && $(node, {"fill-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});6094case "stroke":6095clr = R.getRGB(value);6096node.setAttribute(att, clr.hex);6097att == "stroke" && clr[has]("opacity") && $(node, {"stroke-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});6098if (att == "stroke" && o._.arrows) {6099"startString" in o._.arrows && addArrow(o, o._.arrows.startString);6100"endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);6101}6102break;6103case "gradient":6104(o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value);6105break;6106case "opacity":6107if (attrs.gradient && !attrs[has]("stroke-opacity")) {6108$(node, {"stroke-opacity": value > 1 ? value / 100 : value});6109}6110// fall6111case "fill-opacity":6112if (attrs.gradient) {6113gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E));6114if (gradient) {6115stops = gradient.getElementsByTagName("stop");6116$(stops[stops.length - 1], {"stop-opacity": value});6117}6118break;6119}6120default:6121att == "font-size" && (value = toInt(value, 10) + "px");6122var cssrule = att.replace(/(\-.)/g, function (w) {6123return w.substring(1).toUpperCase();6124});6125node.style[cssrule] = value;6126o._.dirty = 1;6127node.setAttribute(att, value);6128break;6129}6130}6131}6132
6133tuneText(o, params);6134node.style.visibility = vis;6135},6136leading = 1.2,6137tuneText = function (el, params) {6138if (el.type != "text" || !(params[has]("text") || params[has]("font") || params[has]("font-size") || params[has]("x") || params[has]("y"))) {6139return;6140}6141var a = el.attrs,6142node = el.node,6143fontSize = node.firstChild ? toInt(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size"), 10) : 10;6144
6145if (params[has]("text")) {6146a.text = params.text;6147while (node.firstChild) {6148node.removeChild(node.firstChild);6149}6150var texts = Str(params.text).split("\n"),6151tspans = [],6152tspan;6153for (var i = 0, ii = texts.length; i < ii; i++) {6154tspan = $("tspan");6155i && $(tspan, {dy: fontSize * leading, x: a.x});6156tspan.appendChild(R._g.doc.createTextNode(texts[i]));6157node.appendChild(tspan);6158tspans[i] = tspan;6159}6160} else {6161tspans = node.getElementsByTagName("tspan");6162for (i = 0, ii = tspans.length; i < ii; i++) if (i) {6163$(tspans[i], {dy: fontSize * leading, x: a.x});6164} else {6165$(tspans[0], {dy: 0});6166}6167}6168$(node, {x: a.x, y: a.y});6169el._.dirty = 1;6170var bb = el._getBBox(),6171dif = a.y - (bb.y + bb.height / 2);6172dif && R.is(dif, "finite") && $(tspans[0], {dy: dif});6173},6174getRealNode = function (node) {6175if (node.parentNode && node.parentNode.tagName.toLowerCase() === "a") {6176return node.parentNode;6177} else {6178return node;6179}6180},6181Element = function (node, svg) {6182var X = 0,6183Y = 0;6184/*\6185* Element.node
6186[ property (object) ]
6187**
6188* Gives you a reference to the DOM object, so you can assign event handlers or just mess around.
6189**
6190* Note: Don’t mess with it.
6191> Usage
6192| // draw a circle at coordinate 10,10 with radius of 10
6193| var c = paper.circle(10, 10, 10);
6194| c.node.onclick = function () {
6195| c.attr("fill", "red");
6196| };
6197\*/
6198this[0] = this.node = node;6199/*\6200* Element.raphael
6201[ property (object) ]
6202**
6203* Internal reference to @Raphael object. In case it is not available.
6204> Usage
6205| Raphael.el.red = function () {
6206| var hsb = this.paper.raphael.rgb2hsb(this.attr("fill"));
6207| hsb.h = 1;
6208| this.attr({fill: this.paper.raphael.hsb2rgb(hsb).hex});
6209| }
6210\*/
6211node.raphael = true;6212/*\6213* Element.id
6214[ property (number) ]
6215**
6216* Unique id of the element. Especially useful when you want to listen to events of the element,
6217* because all events are fired in format `<module>.<action>.<id>`. Also useful for @Paper.getById method.
6218\*/
6219this.id = guid();6220node.raphaelid = this.id;6221
6222/**6223* Method that returns a 5 letter/digit id, enough for 36^5 = 60466176 elements
6224* @returns {string} id
6225*/
6226function guid() {6227return ("0000" + (Math.random()*Math.pow(36,5) << 0).toString(36)).slice(-5);6228}6229
6230this.matrix = R.matrix();6231this.realPath = null;6232/*\6233* Element.paper
6234[ property (object) ]
6235**
6236* Internal reference to “paper” where object drawn. Mainly for use in plugins and element extensions.
6237> Usage
6238| Raphael.el.cross = function () {
6239| this.attr({fill: "red"});
6240| this.paper.path("M10,10L50,50M50,10L10,50")
6241| .attr({stroke: "red"});
6242| }
6243\*/
6244this.paper = svg;6245this.attrs = this.attrs || {};6246this._ = {6247transform: [],6248sx: 1,6249sy: 1,6250deg: 0,6251dx: 0,6252dy: 0,6253dirty: 16254};6255!svg.bottom && (svg.bottom = this);6256/*\6257* Element.prev
6258[ property (object) ]
6259**
6260* Reference to the previous element in the hierarchy.
6261\*/
6262this.prev = svg.top;6263svg.top && (svg.top.next = this);6264svg.top = this;6265/*\6266* Element.next
6267[ property (object) ]
6268**
6269* Reference to the next element in the hierarchy.
6270\*/
6271this.next = null;6272},6273elproto = R.el;6274
6275Element.prototype = elproto;6276elproto.constructor = Element;6277
6278R._engine.path = function (pathString, SVG) {6279var el = $("path");6280SVG.canvas && SVG.canvas.appendChild(el);6281var p = new Element(el, SVG);6282p.type = "path";6283setFillAndStroke(p, {6284fill: "none",6285stroke: "#000",6286path: pathString6287});6288return p;6289};6290/*\6291* Element.rotate
6292[ method ]
6293**
6294* Deprecated! Use @Element.transform instead.
6295* Adds rotation by given angle around given point to the list of
6296* transformations of the element.
6297> Parameters
6298- deg (number) angle in degrees
6299- cx (number) #optional x coordinate of the centre of rotation
6300- cy (number) #optional y coordinate of the centre of rotation
6301* If cx & cy aren’t specified centre of the shape is used as a point of rotation.
6302= (object) @Element
6303\*/
6304elproto.rotate = function (deg, cx, cy) {6305if (this.removed) {6306return this;6307}6308deg = Str(deg).split(separator);6309if (deg.length - 1) {6310cx = toFloat(deg[1]);6311cy = toFloat(deg[2]);6312}6313deg = toFloat(deg[0]);6314(cy == null) && (cx = cy);6315if (cx == null || cy == null) {6316var bbox = this.getBBox(1);6317cx = bbox.x + bbox.width / 2;6318cy = bbox.y + bbox.height / 2;6319}6320this.transform(this._.transform.concat([["r", deg, cx, cy]]));6321return this;6322};6323/*\6324* Element.scale
6325[ method ]
6326**
6327* Deprecated! Use @Element.transform instead.
6328* Adds scale by given amount relative to given point to the list of
6329* transformations of the element.
6330> Parameters
6331- sx (number) horisontal scale amount
6332- sy (number) vertical scale amount
6333- cx (number) #optional x coordinate of the centre of scale
6334- cy (number) #optional y coordinate of the centre of scale
6335* If cx & cy aren’t specified centre of the shape is used instead.
6336= (object) @Element
6337\*/
6338elproto.scale = function (sx, sy, cx, cy) {6339if (this.removed) {6340return this;6341}6342sx = Str(sx).split(separator);6343if (sx.length - 1) {6344sy = toFloat(sx[1]);6345cx = toFloat(sx[2]);6346cy = toFloat(sx[3]);6347}6348sx = toFloat(sx[0]);6349(sy == null) && (sy = sx);6350(cy == null) && (cx = cy);6351if (cx == null || cy == null) {6352var bbox = this.getBBox(1);6353}6354cx = cx == null ? bbox.x + bbox.width / 2 : cx;6355cy = cy == null ? bbox.y + bbox.height / 2 : cy;6356this.transform(this._.transform.concat([["s", sx, sy, cx, cy]]));6357return this;6358};6359/*\6360* Element.translate
6361[ method ]
6362**
6363* Deprecated! Use @Element.transform instead.
6364* Adds translation by given amount to the list of transformations of the element.
6365> Parameters
6366- dx (number) horisontal shift
6367- dy (number) vertical shift
6368= (object) @Element
6369\*/
6370elproto.translate = function (dx, dy) {6371if (this.removed) {6372return this;6373}6374dx = Str(dx).split(separator);6375if (dx.length - 1) {6376dy = toFloat(dx[1]);6377}6378dx = toFloat(dx[0]) || 0;6379dy = +dy || 0;6380this.transform(this._.transform.concat([["t", dx, dy]]));6381return this;6382};6383/*\6384* Element.transform
6385[ method ]
6386**
6387* Adds transformation to the element which is separate to other attributes,
6388* i.e. translation doesn’t change `x` or `y` of the rectange. The format
6389* of transformation string is similar to the path string syntax:
6390| "t100,100r30,100,100s2,2,100,100r45s1.5"
6391* Each letter is a command. There are four commands: `t` is for translate, `r` is for rotate, `s` is for
6392* scale and `m` is for matrix.
6393*
6394* There are also alternative “absolute” translation, rotation and scale: `T`, `R` and `S`. They will not take previous transformation into account. For example, `...T100,0` will always move element 100 px horisontally, while `...t100,0` could move it vertically if there is `r90` before. Just compare results of `r90t100,0` and `r90T100,0`.
6395*
6396* So, the example line above could be read like “translate by 100, 100; rotate 30° around 100, 100; scale twice around 100, 100;
6397* rotate 45° around centre; scale 1.5 times relative to centre”. As you can see rotate and scale commands have origin
6398* coordinates as optional parameters, the default is the centre point of the element.
6399* Matrix accepts six parameters.
6400> Usage
6401| var el = paper.rect(10, 20, 300, 200);
6402| // translate 100, 100, rotate 45°, translate -100, 0
6403| el.transform("t100,100r45t-100,0");
6404| // if you want you can append or prepend transformations
6405| el.transform("...t50,50");
6406| el.transform("s2...");
6407| // or even wrap
6408| el.transform("t50,50...t-50-50");
6409| // to reset transformation call method with empty string
6410| el.transform("");
6411| // to get current value call it without parameters
6412| console.log(el.transform());
6413> Parameters
6414- tstr (string) #optional transformation string
6415* If tstr isn’t specified
6416= (string) current transformation string
6417* else
6418= (object) @Element
6419\*/
6420elproto.transform = function (tstr) {6421var _ = this._;6422if (tstr == null) {6423return _.transform;6424}6425R._extractTransform(this, tstr);6426
6427this.clip && $(this.clip, {transform: this.matrix.invert()});6428this.pattern && updatePosition(this);6429this.node && $(this.node, {transform: this.matrix});6430
6431if (_.sx != 1 || _.sy != 1) {6432var sw = this.attrs[has]("stroke-width") ? this.attrs["stroke-width"] : 1;6433this.attr({"stroke-width": sw});6434}6435
6436return this;6437};6438/*\6439* Element.hide
6440[ method ]
6441**
6442* Makes element invisible. See @Element.show.
6443= (object) @Element
6444\*/
6445elproto.hide = function () {6446if(!this.removed) this.node.style.display = "none";6447return this;6448};6449/*\6450* Element.show
6451[ method ]
6452**
6453* Makes element visible. See @Element.hide.
6454= (object) @Element
6455\*/
6456elproto.show = function () {6457if(!this.removed) this.node.style.display = "";6458return this;6459};6460/*\6461* Element.remove
6462[ method ]
6463**
6464* Removes element from the paper.
6465\*/
6466elproto.remove = function () {6467var node = getRealNode(this.node);6468if (this.removed || !node.parentNode) {6469return;6470}6471var paper = this.paper;6472paper.__set__ && paper.__set__.exclude(this);6473eve.unbind("raphael.*.*." + this.id);6474if (this.gradient) {6475paper.defs.removeChild(this.gradient);6476}6477R._tear(this, paper);6478
6479node.parentNode.removeChild(node);6480
6481// Remove custom data for element6482this.removeData();6483
6484for (var i in this) {6485this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;6486}6487this.removed = true;6488};6489elproto._getBBox = function () {6490if (this.node.style.display == "none") {6491this.show();6492var hide = true;6493}6494var canvasHidden = false,6495containerStyle;6496if (this.paper.canvas.parentElement) {6497containerStyle = this.paper.canvas.parentElement.style;6498} //IE10+ can't find parentElement6499else if (this.paper.canvas.parentNode) {6500containerStyle = this.paper.canvas.parentNode.style;6501}6502
6503if(containerStyle && containerStyle.display == "none") {6504canvasHidden = true;6505containerStyle.display = "";6506}6507var bbox = {};6508try {6509bbox = this.node.getBBox();6510} catch(e) {6511// Firefox 3.0.x, 25.0.1 (probably more versions affected) play badly here - possible fix6512bbox = {6513x: this.node.clientLeft,6514y: this.node.clientTop,6515width: this.node.clientWidth,6516height: this.node.clientHeight6517}6518} finally {6519bbox = bbox || {};6520if(canvasHidden){6521containerStyle.display = "none";6522}6523}6524hide && this.hide();6525return bbox;6526};6527/*\6528* Element.attr
6529[ method ]
6530**
6531* Sets the attributes of the element.
6532> Parameters
6533- attrName (string) attribute’s name
6534- value (string) value
6535* or
6536- params (object) object of name/value pairs
6537* or
6538- attrName (string) attribute’s name
6539* or
6540- attrNames (array) in this case method returns array of current values for given attribute names
6541= (object) @Element if attrsName & value or params are passed in.
6542= (...) value of the attribute if only attrsName is passed in.
6543= (array) array of values of the attribute if attrsNames is passed in.
6544= (object) object of attributes if nothing is passed in.
6545> Possible parameters
6546# <p>Please refer to the <a href="http://www.w3.org/TR/SVG/" title="The W3C Recommendation for the SVG language describes these properties in detail.">SVG specification</a> for an explanation of these parameters.</p>
6547o arrow-end (string) arrowhead on the end of the path. The format for string is `<type>[-<width>[-<length>]]`. Possible types: `classic`, `block`, `open`, `oval`, `diamond`, `none`, width: `wide`, `narrow`, `medium`, length: `long`, `short`, `midium`.
6548o clip-rect (string) comma or space separated values: x, y, width and height
6549o cursor (string) CSS type of the cursor
6550o cx (number) the x-axis coordinate of the center of the circle, or ellipse
6551o cy (number) the y-axis coordinate of the center of the circle, or ellipse
6552o fill (string) colour, gradient or image
6553o fill-opacity (number)
6554o font (string)
6555o font-family (string)
6556o font-size (number) font size in pixels
6557o font-weight (string)
6558o height (number)
6559o href (string) URL, if specified element behaves as hyperlink
6560o opacity (number)
6561o path (string) SVG path string format
6562o r (number) radius of the circle, ellipse or rounded corner on the rect
6563o rx (number) horisontal radius of the ellipse
6564o ry (number) vertical radius of the ellipse
6565o src (string) image URL, only works for @Element.image element
6566o stroke (string) stroke colour
6567o stroke-dasharray (string) [“”, “none”, “`-`”, “`.`”, “`-.`”, “`-..`”, “`. `”, “`- `”, “`--`”, “`- .`”, “`--.`”, “`--..`”]
6568o stroke-linecap (string) [“`butt`”, “`square`”, “`round`”]
6569o stroke-linejoin (string) [“`bevel`”, “`round`”, “`miter`”]
6570o stroke-miterlimit (number)
6571o stroke-opacity (number)
6572o stroke-width (number) stroke width in pixels, default is '1'
6573o target (string) used with href
6574o text (string) contents of the text element. Use `\n` for multiline text
6575o text-anchor (string) [“`start`”, “`middle`”, “`end`”], default is “`middle`”
6576o title (string) will create tooltip with a given text
6577o transform (string) see @Element.transform
6578o width (number)
6579o x (number)
6580o y (number)
6581> Gradients
6582* Linear gradient format: “`‹angle›-‹colour›[-‹colour›[:‹offset›]]*-‹colour›`”, example: “`90-#fff-#000`” – 90°
6583* gradient from white to black or “`0-#fff-#f00:20-#000`” – 0° gradient from white via red (at 20%) to black.
6584*
6585* radial gradient: “`r[(‹fx›, ‹fy›)]‹colour›[-‹colour›[:‹offset›]]*-‹colour›`”, example: “`r#fff-#000`” –
6586* gradient from white to black or “`r(0.25, 0.75)#fff-#000`” – gradient from white to black with focus point
6587* at 0.25, 0.75. Focus point coordinates are in 0..1 range. Radial gradients can only be applied to circles and ellipses.
6588> Path String
6589# <p>Please refer to <a href="http://www.w3.org/TR/SVG/paths.html#PathData" title="Details of a path’s data attribute’s format are described in the SVG specification.">SVG documentation regarding path string</a>. Raphaël fully supports it.</p>
6590> Colour Parsing
6591# <ul>
6592# <li>Colour name (“<code>red</code>”, “<code>green</code>”, “<code>cornflowerblue</code>”, etc)</li>
6593# <li>#••• — shortened HTML colour: (“<code>#000</code>”, “<code>#fc0</code>”, etc)</li>
6594# <li>#•••••• — full length HTML colour: (“<code>#000000</code>”, “<code>#bd2300</code>”)</li>
6595# <li>rgb(•••, •••, •••) — red, green and blue channels’ values: (“<code>rgb(200, 100, 0)</code>”)</li>
6596# <li>rgb(•••%, •••%, •••%) — same as above, but in %: (“<code>rgb(100%, 175%, 0%)</code>”)</li>
6597# <li>rgba(•••, •••, •••, •••) — red, green and blue channels’ values: (“<code>rgba(200, 100, 0, .5)</code>”)</li>
6598# <li>rgba(•••%, •••%, •••%, •••%) — same as above, but in %: (“<code>rgba(100%, 175%, 0%, 50%)</code>”)</li>
6599# <li>hsb(•••, •••, •••) — hue, saturation and brightness values: (“<code>hsb(0.5, 0.25, 1)</code>”)</li>
6600# <li>hsb(•••%, •••%, •••%) — same as above, but in %</li>
6601# <li>hsba(•••, •••, •••, •••) — same as above, but with opacity</li>
6602# <li>hsl(•••, •••, •••) — almost the same as hsb, see <a href="http://en.wikipedia.org/wiki/HSL_and_HSV" title="HSL and HSV - Wikipedia, the free encyclopedia">Wikipedia page</a></li>
6603# <li>hsl(•••%, •••%, •••%) — same as above, but in %</li>
6604# <li>hsla(•••, •••, •••, •••) — same as above, but with opacity</li>
6605# <li>Optionally for hsb and hsl you could specify hue as a degree: “<code>hsl(240deg, 1, .5)</code>” or, if you want to go fancy, “<code>hsl(240°, 1, .5)</code>”</li>
6606# </ul>
6607\*/
6608elproto.attr = function (name, value) {6609if (this.removed) {6610return this;6611}6612if (name == null) {6613var res = {};6614for (var a in this.attrs) if (this.attrs[has](a)) {6615res[a] = this.attrs[a];6616}6617res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient;6618res.transform = this._.transform;6619return res;6620}6621if (value == null && R.is(name, "string")) {6622if (name == "fill" && this.attrs.fill == "none" && this.attrs.gradient) {6623return this.attrs.gradient;6624}6625if (name == "transform") {6626return this._.transform;6627}6628var names = name.split(separator),6629out = {};6630for (var i = 0, ii = names.length; i < ii; i++) {6631name = names[i];6632if (name in this.attrs) {6633out[name] = this.attrs[name];6634} else if (R.is(this.paper.customAttributes[name], "function")) {6635out[name] = this.paper.customAttributes[name].def;6636} else {6637out[name] = R._availableAttrs[name];6638}6639}6640return ii - 1 ? out : out[names[0]];6641}6642if (value == null && R.is(name, "array")) {6643out = {};6644for (i = 0, ii = name.length; i < ii; i++) {6645out[name[i]] = this.attr(name[i]);6646}6647return out;6648}6649if (value != null) {6650var params = {};6651params[name] = value;6652} else if (name != null && R.is(name, "object")) {6653params = name;6654}6655for (var key in params) {6656eve("raphael.attr." + key + "." + this.id, this, params[key]);6657}6658for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) {6659var par = this.paper.customAttributes[key].apply(this, [].concat(params[key]));6660this.attrs[key] = params[key];6661for (var subkey in par) if (par[has](subkey)) {6662params[subkey] = par[subkey];6663}6664}6665setFillAndStroke(this, params);6666return this;6667};6668/*\6669* Element.toFront
6670[ method ]
6671**
6672* Moves the element so it is the closest to the viewer’s eyes, on top of other elements.
6673= (object) @Element
6674\*/
6675elproto.toFront = function () {6676if (this.removed) {6677return this;6678}6679var node = getRealNode(this.node);6680node.parentNode.appendChild(node);6681var svg = this.paper;6682svg.top != this && R._tofront(this, svg);6683return this;6684};6685/*\6686* Element.toBack
6687[ method ]
6688**
6689* Moves the element so it is the furthest from the viewer’s eyes, behind other elements.
6690= (object) @Element
6691\*/
6692elproto.toBack = function () {6693if (this.removed) {6694return this;6695}6696var node = getRealNode(this.node);6697var parentNode = node.parentNode;6698parentNode.insertBefore(node, parentNode.firstChild);6699R._toback(this, this.paper);6700var svg = this.paper;6701return this;6702};6703/*\6704* Element.insertAfter
6705[ method ]
6706**
6707* Inserts current object after the given one.
6708= (object) @Element
6709\*/
6710elproto.insertAfter = function (element) {6711if (this.removed || !element) {6712return this;6713}6714
6715var node = getRealNode(this.node);6716var afterNode = getRealNode(element.node || element[element.length - 1].node);6717if (afterNode.nextSibling) {6718afterNode.parentNode.insertBefore(node, afterNode.nextSibling);6719} else {6720afterNode.parentNode.appendChild(node);6721}6722R._insertafter(this, element, this.paper);6723return this;6724};6725/*\6726* Element.insertBefore
6727[ method ]
6728**
6729* Inserts current object before the given one.
6730= (object) @Element
6731\*/
6732elproto.insertBefore = function (element) {6733if (this.removed || !element) {6734return this;6735}6736
6737var node = getRealNode(this.node);6738var beforeNode = getRealNode(element.node || element[0].node);6739beforeNode.parentNode.insertBefore(node, beforeNode);6740R._insertbefore(this, element, this.paper);6741return this;6742};6743elproto.blur = function (size) {6744// Experimental. No Safari support. Use it on your own risk.6745var t = this;6746if (+size !== 0) {6747var fltr = $("filter"),6748blur = $("feGaussianBlur");6749t.attrs.blur = size;6750fltr.id = R.createUUID();6751$(blur, {stdDeviation: +size || 1.5});6752fltr.appendChild(blur);6753t.paper.defs.appendChild(fltr);6754t._blur = fltr;6755$(t.node, {filter: "url(#" + fltr.id + ")"});6756} else {6757if (t._blur) {6758t._blur.parentNode.removeChild(t._blur);6759delete t._blur;6760delete t.attrs.blur;6761}6762t.node.removeAttribute("filter");6763}6764return t;6765};6766R._engine.circle = function (svg, x, y, r) {6767var el = $("circle");6768svg.canvas && svg.canvas.appendChild(el);6769var res = new Element(el, svg);6770res.attrs = {cx: x, cy: y, r: r, fill: "none", stroke: "#000"};6771res.type = "circle";6772$(el, res.attrs);6773return res;6774};6775R._engine.rect = function (svg, x, y, w, h, r) {6776var el = $("rect");6777svg.canvas && svg.canvas.appendChild(el);6778var res = new Element(el, svg);6779res.attrs = {x: x, y: y, width: w, height: h, rx: r || 0, ry: r || 0, fill: "none", stroke: "#000"};6780res.type = "rect";6781$(el, res.attrs);6782return res;6783};6784R._engine.ellipse = function (svg, x, y, rx, ry) {6785var el = $("ellipse");6786svg.canvas && svg.canvas.appendChild(el);6787var res = new Element(el, svg);6788res.attrs = {cx: x, cy: y, rx: rx, ry: ry, fill: "none", stroke: "#000"};6789res.type = "ellipse";6790$(el, res.attrs);6791return res;6792};6793R._engine.image = function (svg, src, x, y, w, h) {6794var el = $("image");6795$(el, {x: x, y: y, width: w, height: h, preserveAspectRatio: "none"});6796el.setAttributeNS(xlink, "href", src);6797svg.canvas && svg.canvas.appendChild(el);6798var res = new Element(el, svg);6799res.attrs = {x: x, y: y, width: w, height: h, src: src};6800res.type = "image";6801return res;6802};6803R._engine.text = function (svg, x, y, text) {6804var el = $("text");6805svg.canvas && svg.canvas.appendChild(el);6806var res = new Element(el, svg);6807res.attrs = {6808x: x,6809y: y,6810"text-anchor": "middle",6811text: text,6812"font-family": R._availableAttrs["font-family"],6813"font-size": R._availableAttrs["font-size"],6814stroke: "none",6815fill: "#000"6816};6817res.type = "text";6818setFillAndStroke(res, res.attrs);6819return res;6820};6821R._engine.setSize = function (width, height) {6822this.width = width || this.width;6823this.height = height || this.height;6824this.canvas.setAttribute("width", this.width);6825this.canvas.setAttribute("height", this.height);6826if (this._viewBox) {6827this.setViewBox.apply(this, this._viewBox);6828}6829return this;6830};6831R._engine.create = function () {6832var con = R._getContainer.apply(0, arguments),6833container = con && con.container;6834if (!container) {6835throw new Error("SVG container not found.");6836}6837var x = con.x,6838y = con.y,6839width = con.width,6840height = con.height,6841cnvs = $("svg"),6842css = "overflow:hidden;",6843isFloating;6844x = x || 0;6845y = y || 0;6846width = width || 512;6847height = height || 342;6848$(cnvs, {6849height: height,6850version: 1.1,6851width: width,6852xmlns: "http://www.w3.org/2000/svg",6853"xmlns:xlink": "http://www.w3.org/1999/xlink"6854});6855if (container == 1) {6856cnvs.style.cssText = css + "position:absolute;left:" + x + "px;top:" + y + "px";6857R._g.doc.body.appendChild(cnvs);6858isFloating = 1;6859} else {6860cnvs.style.cssText = css + "position:relative";6861if (container.firstChild) {6862container.insertBefore(cnvs, container.firstChild);6863} else {6864container.appendChild(cnvs);6865}6866}6867container = new R._Paper;6868container.width = width;6869container.height = height;6870container.canvas = cnvs;6871container.clear();6872container._left = container._top = 0;6873isFloating && (container.renderfix = function () {});6874container.renderfix();6875return container;6876};6877R._engine.setViewBox = function (x, y, w, h, fit) {6878eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]);6879var paperSize = this.getSize(),6880size = mmax(w / paperSize.width, h / paperSize.height),6881top = this.top,6882aspectRatio = fit ? "xMidYMid meet" : "xMinYMin",6883vb,6884sw;6885if (x == null) {6886if (this._vbSize) {6887size = 1;6888}6889delete this._vbSize;6890vb = "0 0 " + this.width + S + this.height;6891} else {6892this._vbSize = size;6893vb = x + S + y + S + w + S + h;6894}6895$(this.canvas, {6896viewBox: vb,6897preserveAspectRatio: aspectRatio6898});6899while (size && top) {6900sw = "stroke-width" in top.attrs ? top.attrs["stroke-width"] : 1;6901top.attr({"stroke-width": sw});6902top._.dirty = 1;6903top._.dirtyT = 1;6904top = top.prev;6905}6906this._viewBox = [x, y, w, h, !!fit];6907return this;6908};6909/*\6910* Paper.renderfix
6911[ method ]
6912**
6913* Fixes the issue of Firefox and IE9 regarding subpixel rendering. If paper is dependent
6914* on other elements after reflow it could shift half pixel which cause for lines to lost their crispness.
6915* This method fixes the issue.
6916**
6917Special thanks to Mariusz Nowak (http://www.medikoo.com/) for this method.
6918\*/
6919R.prototype.renderfix = function () {6920var cnvs = this.canvas,6921s = cnvs.style,6922pos;6923try {6924pos = cnvs.getScreenCTM() || cnvs.createSVGMatrix();6925} catch (e) {6926pos = cnvs.createSVGMatrix();6927}6928var left = -pos.e % 1,6929top = -pos.f % 1;6930if (left || top) {6931if (left) {6932this._left = (this._left + left) % 1;6933s.left = this._left + "px";6934}6935if (top) {6936this._top = (this._top + top) % 1;6937s.top = this._top + "px";6938}6939}6940};6941/*\6942* Paper.clear
6943[ method ]
6944**
6945* Clears the paper, i.e. removes all the elements.
6946\*/
6947R.prototype.clear = function () {6948R.eve("raphael.clear", this);6949var c = this.canvas;6950while (c.firstChild) {6951c.removeChild(c.firstChild);6952}6953this.bottom = this.top = null;6954(this.desc = $("desc")).appendChild(R._g.doc.createTextNode("Created with Rapha\xebl " + R.version));6955c.appendChild(this.desc);6956c.appendChild(this.defs = $("defs"));6957};6958/*\6959* Paper.remove
6960[ method ]
6961**
6962* Removes the paper from the DOM.
6963\*/
6964R.prototype.remove = function () {6965eve("raphael.remove", this);6966this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);6967for (var i in this) {6968this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;6969}6970};6971var setproto = R.st;6972for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) {6973setproto[method] = (function (methodname) {6974return function () {6975var arg = arguments;6976return this.forEach(function (el) {6977el[methodname].apply(el, arg);6978});6979};6980})(method);6981}6982}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),6983__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));6984
6985
6986/***/ }),6987
6988/***/ "./dev/raphael.vml.js":6989/*!****************************!*\
6990!*** ./dev/raphael.vml.js ***!
6991\****************************/
6992/*! no static exports found */
6993/***/ (function(module, exports, __webpack_require__) {6994
6995var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./raphael.core */ "./dev/raphael.core.js")], __WEBPACK_AMD_DEFINE_RESULT__ = (function(R) {6996if (R && !R.vml) {6997return;6998}6999
7000var has = "hasOwnProperty",7001Str = String,7002toFloat = parseFloat,7003math = Math,7004round = math.round,7005mmax = math.max,7006mmin = math.min,7007abs = math.abs,7008fillString = "fill",7009separator = /[, ]+/,7010eve = R.eve,7011ms = " progid:DXImageTransform.Microsoft",7012S = " ",7013E = "",7014map = {M: "m", L: "l", C: "c", Z: "x", m: "t", l: "r", c: "v", z: "x"},7015bites = /([clmz]),?([^clmz]*)/gi,7016blurregexp = / progid:\S+Blur\([^\)]+\)/g,7017val = /-?[^,\s-]+/g,7018cssDot = "position:absolute;left:0;top:0;width:1px;height:1px;behavior:url(#default#VML)",7019zoom = 21600,7020pathTypes = {path: 1, rect: 1, image: 1},7021ovalTypes = {circle: 1, ellipse: 1},7022path2vml = function (path) {7023var total = /[ahqstv]/ig,7024command = R._pathToAbsolute;7025Str(path).match(total) && (command = R._path2curve);7026total = /[clmz]/g;7027if (command == R._pathToAbsolute && !Str(path).match(total)) {7028var res = Str(path).replace(bites, function (all, command, args) {7029var vals = [],7030isMove = command.toLowerCase() == "m",7031res = map[command];7032args.replace(val, function (value) {7033if (isMove && vals.length == 2) {7034res += vals + map[command == "m" ? "l" : "L"];7035vals = [];7036}7037vals.push(round(value * zoom));7038});7039return res + vals;7040});7041return res;7042}7043var pa = command(path), p, r;7044res = [];7045for (var i = 0, ii = pa.length; i < ii; i++) {7046p = pa[i];7047r = pa[i][0].toLowerCase();7048r == "z" && (r = "x");7049for (var j = 1, jj = p.length; j < jj; j++) {7050r += round(p[j] * zoom) + (j != jj - 1 ? "," : E);7051}7052res.push(r);7053}7054return res.join(S);7055},7056compensation = function (deg, dx, dy) {7057var m = R.matrix();7058m.rotate(-deg, .5, .5);7059return {7060dx: m.x(dx, dy),7061dy: m.y(dx, dy)7062};7063},7064setCoords = function (p, sx, sy, dx, dy, deg) {7065var _ = p._,7066m = p.matrix,7067fillpos = _.fillpos,7068o = p.node,7069s = o.style,7070y = 1,7071flip = "",7072dxdy,7073kx = zoom / sx,7074ky = zoom / sy;7075s.visibility = "hidden";7076if (!sx || !sy) {7077return;7078}7079o.coordsize = abs(kx) + S + abs(ky);7080s.rotation = deg * (sx * sy < 0 ? -1 : 1);7081if (deg) {7082var c = compensation(deg, dx, dy);7083dx = c.dx;7084dy = c.dy;7085}7086sx < 0 && (flip += "x");7087sy < 0 && (flip += " y") && (y = -1);7088s.flip = flip;7089o.coordorigin = (dx * -kx) + S + (dy * -ky);7090if (fillpos || _.fillsize) {7091var fill = o.getElementsByTagName(fillString);7092fill = fill && fill[0];7093o.removeChild(fill);7094if (fillpos) {7095c = compensation(deg, m.x(fillpos[0], fillpos[1]), m.y(fillpos[0], fillpos[1]));7096fill.position = c.dx * y + S + c.dy * y;7097}7098if (_.fillsize) {7099fill.size = _.fillsize[0] * abs(sx) + S + _.fillsize[1] * abs(sy);7100}7101o.appendChild(fill);7102}7103s.visibility = "visible";7104};7105R.toString = function () {7106return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version;7107};7108var addArrow = function (o, value, isEnd) {7109var values = Str(value).toLowerCase().split("-"),7110se = isEnd ? "end" : "start",7111i = values.length,7112type = "classic",7113w = "medium",7114h = "medium";7115while (i--) {7116switch (values[i]) {7117case "block":7118case "classic":7119case "oval":7120case "diamond":7121case "open":7122case "none":7123type = values[i];7124break;7125case "wide":7126case "narrow": h = values[i]; break;7127case "long":7128case "short": w = values[i]; break;7129}7130}7131var stroke = o.node.getElementsByTagName("stroke")[0];7132stroke[se + "arrow"] = type;7133stroke[se + "arrowlength"] = w;7134stroke[se + "arrowwidth"] = h;7135},7136setFillAndStroke = function (o, params) {7137// o.paper.canvas.style.display = "none";7138o.attrs = o.attrs || {};7139var node = o.node,7140a = o.attrs,7141s = node.style,7142xy,7143newpath = pathTypes[o.type] && (params.x != a.x || params.y != a.y || params.width != a.width || params.height != a.height || params.cx != a.cx || params.cy != a.cy || params.rx != a.rx || params.ry != a.ry || params.r != a.r),7144isOval = ovalTypes[o.type] && (a.cx != params.cx || a.cy != params.cy || a.r != params.r || a.rx != params.rx || a.ry != params.ry),7145res = o;7146
7147
7148for (var par in params) if (params[has](par)) {7149a[par] = params[par];7150}7151if (newpath) {7152a.path = R._getPath[o.type](o);7153o._.dirty = 1;7154}7155params.href && (node.href = params.href);7156params.title && (node.title = params.title);7157params.target && (node.target = params.target);7158params.cursor && (s.cursor = params.cursor);7159"blur" in params && o.blur(params.blur);7160if (params.path && o.type == "path" || newpath) {7161node.path = path2vml(~Str(a.path).toLowerCase().indexOf("r") ? R._pathToAbsolute(a.path) : a.path);7162o._.dirty = 1;7163if (o.type == "image") {7164o._.fillpos = [a.x, a.y];7165o._.fillsize = [a.width, a.height];7166setCoords(o, 1, 1, 0, 0, 0);7167}7168}7169"transform" in params && o.transform(params.transform);7170if (isOval) {7171var cx = +a.cx,7172cy = +a.cy,7173rx = +a.rx || +a.r || 0,7174ry = +a.ry || +a.r || 0;7175node.path = R.format("ar{0},{1},{2},{3},{4},{1},{4},{1}x", round((cx - rx) * zoom), round((cy - ry) * zoom), round((cx + rx) * zoom), round((cy + ry) * zoom), round(cx * zoom));7176o._.dirty = 1;7177}7178if ("clip-rect" in params) {7179var rect = Str(params["clip-rect"]).split(separator);7180if (rect.length == 4) {7181rect[2] = +rect[2] + (+rect[0]);7182rect[3] = +rect[3] + (+rect[1]);7183var div = node.clipRect || R._g.doc.createElement("div"),7184dstyle = div.style;7185dstyle.clip = R.format("rect({1}px {2}px {3}px {0}px)", rect);7186if (!node.clipRect) {7187dstyle.position = "absolute";7188dstyle.top = 0;7189dstyle.left = 0;7190dstyle.width = o.paper.width + "px";7191dstyle.height = o.paper.height + "px";7192node.parentNode.insertBefore(div, node);7193div.appendChild(node);7194node.clipRect = div;7195}7196}7197if (!params["clip-rect"]) {7198node.clipRect && (node.clipRect.style.clip = "auto");7199}7200}7201if (o.textpath) {7202var textpathStyle = o.textpath.style;7203params.font && (textpathStyle.font = params.font);7204params["font-family"] && (textpathStyle.fontFamily = '"' + params["font-family"].split(",")[0].replace(/^['"]+|['"]+$/g, E) + '"');7205params["font-size"] && (textpathStyle.fontSize = params["font-size"]);7206params["font-weight"] && (textpathStyle.fontWeight = params["font-weight"]);7207params["font-style"] && (textpathStyle.fontStyle = params["font-style"]);7208}7209if ("arrow-start" in params) {7210addArrow(res, params["arrow-start"]);7211}7212if ("arrow-end" in params) {7213addArrow(res, params["arrow-end"], 1);7214}7215if (params.opacity != null ||7216params.fill != null ||7217params.src != null ||7218params.stroke != null ||7219params["stroke-width"] != null ||7220params["stroke-opacity"] != null ||7221params["fill-opacity"] != null ||7222params["stroke-dasharray"] != null ||7223params["stroke-miterlimit"] != null ||7224params["stroke-linejoin"] != null ||7225params["stroke-linecap"] != null) {7226var fill = node.getElementsByTagName(fillString),7227newfill = false;7228fill = fill && fill[0];7229!fill && (newfill = fill = createNode(fillString));7230if (o.type == "image" && params.src) {7231fill.src = params.src;7232}7233params.fill && (fill.on = true);7234if (fill.on == null || params.fill == "none" || params.fill === null) {7235fill.on = false;7236}7237if (fill.on && params.fill) {7238var isURL = Str(params.fill).match(R._ISURL);7239if (isURL) {7240fill.parentNode == node && node.removeChild(fill);7241fill.rotate = true;7242fill.src = isURL[1];7243fill.type = "tile";7244var bbox = o.getBBox(1);7245fill.position = bbox.x + S + bbox.y;7246o._.fillpos = [bbox.x, bbox.y];7247
7248R._preload(isURL[1], function () {7249o._.fillsize = [this.offsetWidth, this.offsetHeight];7250});7251} else {7252fill.color = R.getRGB(params.fill).hex;7253fill.src = E;7254fill.type = "solid";7255if (R.getRGB(params.fill).error && (res.type in {circle: 1, ellipse: 1} || Str(params.fill).charAt() != "r") && addGradientFill(res, params.fill, fill)) {7256a.fill = "none";7257a.gradient = params.fill;7258fill.rotate = false;7259}7260}7261}7262if ("fill-opacity" in params || "opacity" in params) {7263var opacity = ((+a["fill-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+R.getRGB(params.fill).o + 1 || 2) - 1);7264opacity = mmin(mmax(opacity, 0), 1);7265fill.opacity = opacity;7266if (fill.src) {7267fill.color = "none";7268}7269}7270node.appendChild(fill);7271var stroke = (node.getElementsByTagName("stroke") && node.getElementsByTagName("stroke")[0]),7272newstroke = false;7273!stroke && (newstroke = stroke = createNode("stroke"));7274if ((params.stroke && params.stroke != "none") ||7275params["stroke-width"] ||7276params["stroke-opacity"] != null ||7277params["stroke-dasharray"] ||7278params["stroke-miterlimit"] ||7279params["stroke-linejoin"] ||7280params["stroke-linecap"]) {7281stroke.on = true;7282}7283(params.stroke == "none" || params.stroke === null || stroke.on == null || params.stroke == 0 || params["stroke-width"] == 0) && (stroke.on = false);7284var strokeColor = R.getRGB(params.stroke);7285stroke.on && params.stroke && (stroke.color = strokeColor.hex);7286opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+strokeColor.o + 1 || 2) - 1);7287var width = (toFloat(params["stroke-width"]) || 1) * .75;7288opacity = mmin(mmax(opacity, 0), 1);7289params["stroke-width"] == null && (width = a["stroke-width"]);7290params["stroke-width"] && (stroke.weight = width);7291width && width < 1 && (opacity *= width) && (stroke.weight = 1);7292stroke.opacity = opacity;7293
7294params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter");7295stroke.miterlimit = params["stroke-miterlimit"] || 8;7296params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round");7297if ("stroke-dasharray" in params) {7298var dasharray = {7299"-": "shortdash",7300".": "shortdot",7301"-.": "shortdashdot",7302"-..": "shortdashdotdot",7303". ": "dot",7304"- ": "dash",7305"--": "longdash",7306"- .": "dashdot",7307"--.": "longdashdot",7308"--..": "longdashdotdot"7309};7310stroke.dashstyle = dasharray[has](params["stroke-dasharray"]) ? dasharray[params["stroke-dasharray"]] : E;7311}7312newstroke && node.appendChild(stroke);7313}7314if (res.type == "text") {7315res.paper.canvas.style.display = E;7316var span = res.paper.span,7317m = 100,7318fontSize = a.font && a.font.match(/\d+(?:\.\d*)?(?=px)/);7319s = span.style;7320a.font && (s.font = a.font);7321a["font-family"] && (s.fontFamily = a["font-family"]);7322a["font-weight"] && (s.fontWeight = a["font-weight"]);7323a["font-style"] && (s.fontStyle = a["font-style"]);7324fontSize = toFloat(a["font-size"] || fontSize && fontSize[0]) || 10;7325s.fontSize = fontSize * m + "px";7326res.textpath.string && (span.innerHTML = Str(res.textpath.string).replace(/</g, "<").replace(/&/g, "&").replace(/\n/g, "<br>"));7327var brect = span.getBoundingClientRect();7328res.W = a.w = (brect.right - brect.left) / m;7329res.H = a.h = (brect.bottom - brect.top) / m;7330// res.paper.canvas.style.display = "none";7331res.X = a.x;7332res.Y = a.y + res.H / 2;7333
7334("x" in params || "y" in params) && (res.path.v = R.format("m{0},{1}l{2},{1}", round(a.x * zoom), round(a.y * zoom), round(a.x * zoom) + 1));7335var dirtyattrs = ["x", "y", "text", "font", "font-family", "font-weight", "font-style", "font-size"];7336for (var d = 0, dd = dirtyattrs.length; d < dd; d++) if (dirtyattrs[d] in params) {7337res._.dirty = 1;7338break;7339}7340
7341// text-anchor emulation7342switch (a["text-anchor"]) {7343case "start":7344res.textpath.style["v-text-align"] = "left";7345res.bbx = res.W / 2;7346break;7347case "end":7348res.textpath.style["v-text-align"] = "right";7349res.bbx = -res.W / 2;7350break;7351default:7352res.textpath.style["v-text-align"] = "center";7353res.bbx = 0;7354break;7355}7356res.textpath.style["v-text-kern"] = true;7357}7358// res.paper.canvas.style.display = E;7359},7360addGradientFill = function (o, gradient, fill) {7361o.attrs = o.attrs || {};7362var attrs = o.attrs,7363pow = Math.pow,7364opacity,7365oindex,7366type = "linear",7367fxfy = ".5 .5";7368o.attrs.gradient = gradient;7369gradient = Str(gradient).replace(R._radial_gradient, function (all, fx, fy) {7370type = "radial";7371if (fx && fy) {7372fx = toFloat(fx);7373fy = toFloat(fy);7374pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && (fy = math.sqrt(.25 - pow(fx - .5, 2)) * ((fy > .5) * 2 - 1) + .5);7375fxfy = fx + S + fy;7376}7377return E;7378});7379gradient = gradient.split(/\s*\-\s*/);7380if (type == "linear") {7381var angle = gradient.shift();7382angle = -toFloat(angle);7383if (isNaN(angle)) {7384return null;7385}7386}7387var dots = R._parseDots(gradient);7388if (!dots) {7389return null;7390}7391o = o.shape || o.node;7392if (dots.length) {7393o.removeChild(fill);7394fill.on = true;7395fill.method = "none";7396fill.color = dots[0].color;7397fill.color2 = dots[dots.length - 1].color;7398var clrs = [];7399for (var i = 0, ii = dots.length; i < ii; i++) {7400dots[i].offset && clrs.push(dots[i].offset + S + dots[i].color);7401}7402fill.colors = clrs.length ? clrs.join() : "0% " + fill.color;7403if (type == "radial") {7404fill.type = "gradientTitle";7405fill.focus = "100%";7406fill.focussize = "0 0";7407fill.focusposition = fxfy;7408fill.angle = 0;7409} else {7410// fill.rotate= true;7411fill.type = "gradient";7412fill.angle = (270 - angle) % 360;7413}7414o.appendChild(fill);7415}7416return 1;7417},7418Element = function (node, vml) {7419this[0] = this.node = node;7420node.raphael = true;7421this.id = R._oid++;7422node.raphaelid = this.id;7423this.X = 0;7424this.Y = 0;7425this.attrs = {};7426this.paper = vml;7427this.matrix = R.matrix();7428this._ = {7429transform: [],7430sx: 1,7431sy: 1,7432dx: 0,7433dy: 0,7434deg: 0,7435dirty: 1,7436dirtyT: 17437};7438!vml.bottom && (vml.bottom = this);7439this.prev = vml.top;7440vml.top && (vml.top.next = this);7441vml.top = this;7442this.next = null;7443};7444var elproto = R.el;7445
7446Element.prototype = elproto;7447elproto.constructor = Element;7448elproto.transform = function (tstr) {7449if (tstr == null) {7450return this._.transform;7451}7452var vbs = this.paper._viewBoxShift,7453vbt = vbs ? "s" + [vbs.scale, vbs.scale] + "-1-1t" + [vbs.dx, vbs.dy] : E,7454oldt;7455if (vbs) {7456oldt = tstr = Str(tstr).replace(/\.{3}|\u2026/g, this._.transform || E);7457}7458R._extractTransform(this, vbt + tstr);7459var matrix = this.matrix.clone(),7460skew = this.skew,7461o = this.node,7462split,7463isGrad = ~Str(this.attrs.fill).indexOf("-"),7464isPatt = !Str(this.attrs.fill).indexOf("url(");7465matrix.translate(1, 1);7466if (isPatt || isGrad || this.type == "image") {7467skew.matrix = "1 0 0 1";7468skew.offset = "0 0";7469split = matrix.split();7470if ((isGrad && split.noRotation) || !split.isSimple) {7471o.style.filter = matrix.toFilter();7472var bb = this.getBBox(),7473bbt = this.getBBox(1),7474dx = bb.x - bbt.x,7475dy = bb.y - bbt.y;7476o.coordorigin = (dx * -zoom) + S + (dy * -zoom);7477setCoords(this, 1, 1, dx, dy, 0);7478} else {7479o.style.filter = E;7480setCoords(this, split.scalex, split.scaley, split.dx, split.dy, split.rotate);7481}7482} else {7483o.style.filter = E;7484skew.matrix = Str(matrix);7485skew.offset = matrix.offset();7486}7487if (oldt !== null) { // empty string value is true as well7488this._.transform = oldt;7489R._extractTransform(this, oldt);7490}7491return this;7492};7493elproto.rotate = function (deg, cx, cy) {7494if (this.removed) {7495return this;7496}7497if (deg == null) {7498return;7499}7500deg = Str(deg).split(separator);7501if (deg.length - 1) {7502cx = toFloat(deg[1]);7503cy = toFloat(deg[2]);7504}7505deg = toFloat(deg[0]);7506(cy == null) && (cx = cy);7507if (cx == null || cy == null) {7508var bbox = this.getBBox(1);7509cx = bbox.x + bbox.width / 2;7510cy = bbox.y + bbox.height / 2;7511}7512this._.dirtyT = 1;7513this.transform(this._.transform.concat([["r", deg, cx, cy]]));7514return this;7515};7516elproto.translate = function (dx, dy) {7517if (this.removed) {7518return this;7519}7520dx = Str(dx).split(separator);7521if (dx.length - 1) {7522dy = toFloat(dx[1]);7523}7524dx = toFloat(dx[0]) || 0;7525dy = +dy || 0;7526if (this._.bbox) {7527this._.bbox.x += dx;7528this._.bbox.y += dy;7529}7530this.transform(this._.transform.concat([["t", dx, dy]]));7531return this;7532};7533elproto.scale = function (sx, sy, cx, cy) {7534if (this.removed) {7535return this;7536}7537sx = Str(sx).split(separator);7538if (sx.length - 1) {7539sy = toFloat(sx[1]);7540cx = toFloat(sx[2]);7541cy = toFloat(sx[3]);7542isNaN(cx) && (cx = null);7543isNaN(cy) && (cy = null);7544}7545sx = toFloat(sx[0]);7546(sy == null) && (sy = sx);7547(cy == null) && (cx = cy);7548if (cx == null || cy == null) {7549var bbox = this.getBBox(1);7550}7551cx = cx == null ? bbox.x + bbox.width / 2 : cx;7552cy = cy == null ? bbox.y + bbox.height / 2 : cy;7553
7554this.transform(this._.transform.concat([["s", sx, sy, cx, cy]]));7555this._.dirtyT = 1;7556return this;7557};7558elproto.hide = function () {7559!this.removed && (this.node.style.display = "none");7560return this;7561};7562elproto.show = function () {7563!this.removed && (this.node.style.display = E);7564return this;7565};7566// Needed to fix the vml setViewBox issues7567elproto.auxGetBBox = R.el.getBBox;7568elproto.getBBox = function(){7569var b = this.auxGetBBox();7570if (this.paper && this.paper._viewBoxShift)7571{7572var c = {};7573var z = 1/this.paper._viewBoxShift.scale;7574c.x = b.x - this.paper._viewBoxShift.dx;7575c.x *= z;7576c.y = b.y - this.paper._viewBoxShift.dy;7577c.y *= z;7578c.width = b.width * z;7579c.height = b.height * z;7580c.x2 = c.x + c.width;7581c.y2 = c.y + c.height;7582return c;7583}7584return b;7585};7586elproto._getBBox = function () {7587if (this.removed) {7588return {};7589}7590return {7591x: this.X + (this.bbx || 0) - this.W / 2,7592y: this.Y - this.H,7593width: this.W,7594height: this.H7595};7596};7597elproto.remove = function () {7598if (this.removed || !this.node.parentNode) {7599return;7600}7601this.paper.__set__ && this.paper.__set__.exclude(this);7602R.eve.unbind("raphael.*.*." + this.id);7603R._tear(this, this.paper);7604this.node.parentNode.removeChild(this.node);7605this.shape && this.shape.parentNode.removeChild(this.shape);7606for (var i in this) {7607this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;7608}7609this.removed = true;7610};7611elproto.attr = function (name, value) {7612if (this.removed) {7613return this;7614}7615if (name == null) {7616var res = {};7617for (var a in this.attrs) if (this.attrs[has](a)) {7618res[a] = this.attrs[a];7619}7620res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient;7621res.transform = this._.transform;7622return res;7623}7624if (value == null && R.is(name, "string")) {7625if (name == fillString && this.attrs.fill == "none" && this.attrs.gradient) {7626return this.attrs.gradient;7627}7628var names = name.split(separator),7629out = {};7630for (var i = 0, ii = names.length; i < ii; i++) {7631name = names[i];7632if (name in this.attrs) {7633out[name] = this.attrs[name];7634} else if (R.is(this.paper.customAttributes[name], "function")) {7635out[name] = this.paper.customAttributes[name].def;7636} else {7637out[name] = R._availableAttrs[name];7638}7639}7640return ii - 1 ? out : out[names[0]];7641}7642if (this.attrs && value == null && R.is(name, "array")) {7643out = {};7644for (i = 0, ii = name.length; i < ii; i++) {7645out[name[i]] = this.attr(name[i]);7646}7647return out;7648}7649var params;7650if (value != null) {7651params = {};7652params[name] = value;7653}7654value == null && R.is(name, "object") && (params = name);7655for (var key in params) {7656eve("raphael.attr." + key + "." + this.id, this, params[key]);7657}7658if (params) {7659for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) {7660var par = this.paper.customAttributes[key].apply(this, [].concat(params[key]));7661this.attrs[key] = params[key];7662for (var subkey in par) if (par[has](subkey)) {7663params[subkey] = par[subkey];7664}7665}7666// this.paper.canvas.style.display = "none";7667if (params.text && this.type == "text") {7668this.textpath.string = params.text;7669}7670setFillAndStroke(this, params);7671// this.paper.canvas.style.display = E;7672}7673return this;7674};7675elproto.toFront = function () {7676!this.removed && this.node.parentNode.appendChild(this.node);7677this.paper && this.paper.top != this && R._tofront(this, this.paper);7678return this;7679};7680elproto.toBack = function () {7681if (this.removed) {7682return this;7683}7684if (this.node.parentNode.firstChild != this.node) {7685this.node.parentNode.insertBefore(this.node, this.node.parentNode.firstChild);7686R._toback(this, this.paper);7687}7688return this;7689};7690elproto.insertAfter = function (element) {7691if (this.removed) {7692return this;7693}7694if (element.constructor == R.st.constructor) {7695element = element[element.length - 1];7696}7697if (element.node.nextSibling) {7698element.node.parentNode.insertBefore(this.node, element.node.nextSibling);7699} else {7700element.node.parentNode.appendChild(this.node);7701}7702R._insertafter(this, element, this.paper);7703return this;7704};7705elproto.insertBefore = function (element) {7706if (this.removed) {7707return this;7708}7709if (element.constructor == R.st.constructor) {7710element = element[0];7711}7712element.node.parentNode.insertBefore(this.node, element.node);7713R._insertbefore(this, element, this.paper);7714return this;7715};7716elproto.blur = function (size) {7717var s = this.node.runtimeStyle,7718f = s.filter;7719f = f.replace(blurregexp, E);7720if (+size !== 0) {7721this.attrs.blur = size;7722s.filter = f + S + ms + ".Blur(pixelradius=" + (+size || 1.5) + ")";7723s.margin = R.format("-{0}px 0 0 -{0}px", round(+size || 1.5));7724} else {7725s.filter = f;7726s.margin = 0;7727delete this.attrs.blur;7728}7729return this;7730};7731
7732R._engine.path = function (pathString, vml) {7733var el = createNode("shape");7734el.style.cssText = cssDot;7735el.coordsize = zoom + S + zoom;7736el.coordorigin = vml.coordorigin;7737var p = new Element(el, vml),7738attr = {fill: "none", stroke: "#000"};7739pathString && (attr.path = pathString);7740p.type = "path";7741p.path = [];7742p.Path = E;7743setFillAndStroke(p, attr);7744vml.canvas && vml.canvas.appendChild(el);7745var skew = createNode("skew");7746skew.on = true;7747el.appendChild(skew);7748p.skew = skew;7749p.transform(E);7750return p;7751};7752R._engine.rect = function (vml, x, y, w, h, r) {7753var path = R._rectPath(x, y, w, h, r),7754res = vml.path(path),7755a = res.attrs;7756res.X = a.x = x;7757res.Y = a.y = y;7758res.W = a.width = w;7759res.H = a.height = h;7760a.r = r;7761a.path = path;7762res.type = "rect";7763return res;7764};7765R._engine.ellipse = function (vml, x, y, rx, ry) {7766var res = vml.path(),7767a = res.attrs;7768res.X = x - rx;7769res.Y = y - ry;7770res.W = rx * 2;7771res.H = ry * 2;7772res.type = "ellipse";7773setFillAndStroke(res, {7774cx: x,7775cy: y,7776rx: rx,7777ry: ry7778});7779return res;7780};7781R._engine.circle = function (vml, x, y, r) {7782var res = vml.path(),7783a = res.attrs;7784res.X = x - r;7785res.Y = y - r;7786res.W = res.H = r * 2;7787res.type = "circle";7788setFillAndStroke(res, {7789cx: x,7790cy: y,7791r: r7792});7793return res;7794};7795R._engine.image = function (vml, src, x, y, w, h) {7796var path = R._rectPath(x, y, w, h),7797res = vml.path(path).attr({stroke: "none"}),7798a = res.attrs,7799node = res.node,7800fill = node.getElementsByTagName(fillString)[0];7801a.src = src;7802res.X = a.x = x;7803res.Y = a.y = y;7804res.W = a.width = w;7805res.H = a.height = h;7806a.path = path;7807res.type = "image";7808fill.parentNode == node && node.removeChild(fill);7809fill.rotate = true;7810fill.src = src;7811fill.type = "tile";7812res._.fillpos = [x, y];7813res._.fillsize = [w, h];7814node.appendChild(fill);7815setCoords(res, 1, 1, 0, 0, 0);7816return res;7817};7818R._engine.text = function (vml, x, y, text) {7819var el = createNode("shape"),7820path = createNode("path"),7821o = createNode("textpath");7822x = x || 0;7823y = y || 0;7824text = text || "";7825path.v = R.format("m{0},{1}l{2},{1}", round(x * zoom), round(y * zoom), round(x * zoom) + 1);7826path.textpathok = true;7827o.string = Str(text);7828o.on = true;7829el.style.cssText = cssDot;7830el.coordsize = zoom + S + zoom;7831el.coordorigin = "0 0";7832var p = new Element(el, vml),7833attr = {7834fill: "#000",7835stroke: "none",7836font: R._availableAttrs.font,7837text: text7838};7839p.shape = el;7840p.path = path;7841p.textpath = o;7842p.type = "text";7843p.attrs.text = Str(text);7844p.attrs.x = x;7845p.attrs.y = y;7846p.attrs.w = 1;7847p.attrs.h = 1;7848setFillAndStroke(p, attr);7849el.appendChild(o);7850el.appendChild(path);7851vml.canvas.appendChild(el);7852var skew = createNode("skew");7853skew.on = true;7854el.appendChild(skew);7855p.skew = skew;7856p.transform(E);7857return p;7858};7859R._engine.setSize = function (width, height) {7860var cs = this.canvas.style;7861this.width = width;7862this.height = height;7863width == +width && (width += "px");7864height == +height && (height += "px");7865cs.width = width;7866cs.height = height;7867cs.clip = "rect(0 " + width + " " + height + " 0)";7868if (this._viewBox) {7869R._engine.setViewBox.apply(this, this._viewBox);7870}7871return this;7872};7873R._engine.setViewBox = function (x, y, w, h, fit) {7874R.eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]);7875var paperSize = this.getSize(),7876width = paperSize.width,7877height = paperSize.height,7878H, W;7879if (fit) {7880H = height / h;7881W = width / w;7882if (w * H < width) {7883x -= (width - w * H) / 2 / H;7884}7885if (h * W < height) {7886y -= (height - h * W) / 2 / W;7887}7888}7889this._viewBox = [x, y, w, h, !!fit];7890this._viewBoxShift = {7891dx: -x,7892dy: -y,7893scale: paperSize7894};7895this.forEach(function (el) {7896el.transform("...");7897});7898return this;7899};7900var createNode;7901R._engine.initWin = function (win) {7902var doc = win.document;7903if (doc.styleSheets.length < 31) {7904doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)");7905} else {7906// no more room, add to the existing one7907// http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx7908doc.styleSheets[0].addRule(".rvml", "behavior:url(#default#VML)");7909}7910try {7911!doc.namespaces.rvml && doc.namespaces.add("rvml", "urn:schemas-microsoft-com:vml");7912createNode = function (tagName) {7913return doc.createElement('<rvml:' + tagName + ' class="rvml">');7914};7915} catch (e) {7916createNode = function (tagName) {7917return doc.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');7918};7919}7920};7921R._engine.initWin(R._g.win);7922R._engine.create = function () {7923var con = R._getContainer.apply(0, arguments),7924container = con.container,7925height = con.height,7926s,7927width = con.width,7928x = con.x,7929y = con.y;7930if (!container) {7931throw new Error("VML container not found.");7932}7933var res = new R._Paper,7934c = res.canvas = R._g.doc.createElement("div"),7935cs = c.style;7936x = x || 0;7937y = y || 0;7938width = width || 512;7939height = height || 342;7940res.width = width;7941res.height = height;7942width == +width && (width += "px");7943height == +height && (height += "px");7944res.coordsize = zoom * 1e3 + S + zoom * 1e3;7945res.coordorigin = "0 0";7946res.span = R._g.doc.createElement("span");7947res.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;";7948c.appendChild(res.span);7949cs.cssText = R.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden", width, height);7950if (container == 1) {7951R._g.doc.body.appendChild(c);7952cs.left = x + "px";7953cs.top = y + "px";7954cs.position = "absolute";7955} else {7956if (container.firstChild) {7957container.insertBefore(c, container.firstChild);7958} else {7959container.appendChild(c);7960}7961}7962res.renderfix = function () {};7963return res;7964};7965R.prototype.clear = function () {7966R.eve("raphael.clear", this);7967this.canvas.innerHTML = E;7968this.span = R._g.doc.createElement("span");7969this.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";7970this.canvas.appendChild(this.span);7971this.bottom = this.top = null;7972};7973R.prototype.remove = function () {7974R.eve("raphael.remove", this);7975this.canvas.parentNode.removeChild(this.canvas);7976for (var i in this) {7977this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;7978}7979return true;7980};7981
7982var setproto = R.st;7983for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) {7984setproto[method] = (function (methodname) {7985return function () {7986var arg = arguments;7987return this.forEach(function (el) {7988el[methodname].apply(el, arg);7989});7990};7991})(method);7992}7993}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),7994__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));7995
7996
7997/***/ }),7998
7999/***/ "./node_modules/eve-raphael/eve.js":8000/*!*****************************************!*\
8001!*** ./node_modules/eve-raphael/eve.js ***!
8002\*****************************************/
8003/*! no static exports found */
8004/***/ (function(module, exports, __webpack_require__) {8005
8006var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.8007//
8008// Licensed under the Apache License, Version 2.0 (the "License");
8009// you may not use this file except in compliance with the License.
8010// You may obtain a copy of the License at
8011//
8012// http://www.apache.org/licenses/LICENSE-2.0
8013//
8014// Unless required by applicable law or agreed to in writing, software
8015// distributed under the License is distributed on an "AS IS" BASIS,
8016// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8017// See the License for the specific language governing permissions and
8018// limitations under the License.
8019// ┌────────────────────────────────────────────────────────────┐ \\
8020// │ Eve 0.5.0 - JavaScript Events Library │ \\
8021// ├────────────────────────────────────────────────────────────┤ \\
8022// │ Author Dmitry Baranovskiy (http://dmitry.baranovskiy.com/) │ \\
8023// └────────────────────────────────────────────────────────────┘ \\
8024
8025(function (glob) {8026var version = "0.5.0",8027has = "hasOwnProperty",8028separator = /[\.\/]/,8029comaseparator = /\s*,\s*/,8030wildcard = "*",8031fun = function () {},8032numsort = function (a, b) {8033return a - b;8034},8035current_event,8036stop,8037events = {n: {}},8038firstDefined = function () {8039for (var i = 0, ii = this.length; i < ii; i++) {8040if (typeof this[i] != "undefined") {8041return this[i];8042}8043}8044},8045lastDefined = function () {8046var i = this.length;8047while (--i) {8048if (typeof this[i] != "undefined") {8049return this[i];8050}8051}8052},8053objtos = Object.prototype.toString,8054Str = String,8055isArray = Array.isArray || function (ar) {8056return ar instanceof Array || objtos.call(ar) == "[object Array]";8057};8058/*\8059* eve
8060[ method ]
8061
8062* Fires event with given `name`, given scope and other parameters.
8063
8064> Arguments
8065
8066- name (string) name of the *event*, dot (`.`) or slash (`/`) separated
8067- scope (object) context for the event handlers
8068- varargs (...) the rest of arguments will be sent to event handlers
8069
8070= (object) array of returned values from the listeners. Array has two methods `.firstDefined()` and `.lastDefined()` to get first or last not `undefined` value.
8071\*/
8072var eve = function (name, scope) {8073var e = events,8074oldstop = stop,8075args = Array.prototype.slice.call(arguments, 2),8076listeners = eve.listeners(name),8077z = 0,8078f = false,8079l,8080indexed = [],8081queue = {},8082out = [],8083ce = current_event,8084errors = [];8085out.firstDefined = firstDefined;8086out.lastDefined = lastDefined;8087current_event = name;8088stop = 0;8089for (var i = 0, ii = listeners.length; i < ii; i++) if ("zIndex" in listeners[i]) {8090indexed.push(listeners[i].zIndex);8091if (listeners[i].zIndex < 0) {8092queue[listeners[i].zIndex] = listeners[i];8093}8094}8095indexed.sort(numsort);8096while (indexed[z] < 0) {8097l = queue[indexed[z++]];8098out.push(l.apply(scope, args));8099if (stop) {8100stop = oldstop;8101return out;8102}8103}8104for (i = 0; i < ii; i++) {8105l = listeners[i];8106if ("zIndex" in l) {8107if (l.zIndex == indexed[z]) {8108out.push(l.apply(scope, args));8109if (stop) {8110break;8111}8112do {8113z++;8114l = queue[indexed[z]];8115l && out.push(l.apply(scope, args));8116if (stop) {8117break;8118}8119} while (l)8120} else {8121queue[l.zIndex] = l;8122}8123} else {8124out.push(l.apply(scope, args));8125if (stop) {8126break;8127}8128}8129}8130stop = oldstop;8131current_event = ce;8132return out;8133};8134// Undocumented. Debug only.8135eve._events = events;8136/*\8137* eve.listeners
8138[ method ]
8139
8140* Internal method which gives you array of all event handlers that will be triggered by the given `name`.
8141
8142> Arguments
8143
8144- name (string) name of the event, dot (`.`) or slash (`/`) separated
8145
8146= (array) array of event handlers
8147\*/
8148eve.listeners = function (name) {8149var names = isArray(name) ? name : name.split(separator),8150e = events,8151item,8152items,8153k,8154i,8155ii,8156j,8157jj,8158nes,8159es = [e],8160out = [];8161for (i = 0, ii = names.length; i < ii; i++) {8162nes = [];8163for (j = 0, jj = es.length; j < jj; j++) {8164e = es[j].n;8165items = [e[names[i]], e[wildcard]];8166k = 2;8167while (k--) {8168item = items[k];8169if (item) {8170nes.push(item);8171out = out.concat(item.f || []);8172}8173}8174}8175es = nes;8176}8177return out;8178};8179/*\8180* eve.separator
8181[ method ]
8182
8183* If for some reasons you don’t like default separators (`.` or `/`) you can specify yours
8184* here. Be aware that if you pass a string longer than one character it will be treated as
8185* a list of characters.
8186
8187- separator (string) new separator. Empty string resets to default: `.` or `/`.
8188\*/
8189eve.separator = function (sep) {8190if (sep) {8191sep = Str(sep).replace(/(?=[\.\^\]\[\-])/g, "\\");8192sep = "[" + sep + "]";8193separator = new RegExp(sep);8194} else {8195separator = /[\.\/]/;8196}8197};8198/*\8199* eve.on
8200[ method ]
8201**
8202* Binds given event handler with a given name. You can use wildcards “`*`” for the names:
8203| eve.on("*.under.*", f);
8204| eve("mouse.under.floor"); // triggers f
8205* Use @eve to trigger the listener.
8206**
8207- name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
8208- f (function) event handler function
8209**
8210- name (array) if you don’t want to use separators, you can use array of strings
8211- f (function) event handler function
8212**
8213= (function) returned function accepts a single numeric parameter that represents z-index of the handler. It is an optional feature and only used when you need to ensure that some subset of handlers will be invoked in a given order, despite of the order of assignment.
8214> Example:
8215| eve.on("mouse", eatIt)(2);
8216| eve.on("mouse", scream);
8217| eve.on("mouse", catchIt)(1);
8218* This will ensure that `catchIt` function will be called before `eatIt`.
8219*
8220* If you want to put your handler before non-indexed handlers, specify a negative value.
8221* Note: I assume most of the time you don’t need to worry about z-index, but it’s nice to have this feature “just in case”.
8222\*/
8223eve.on = function (name, f) {8224if (typeof f != "function") {8225return function () {};8226}8227var names = isArray(name) ? (isArray(name[0]) ? name : [name]) : Str(name).split(comaseparator);8228for (var i = 0, ii = names.length; i < ii; i++) {8229(function (name) {8230var names = isArray(name) ? name : Str(name).split(separator),8231e = events,8232exist;8233for (var i = 0, ii = names.length; i < ii; i++) {8234e = e.n;8235e = e.hasOwnProperty(names[i]) && e[names[i]] || (e[names[i]] = {n: {}});8236}8237e.f = e.f || [];8238for (i = 0, ii = e.f.length; i < ii; i++) if (e.f[i] == f) {8239exist = true;8240break;8241}8242!exist && e.f.push(f);8243}(names[i]));8244}8245return function (zIndex) {8246if (+zIndex == +zIndex) {8247f.zIndex = +zIndex;8248}8249};8250};8251/*\8252* eve.f
8253[ method ]
8254**
8255* Returns function that will fire given event with optional arguments.
8256* Arguments that will be passed to the result function will be also
8257* concated to the list of final arguments.
8258| el.onclick = eve.f("click", 1, 2);
8259| eve.on("click", function (a, b, c) {
8260| console.log(a, b, c); // 1, 2, [event object]
8261| });
8262> Arguments
8263- event (string) event name
8264- varargs (…) and any other arguments
8265= (function) possible event handler function
8266\*/
8267eve.f = function (event) {8268var attrs = [].slice.call(arguments, 1);8269return function () {8270eve.apply(null, [event, null].concat(attrs).concat([].slice.call(arguments, 0)));8271};8272};8273/*\8274* eve.stop
8275[ method ]
8276**
8277* Is used inside an event handler to stop the event, preventing any subsequent listeners from firing.
8278\*/
8279eve.stop = function () {8280stop = 1;8281};8282/*\8283* eve.nt
8284[ method ]
8285**
8286* Could be used inside event handler to figure out actual name of the event.
8287**
8288> Arguments
8289**
8290- subname (string) #optional subname of the event
8291**
8292= (string) name of the event, if `subname` is not specified
8293* or
8294= (boolean) `true`, if current event’s name contains `subname`
8295\*/
8296eve.nt = function (subname) {8297var cur = isArray(current_event) ? current_event.join(".") : current_event;8298if (subname) {8299return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(cur);8300}8301return cur;8302};8303/*\8304* eve.nts
8305[ method ]
8306**
8307* Could be used inside event handler to figure out actual name of the event.
8308**
8309**
8310= (array) names of the event
8311\*/
8312eve.nts = function () {8313return isArray(current_event) ? current_event : current_event.split(separator);8314};8315/*\8316* eve.off
8317[ method ]
8318**
8319* Removes given function from the list of event listeners assigned to given name.
8320* If no arguments specified all the events will be cleared.
8321**
8322> Arguments
8323**
8324- name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
8325- f (function) event handler function
8326\*/
8327/*\8328* eve.unbind
8329[ method ]
8330**
8331* See @eve.off
8332\*/
8333eve.off = eve.unbind = function (name, f) {8334if (!name) {8335eve._events = events = {n: {}};8336return;8337}8338var names = isArray(name) ? (isArray(name[0]) ? name : [name]) : Str(name).split(comaseparator);8339if (names.length > 1) {8340for (var i = 0, ii = names.length; i < ii; i++) {8341eve.off(names[i], f);8342}8343return;8344}8345names = isArray(name) ? name : Str(name).split(separator);8346var e,8347key,8348splice,8349i, ii, j, jj,8350cur = [events];8351for (i = 0, ii = names.length; i < ii; i++) {8352for (j = 0; j < cur.length; j += splice.length - 2) {8353splice = [j, 1];8354e = cur[j].n;8355if (names[i] != wildcard) {8356if (e[names[i]]) {8357splice.push(e[names[i]]);8358}8359} else {8360for (key in e) if (e[has](key)) {8361splice.push(e[key]);8362}8363}8364cur.splice.apply(cur, splice);8365}8366}8367for (i = 0, ii = cur.length; i < ii; i++) {8368e = cur[i];8369while (e.n) {8370if (f) {8371if (e.f) {8372for (j = 0, jj = e.f.length; j < jj; j++) if (e.f[j] == f) {8373e.f.splice(j, 1);8374break;8375}8376!e.f.length && delete e.f;8377}8378for (key in e.n) if (e.n[has](key) && e.n[key].f) {8379var funcs = e.n[key].f;8380for (j = 0, jj = funcs.length; j < jj; j++) if (funcs[j] == f) {8381funcs.splice(j, 1);8382break;8383}8384!funcs.length && delete e.n[key].f;8385}8386} else {8387delete e.f;8388for (key in e.n) if (e.n[has](key) && e.n[key].f) {8389delete e.n[key].f;8390}8391}8392e = e.n;8393}8394}8395};8396/*\8397* eve.once
8398[ method ]
8399**
8400* Binds given event handler with a given name to only run once then unbind itself.
8401| eve.once("login", f);
8402| eve("login"); // triggers f
8403| eve("login"); // no listeners
8404* Use @eve to trigger the listener.
8405**
8406> Arguments
8407**
8408- name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
8409- f (function) event handler function
8410**
8411= (function) same return function as @eve.on
8412\*/
8413eve.once = function (name, f) {8414var f2 = function () {8415eve.off(name, f2);8416return f.apply(this, arguments);8417};8418return eve.on(name, f2);8419};8420/*\8421* eve.version
8422[ property (string) ]
8423**
8424* Current version of the library.
8425\*/
8426eve.version = version;8427eve.toString = function () {8428return "You are running Eve " + version;8429};8430( true && module.exports) ? (module.exports = eve) : ( true ? (!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() { return eve; }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),8431__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))) : (undefined));8432})(this);8433
8434
8435/***/ })8436
8437/******/ });8438});