From 38696874c1e4ebb08b4c8da68afe7a03db7db983 Mon Sep 17 00:00:00 2001 From: Dmitry Baranovskiy Date: Thu, 19 Sep 2013 21:03:24 +1000 Subject: [PATCH] Fix for bug #17. New method Savage.angle. Fixed handling of . Fix use.getBBox. New method Element.toDefs(). Fix for gradient rgba. Fix for double defs. --- README.md | 6 + dist/reference.html | 258 +++++++++++++++++------------- dist/savage-min.js | 8 +- dist/savage.js | 374 ++++++++++++++++++++++++++++---------------- src/set.js | 1 + src/svg.js | 336 ++++++++++++++++++++++++--------------- 6 files changed, 602 insertions(+), 381 deletions(-) diff --git a/README.md b/README.md index 7384589..4b4aec0 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,9 @@ _*Savage uses Grunt 0.4.0. You might want to [read](http://gruntjs.com/getting-s * Type `grunt` in the command line to build the files. * The results will be built into the release folder. * Alternatively type `grunt watch` to have the build run automatically when you make changes to source files. + +* For documentation generation use this command + + cd node_modules/dr.js/; node dr ../../dr.json; cd ../../ + +_It’s ugly at the moment. Somebody should port it to grunt. May be even me :)_ diff --git a/dist/reference.html b/dist/reference.html index b1eb425..c3a6f14 100644 --- a/dist/reference.html +++ b/dist/reference.html @@ -18,7 +18,7 @@
- +
@@ -31,10 +31,10 @@

Element.after(el)

Inserts given element after the current one.

Parameters

  1. el @@ -42,7 +42,7 @@ element to insert

Returns: Element parent

-

Element.animate(attrs, ms, [easing], [callback])

+

Element.animate(attrs, ms, [easing], [callback])

Animate given attributes of the element.

Parameters

  1. attrs @@ -61,7 +61,7 @@  

Returns: Element the element

-

Element.append(el)

Appends given element to current one.

Parameters

  1. el @@ -69,7 +69,7 @@ element to append

Returns: Element parent

-

Element.asPX(attr, [value])

+

Element.asPX(attr, [value])

Return given attribute of the element as a px value. (Not %, em, etc)

Parameters

  1. attr @@ -81,7 +81,7 @@ attribute value

Returns: Element result of query selection

-

Element.attr(…)

Gets or sets given attributes of the element

Parameters

  1. params @@ -106,7 +106,7 @@ }); console.log(el.attr("fill")); // “#fc0”
-

Element.before(el)

Inserts given element before the current one.

Parameters

  1. el @@ -122,11 +122,11 @@ console.log(el.attr("fill")); // “#fc0” handler for the event

Returns: object Element

-

Element.clone()

Creates clone of the element and inserts it after the element.

Returns: Element the clone

-

Element.data(key, [value])

+

Element.getBBox()

Returns bounding box descriptor for the given element.

Returns: object bounding box descriptor:

@@ -274,7 +274,7 @@ See also Element.removeData
  • y2:numbery of the right side,
  • y:numbery of the left side
  • }
  • -

    Element.getPointAtLength(length)

    +

    Element.getPointAtLength(length)

    Return coordinates of the point located at the given length on the given path. Only works for element of “path” type.

    Parameters

    1. length @@ -286,7 +286,7 @@ See also Element.removeData
    2. y:numbery coordinate
    3. alpha:numberangle of derivative
  • }
  • -

    Element.getSubpath(from, to)

    +

    Element.getSubpath(from, to)

    Return subpath of a given element from given length to given length. Only works for element of “path” type.

    Parameters

    1. from @@ -297,7 +297,7 @@ See also Element.removeData position of the end of the segment

    Returns: string pathstring for the segment

    -

    Element.getTotalLength()

    +

    Element.getTotalLength()

    Returns length of the path in pixels. Only works for element of “path” type.

    Returns: number length.

    @@ -320,7 +320,7 @@ See also Element.removeData context for hover out handler

    Returns: object Element

    -

    Element.inAnim()

    Returns an array of animations element currently in

    Returns: object in format

    @@ -329,11 +329,11 @@ See also Element.removeData
  • statusfunctiongets or sets the status of the animation,
  • stopfunctionstops the animation
  • }
  • -

    Element.innerSVG()

    Returns SVG code of the element. Equivalent to innerHTML in HTML context.

    Returns: string SVG code of the element.

    -

    Element.insertAfter(el)

    +

    Element.insertAfter(el)

    Inserts the element after the given one.

    Parameters

    1. el @@ -341,7 +341,7 @@ See also Element.removeData element next to whom insert to

    Returns: Element parent

    -

    Element.insertBefore(el)

    +

    Element.insertBefore(el)

    Inserts the element after the given one.

    Parameters

    1. el @@ -349,7 +349,7 @@ See also Element.removeData element next to whom insert to

    Returns: Element parent

    -

    Element.marker(x, y, width, height, refX, refY)

    +

    Element.marker(x, y, width, height, refX, refY)

    Creates <marker> element from the current element. To create a marker you have to specify the bounding rect and reference point:

    @@ -415,11 +415,11 @@ To create a marker you have to specify the bounding rect and reference point: handler for the event

    Returns: object Element

    -

    Element.parent()

    Returns parent of the element

    Returns: Element parent

    -

    Element.pattern(x, y, width, height)

    +

    Element.pattern(x, y, width, height)

    Creates <pattern> element from the current element. To create a pattern you have to specify the pattern rect:

    @@ -449,7 +449,7 @@ c.attr({ fill: p });
    -

    Element.prepend(el)

    Prepends given element to current one.

    Parameters

    1. el @@ -457,11 +457,11 @@ c.attr({ element to prepend

    Returns: Element parent

    -

    Element.remove()

    Removes element from the DOM

    Returns: Element removed element

    -

    Element.removeData([key])

    +

    Element.removeData([key])

    Removes value associated with an element by given key. If key is not provided, removes all the data of the element.

    @@ -471,7 +471,7 @@ If key is not provided, removes all the data of the element. key

    Returns: object Element

    -

    Element.select(query)

    Applies CSS selector with the element as a parent and returns the result as an Element.

    Parameters

    1. query @@ -479,7 +479,7 @@ If key is not provided, removes all the data of the element. CSS selector

    Returns: Element result of query selection

    -

    Element.selectAll(query)

    +

    Element.selectAll(query)

    Applies CSS selector with the element as a parent and returns the result as a set or array of elements.

    Parameters

    1. query @@ -487,11 +487,15 @@ If key is not provided, removes all the data of the element. CSS selector

    Returns: Set array result of query selection

    -

    Element.stop()

    Stops all the animations of the current element.

    Returns: Element the element

    -

    Element.toDefs()

    +

    Moves element to the relative <defs> section. +

    +

    Returns: Element the clone

    +

    Element.toString()

    Returns SVG code of the element. Equivalent to outerHTML in HTML context.

    Returns: string SVG code of the element.

    @@ -530,7 +534,7 @@ If key is not provided, removes all the data of the element. handler for the event

    Returns: object Element

    -

    Element.transform(tstr)

    +

    Element.transform(tstr)

    Gets or sets transformation of the element

    Parameters

    1. tstr @@ -651,19 +655,19 @@ If key is not provided, removes all the data of the element. handler for the event

    Returns: object Element

    -

    Element.use()

    Creates <use> element linked to the current element.

    Returns: Element <use> element

    Matrix.add(a, b, c, d, e, f, matrix)

    +

    Matrix.add(…)

    Adds given matrix to existing one.

    Parameters

    1. a @@ -684,19 +688,22 @@ If key is not provided, removes all the data of the element.
    2. f number  
    3. -
    4. matrix +
    +

    or +

    +

    Parameters

    1. matrix object Matrix
    -

    Matrix.clone()

    Returns copy of the matrix

    Returns: object Matrix

    -

    Matrix.invert()

    Returns inverted version of the matrix

    Returns: object Matrix

    -

    Matrix.rotate(a, x, y)

    +

    Matrix.rotate(a, x, y)

    Rotates the matrix

    Parameters

    1. a @@ -709,7 +716,7 @@ If key is not provided, removes all the data of the element. number  
    -

    Matrix.scale(x, [y], [cx], [cy])

    +

    Matrix.scale(x, [y], [cx], [cy])

    Scales the matrix

    Parameters

    1. x @@ -728,7 +735,7 @@ If key is not provided, removes all the data of the element. number  
    -

    Matrix.split()

    Splits matrix into primitive transformations

    Returns: object in format:

    @@ -740,11 +747,11 @@ If key is not provided, removes all the data of the element.
  • rotatenumberrotation in deg
  • isSimplebooleancould it be represented via simple transformations -
  • Matrix.toTransformString()

    +

    Matrix.toTransformString()

    Return transform string that represents given matrix

    Returns: string transform string

    -

    Matrix.translate(x, y)

    +

    Matrix.translate(x, y)

    Translate the matrix

    Parameters

    1. x @@ -754,7 +761,7 @@ If key is not provided, removes all the data of the element. number  
    -

    Matrix.x(x, y)

    Return x coordinate for given point after transformation described by the matrix. See also Matrix.y

    Parameters

    1. x @@ -765,7 +772,7 @@ If key is not provided, removes all the data of the element.  

    Returns: number x

    -

    Matrix.y(x, y)

    Return y coordinate for given point after transformation described by the matrix. See also Matrix.x

    Parameters

    1. x @@ -777,7 +784,7 @@ If key is not provided, removes all the data of the element.

    Returns: number y

    Paper.circle(x, y, r)

    Draws a circle.

    Parameters

    1. x @@ -793,7 +800,7 @@ If key is not provided, removes all the data of the element.

      Returns: object Element object with type “circle”

      Usage

      var c = paper.circle(50, 50, 40);
       
      -

    Paper.el(name, attr)

    Creates element on paper with a given name and no attributes.

    Parameters

    1. name @@ -811,7 +818,7 @@ var c = paper.el("circle").attr({ r: 10 });
    -

    Paper.ellipse(x, y, rx, ry)

    +

    Paper.ellipse(x, y, rx, ry)

    Draws an ellipse.

    Parameters

    1. x @@ -845,7 +852,7 @@ var c = paper.el("circle").attr({ filter: f });
    -

    Paper.g([varargs])

    Makes a group element.

    Parameters

    1. varargs @@ -865,7 +872,7 @@ var c = paper.el("circle").attr({ g = paper.g(); g.add(c2, c1);
    -

    Paper.gradient(gradient)

    +

    Paper.gradient(gradient)

    Creates a gradient element.

    Parameters

    1. gradient @@ -903,10 +910,10 @@ through red at 25% to white. });

    Returns: object Element object with type “gradient”

    -

    Paper.image(src, x, y, width, height)

    +

    Paper.image(src, x, y, width, height)

    Embeds an image into the surface.

    Parameters

    1. src @@ -949,7 +956,7 @@ through red at 25% to white.

      Returns: object Element object with type “image”

      Usage

      var c = paper.image("apple.png", 10, 10, 80, 80);
       
      -

    Paper.line(x1, y1, x2, y2)

    +

    Paper.line(x1, y1, x2, y2)

    Draws a line.

    Parameters

    1. x1 @@ -968,7 +975,7 @@ through red at 25% to white.

      Returns: object Element object with type “line”

      Usage

      var t1 = paper.line(50, 50, 100, 100);
       
      -

    Paper.path([pathString])

    +

    Paper.path([pathString])

    Creates a path element by given path data string.

    Parameters

    1. pathString @@ -1003,10 +1010,10 @@ Note: there is a special case when path consist of just three commands: “M10,1 // draw a diagonal line: // move to 10,10, line to 90,90
    -

    Paper.polyline(…)

    Draws a polyline.

    Parameters

    1. points @@ -1023,7 +1030,7 @@ Note: there is a special case when path consist of just three commands: “M10,1

      Usage

      var p1 = paper.polyline([10, 10, 100, 100]);
       var p2 = paper.polyline(10, 10, 100, 100);
       
      -

    Paper.rect(x, y, width, height, [rx], [ry])

    +

    Paper.rect(x, y, width, height, [rx], [ry])

    Draws a rectangle.

    @@ -1054,7 +1061,7 @@ var c = paper.rect(10, 10, 50, 50); // rectangle with rounded corners var c = paper.rect(40, 40, 50, 50, 10);
    -

    Paper.text(x, y, text)

    +

    Paper.text(x, y, text)

    Draws a text string.

    Parameters

    1. x @@ -1071,7 +1078,7 @@ var c = paper.rect(40, 40, 50, 50, 10);

      Usage

      var t1 = paper.text(50, 50, "Savage");
       var t2 = paper.text(50, 50, ["S","a","v","a","g","e"]);
       
      -

    Paper.toString()

    Returns SVG code of the element. Equivalent to outerHTML in HTML context.

    Returns: string SVG code of the element.

    @@ -1079,7 +1086,7 @@ var t2 = paper.text(50, 50, ["S","a","v","a","g","e"]);

    Returns: string SVG code of the Paper.

    Savage.Matrix(…)

    Utility method Returns matrix based on given parameters.

    @@ -1109,7 +1116,7 @@ Returns matrix based on given parameters.  

    Returns: object Matrix

    -

    Savage.ajax(…)

    Simple implementation of Ajax.

    Parameters

    1. url @@ -1140,7 +1147,32 @@ Returns matrix based on given parameters. scope of callback

    Returns: XMLHttpRequest XMLHttpRequest (just in case)

    -

    Savage.animate(from, to, setter, ms, [easing], [callback])

    +

    Savage.angle(x1, y1, x2, y2, [x3], [y3])

    +

    Returns angle between two or three points. +

    +

    Parameters

    Parameters

    1. x1 +number +x coord of first point
    2. +
    3. y1 +number +y coord of first point
    4. +
    5. x2 +number +x coord of second point
    6. +
    7. y2 +number +y coord of second point
    8. +
    9. x3 +optional +number +x coord of third point
    10. +
    11. y3 +optional +number +y coord of third point
    12. +
    +

    Returns: number angle in degrees.

    +

    Savage.animate(from, to, setter, ms, [easing], [callback])

    Runs generic animation of one number into another with a caring function.

    Parameters

    1. from @@ -1172,7 +1204,7 @@ Returns matrix based on given parameters.
    2. statusfunctiongets or sets the status of the animation,
    3. stopfunctionstops the animation
  • }
  • -

    Savage.animation(attr, ms, [easing], [callback])

    +

    Savage.animation(attr, ms, [easing], [callback])

    Creates animation object.

    Parameters

    1. attr @@ -1191,7 +1223,7 @@ Returns matrix based on given parameters. callback

    Returns: object animation object

    -

    Savage.color(clr)

    Parses the color string and returns object with all values for the given color.

    Parameters

    1. clr @@ -1209,7 +1241,7 @@ Returns matrix based on given parameters.
    2. vnumbervalue (brightness),
    3. lnumberlightness
  • }
  • -

    Savage.deg(deg)

    Transform angle to degrees

    Parameters

    1. deg @@ -1235,7 +1267,7 @@ Returns matrix based on given parameters. filter: f });
    -

    Savage.filter.brightness(amount)

    +

    Savage.filter.brightness(amount)

    Returns string of the brightness filter.

    Parameters

    1. amount @@ -1243,7 +1275,7 @@ Returns matrix based on given parameters. amount of filter (0..1).

    Returns: string filter representation

    -

    Savage.filter.contrast(amount)

    +

    Savage.filter.contrast(amount)

    Returns string of the contrast filter.

    Parameters

    1. amount @@ -1251,7 +1283,7 @@ Returns matrix based on given parameters. amount of filter (0..1).

    Returns: string filter representation

    -

    Savage.filter.grayscale(amount)

    +

    Savage.filter.grayscale(amount)

    Returns string of the grayscale filter.

    Parameters

    1. amount @@ -1259,7 +1291,7 @@ Returns matrix based on given parameters. amount of filter (0..1).

    Returns: string filter representation

    -

    Savage.filter.hueRotate(angle)

    +

    Savage.filter.hueRotate(angle)

    Returns string of the hue-rotate filter.

    Parameters

    1. angle @@ -1267,7 +1299,7 @@ Returns matrix based on given parameters. angle of rotation.

    Returns: string filter representation

    -

    Savage.filter.invert(amount)

    +

    Savage.filter.invert(amount)

    Returns string of the invert filter.

    Parameters

    1. amount @@ -1275,7 +1307,7 @@ Returns matrix based on given parameters. amount of filter (0..1).

    Returns: string filter representation

    -

    Savage.filter.saturate(amount)

    +

    Savage.filter.saturate(amount)

    Returns string of the saturate filter.

    Parameters

    1. amount @@ -1283,7 +1315,7 @@ Returns matrix based on given parameters. amount of filter (0..1).

    Returns: string filter representation

    -

    Savage.filter.sepia(amount)

    +

    Savage.filter.sepia(amount)

    Returns string of the sepia filter.

    Parameters

    1. amount @@ -1337,7 +1369,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width } }));
    -

    Savage.fragment(varargs)

    +

    Savage.fragment(varargs)

    Creates DOM fragment from given list of elements or strings

    Parameters

    1. varargs @@ -1345,7 +1377,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width SVG string

    Returns: Fragment the Fragment

    -

    Savage.getRGB(colour)

    Parses colour string as RGB object

    Parameters

    1. colour @@ -1378,7 +1410,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width
    2. hexstringcolor in HTML/CSS format: #••••••,
    3. errorbooleantrue if string cant be parsed
  • }
  • -

    Savage.hsb(h, s, b)

    Converts HSB values to hex representation of the colour.

    Parameters

    1. h @@ -1392,7 +1424,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width value or brightness

    Returns: string hex representation of the colour.

    -

    Savage.hsb2rgb(h, s, v)

    +

    Savage.hsb2rgb(h, s, v)

    Converts HSB values to RGB object.

    Parameters

    1. h @@ -1411,7 +1443,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width
    2. bnumberblue,
    3. hexstringcolor in HTML/CSS format: #••••••
  • }
  • -

    Savage.hsl(h, s, l)

    Converts HSL values to hex representation of the colour.

    Parameters

    1. h @@ -1425,7 +1457,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width luminosity

    Returns: string hex representation of the colour.

    -

    Savage.hsl2rgb(h, s, l)

    +

    Savage.hsl2rgb(h, s, l)

    Converts HSL values to RGB object.

    Parameters

    1. h @@ -1444,7 +1476,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width
    2. bnumberblue,
    3. hexstringcolor in HTML/CSS format: #••••••
  • }
  • -

    Savage.is(o, type)

    Handfull replacement for typeof operator.

    Parameters

    1. o @@ -1455,7 +1487,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width name of the type, i.e. “string”, “function”, “number”, etc.

    Returns: boolean is given value is of given type

    -

    Savage.load(url, callback, [scope])

    +

    Savage.load(url, callback, [scope])

    Loads external SVG file as a Fragment. For more advanced AJAX see Savage.ajax.

    Parameters

    1. url @@ -1469,7 +1501,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width object scope of callback
    -

    Savage.parse(svg)

    Parses SVG fragment and converts it into Fragment.

    Parameters

    1. svg @@ -1477,7 +1509,7 @@ paper.path(Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width SVG string

    Returns: Fragment the fragment

    -

    Savage.parsePathString(pathString)

    +

    Savage.parsePathString(pathString)

    Utility method Parses given path string into an array of arrays of path segments.

    @@ -1486,7 +1518,7 @@ Parses given path string into an array of arrays of path segments. path string or array of segments (in the last case it will be returned straight away)

    Returns: array array of segments.

    -

    Savage.parseTransformString(TString)

    +

    Savage.parseTransformString(TString)

    Utility method Parses given path string into an array of transformations.

    @@ -1496,7 +1528,7 @@ Parses given path string into an array of transformations.

    Returns: array array of transformations.

    Savage.path

    -

    Savage.path.bezierBBox(…)

    +

    Savage.path.bezierBBox(…)

    Utility method Return bounding box of a given cubic bezier curve

    @@ -1537,7 +1569,7 @@ Return bounding box of a given cubic bezier curve
  • }
  • max: {
    1. x:numberx coordinate of the right point
    2. y:numbery coordinate of the bottom point
  • }
  • }
  • -

    Savage.path.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t)

    +

    Savage.path.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t)

    Utility method Find dot coordinates on the given cubic bezier curve at the given t.

    @@ -1582,7 +1614,7 @@ Find dot coordinates on the given cubic bezier curve at the given t.
  • y:numbery coordinate of the end of the curve
  • }
  • alpha:numberangle of the curve derivative at the point
  • }
  • -

    Savage.path.getBBox(path)

    +

    Savage.path.getBBox(path)

    Utility method Return bounding box of a given path

    @@ -1598,7 +1630,7 @@ Return bounding box of a given path
  • width:numberwidth of the box
  • height:numberheight of the box
  • }
  • -

    Savage.path.getPointAtLength(path, length)

    +

    Savage.path.getPointAtLength(path, length)

    Return coordinates of the point located at the given length on the given path.

    Parameters

    1. path @@ -1613,7 +1645,7 @@ Return bounding box of a given path
    2. y:numbery coordinate
    3. alpha:numberangle of derivative
  • }
  • -

    Savage.path.getSubpath(path, from, to)

    +

    Savage.path.getSubpath(path, from, to)

    Return subpath of a given path from given length to given length.

    Parameters

    1. path @@ -1627,7 +1659,7 @@ Return bounding box of a given path position of the end of the segment

    Returns: string pathstring for the segment

    -

    Savage.path.getTotalLength(path)

    +

    Savage.path.getTotalLength(path)

    Returns length of the given path in pixels.

    Parameters

    1. path @@ -1635,7 +1667,7 @@ Return bounding box of a given path SVG path string.

    Returns: number length.

    -

    Savage.path.intersection(path1, path2)

    +

    Savage.path.intersection(path1, path2)

    Utility method Finds intersections of two paths

    @@ -1656,7 +1688,7 @@ Finds intersections of two paths
  • bez1:arrayeight coordinates representing beziér curve for the segment of path1
  • bez2:arrayeight coordinates representing beziér curve for the segment of path2
  • }
  • ] -
  • Savage.path.isBBoxIntersect(bbox1, bbox2)

    +

    Savage.path.isBBoxIntersect(bbox1, bbox2)

    Utility method Returns true if two bounding boxes intersect

    @@ -1668,7 +1700,7 @@ Returns true if two bounding boxes intersect second bounding box

    Returns: boolean true if they intersect

    -

    Savage.path.isPointInside(path, x, y)

    +

    Savage.path.isPointInside(path, x, y)

    Utility method Returns true if given point is inside a given closed path.

    @@ -1683,7 +1715,7 @@ Returns true if given point is inside a given closed path. y of the point

    Returns: boolean true, if point is inside the path

    -

    Savage.path.isPointInsideBBox(bbox, x, y)

    +

    Savage.path.isPointInsideBBox(bbox, x, y)

    Utility method Returns true if given point is inside bounding box.

    @@ -1698,7 +1730,7 @@ Returns true if given point is inside bounding box. y coordinate of the point

    Returns: boolean true if point inside

    -

    Savage.path.map(path, matrix)

    +

    Savage.path.map(path, matrix)

    Transform the path string with given matrix.

    Parameters

    1. path @@ -1709,7 +1741,7 @@ Returns true if given point is inside bounding box. see Matrix

    Returns: string transformed path string

    -

    Savage.path.toAbsolute(path)

    +

    Savage.path.toAbsolute(path)

    Utility method Converts path coordinates into absolute values.

    @@ -1718,7 +1750,7 @@ Converts path coordinates into absolute values. path string

    Returns: array path string

    -

    Savage.path.toCubic(pathString)

    +

    Savage.path.toCubic(pathString)

    Utility method Converts path to a new path where all segments are cubic bezier curves.

    @@ -1727,7 +1759,7 @@ Converts path to a new path where all segments are cubic bezier curves. path string or array of segments

    Returns: array array of segments.

    -

    Savage.path.toRelative(path)

    +

    Savage.path.toRelative(path)

    Utility method Converts path coordinates into relative values.

    @@ -1736,7 +1768,7 @@ Converts path coordinates into relative values. path string

    Returns: array path string

    -

    Savage.rad(deg)

    Transform angle to radians

    Parameters

    1. deg @@ -1744,7 +1776,7 @@ Converts path coordinates into relative values. angle in degrees

    Returns: number angle in radians.

    -

    Savage.rgb(r, g, b)

    Converts RGB values to hex representation of the colour.

    Parameters

    1. r @@ -1758,7 +1790,7 @@ Converts path coordinates into relative values. blue

    Returns: string hex representation of the colour.

    -

    Savage.rgb2hsb(r, g, b)

    +

    Savage.rgb2hsb(r, g, b)

    Converts RGB values to HSB object.

    Parameters

    1. r @@ -1776,7 +1808,7 @@ Converts path coordinates into relative values.
    2. snumbersaturation
    3. bnumberbrightness
  • }
  • -

    Savage.rgb2hsl(r, g, b)

    +

    Savage.rgb2hsl(r, g, b)

    Converts RGB values to HSL object.

    Parameters

    1. r @@ -1794,7 +1826,7 @@ Converts path coordinates into relative values.
    2. snumbersaturation
    3. lnumberluminosity
  • }
  • -

    Savage.select(query)

    Wraps DOM element specified by CSS selector as Element

    Parameters

    1. query @@ -1802,7 +1834,7 @@ Converts path coordinates into relative values. CSS selector of the element

    Returns: Element

    -

    Savage.selectAll(query)

    +

    Savage.selectAll(query)

    Wraps DOM elements specified by CSS selector as set or array of Element

    Parameters

    1. query @@ -1810,7 +1842,7 @@ Converts path coordinates into relative values. CSS selector of the element

    Returns: Element

    -

    Savage.snapTo(values, value, [tolerance])

    +

    Savage.snapTo(values, value, [tolerance])

    Snaps given value to given grid.

    Parameters

    1. values @@ -1873,7 +1905,7 @@ Converts path coordinates into relative values. elements to insert

    Returns: object set elements that were deleted

    -

    mina(a, A, b, B, get, set, [easing])

    +

    mina(a, A, b, B, get, set, [easing])

    Generic animation of numbers.

    Parameters

    1. a @@ -1915,7 +1947,7 @@ Converts path coordinates into relative values.
    2. durationfunctionduration getter/setter,
    3. stopfunctionanimation stopper
  • }
  • -

    mina.backin(n)

    Backin easing.

    Parameters

    1. n @@ -1923,7 +1955,7 @@ Converts path coordinates into relative values. input 0..1

    Returns: number output 0..1

    -

    mina.backout(n)

    Backout easing.

    Parameters

    1. n @@ -1931,7 +1963,7 @@ Converts path coordinates into relative values. input 0..1

    Returns: number output 0..1

    -

    mina.bounce(n)

    Bounce easing.

    Parameters

    1. n @@ -1939,7 +1971,7 @@ Converts path coordinates into relative values. input 0..1

    Returns: number output 0..1

    -

    mina.easein(n)

    Easein easing.

    Parameters

    1. n @@ -1947,7 +1979,7 @@ Converts path coordinates into relative values. input 0..1

    Returns: number output 0..1

    -

    mina.easeinout(n)

    Easeinout easing.

    Parameters

    1. n @@ -1955,7 +1987,7 @@ Converts path coordinates into relative values. input 0..1

    Returns: number output 0..1

    -

    mina.easeout(n)

    Easeout easing.

    Parameters

    1. n @@ -1963,7 +1995,7 @@ Converts path coordinates into relative values. input 0..1

    Returns: number output 0..1

    -

    mina.elastic(n)

    Elastic easing.

    Parameters

    1. n @@ -1971,7 +2003,7 @@ Converts path coordinates into relative values. input 0..1

    Returns: number output 0..1

    -

    mina.getById(id)

    Returns animation by it’s id.

    Parameters

    1. id @@ -1979,7 +2011,7 @@ Converts path coordinates into relative values. animation’s id

    Returns: object See mina

    -

    mina.linear(n)

    Default linear easing.

    Parameters

    1. n @@ -1987,7 +2019,7 @@ Converts path coordinates into relative values. input 0..1

    Returns: number output 0..1

    -

    mina.time()

    Returns current time. Equal to

    function () {
    diff --git a/dist/savage-min.js b/dist/savage-min.js
    index 03588e0..b5c45fb 100644
    --- a/dist/savage-min.js
    +++ b/dist/savage-min.js
    @@ -28,7 +28,7 @@
     // See the License for the specific language governing permissions and
     // limitations under the License.
     // 
    -// build: 2013-09-17
    -!function(a){var b,c,d="0.4.2",e="hasOwnProperty",f=/[\.\/]/,g="*",h=function(){},i=function(a,b){return a-b},j={n:{}},k=function(a,d){a=String(a);var e,f=c,g=Array.prototype.slice.call(arguments,2),h=k.listeners(a),j=0,l=[],m={},n=[],o=b;b=a,c=0;for(var p=0,q=h.length;q>p;p++)"zIndex"in h[p]&&(l.push(h[p].zIndex),h[p].zIndex<0&&(m[h[p].zIndex]=h[p]));for(l.sort(i);l[j]<0;)if(e=m[l[j++]],n.push(e.apply(d,g)),c)return c=f,n;for(p=0;q>p;p++)if(e=h[p],"zIndex"in e)if(e.zIndex==l[j]){if(n.push(e.apply(d,g)),c)break;do if(j++,e=m[l[j]],e&&n.push(e.apply(d,g)),c)break;while(e)}else m[e.zIndex]=e;else if(n.push(e.apply(d,g)),c)break;return c=f,b=o,n.length?n:null};k._events=j,k.listeners=function(a){var b,c,d,e,h,i,k,l,m=a.split(f),n=j,o=[n],p=[];for(e=0,h=m.length;h>e;e++){for(l=[],i=0,k=o.length;k>i;i++)for(n=o[i].n,c=[n[m[e]],n[g]],d=2;d--;)b=c[d],b&&(l.push(b),p=p.concat(b.f||[]));o=l}return p},k.on=function(a,b){if(a=String(a),"function"!=typeof b)return function(){};for(var c=a.split(f),d=j,e=0,g=c.length;g>e;e++)d=d.n,d=d.hasOwnProperty(c[e])&&d[c[e]]||(d[c[e]]={n:{}});for(d.f=d.f||[],e=0,g=d.f.length;g>e;e++)if(d.f[e]==b)return h;return d.f.push(b),function(a){+a==+a&&(b.zIndex=+a)}},k.f=function(a){var b=[].slice.call(arguments,1);return function(){k.apply(null,[a,null].concat(b).concat([].slice.call(arguments,0)))}},k.stop=function(){c=1},k.nt=function(a){return a?new RegExp("(?:\\.|\\/|^)"+a+"(?:\\.|\\/|$)").test(b):b},k.nts=function(){return b.split(f)},k.off=k.unbind=function(a,b){if(!a)return k._events=j={n:{}},void 0;var c,d,h,i,l,m,n,o=a.split(f),p=[j];for(i=0,l=o.length;l>i;i++)for(m=0;mi;i++)for(c=p[i];c.n;){if(b){if(c.f){for(m=0,n=c.f.length;n>m;m++)if(c.f[m]==b){c.f.splice(m,1);break}!c.f.length&&delete c.f}for(d in c.n)if(c.n[e](d)&&c.n[d].f){var q=c.n[d].f;for(m=0,n=q.length;n>m;m++)if(q[m]==b){q.splice(m,1);break}!q.length&&delete c.n[d].f}}else{delete c.f;for(d in c.n)c.n[e](d)&&c.n[d].f&&delete c.n[d].f}c=c.n}},k.once=function(a,b){var c=function(){return k.unbind(a,c),b.apply(this,arguments)};return k.on(a,c)},k.version=d,k.toString=function(){return"You are running Eve "+d},"undefined"!=typeof module&&module.exports?module.exports=k:"undefined"!=typeof define?define("eve",[],function(){return k}):a.eve=k}(this);var mina=function(a){var b={},c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,16)},d=Array.isArray||function(a){return a instanceof Array||"[object Array]"==Object.prototype.toString.call(a)},e=0,f="M"+(+new Date).toString(36),g=function(){return f+(e++).toString(36)},h=function(){return+new Date},i=function(a){var b=this;if(null==a)return b.s;var c=b.s-a;b.b+=b.dur*c,b.B+=b.dur*c,b.s=a},j=function(a){var b=this;return null==a?b.spd:(b.spd=a,void 0)},k=function(a){var b=this;return null==a?b.dur:(b.s=b.s*a/b.dur,b.dur=a,void 0)},l=function(){var c=this;delete b[c.id],a("mina.stop."+c.id,c)},m=function(){var e=0;for(var f in b)if(b.hasOwnProperty(f)){var g,h=b[f],i=h.get();if(e++,h.s=(i-h.b)/(h.dur/h.spd),h.s>=1&&(delete b[f],h.s=1,e--),d(h.start)){g=[];for(var j=0,k=h.start.length;k>j;j++)g[j]=h.start[j]+(h.end[j]-h.start[j])*h.easing(h.s)}else g=h.start+(h.end-h.start)*h.easing(h.s);h.set(g),1==h.s&&a("mina.finish."+h.id,h)}e&&c(m)},n=function(a,d,e,f,h,o,p){var q={id:g(),start:a,end:d,b:e,s:0,dur:f-e,spd:1,get:h,set:o,easing:p||n.linear,status:i,speed:j,duration:k,stop:l};b[q.id]=q;var r,s=0;for(r in b)if(b.hasOwnProperty(r)&&(s++,2==s))break;return 1==s&&c(m),q};return n.time=h,n.getById=function(){return b[anim.id]||null},n.linear=function(a){return a},n.easeout=function(a){return Math.pow(a,1.7)},n.easein=function(a){return Math.pow(a,.48)},n.easeinout=function(a){if(1==a)return 1;if(0==a)return 0;var b=.48-a/1.04,c=Math.sqrt(.1734+b*b),d=c-b,e=Math.pow(Math.abs(d),1/3)*(0>d?-1:1),f=-c-b,g=Math.pow(Math.abs(f),1/3)*(0>f?-1:1),h=e+g+.5;return 3*(1-h)*h*h+h*h*h},n.backin=function(a){if(1==a)return 1;var b=1.70158;return a*a*((b+1)*a-b)},n.backout=function(a){if(0==a)return 0;a-=1;var b=1.70158;return a*a*((b+1)*a+b)+1},n.elastic=function(a){return a==!!a?a:Math.pow(2,-10*a)*Math.sin((a-.075)*2*Math.PI/.3)+1},n.bounce=function(a){var b,c=7.5625,d=2.75;return 1/d>a?b=c*a*a:2/d>a?(a-=1.5/d,b=c*a*a+.75):2.5/d>a?(a-=2.25/d,b=c*a*a+.9375):(a-=2.625/d,b=c*a*a+.984375),b},n}("undefined"==typeof eve?function(){}:eve);!function(){function a(a){a=a||Object(a);for(var c,d,e=1,g=a.length+1,h=b(a,0);g>e;e++)c=d,d=h,h=b(a,e),this.raw+=d,f.call(this,d,h,c);return this._beforeEnd=function(){f.call(this,"","",d)},this}function b(a,b){return a&&(a.charAt?a.charAt(b):a[b])}function c(a,b){this.events=this.events||{},this.events[a]=this.events[a]||[],this.events[a].push(b)}function d(a,b,c){"function"==typeof eve&&eve("elemental."+a+(b?"."+b:""),null,b,c||"",this.raw);for(var d=this.events&&this.events[a],e=d&&d.length;e--;)try{this.events[a][e](b,c||"",this.raw)}catch(f){}this.raw=""}function e(){f.call(this,"eof"),this.event("eof")}function f(a,b,c){"\n"==a&&this.event("newline"),l[this.mode].call(this,a,b,c)}function g(b,f){var g=function(a){g.parse(a)};return g.mode="text",g.type=String(b||"html").toLowerCase(),g.textchunk="",g.raw="",g.parse=a,g.on=c,g.event=d,g.end=e,f&&(h=f),g}var h={lt:60,"lt;":60,"AMP;":38,AMP:38,"GT;":62,GT:62,"QUOT;":34,QUOT:34,"apos;":39,"bull;":8226,"bullet;":8226,"copy;":169,copy:169,"deg;":176,deg:176},i=/[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]/,j=function(a){var b;return"#"==a.charAt()&&(b="x"==a.charAt(1).toLowerCase()?parseInt(a.substring(2),16):parseInt(a.substring(1),10)),b=h[a],b?String.fromCharCode(b):"&"+a},k=function(){for(var a in this.attr)this.attr.hasOwnProperty(a)&&this.event("attr",a,{value:this.attr[a],tagname:this.tagname,attr:this.attr})},l={text:function(a){switch(a){case"<":case"eof":this.nodename="",this.attr={},this.mode="tag name start",this.raw=this.raw.slice(0,-1),this.textchunk&&this.event("text",this.textchunk),this.raw+=a,this.textchunk="";break;case"&":this.mode="entity",this.entity="";break;default:this.textchunk+=a}},entity:function(a){i.test(a)?(this.textchunk+=j(this.entity),this.mode="text"):";"==a?(this.textchunk+=j(this.entity+a),this.mode="text"):this.entity+=a},special:function(a,b,c){return"!"==c&&"-"==a&&"-"==b?(this.mode="comment start",void 0):"[CDATA"==this.textchunk&&"["==a?(this.mode="cdata",this.textchunk="",void 0):">"==a||"eof"==a?(this.event("special",this.textchunk),this.mode="text",this.textchunk="",void 0):(this.textchunk+=a,void 0)},cdata:function(a,b,c){return"]"==c&&"]"==a&&">"==b?(this.mode="cdata end",this.textchunk=this.textchunk.slice(0,-1),void 0):("eof"==a&&l["cdata end"].call(this),this.textchunk+=a,void 0)},"cdata end":function(){this.event("cdata",this.textchunk),this.textchunk="",this.mode="text"},"comment start":function(a,b){">"==b||"eof"==a?(this.event("comment",""),this.mode="skip"):this.mode="comment"},skip:function(){this.mode="text"},comment:function(a,b,c){"-"==a&&"-"==c&&">"==b?(this.mode="comment end",this.textchunk=this.textchunk.slice(0,-1)):"eof"==a?this.event("comment",this.textchunk):this.textchunk+=a},"comment end":function(){this.event("comment",this.textchunk),this.textchunk="",this.mode="text"},declaration:function(a,b){return"?"==a&&">"==b?(this.mode="declaration end",void 0):("eof"==a&&this.event("comment",this.textchunk),this.textchunk+=a,void 0)},"declaration end":function(){this.event("comment",this.textchunk),this.textchunk="",this.mode="text"},"tag name start":function(a,b,c){if("eof"==a)return this.event("text","<"),void 0;if(!i.test(a)){if(this.mode="tag name","/"==a)return this.mode="close tag name start",void 0;if("!"==a)return this.mode="special",this.textchunk="",void 0;if("?"==a)return this.mode="declaration",void 0;l[this.mode].call(this,a,b,c)}},"close tag name start":function(a,b,c){i.test(a)||(this.mode="close tag name",this.tagname="",this.nodename="",l[this.mode].call(this,a,b,c))},"close tag name":function(a){if(i.test(a))this.tagname=this.nodename;else switch(a){case">":this.event("/tag",this.tagname||this.nodename),this.mode="text";break;default:!this.tagname&&(this.nodename+=a)}},"tag name":function(a,b){if(i.test(a))this.tagname=this.nodename,this.nodename="",this.mode="attr start";else switch(a){case">":this.event("tag",this.nodename),this.mode="text";break;case"/":this.raw+=b,this.event("tag",this.nodename),this.event("/tag",this.nodename),this.mode="skip";break;default:this.nodename+=a}},"attr start":function(a,b,c){i.test(a)||(this.mode="attr",this.nodename="",l[this.mode].call(this,a,b,c))},attr:function(a){if(i.test(a)||"="==a)this.attr[this.nodename]="",this.mode="attr value start";else switch(a){case">":"/"==this.nodename?(delete this.attr["/"],this.event("tag",this.tagname,this.attr),k.call(this),this.event("/tag",this.tagname,!0)):(this.nodename&&(this.attr[this.nodename]=""),this.event("tag",this.tagname,this.attr),k.call(this)),this.mode="text";break;default:this.nodename+=a}},"attr value start":function(a,b,c){if(!i.test(a)){if(this.mode="attr value",this.quote=!1,"'"==a||'"'==a)return this.quote=a,void 0;l[this.mode].call(this,a,b,c)}},"attr value":function(a,b,c){if(i.test(a)&&!this.quote)this.mode="attr start";else if(">"!=a||this.quote)switch(a){case'"':case"'":this.quote==a&&"\\"!=c&&(this.mode="attr start");break;default:this.attr[this.nodename]+=a}else this.event("tag",this.tagname,this.attr),this.mode="text"}};g.version="0.2.4",("undefined"==typeof exports?this:exports).elemental=g}();var Savage=function(){function a(a,b){if(a){if(a.tagName)return t(a);if(a instanceof o)return a;if(null==b)return a=w.doc.querySelector(a),t(a)}return a=null==a?"100%":a,b=null==b?"100%":b,new s(a,b)}function b(a,c){if(c){if("string"==typeof a&&(a=b(a)),"string"==typeof c)return"xlink:"==c.substring(0,6)?a.getAttributeNS(W,c.substring(6)):a.getAttribute(c);for(var d in c)if(c[x](d)){var e=y(c[d]);e?"xlink:"==d.substring(0,6)?a.setAttributeNS(W,d.substring(6),e):a.setAttribute(d,e):a.removeAttribute(d)}}else a=w.doc.createElementNS("http://www.w3.org/2000/svg",a);return a}function c(a,b){return b=y.prototype.toLowerCase.call(b),"finite"==b?!K[x](+a):"array"==b&&(a instanceof Array||Array.isArray&&Array.isArray(a))?!0:"null"==b&&null===a||b==typeof a&&null!==a||"object"==b&&a===Object(a)||I.call(a).slice(8,-1).toLowerCase()==b}function d(a){if("function"==typeof a||Object(a)!==a)return a;var b=new a.constructor;for(var c in a)a[x](c)&&(b[c]=d(a[c]));return b}function e(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return a.push(a.splice(c,1)[0])}function f(a,b,c){function d(){var f=Array.prototype.slice.call(arguments,0),g=f.join("␀"),h=d.cache=d.cache||{},i=d.count=d.count||[];return h[x](g)?(e(i,g),c?c(h[g]):h[g]):(i.length>=1e3&&delete h[i.shift()],i.push(g),h[g]=a.apply(b,f),c?c(h[g]):h[g])}return d}function g(a){return a%360*F/180}function h(a){return 180*a/F%360}function i(){return this.x+H+this.y+H+this.width+" × "+this.height}function j(a,b,c,d,e,f){return null==b&&"[object SVGMatrix]"==I.call(a)?(this.a=a.a,this.b=a.b,this.c=a.c,this.d=a.d,this.e=a.e,this.f=a.f,void 0):(null!=a?(this.a=+a,this.b=+b,this.c=+c,this.d=+d,this.e=+e,this.f=+f):(this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0),void 0)}function k(a){var b=[];return a=a.replace(/(?:^|\s)(\w+)\(([^)]+)\)/g,function(a,c,d){return d=d.split(/\s*,\s*/),"rotate"==c&&1==d.length&&d.push(0,0),"scale"==c&&(2==d.length&&d.push(0,0),1==d.length&&d.push(d[0],0,0)),"skewX"==c?b.push(["m",1,0,B.tan(g(d[0])),1,0,0]):"skewY"==c?b.push(["m",1,B.tan(g(d[0])),0,1,0,0]):b.push([c.charAt(0)].concat(d)),a}),b}function l(a,b){if(null==b){var c=!0;if(b="linearGradient"==a.type||"radialGradient"==a.type?a.node.getAttribute("gradientTransform"):"pattern"==a.type?a.node.getAttribute("patternTransform"):a.node.getAttribute("transform"),!b)return new j;b=k(b)}else b=eb.test(b)?y(b).replace(/\.{3}|\u2026/g,a._.transform||G):k(b);var d=db(b),e=0,f=0,g=0,h=1,i=1,l=a._,m=new j;if(l.transform=d||[],d){for(var n=0,o=d.length;o>n;n++){var p,q,r,s,t,u=d[n],v=u.length,w=y(u[0]).toLowerCase(),x=u[0]!=w,z=x?m.invert():0;"t"==w&&3==v?x?(p=z.x(0,0),q=z.y(0,0),r=z.x(u[1],u[2]),s=z.y(u[1],u[2]),m.translate(r-p,s-q)):m.translate(u[1],u[2]):"r"==w?2==v?(t=t||a.getBBox(1),m.rotate(u[1],t.x+t.width/2,t.y+t.height/2),e+=u[1]):4==v&&(x?(r=z.x(u[2],u[3]),s=z.y(u[2],u[3]),m.rotate(u[1],r,s)):m.rotate(u[1],u[2],u[3]),e+=u[1]):"s"==w?2==v||3==v?(t=t||a.getBBox(1),m.scale(u[1],u[v-1],t.x+t.width/2,t.y+t.height/2),h*=u[1],i*=u[v-1]):5==v&&(x?(r=z.x(u[3],u[4]),s=z.y(u[3],u[4]),m.scale(u[1],u[2],r,s)):m.scale(u[1],u[2],u[3],u[4]),h*=u[1],i*=u[2]):"m"==w&&7==v&&m.add(u[1],u[2],u[3],u[4],u[5],u[6])}if(c)return m;l.dirtyT=1,a.matrix=m}a.matrix=m,l.sx=h,l.sy=i,l.deg=e,l.dx=f=m.e,l.dy=g=m.f,1==h&&1==i&&!e&&l.bbox?(l.bbox.x+=+f,l.bbox.y+=+g):l.dirtyT=1}function m(a,c,d){function e(a){return null==a?G:a==+a?a:(b(j,{width:a}),j.getBBox().width)}function f(a){return null==a?G:a==+a?a:(b(j,{height:a}),j.getBBox().height)}function g(b,e){null==c?i[b]=e(a.attr(b)):b==c&&(i=e(null==d?a.attr(b):d))}var h=a.paper.defs,i={},j=a.paper.measurer;switch(j||(a.paper.measurer=j=b("rect"),b(j,{width:10,height:10}),h.appendChild(j)),a.type){case"rect":g("rx",e),g("ry",f);case"image":g("width",e),g("height",f);case"text":g("x",e),g("y",f);break;case"circle":g("cx",e),g("cy",f),g("r",e);break;case"ellipse":g("cx",e),g("cy",f),g("rx",e),g("ry",f);break;case"line":g("x1",e),g("x2",e),g("y1",f),g("y2",f);break;case"marker":g("refX",e),g("markerWidth",e),g("refY",f),g("markerHeight",f);break;case"radialGradient":g("fx",e),g("fy",f);break;case"tspan":g("dx",e),g("dy",f);break;default:i=null}return i}function n(a){c(a,"array")||(a=Array.prototype.slice.call(arguments,0));for(var b=0,d=0,e=this.node;this[b];)delete this[b++];for(b=0;bc;c++)if(b=b||a[c])return b}function q(a){this.node=a}function r(a,c){var d=b(a);c.appendChild(d);var e=t(d);return e.type=a,e}function s(a,c){var d,e,f,g=s.prototype;if(a&&"svg"==a.tagName){if(a.savage in X)return X[a.savage];d=new o(a),e=a.getElementsByTagName("desc")[0],f=a.getElementsByTagName("defs")[0]}else d=r("svg",w.doc.body),b(d.node,{height:c,version:1.1,width:a,xmlns:"http://www.w3.org/2000/svg"});e||(e=b("desc"),e.appendChild(w.doc.createTextNode("Created with Savage")),d.node.appendChild(e)),f||(f=b("defs"),d.node.appendChild(f));for(var h in g)g[x](h)&&(d[h]=g[h]);return d.paper=d.root=d,d.defs=f,d}function t(a){return a?a instanceof o||a instanceof q?a:"svg"==a.tagName?new s(a):new o(a):a}function u(c){return function(d){if(eve.stop(),d instanceof q&&1==d.node.childNodes.length&&("radialGradient"==d.node.firstChild.tagName||"linearGradient"==d.node.firstChild.tagName||"pattern"==d.node.firstChild.tagName)&&(d=d.node.firstChild,this.paper.defs.appendChild(d),d=t(d)),d instanceof o)if("radialGradient"==d.type||"linearGradient"==d.type||"pattern"==d.type){d.node.id||b(d.node,{id:d.id});var e="url(#"+d.node.id+")"}else e=d.attr(c);else if(e=a.color(d),e.error){var f=this.paper.gradient(d);f?(f.node.id||b(f.node,{id:f.id}),e="url(#"+f.node.id+")"):e=d}else e=y(e);var g={};g[c]=e,b(this.node,g),this.node.style[c]=G}}function v(a){for(var b=[],c=a.childNodes,d=0,e=c.length;e>d;d++){var f=c[d];3==f.nodeType&&b.push(f.nodeValue),"tspan"==f.tagName&&(1==f.childNodes.length&&3==f.firstChild.nodeType?b.push(f.firstChild.nodeValue):b.push(v(f)))}return b}a.version="0.0.1",a.toString=function(){return"Savage v"+this.version},a._={};var w={win:window,doc:window.document};a._.glob=w;var x="hasOwnProperty",y=String,z=parseFloat,A=parseInt,B=Math,C=B.max,D=B.min,E=B.abs,F=(B.pow,B.PI),G=(B.round,""),H=" ",I=Object.prototype.toString,J=/^\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,K={NaN:1,Infinity:1,"-Infinity":1},L=/^url\(#?([^)]+)\)$/,M="	\n\f\r   ᠎              \u2028\u2029",N=new RegExp("[,"+M+"]+"),O=(new RegExp("["+M+"]","g"),new RegExp("["+M+"]*,["+M+"]*")),P={hs:1,rg:1},Q=new RegExp("([a-z])["+M+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+M+"]*,?["+M+"]*)+)","ig"),R=new RegExp("([rstm])["+M+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+M+"]*,?["+M+"]*)+)","ig"),S=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+M+"]*,?["+M+"]*","ig"),T=0,U="S"+(+new Date).toString(36),V=function(){return U+(T++).toString(36)},W="http://www.w3.org/1999/xlink",X={};a._.$=b,a._.id=V,a.format=function(){var a=/\{([^\}]+)\}/g,b=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g,c=function(a,c,d){var e=d;return c.replace(b,function(a,b,c,d,f){b=b||d,e&&(b in e&&(e=e[b]),"function"==typeof e&&f&&(e=e()))}),e=(null==e||e==d?a:e)+""};return function(b,d){return y(b).replace(a,function(a,b){return c(a,b,d)})}}();var Y=function(){function a(){this.parentNode.removeChild(this)}return function(b,c){var d=w.doc.createElement("img"),e=w.doc.body;d.style.cssText="position:absolute;left:-9999em;top:-9999em",d.onload=function(){c.call(d),d.onload=d.onerror=null,e.removeChild(d)},d.onerror=a,e.appendChild(d),d.src=b}}();a._.clone=d,a._.cacher=f,a.rad=g,a.deg=h,a.is=c,a.snapTo=function(a,b,d){if(d=c(d,"finite")?d:10,c(a,"array")){for(var e=a.length;e--;)if(E(a[e]-b)<=d)return a[e]}else{a=+a;var f=b%a;if(d>f)return b-f;if(f>a-d)return b-f+a}return b},function(a){function b(a){return a[0]*a[0]+a[1]*a[1]}function c(a){var c=B.sqrt(b(a));a[0]&&(a[0]/=c),a[1]&&(a[1]/=c)}a.add=function(a,b,c,d,e,f){var g,h,i,k,l=[[],[],[]],m=[[this.a,this.c,this.e],[this.b,this.d,this.f],[0,0,1]],n=[[a,c,e],[b,d,f],[0,0,1]];for(a&&a instanceof j&&(n=[[a.a,a.c,a.e],[a.b,a.d,a.f],[0,0,1]]),g=0;3>g;g++)for(h=0;3>h;h++){for(k=0,i=0;3>i;i++)k+=m[g][i]*n[i][h];l[g][h]=k}return this.a=l[0][0],this.b=l[1][0],this.c=l[0][1],this.d=l[1][1],this.e=l[0][2],this.f=l[1][2],this},a.invert=function(){var a=this,b=a.a*a.d-a.b*a.c;return new j(a.d/b,-a.b/b,-a.c/b,a.a/b,(a.c*a.f-a.d*a.e)/b,(a.b*a.e-a.a*a.f)/b)},a.clone=function(){return new j(this.a,this.b,this.c,this.d,this.e,this.f)},a.translate=function(a,b){return this.add(1,0,0,1,a,b)},a.scale=function(a,b,c,d){return null==b&&(b=a),(c||d)&&this.add(1,0,0,1,c,d),this.add(a,0,0,b,0,0),(c||d)&&this.add(1,0,0,1,-c,-d),this},a.rotate=function(a,b,c){a=g(a),b=b||0,c=c||0;var d=+B.cos(a).toFixed(9),e=+B.sin(a).toFixed(9);return this.add(d,e,-e,d,b,c),this.add(1,0,0,1,-b,-c)},a.x=function(a,b){return a*this.a+b*this.c+this.e},a.y=function(a,b){return a*this.b+b*this.d+this.f},a.get=function(a){return+this[y.fromCharCode(97+a)].toFixed(4)},a.toString=function(){return"matrix("+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)].join()+")"},a.offset=function(){return[this.e.toFixed(4),this.f.toFixed(4)]},a.split=function(){var a={};a.dx=this.e,a.dy=this.f;var d=[[this.a,this.c],[this.b,this.d]];a.scalex=B.sqrt(b(d[0])),c(d[0]),a.shear=d[0][0]*d[1][0]+d[0][1]*d[1][1],d[1]=[d[1][0]-d[0][0]*a.shear,d[1][1]-d[0][1]*a.shear],a.scaley=B.sqrt(b(d[1])),c(d[1]),a.shear/=a.scaley;var e=-d[0][1],f=d[1][1];return 0>f?(a.rotate=h(B.acos(f)),0>e&&(a.rotate=360-a.rotate)):a.rotate=h(B.asin(e)),a.isSimple=!(+a.shear.toFixed(9)||a.scalex.toFixed(9)!=a.scaley.toFixed(9)&&a.rotate),a.isSuperSimple=!+a.shear.toFixed(9)&&a.scalex.toFixed(9)==a.scaley.toFixed(9)&&!a.rotate,a.noRotation=!+a.shear.toFixed(9)&&!a.rotate,a},a.toTransformString=function(a){var b=a||this.split();return b.isSimple?(b.scalex=+b.scalex.toFixed(4),b.scaley=+b.scaley.toFixed(4),b.rotate=+b.rotate.toFixed(4),(b.dx||b.dy?"t"+[+b.dx.toFixed(4),+b.dy.toFixed(4)]:G)+(1!=b.scalex||1!=b.scaley?"s"+[b.scalex,b.scaley,0,0]:G)+(b.rotate?"r"+[+b.rotate.toFixed(4),0,0]:G)):"m"+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)]}}(j.prototype),a.Matrix=j,a.getRGB=f(function(b){if(!b||(b=y(b)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:ab};if("none"==b)return{r:-1,g:-1,b:-1,hex:"none",toString:ab};if(!(P[x](b.toLowerCase().substring(0,2))||"#"==b.charAt())&&(b=Z(b)),!b)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:ab};var d,e,f,g,h,i,j=b.match(J);return j?(j[2]&&(f=A(j[2].substring(5),16),e=A(j[2].substring(3,5),16),d=A(j[2].substring(1,3),16)),j[3]&&(f=A((h=j[3].charAt(3))+h,16),e=A((h=j[3].charAt(2))+h,16),d=A((h=j[3].charAt(1))+h,16)),j[4]&&(i=j[4].split(O),d=z(i[0]),"%"==i[0].slice(-1)&&(d*=2.55),e=z(i[1]),"%"==i[1].slice(-1)&&(e*=2.55),f=z(i[2]),"%"==i[2].slice(-1)&&(f*=2.55),"rgba"==j[1].toLowerCase().slice(0,4)&&(g=z(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100)),j[5]?(i=j[5].split(O),d=z(i[0]),"%"==i[0].slice(-1)&&(d/=100),e=z(i[1]),"%"==i[1].slice(-1)&&(e/=100),f=z(i[2]),"%"==i[2].slice(-1)&&(f/=100),("deg"==i[0].slice(-3)||"°"==i[0].slice(-1))&&(d/=360),"hsba"==j[1].toLowerCase().slice(0,4)&&(g=z(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100),a.hsb2rgb(d,e,f,g)):j[6]?(i=j[6].split(O),d=z(i[0]),"%"==i[0].slice(-1)&&(d/=100),e=z(i[1]),"%"==i[1].slice(-1)&&(e/=100),f=z(i[2]),"%"==i[2].slice(-1)&&(f/=100),("deg"==i[0].slice(-3)||"°"==i[0].slice(-1))&&(d/=360),"hsla"==j[1].toLowerCase().slice(0,4)&&(g=z(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100),a.hsl2rgb(d,e,f,g)):(d=D(B.round(d),255),e=D(B.round(e),255),f=D(B.round(f),255),g=D(C(g,0),1),j={r:d,g:e,b:f,toString:ab},j.hex="#"+(16777216|f|e<<8|d<<16).toString(16).slice(1),j.opacity=c(g,"finite")?g:1,j)):{r:-1,g:-1,b:-1,hex:"none",error:1,toString:ab}},a),a.hsb=f(function(b,c,d){return a.hsb2rgb(b,c,d).hex}),a.hsl=f(function(b,c,d){return a.hsl2rgb(b,c,d).hex}),a.rgb=f(function(a,b,d,e){if(c(e,"finite")){var f=B.round;return"rgba("+[f(a),f(b),f(d),+e.toFixed(2)]+")"}return"#"+(16777216|d|b<<8|a<<16).toString(16).slice(1)});var Z=function(a){var b=w.doc.getElementsByTagName("head")[0],c="rgb(255, 0, 0)";return Z=f(function(a){if("red"==a.toLowerCase())return c;b.style.color=c,b.style.color=a;var d=w.doc.defaultView.getComputedStyle(b,G).getPropertyValue("color");return d==c?null:d}),Z(a)},$=function(){return"hsb("+[this.h,this.s,this.b]+")"},_=function(){return"hsl("+[this.h,this.s,this.l]+")"},ab=function(){return 1==this.opacity||null==this.opacity?this.hex:"rgba("+[this.r,this.g,this.b,this.opacity]+")"},bb=function(b,d,e){if(null==d&&c(b,"object")&&"r"in b&&"g"in b&&"b"in b&&(e=b.b,d=b.g,b=b.r),null==d&&c(b,string)){var f=a.getRGB(b);b=f.r,d=f.g,e=f.b}return(b>1||d>1||e>1)&&(b/=255,d/=255,e/=255),[b,d,e]},cb=function(b,d,e,f){b=B.round(255*b),d=B.round(255*d),e=B.round(255*e);var g={r:b,g:d,b:e,opacity:c(f,"finite")?f:1,hex:a.rgb(b,d,e),toString:ab};return c(f,"finite")&&(g.opacity=f),g};a.color=function(b){var d;return c(b,"object")&&"h"in b&&"s"in b&&"b"in b?(d=a.hsb2rgb(b),b.r=d.r,b.g=d.g,b.b=d.b,b.opacity=1,b.hex=d.hex):c(b,"object")&&"h"in b&&"s"in b&&"l"in b?(d=a.hsl2rgb(b),b.r=d.r,b.g=d.g,b.b=d.b,b.opacity=1,b.hex=d.hex):(c(b,"string")&&(b=a.getRGB(b)),c(b,"object")&&"r"in b&&"g"in b&&"b"in b&&!("error"in b)?(d=a.rgb2hsl(b),b.h=d.h,b.s=d.s,b.l=d.l,d=a.rgb2hsb(b),b.v=d.b):(b={hex:"none"},b.r=b.g=b.b=b.h=b.s=b.v=b.l=-1,b.error=1)),b.toString=ab,b},a.hsb2rgb=function(a,b,d,e){c(a,"object")&&"h"in a&&"s"in a&&"b"in a&&(d=a.b,b=a.s,a=a.h,e=a.o),a*=360;var f,g,h,i,j;return a=a%360/60,j=d*b,i=j*(1-E(a%2-1)),f=g=h=d-j,a=~~a,f+=[j,i,0,0,i,j][a],g+=[i,j,j,i,0,0][a],h+=[0,0,i,j,j,i][a],cb(f,g,h,e)},a.hsl2rgb=function(a,b,d,e){c(a,"object")&&"h"in a&&"s"in a&&"l"in a&&(d=a.l,b=a.s,a=a.h),(a>1||b>1||d>1)&&(a/=360,b/=100,d/=100),a*=360;var f,g,h,i,j;return a=a%360/60,j=2*b*(.5>d?d:1-d),i=j*(1-E(a%2-1)),f=g=h=d-j/2,a=~~a,f+=[j,i,0,0,i,j][a],g+=[i,j,j,i,0,0][a],h+=[0,0,i,j,j,i][a],cb(f,g,h,e)},a.rgb2hsb=function(a,b,c){c=bb(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g;return f=C(a,b,c),g=f-D(a,b,c),d=0==g?null:f==a?(b-c)/g:f==b?(c-a)/g+2:(a-b)/g+4,d=60*((d+360)%6)/360,e=0==g?0:g/f,{h:d,s:e,b:f,toString:$}},a.rgb2hsl=function(a,b,c){c=bb(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g,h,i;return g=C(a,b,c),h=D(a,b,c),i=g-h,d=0==i?null:g==a?(b-c)/i:g==b?(c-a)/i+2:(a-b)/i+4,d=60*((d+360)%6)/360,f=(g+h)/2,e=0==i?0:.5>f?i/(2*f):i/(2-2*f),{h:d,s:e,l:f,toString:_}},a.parsePathString=function(b){if(!b)return null;var d=a.path(b);if(d.arr)return a.path.clone(d.arr);var e={a:7,c:6,o:2,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,u:3,z:0},f=[];return c(b,"array")&&c(b[0],"array")&&(f=a.path.clone(b)),f.length||y(b).replace(Q,function(a,b,c){var d=[],g=b.toLowerCase();if(c.replace(S,function(a,b){b&&d.push(+b)}),"m"==g&&d.length>2&&(f.push([b].concat(d.splice(0,2))),g="l",b="m"==b?"l":"L"),"o"==g&&1==d.length&&f.push([b,d[0]]),"r"==g)f.push([b].concat(d));else for(;d.length>=e[g]&&(f.push([b].concat(d.splice(0,e[g]))),e[g]););}),f.toString=a.path.toString,d.arr=a.path.clone(f),f};var db=a.parseTransformString=function(b){if(!b)return null;var d=[];return c(b,"array")&&c(b[0],"array")&&(d=a.path.clone(b)),d.length||y(b).replace(R,function(a,b,c){var e=[];b.toLowerCase(),c.replace(S,function(a,b){b&&e.push(+b)}),d.push([b].concat(e))}),d.toString=a.path.toString,d},eb=new RegExp("^[a-z]["+M+"]*-?\\.?\\d");a._unit2px=m,a.select=function(a){return t(w.doc.querySelector(a))},a.selectAll=function(b){for(var c=w.doc.querySelectorAll(b),d=(a.set||Array)(),e=0;ej;j++){e=f[j],c(e,"fill"),c(e,"stroke"),c(e,"filter"),c(e,"mask"),c(e,"clip-path"),d(e);var l=b(e.node,"id");l&&(b(e.node,{id:e.id}),h.push({old:l,id:e.id}))}for(j=0,k=h.length;k>j;j++){var m=i[h[j].old];if(m)for(var n=0,o=m.length;o>n;n++)m[n](h[j].id)}}function f(a,b,c){return function(d){var e=d.slice(a,b);return 1==e.length&&(e=e[0]),c?c(e):e}}function g(a){return function(){var b=a?"<"+this.type:"",c=this.node.attributes,d=this.node.childNodes;if(a)for(var e=0,f=c.length;f>e;e++)b+=" "+c[e].name+'="'+c[e].value.replace(/"/g,'\\"')+'"';if(d.length){for(a&&(b+=">"),e=0,f=d.length;f>e;e++)3==d[e].nodeType?b+=d[e].nodeValue:1==d[e].nodeType&&(b+=t(d[e]).toString());a&&(b+="")}else a&&(b+="/>");return b}}d.attr=function(a,b){var d=this;if(d.node,!a)return d;if(c(a,"string")){if(!(arguments.length>1))return p(eve("savage.util.getattr."+a,d));var e={};e[a]=b,a=e}for(var f in a)a[x](f)&&eve("savage.util.attr."+f,d,a[f]);return d},d.getBBox=function(b){if(this.removed)return{};var c=this._;return b?((c.dirty||!c.bboxwt)&&(this.realPath=a.path.get[this.type](this),c.bboxwt=a.path.getBBox(this.realPath),c.bboxwt.toString=i,c.dirty=0),a._.box(c.bboxwt)):((c.dirty||c.dirtyT||!c.bbox)&&((c.dirty||!this.realPath)&&(c.bboxwt=0,this.realPath=a.path.get[this.type](this)),c.bbox=a.path.getBBox(a.path.map(this.realPath,this.matrix)),c.bbox.toString=i,c.dirty=c.dirtyT=0),a._.box(c.bbox))};var h=function(){return this.local};d.transform=function(a){var c=this._;if(null==a){var d=new j(this.node.getCTM()),e=l(this);return{string:y(c.transform)||"",globalMatrix:d,localMatrix:e,diffMatrix:d.clone().add(e.invert()),global:d.toTransformString(),local:e.toTransformString(),toString:h}}return a instanceof j&&(a=a.toTransformString()),l(this,a),this.node&&("linearGradient"==this.type||"radialGradient"==this.type?b(this.node,{gradientTransform:this.matrix}):"pattern"==this.type?b(this.node,{patternTransform:this.matrix}):b(this.node,{transform:this.matrix})),this},d.parent=function(){return t(this.node.parentNode)},d.append=d.add=function(a){if("set"==a.type){var b=this;return a.forEach(function(a){b.append(a)}),this}return a=t(a),this.node.appendChild(a.node),a.paper=this.paper,this},d.prepend=function(a){return a=t(a),this.node.insertBefore(a.node,this.node.firstChild),a.paper=this.paper,this},d.before=function(a){return a=t(a),this.node.parentNode.insertBefore(a.node,this.node),a.paper=this.paper,this},d.after=function(a){return a=t(a),this.node.parentNode.insertBefore(a.node,this.node.nextSibling),a.paper=this.paper,this},d.insertBefore=function(a){return a=t(a),a.node.parentNode.insertBefore(this.node,a.node),this.paper=a.paper,this},d.insertAfter=function(a){return a=t(a),a.node.parentNode.insertBefore(this.node,a.node.nextSibling),this.paper=a.paper,this},d.remove=function(){return this.node.parentNode.removeChild(this.node),delete this.paper,this.removed=!0,this},d.select=function(a){return t(this.node.querySelector(a))},d.selectAll=function(b){for(var c=this.node.querySelectorAll(b),d=(a.set||Array)(),e=0;eb;b++)a[b].stop();return this},d.animate=function(a,b,d,e){"function"!=typeof d||d.length||(e=d,d=mina.linear),a instanceof k&&(e=a.callback,d=a.easing,b=d.dur,a=a.attr);var g,h,i,j,l=[],m=[],n={},o=this;for(var p in a)if(a[x](p)){o.equal?(j=o.equal(p,y(a[p])),g=j.from,h=j.to,i=j.f):(g=+o.attr(p),h=+a[p]);var q=c(g,"array")?g.length:1;n[p]=f(l.length,l.length+q,i),l=l.concat(g),m=m.concat(h)}var r=mina.time(),s=mina(l,m,r,r+b,mina.time,function(a){var b={};for(var c in n)n[x](c)&&(b[c]=n[c](a));o.attr(b)},d);return o.anims[s.id]=s,s._attrs=a,s._callback=e,eve.once("mina.finish."+s.id,function(){delete o.anims[s.id],e&&e.call(o)
    -}),eve.once("mina.stop."+s.id,function(){delete o.anims[s.id]}),o};var n={};d.data=function(b,c){var d=n[this.id]=n[this.id]||{};if(1==arguments.length){if(a.is(b,"object")){for(var e in b)b[x](e)&&this.data(e,b[e]);return this}return eve("savage.data.get."+this.id,this,d[b],b),d[b]}return d[b]=c,eve("savage.data.set."+this.id,this,c,b),this},d.removeData=function(a){return null==a?n[this.id]={}:n[this.id]&&delete n[this.id][a],this},d.toString=g(1),d.innerSVG=g()}(o.prototype),a.parse=function(a){var c=w.doc.createDocumentFragment(),d=c;return eve.on("elemental.tag",function(a,c){var e=b(a);c&&b(e,c),d.appendChild(e),d=e}),eve.on("elemental.text",function(a){d.appendChild(w.doc.createTextNode(a))}),eve.on("elemental./tag",function(){d=d.parentNode}),eve.on("elemental.eof",function(){eve.off("elemental.*"),eve("savage.parsed",c)}),elemental().parse(a).end(),new q(c)},q.prototype.select=o.prototype.select,q.prototype.selectAll=o.prototype.selectAll,a.fragment=function(){for(var b=Array.prototype.slice.call(arguments,0),c=w.doc.createDocumentFragment(),d=0,e=b.length;e>d;d++){var f=b[d];f.node&&f.node.nodeType&&c.appendChild(f.node),f.nodeType&&c.appendChild(f),"string"==typeof f&&c.appendChild(a.parse(f).node)}return new q(c)},function(d){d.el=function(a,b){return r(a,this.node).attr(b)},d.rect=function(a,b,d,e,f,g){var h=r("rect",this.node);return null==g&&(g=f),c(a,"object")&&"x"in a?h.attr(a):null!=a&&(h.attr({x:a,y:b,width:d,height:e}),null!=f&&h.attr({rx:f,ry:g})),h},d.circle=function(a,b,d){var e=r("circle",this.node);return c(a,"object")&&"cx"in a?e.attr(a):null!=a&&e.attr({cx:a,cy:b,r:d}),e},d.image=function(a,d,e,f,g){var h=r("image",this.node);if(c(a,"object")&&"src"in a)h.attr(a);else if(null!=a){var i={"xlink:href":a,preserveAspectRatio:"none"};null!=d&&null!=e&&(i.x=d,i.y=e),null!=f&&null!=g?(i.width=f,i.height=g):Y(a,function(){b(h.node,{width:this.offsetWidth,height:this.offsetHeight})}),b(h.node,i)}return h},d.ellipse=function(a,b,d,e){var f=r("ellipse",this.node);return c(a,"object")&&"cx"in a?f.attr(a):null!=a&&f.attr({cx:a,cy:b,rx:d,ry:e}),f},d.path=function(a){var b=r("path",this.node);return c(a,"object")&&!c(a,"array")?b.attr(a):a&&b.attr({d:a}),b},d.group=d.g=function(a){var b=r("g",this.node);b.add=n;for(var c in d)d[x](c)&&(b[c]=d[c]);return 1==arguments.length&&a&&!a.type?b.attr(a):arguments.length&&b.add(Array.prototype.slice.call(arguments,0)),b},d.text=function(a,b,d){var e=r("text",this.node);return c(a,"object")?e.attr(a):null!=a&&e.attr({x:a,y:b,text:d||""}),e},d.line=function(a,b,d,e){var f=r("line",this.node);return c(a,"object")?f.attr(a):null!=a&&f.attr({x1:a,x2:d,y1:b,y2:e}),f},d.polyline=function(a){arguments.length>1&&(a=Array.prototype.slice.call(arguments,0));var b=r("polyline",this.node);return c(a,"object")&&!c(a,"array")?b.attr(a):null!=a&&b.attr({points:a}),b},d.polygon=function(a){arguments.length>1&&(a=Array.prototype.slice.call(arguments,0));var b=r("polygon",this.node);return c(a,"object")&&!c(a,"array")?b.attr(a):null!=a&&b.attr({points:a}),b},function(){function c(){return this.selectAll("stop")}function e(a,c){var d=b("stop");return b(d,{"stop-color":a,offset:+c+"%"}),this.node.appendChild(d),this}function f(){if("linearGradient"==this.type){var c=b(this.node,"x1")||0,d=b(this.node,"x2")||1,e=b(this.node,"y1")||0,f=b(this.node,"y2")||0;return a._.box(c,e,B.abs(d-c),B.abs(f-e))}var g=this.node.cx||.5,h=this.node.cy||.5,i=this.node.r||0;return a._.box(g-i,h-i,2*i,2*i)}d.gradient=function(a){function c(a,b){for(var c=(b-h)/(a-i),d=i;a>d;d++)f[d].offset=+(+h+c*(d-i)).toFixed(2);i=a,h=b}var d,e=p(eve("savage.util.grad.parse",null,a));if(!e)return null;d="l"==e.type.toLowerCase()?this.gradientLinear.apply(this,e.params):this.gradientRadial.apply(this,e.params),e.type!=e.type.toLowerCase()&&b(d.node,{gradientUnits:"userSpaceOnUse"});var f=e.stops,g=f.length,h=0,i=0;g--;for(var j=0;g>j;j++)"offset"in f[j]&&c(j,f[j].offset);for(f[g].offset=f[g].offset||100,c(g,f[g].offset),j=0;g>=j;j++){var k=f[j];d.addStop(k.color,k.offset)}return d},d.gradientLinear=function(a,d,g,h){var i=r("linearGradient",this.node);return i.stops=c,i.addStop=e,i.getBBox=f,null!=a&&b(i.node,{x1:a,y1:d,x2:g,y2:h}),i},d.gradientRadial=function(a,d,g,h,i){var j=r("radialGradient",this.node);return j.stops=c,j.addStop=e,j.getBBox=f,null!=a&&b(j.node,{cx:a,cy:d,r:g}),null!=h&&null!=i&&b(j.node,{fx:h,fy:i}),j},d.toString=function(){var a,c=w.doc.createDocumentFragment(),d=w.doc.createElement("div"),e=this.node.cloneNode(!0);return c.appendChild(d),d.appendChild(e),b(e,{xmlns:"http://www.w3.org/2000/svg"}),a=d.innerHTML,c.removeChild(c.firstChild),a}}()}(s.prototype),a.ajax=function(a,b,d,e){var f=new XMLHttpRequest,g=V();if(f){if(c(b,"function"))e=d,d=b,b=null;else if(c(b,"object")){var h=[];for(var i in b)b.hasOwnProperty(i)&&h.push(encodeURIComponent(i)+"="+encodeURIComponent(b[i]));b=h.join("&")}return f.open(b?"POST":"GET",a,!0),f.setRequestHeader("X-Requested-With","XMLHttpRequest"),b&&f.setRequestHeader("Content-type","application/x-www-form-urlencoded"),d&&(eve.once("savage.ajax."+g+".0",d),eve.once("savage.ajax."+g+".200",d),eve.once("savage.ajax."+g+".304",d)),f.onreadystatechange=function(){4==f.readyState&&eve("savage.ajax."+g+"."+f.status,e,f)},4==f.readyState?f:(f.send(b),f)}},a.load=function(b,c,d){a.ajax(b,function(b){var e=a.parse(b.responseText);d?c.call(d,e):c(e)})},eve.on("savage.util.attr.mask",function(a){if(a instanceof o||a instanceof q){if(eve.stop(),a instanceof q&&1==a.node.childNodes.length&&(a=a.node.firstChild,this.paper.defs.appendChild(a),a=t(a)),"mask"==a.type)var c=a;else c=r("mask",this.paper.defs),c.node.appendChild(a.node),!c.node.id&&b(c.node,{id:c.id});b(this.node,{mask:"url(#"+c.id+")"})}}),function(a){eve.on("savage.util.attr.clip",a),eve.on("savage.util.attr.clip-path",a),eve.on("savage.util.attr.clipPath",a)}(function(a){if(a instanceof o||a instanceof q){if(eve.stop(),"clipPath"==a.type)var c=a;else c=r("clipPath",this.paper.defs),c.node.appendChild(a.node),!c.node.id&&b(c.node,{id:c.id});b(this.node,{"clip-path":"url(#"+c.id+")"})}}),eve.on("savage.util.attr.fill",u("fill")),eve.on("savage.util.attr.stroke",u("stroke"));var fb=/^([lr])(?:\(([^)]*)\))?(.*)$/i;eve.on("savage.util.grad.parse",function(a){a=y(a);var b=a.match(fb);if(!b)return null;var c=b[1],d=b[2],e=b[3];return d=d.split(/\s*,\s*/).map(function(a){return+a==a?+a:a}),1==d.length&&0==d[0]&&(d=[]),e=e.split("-"),e=e.map(function(a){a=a.split(":");var b={color:a[0]};return a[1]&&(b.offset=a[1]),b}),{type:c,params:d,stops:e}}),eve.on("savage.util.attr.d",function(d){eve.stop(),c(d,"array")&&c(d[0],"array")&&(d=a.path.toString.call(d)),d=y(d),d.match(/[ruo]/i)&&(d=a.path.toAbsolute(d)),b(this.node,{d:d})})(-1),eve.on("savage.util.attr.#text",function(a){eve.stop(),a=y(a);for(var b=w.doc.createTextNode(a);this.node.firstChild;)this.node.removeChild(this.node.firstChild);this.node.appendChild(b)})(-1),eve.on("savage.util.attr.path",function(a){eve.stop(),this.attr({d:a})})(-1),eve.on("savage.util.attr.viewBox",function(a){var d;d=c(a,"object")&&"x"in a?[a.x,a.y,a.width,a.height].join(" "):c(a,"array")?a.join(" "):a,b(this.node,{viewBox:d}),eve.stop()})(-1),eve.on("savage.util.attr.transform",function(a){this.transform(a),eve.stop()})(-1),eve.on("savage.util.attr.r",function(a){"rect"==this.type&&(eve.stop(),b(this.node,{rx:a,ry:a}))})(-1),eve.on("savage.util.attr.text",function(a){if("text"==this.type){for(var d=this.node,e=function(a){var d=b("tspan");if(c(a,"array"))for(var f=0;fr;r++){if(l=e[r],"M"==l[0])j=+l[1],k=+l[2];else{if(m=g(j,k,l[1],l[2],l[3],l[4],l[5],l[6]),q+m>f){if(c&&!p.start){if(n=g(j,k,l[1],l[2],l[3],l[4],l[5],l[6],f-q),o+=["C"+d(n.start.x),d(n.start.y),d(n.m.x),d(n.m.y),d(n.x),d(n.y)],h)return o;p.start=o,o=["M"+d(n.x),d(n.y)+"C"+d(n.n.x),d(n.n.y),d(n.end.x),d(n.end.y),d(l[5]),d(l[6])].join(),q+=m,j=+l[5],k=+l[6];continue}if(!a&&!c)return n=g(j,k,l[1],l[2],l[3],l[4],l[5],l[6],f-q)}q+=m,j=+l[5],k=+l[6]}o+=l.shift()+l}return p.end=o,n=a?q:c?p:i(j,k,l[0],l[1],l[2],l[3],l[4],l[5],1)}}function i(a,b,c,d,e,f,g,h,i){var j=1-i,k=S(j,3),l=S(j,2),m=i*i,n=m*i,o=k*a+3*l*i*c+3*j*i*i*e+n*g,p=k*b+3*l*i*d+3*j*i*i*f+n*h,q=a+2*i*(c-a)+m*(e-2*c+a),r=b+2*i*(d-b)+m*(f-2*d+b),s=c+2*i*(e-c)+m*(g-2*e+c),t=d+2*i*(f-d)+m*(h-2*f+d),u=j*a+i*c,v=j*b+i*d,w=j*e+i*g,x=j*f+i*h,y=90-180*O.atan2(q-s,r-t)/P;return{x:o,y:p,m:{x:q,y:r},n:{x:s,y:t},start:{x:u,y:v},end:{x:w,y:x},alpha:y}}function j(b,c,e,f,g,h,i,j){a.is(b,"array")||(b=[b,c,e,f,g,h,i,j]);var k=E.apply(null,b);return d(k.min.x,k.min.y,k.max.x-k.min.x,k.max.y-k.min.y)}function k(a,b,c){return b>=a.x&&b<=a.x+a.width&&c>=a.y&&c<=a.y+a.height}function l(a,b){return a=d(a),b=d(b),k(b,a.x,a.y)||k(b,a.x2,a.y)||k(b,a.x,a.y2)||k(b,a.x2,a.y2)||k(a,b.x,b.y)||k(a,b.x2,b.y)||k(a,b.x,b.y2)||k(a,b.x2,b.y2)||(a.xb.x||b.xa.x)&&(a.yb.y||b.ya.y)}function m(a,b,c,d,e){var f=-3*b+9*c-9*d+3*e,g=a*f+6*b-12*c+6*d;return a*g-3*b+3*c}function n(a,b,c,d,e,f,g,h,i){null==i&&(i=1),i=i>1?1:0>i?0:i;for(var j=i/2,k=12,l=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],n=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],o=0,p=0;k>p;p++){var q=j*l[p]+j,r=m(q,a,c,e,g),s=m(q,b,d,f,h),t=r*r+s*s;o+=n[p]*O.sqrt(t)}return j*o}function o(a,b,c,d,e,f,g,h,i){if(!(0>i||n(a,b,c,d,e,f,g,h)o;)l/=2,m+=(i>j?1:-1)*l,j=n(a,b,c,d,e,f,g,h,m);return m}}function p(a,b,c,d,e,f,g,h){if(!(R(a,c)R(e,g)||R(b,d)R(f,h))){var i=(a*d-b*c)*(e-g)-(a-c)*(e*h-f*g),j=(a*d-b*c)*(f-h)-(b-d)*(e*h-f*g),k=(a-c)*(f-h)-(b-d)*(e-g);if(k){var l=i/k,m=j/k,n=+l.toFixed(2),o=+m.toFixed(2);if(!(n<+Q(a,c).toFixed(2)||n>+R(a,c).toFixed(2)||n<+Q(e,g).toFixed(2)||n>+R(e,g).toFixed(2)||o<+Q(b,d).toFixed(2)||o>+R(b,d).toFixed(2)||o<+Q(f,h).toFixed(2)||o>+R(f,h).toFixed(2)))return{x:l,y:m}}}}function q(a,b,c){var d=j(a),e=j(b);if(!l(d,e))return c?0:[];for(var f=n.apply(0,a),g=n.apply(0,b),h=~~(f/5),k=~~(g/5),m=[],o=[],q={},r=c?0:[],s=0;h+1>s;s++){var t=i.apply(0,a.concat(s/h));m.push({x:t.x,y:t.y,t:s/h})}for(s=0;k+1>s;s++)t=i.apply(0,b.concat(s/k)),o.push({x:t.x,y:t.y,t:s/k});for(s=0;h>s;s++)for(var u=0;k>u;u++){var v=m[s],w=m[s+1],x=o[u],y=o[u+1],z=T(w.x-v.x)<.001?"y":"x",A=T(y.x-x.x)<.001?"y":"x",B=p(v.x,v.y,w.x,w.y,x.x,x.y,y.x,y.y);if(B){if(q[B.x.toFixed(4)]==B.y.toFixed(4))continue;q[B.x.toFixed(4)]=B.y.toFixed(4);var C=v.t+T((B[z]-v[z])/(w[z]-v[z]))*(w.t-v.t),D=x.t+T((B[A]-x[A])/(y[A]-x[A]))*(y.t-x.t);C>=0&&1>=C&&D>=0&&1>=D&&(c?r++:r.push({x:B.x,y:B.y,t1:C,t2:D}))}}return r}function r(a,b){return t(a,b)}function s(a,b){return t(a,b,1)}function t(a,b,c){a=F(a),b=F(b);for(var d,e,f,g,h,i,j,k,l,m,n=c?0:[],o=0,p=a.length;p>o;o++){var r=a[o];if("M"==r[0])d=h=r[1],e=i=r[2];else{"C"==r[0]?(l=[d,e].concat(r.slice(1)),d=l[6],e=l[7]):(l=[d,e,d,e,h,i,h,i],d=h,e=i);for(var s=0,t=b.length;t>s;s++){var u=b[s];if("M"==u[0])f=j=u[1],g=k=u[2];else{"C"==u[0]?(m=[f,g].concat(u.slice(1)),f=m[6],g=m[7]):(m=[f,g,f,g,j,k,j,k],f=j,g=k);var v=q(l,m,c);if(c)n+=v;else{for(var w=0,x=v.length;x>w;w++)v[w].segment1=o,v[w].segment2=s,v[w].bez1=l,v[w].bez2=m;n=n.concat(v)}}}}}return n}function u(a,b,c){var d=v(a);return k(d,b,c)&&1==t(a,[["M",b,c],["H",d.x2+10]],1)%2}function v(a){var b=c(a);if(b.bbox)return K(b.bbox);if(!a)return d();a=F(a);for(var e,f=0,g=0,h=[],i=[],j=0,k=a.length;k>j;j++)if(e=a[j],"M"==e[0])f=e[1],g=e[2],h.push(f),i.push(g);else{var l=E(f,g,e[1],e[2],e[3],e[4],e[5],e[6]);h=h.concat(l.min.x,l.max.x),i=i.concat(l.min.y,l.max.y),f=e[5],g=e[6]}var m=Q.apply(0,h),n=Q.apply(0,i),o=R.apply(0,h),p=R.apply(0,i),q=d(m,n,o-m,p-n);return b.bbox=K(q),q}function w(a,b,c,d,f){if(f)return[["M",a+f,b],["l",c-2*f,0],["a",f,f,0,0,1,f,f],["l",0,d-2*f],["a",f,f,0,0,1,-f,f],["l",2*f-c,0],["a",f,f,0,0,1,-f,-f],["l",0,2*f-d],["a",f,f,0,0,1,f,-f],["z"]];var g=[["M",a,b],["l",c,0],["l",0,d],["l",-c,0],["z"]];return g.toString=e,g}function x(a,b,c,d,f){if(null==f&&null==d&&(d=c),null!=f)var g=Math.PI/180,h=a+c*Math.cos(-d*g),i=a+c*Math.cos(-f*g),j=b+c*Math.sin(-d*g),k=b+c*Math.sin(-f*g),l=[["M",h,j],["A",c,c,0,+(f-d>180),0,i,k]];else l=[["M",a,b],["m",0,-d],["a",c,d,0,1,1,0,2*d],["a",c,d,0,1,1,0,-2*d],["z"]];return l.toString=e,l}function y(b){var d=c(b);if(d.rel)return f(d.rel);a.is(b,"array")&&a.is(b&&b[0],"array")||(b=a.parsePathString(b));var g=[],h=0,i=0,j=0,k=0,l=0;"M"==b[0][0]&&(h=b[0][1],i=b[0][2],j=h,k=i,l++,g.push(["M",h,i]));for(var m=l,n=b.length;n>m;m++){var o=g[m]=[],p=b[m];if(p[0]!=lowerCase.call(p[0]))switch(o[0]=lowerCase.call(p[0]),o[0]){case"a":o[1]=p[1],o[2]=p[2],o[3]=p[3],o[4]=p[4],o[5]=p[5],o[6]=+(p[6]-h).toFixed(3),o[7]=+(p[7]-i).toFixed(3);break;case"v":o[1]=+(p[1]-i).toFixed(3);break;case"m":j=p[1],k=p[2];default:for(var q=1,r=p.length;r>q;q++)o[q]=+(p[q]-(q%2?h:i)).toFixed(3)}else{o=g[m]=[],"m"==p[0]&&(j=p[1]+h,k=p[2]+i);for(var s=0,t=p.length;t>s;s++)g[m][s]=p[s]}var u=g[m].length;switch(g[m][0]){case"z":h=j,i=k;break;case"h":h+=+g[m][u-1];break;case"v":i+=+g[m][u-1];break;default:h+=+g[m][u-2],i+=+g[m][u-1]}}return g.toString=e,d.rel=f(g),g}function z(b){var d=c(b);if(d.abs)return f(d.abs);if(J(b,"array")&&J(b&&b[0],"array")||(b=a.parsePathString(b)),!b||!b.length)return[["M",0,0]];var g,h=[],i=0,j=0,k=0,l=0,m=0;"M"==b[0][0]&&(i=+b[0][1],j=+b[0][2],k=i,l=j,m++,h[0]=["M",i,j]);for(var n,o,p=3==b.length&&"M"==b[0][0]&&"R"==b[1][0].toUpperCase()&&"Z"==b[2][0].toUpperCase(),q=m,r=b.length;r>q;q++){if(h.push(n=[]),o=b[q],g=o[0],g!=g.toUpperCase())switch(n[0]=g.toUpperCase(),n[0]){case"A":n[1]=o[1],n[2]=o[2],n[3]=o[3],n[4]=o[4],n[5]=o[5],n[6]=+(o[6]+i),n[7]=+(o[7]+j);break;case"V":n[1]=+o[1]+j;break;case"H":n[1]=+o[1]+i;break;case"R":for(var s=[i,j].concat(o.slice(1)),t=2,u=s.length;u>t;t++)s[t]=+s[t]+i,s[++t]=+s[t]+j;h.pop(),h=h.concat(H(s,p));break;case"O":h.pop(),s=x(i,j,o[1],o[2]),s.push(s[0]),h=h.concat(s);break;case"U":h.pop(),h=h.concat(x(i,j,o[1],o[2],o[3])),n=["U"].concat(h[h.length-1].slice(-2));break;case"M":k=+o[1]+i,l=+o[2]+j;default:for(t=1,u=o.length;u>t;t++)n[t]=+o[t]+(t%2?i:j)}else if("R"==g)s=[i,j].concat(o.slice(1)),h.pop(),h=h.concat(H(s,p)),n=["R"].concat(o.slice(-2));else if("O"==g)h.pop(),s=x(i,j,o[1],o[2]),s.push(s[0]),h=h.concat(s);else if("U"==g)h.pop(),h=h.concat(x(i,j,o[1],o[2],o[3])),n=["U"].concat(h[h.length-1].slice(-2));else for(var v=0,w=o.length;w>v;v++)n[v]=o[v];if(g=g.toUpperCase(),"O"!=g)switch(n[0]){case"Z":i=k,j=l;break;case"H":i=n[1];break;case"V":j=n[1];break;case"M":k=n[n.length-2],l=n[n.length-1];default:i=n[n.length-2],j=n[n.length-1]}}return h.toString=e,d.abs=f(h),h}function A(a,b,c,d){return[a,b,c,d,c,d]}function B(a,b,c,d,e,f){var g=1/3,h=2/3;return[g*a+h*c,g*b+h*d,g*e+h*c,g*f+h*d,e,f]}function C(b,c,d,e,f,g,h,i,j,k){var l,m=120*P/180,n=P/180*(+f||0),o=[],p=a._.cacher(function(a,b,c){var d=a*O.cos(c)-b*O.sin(c),e=a*O.sin(c)+b*O.cos(c);return{x:d,y:e}});if(k)y=k[0],z=k[1],w=k[2],x=k[3];else{l=p(b,c,-n),b=l.x,c=l.y,l=p(i,j,-n),i=l.x,j=l.y;var q=(O.cos(P/180*f),O.sin(P/180*f),(b-i)/2),r=(c-j)/2,s=q*q/(d*d)+r*r/(e*e);s>1&&(s=O.sqrt(s),d=s*d,e=s*e);var t=d*d,u=e*e,v=(g==h?-1:1)*O.sqrt(T((t*u-t*r*r-u*q*q)/(t*r*r+u*q*q))),w=v*d*r/e+(b+i)/2,x=v*-e*q/d+(c+j)/2,y=O.asin(((c-x)/e).toFixed(9)),z=O.asin(((j-x)/e).toFixed(9));y=w>b?P-y:y,z=w>i?P-z:z,0>y&&(y=2*P+y),0>z&&(z=2*P+z),h&&y>z&&(y-=2*P),!h&&z>y&&(z-=2*P)}var A=z-y;if(T(A)>m){var B=z,D=i,E=j;z=y+m*(h&&z>y?1:-1),i=w+d*O.cos(z),j=x+e*O.sin(z),o=C(i,j,d,e,f,0,h,D,E,[z,B,w,x])}A=z-y;var F=O.cos(y),G=O.sin(y),H=O.cos(z),I=O.sin(z),J=O.tan(A/4),K=4/3*d*J,L=4/3*e*J,M=[b,c],N=[b+K*G,c-L*F],Q=[i+K*I,j-L*H],R=[i,j];if(N[0]=2*M[0]-N[0],N[1]=2*M[1]-N[1],k)return[N,Q,R].concat(o);o=[N,Q,R].concat(o).join().split(",");for(var S=[],U=0,V=o.length;V>U;U++)S[U]=U%2?p(o[U-1],o[U],n).y:p(o[U],o[U+1],n).x;return S}function D(a,b,c,d,e,f,g,h,i){var j=1-i;return{x:S(j,3)*a+3*S(j,2)*i*c+3*j*i*i*e+S(i,3)*g,y:S(j,3)*b+3*S(j,2)*i*d+3*j*i*i*f+S(i,3)*h}}function E(a,b,c,d,e,f,g,h){var i,j=e-2*c+a-(g-2*e+c),k=2*(c-a)-2*(e-c),l=a-c,m=(-k+O.sqrt(k*k-4*j*l))/2/j,n=(-k-O.sqrt(k*k-4*j*l))/2/j,o=[b,h],p=[a,g];return T(m)>"1e12"&&(m=.5),T(n)>"1e12"&&(n=.5),m>0&&1>m&&(i=D(a,b,c,d,e,f,g,h,m),p.push(i.x),o.push(i.y)),n>0&&1>n&&(i=D(a,b,c,d,e,f,g,h,n),p.push(i.x),o.push(i.y)),j=f-2*d+b-(h-2*f+d),k=2*(d-b)-2*(f-d),l=b-d,m=(-k+O.sqrt(k*k-4*j*l))/2/j,n=(-k-O.sqrt(k*k-4*j*l))/2/j,T(m)>"1e12"&&(m=.5),T(n)>"1e12"&&(n=.5),m>0&&1>m&&(i=D(a,b,c,d,e,f,g,h,m),p.push(i.x),o.push(i.y)),n>0&&1>n&&(i=D(a,b,c,d,e,f,g,h,n),p.push(i.x),o.push(i.y)),{min:{x:Q.apply(0,p),y:Q.apply(0,o)},max:{x:R.apply(0,p),y:R.apply(0,o)}}}function F(a,b){var d=!b&&c(a);if(!b&&d.curve)return f(d.curve);for(var e=z(a),g=b&&z(b),h={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},j=(function(a,b){var c,d;if(!a)return["C",b.x,b.y,b.x,b.y,b.x,b.y];switch(!(a[0]in{T:1,Q:1})&&(b.qx=b.qy=null),a[0]){case"M":b.X=a[1],b.Y=a[2];break;case"A":a=["C"].concat(C.apply(0,[b.x,b.y].concat(a.slice(1))));break;case"S":c=b.x+(b.x-(b.bx||b.x)),d=b.y+(b.y-(b.by||b.y)),a=["C",c,d].concat(a.slice(1));break;case"T":b.qx=b.x+(b.x-(b.qx||b.x)),b.qy=b.y+(b.y-(b.qy||b.y)),a=["C"].concat(B(b.x,b.y,b.qx,b.qy,a[1],a[2]));break;case"Q":b.qx=a[1],b.qy=a[2],a=["C"].concat(B(b.x,b.y,a[1],a[2],a[3],a[4]));break;case"L":a=["C"].concat(A(b.x,b.y,a[1],a[2]));break;case"H":a=["C"].concat(A(b.x,b.y,a[1],b.y));break;case"V":a=["C"].concat(A(b.x,b.y,b.x,a[1]));break;case"Z":a=["C"].concat(A(b.x,b.y,b.X,b.Y))}return a}),k=function(a,b){if(a[b].length>7){a[b].shift();for(var c=a[b];c.length;)a.splice(b++,0,["C"].concat(c.splice(0,6)));a.splice(b,1),n=R(e.length,g&&g.length||0)}},l=function(a,b,c,d,f){a&&b&&"M"==a[f][0]&&"M"!=b[f][0]&&(b.splice(f,0,["M",d.x,d.y]),c.bx=0,c.by=0,c.x=a[f][1],c.y=a[f][2],n=R(e.length,g&&g.length||0))},m=0,n=R(e.length,g&&g.length||0);n>m;m++){e[m]=j(e[m],h),k(e,m),g&&(g[m]=j(g[m],i)),g&&k(g,m),l(e,g,h,i,m),l(g,e,i,h,m);var o=e[m],p=g&&g[m],q=o.length,r=g&&p.length;h.x=o[q-2],h.y=o[q-1],h.bx=N(o[q-4])||h.x,h.by=N(o[q-3])||h.y,i.bx=g&&(N(p[r-4])||i.x),i.by=g&&(N(p[r-3])||i.y),i.x=g&&p[r-2],i.y=g&&p[r-1]}return g||(d.curve=f(e)),g?[e,g]:e}function G(a,b){if(!b)return a;var c,d,e,f,g,h,i;for(a=F(a),e=0,g=a.length;g>e;e++)for(i=a[e],f=1,h=i.length;h>f;f+=2)c=b.x(i[f],i[f+1]),d=b.y(i[f],i[f+1]),i[f]=c,i[f+1]=d;return a}function H(a,b){for(var c=[],d=0,e=a.length;e-2*!b>d;d+=2){var f=[{x:+a[d-2],y:+a[d-1]},{x:+a[d],y:+a[d+1]},{x:+a[d+2],y:+a[d+3]},{x:+a[d+4],y:+a[d+5]}];b?d?e-4==d?f[3]={x:+a[0],y:+a[1]}:e-2==d&&(f[2]={x:+a[0],y:+a[1]},f[3]={x:+a[2],y:+a[3]}):f[0]={x:+a[e-2],y:+a[e-1]}:e-4==d?f[3]=f[2]:d||(f[0]={x:+a[d],y:+a[d+1]}),c.push(["C",(-f[0].x+6*f[1].x+f[2].x)/6,(-f[0].y+6*f[1].y+f[2].y)/6,(f[1].x+6*f[2].x-f[3].x)/6,(f[1].y+6*f[2].y-f[3].y)/6,f[2].x,f[2].y])}return c}var I=b.prototype,J=a.is,K=a._.clone,L="hasOwnProperty",M=/,?([a-z]),?/gi,N=parseFloat,O=Math,P=O.PI,Q=O.min,R=O.max,S=O.pow,T=O.abs,U=h(1),V=h(),W=h(0,1),X=a._unit2px,Y={path:function(a){return a.attr("path")},circle:function(a){var b=X(a);return x(b.cx,b.cy,b.r)},ellipse:function(a){var b=X(a);return x(b.cx,b.cy,b.rx,b.ry)},rect:function(a){var b=X(a);return w(b.x,b.y,b.width,b.height,b.rx,b.ry)},image:function(a){var b=X(a);return w(b.x,b.y,b.width,b.height)},text:function(a){var b=a.node.getBBox();return w(b.x,b.y,b.width,b.height)},g:function(a){var b=a.node.getBBox();return w(b.x,b.y,b.width,b.height)},symbol:function(a){var b=a.getBBox();return w(b.x,b.y,b.width,b.height)}};a.path=c,a.path.getTotalLength=U,a.path.getPointAtLength=V,a.path.getSubpath=function(a,b,c){if(this.getTotalLength(a)-c<1e-6)return W(a,b).end;var d=W(a,c,1);return b?W(d,b).end:d},I.getTotalLength=function(){return this.node.getTotalLength?this.node.getTotalLength():void 0},I.getPointAtLength=function(a){return V(this.attr("d"),a)},I.getSubpath=function(b,c){return a.path.getSubpath(this.attr("d"),b,c)},a._.box=d,a.path.findDotsAtSegment=i,a.path.bezierBBox=j,a.path.isPointInsideBBox=k,a.path.isBBoxIntersect=l,a.path.intersection=r,a.path.intersectionNumber=s,a.path.isPointInside=u,a.path.getBBox=v,a.path.get=Y,a.path.toRelative=y,a.path.toAbsolute=z,a.path.toCubic=F,a.path.map=G,a.path.toString=e,a.path.clone=f}),Savage.plugin(function(a){var b=Math.max,c=Math.min,d=function(a){if(this.items=[],this.length=0,this.type="set",a)for(var b=0,c=a.length;c>b;b++)a[b]&&(this[this.items.length]=this.items[this.items.length]=a[b],this.length++)},e=d.prototype;e.push=function(){for(var a,b,c=0,d=arguments.length;d>c;c++)a=arguments[c],a&&(b=this.items.length,this[b]=this.items[b]=a,this.length++);return this},e.pop=function(){return this.length&&delete this[this.length--],this.items.pop()},e.forEach=function(a,b){for(var c=0,d=this.items.length;d>c;c++)if(a.call(b,this.items[c],c)===!1)return this;return this},e.attr=function(a){for(var b=0,c=this.items.length;c>b;b++)this.items[b].attr(a);return this},e.clear=function(){for(;this.length;)this.pop()},e.splice=function(a,e){a=0>a?b(this.length+a,0):a,e=b(0,c(this.length-a,e));var f,g=[],h=[],i=[];for(f=2;ff;f++)h.push(this[a+f]);for(;ff?i[f]:g[f-j];for(f=this.items.length=this.length-=e-j;this[f];)delete this[f++];return new d(h)},e.exclude=function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]==a)return this.splice(b,1),!0},e.insertAfter=function(a){for(var b=this.items.length;b--;)this.items[b].insertAfter(a);return this},e.getBBox=function(){for(var a=[],d=[],e=[],f=[],g=this.items.length;g--;)if(!this.items[g].removed){var h=this.items[g].getBBox();a.push(h.x),d.push(h.y),e.push(h.x+h.width),f.push(h.y+h.height)}return a=c.apply(0,a),d=c.apply(0,d),e=b.apply(0,e),f=b.apply(0,f),{x:a,y:d,x2:e,y2:f,width:e-a,height:f-d,cx:a+(e-a)/2,cy:d+(f-d)/2}},e.clone=function(a){a=new d;for(var b=0,c=this.items.length;c>b;b++)a.push(this.items[b].clone());return a},e.toString=function(){return"Savage‘s set"},e.type="set",a.set=function(){var a=new d;return arguments.length&&a.push.apply(a,Array.prototype.slice.call(arguments,0)),a}}),Savage.plugin(function(a,b){function c(a){var b=a[0];switch(b.toLowerCase()){case"t":return[b,0,0];case"m":return[b,1,0,0,1,0,0];case"r":return 4==a.length?[b,0,a[2],a[3]]:[b,0];case"s":return 5==a.length?[b,1,1,a[3],a[4]]:3==a.length?[b,1,1]:[b,1]}}function d(b,d){d=l(d).replace(/\.{3}|\u2026/g,b),b=a.parseTransformString(b)||[],d=a.parseTransformString(d)||[];for(var e,f,g,j,k=Math.max(b.length,d.length),m=[],n=[],o=0;k>o;o++){if(g=b[o]||c(d[o]),j=d[o]||c(g),g[0]!=j[0]||"r"==g[0].toLowerCase()&&(g[2]!=j[2]||g[3]!=j[3])||"s"==g[0].toLowerCase()&&(g[3]!=j[3]||g[4]!=j[4]))return;for(m[o]=[],n[o]=[],e=0,f=Math.max(g.length,j.length);f>e;e++)e in g&&(m[o][e]=g[e]),e in j&&(n[o][e]=j[e])}return{from:i(m),to:i(n),f:h(m)}}function e(a){return a}function f(a){return function(b){return+b.toFixed(3)+a}}function g(b){return a.rgb(b[0],b[1],b[2])}function h(a){var b,c,d,e,f,g,h=0,i=[];for(b=0,c=a.length;c>b;b++){for(f="[",g=['"'+a[b][0]+'"'],d=1,e=a[b].length;e>d;d++)g[d]="val["+h++ +"]";f+=g+"]",i[b]=f}return Function("val","return Savage.path.toString.call(["+i+"])")}function i(a){for(var b=[],c=0,d=a.length;d>c;c++)for(var e=1,f=a[c].length;f>e;e++)b.push(a[c][e]);return b}var j={},k=/[a-z]+$/i,l=String;j.stroke=j.fill="colour",b.prototype.equal=function(b,c){var m,n,o=l(this.attr(b)||"");if(o==+o&&c==+c)return{from:+o,to:+c,f:e};if("colour"==j[b])return m=a.color(o),n=a.color(c),{from:[m.r,m.g,m.b,m.opacity],to:[n.r,n.g,n.b,n.opacity],f:g};if("transform"==b||"gradientTransform"==b||"patternTransform"==b)return d(o,c);if("d"==b||"path"==b)return m=a.path.toCubic(o,c),{from:i(m[0]),to:i(m[1]),f:h(m[0])};var p=o.match(k),q=c.match(k);return p&&p==q?{from:parseFloat(o),to:parseFloat(c),f:f(p)}:{from:this.asPX(b),to:this.asPX(b,c),f:e}}}),Savage.plugin(function(a,b,c,d){for(var e=b.prototype,f="hasOwnProperty",g=("createTouch"in d.doc),h=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","touchstart","touchmove","touchend","touchcancel"],i={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},j=function(a){var b="y"==a?"scrollTop":"scrollLeft";return d.doc.documentElement[b]||d.doc.body[b]},k=function(){this.returnValue=!1},l=function(){return this.originalEvent.preventDefault()},m=function(){this.cancelBubble=!0},n=function(){return this.originalEvent.stopPropagation()},o=function(){return d.doc.addEventListener?function(a,b,c,d){var e=g&&i[b]?i[b]:b,h=function(e){var h=j("y"),k=j("x"),m=e.clientX+k,o=e.clientY+h;if(g&&i[f](b))for(var p=0,q=e.targetTouches&&e.targetTouches.length;q>p;p++)if(e.targetTouches[p].target==a){var r=e;e=e.targetTouches[p],e.originalEvent=r,e.preventDefault=l,e.stopPropagation=n;break}return c.call(d,e,m,o)};return a.addEventListener(e,h,!1),function(){return a.removeEventListener(e,h,!1),!0}}:d.doc.attachEvent?function(a,b,c,e){var f=function(a){a=a||d.win.event;var b=j("y"),f=j("x"),g=a.clientX+f,h=a.clientY+b;
    -return a.preventDefault=a.preventDefault||k,a.stopPropagation=a.stopPropagation||m,c.call(e,a,g,h)};a.attachEvent("on"+b,f);var g=function(){return a.detachEvent("on"+b,f),!0};return g}:void 0}(),p=[],q=function(b){for(var c,d=b.clientX,e=b.clientY,f=j("y"),h=j("x"),i=p.length;i--;){if(c=p[i],g){for(var k,l=b.touches.length;l--;)if(k=b.touches[l],k.identifier==c.el._drag.id){d=k.clientX,e=k.clientY,(b.originalEvent?b.originalEvent:b).preventDefault();break}}else b.preventDefault();var m=c.el.node;a._.glob,m.nextSibling,m.parentNode,m.style.display,d+=h,e+=f,eve("savage.drag.move."+c.el.id,c.move_scope||c.el,d-c.el._drag.x,e-c.el._drag.y,d,e,b)}},r=function(b){a.unmousemove(q).unmouseup(r);for(var c,d=p.length;d--;)c=p[d],c.el._drag={},eve("savage.drag.end."+c.el.id,c.end_scope||c.start_scope||c.move_scope||c.el,b);p=[]},s=h.length;s--;)!function(b){a[b]=e[b]=function(c,e){return a.is(c,"function")&&(this.events=this.events||[],this.events.push({name:b,f:c,unbind:o(this.shape||this.node||d.doc,b,c,e||this)})),this},a["un"+b]=e["un"+b]=function(a){for(var c=this.events||[],d=c.length;d--;)if(c[d].name==b&&(c[d].f==a||!a))return c[d].unbind(),c.splice(d,1),!c.length&&delete this.events,this;return this}}(h[s]);e.hover=function(a,b,c,d){return this.mouseover(a,c).mouseout(b,d||c)},e.unhover=function(a,b){return this.unmouseover(a).unmouseout(b)};var t=[];e.drag=function(b,c,d,e,f,g){function h(h){(h.originalEvent||h).preventDefault();var i=j("y"),k=j("x");this._drag.x=h.clientX+k,this._drag.y=h.clientY+i,this._drag.id=h.identifier,!p.length&&a.mousemove(q).mouseup(r),p.push({el:this,move_scope:e,start_scope:f,end_scope:g}),c&&eve.on("savage.drag.start."+this.id,c),b&&eve.on("savage.drag.move."+this.id,b),d&&eve.on("savage.drag.end."+this.id,d),eve("savage.drag.start."+this.id,f||e||this,h.clientX+k,h.clientY+i,h)}if(!arguments.length){var i;return this.drag(function(a,b){this.attr({transform:i+(i?"T":"t")+[a,b]})},function(){i=this.transform().local})}return this._drag={},t.push({el:this,start:h}),this.mousedown(h),this},e.undrag=function(){for(var b=t.length;b--;)t[b].el==this&&(this.unmousedown(t[b].start),t.splice(b,1),eve.unbind("savage.drag.*."+this.id));return!t.length&&a.unmousemove(q).unmouseup(r),this}}),Savage.plugin(function(a,b,c){var d=(b.prototype,c.prototype),e=/^\s*url\((.+)\)/,f=String,g=a._.$;a.filter={},d.filter=function(c){var d=a.parse(f(c)),e=a._.id(),h=this.node.offsetWidth,i=this.node.offsetHeight,j=g("filter");return g(j,{id:e,filterUnits:"userSpaceOnUse",x:0,y:0,width:h,height:i}),j.appendChild(d.node),this.defs.appendChild(j),new b(j)},eve.on("savage.util.getattr.filter",function(){eve.stop();var b=g(this.node,"filter");if(b){var c=f(b).match(e);return c&&a.select(c[1])}}),eve.on("savage.util.attr.filter",function(a){if(a instanceof b&&"filter"==a.type){eve.stop();var c=a.node.id;c||(g(a.node,{id:a.id}),c=a.id),g(this.node,{filter:"url(#"+c+")"})}a&&"none"!=a||(eve.stop(),this.node.removeAttribute("filter"))}),a.filter.blur=function(b,c){null==b&&(b=2);var d=null==c?b:[b,c];return a.format('',{def:d})},a.filter.blur.toString=function(){return this()},a.filter.shadow=function(b,c,d,e){return e=e||"#000",null==d&&(d=4),null==b&&(b=0,c=2),null==c&&(c=b),a.format('',{color:e,dx:b,dy:c,blur:d})},a.filter.shadow.toString=function(){return this()},a.filter.grayscale=function(b){return null==b&&(b=1),a.format('',{a:.2126+.7874*(1-b),b:.7152-.7152*(1-b),c:.0722-.0722*(1-b),d:.2126-.2126*(1-b),e:.7152+.2848*(1-b),f:.0722-.0722*(1-b),g:.2126-.2126*(1-b),h:.0722+.9278*(1-b)})},a.filter.grayscale.toString=function(){return this()},a.filter.sepia=function(b){return null==b&&(b=1),a.format('',{a:.393+.607*(1-b),b:.769-.769*(1-b),c:.189-.189*(1-b),d:.349-.349*(1-b),e:.686+.314*(1-b),f:.168-.168*(1-b),g:.272-.272*(1-b),h:.534-.534*(1-b),i:.131+.869*(1-b)})},a.filter.sepia.toString=function(){return this()},a.filter.saturate=function(b){return null==b&&(b=1),a.format('',{amount:1-b})},a.filter.saturate.toString=function(){return this()},a.filter.hueRotate=function(b){return b=b||0,a.format('',{angle:b})},a.filter.hueRotate.toString=function(){return this()},a.filter.invert=function(b){return null==b&&(b=1),a.format('',{amount:b,amount2:1-b})},a.filter.invert.toString=function(){return this()},a.filter.brightness=function(b){return null==b&&(b=1),a.format('',{amount:b})},a.filter.brightness.toString=function(){return this()},a.filter.contrast=function(b){return null==b&&(b=1),a.format('',{amount:b,amount2:.5-b/2})},a.filter.contrast.toString=function(){return this()}});
    \ No newline at end of file
    +// build: 2013-09-19
    +!function(a){var b,c,d="0.4.2",e="hasOwnProperty",f=/[\.\/]/,g="*",h=function(){},i=function(a,b){return a-b},j={n:{}},k=function(a,d){a=String(a);var e,f=c,g=Array.prototype.slice.call(arguments,2),h=k.listeners(a),j=0,l=[],m={},n=[],o=b;b=a,c=0;for(var p=0,q=h.length;q>p;p++)"zIndex"in h[p]&&(l.push(h[p].zIndex),h[p].zIndex<0&&(m[h[p].zIndex]=h[p]));for(l.sort(i);l[j]<0;)if(e=m[l[j++]],n.push(e.apply(d,g)),c)return c=f,n;for(p=0;q>p;p++)if(e=h[p],"zIndex"in e)if(e.zIndex==l[j]){if(n.push(e.apply(d,g)),c)break;do if(j++,e=m[l[j]],e&&n.push(e.apply(d,g)),c)break;while(e)}else m[e.zIndex]=e;else if(n.push(e.apply(d,g)),c)break;return c=f,b=o,n.length?n:null};k._events=j,k.listeners=function(a){var b,c,d,e,h,i,k,l,m=a.split(f),n=j,o=[n],p=[];for(e=0,h=m.length;h>e;e++){for(l=[],i=0,k=o.length;k>i;i++)for(n=o[i].n,c=[n[m[e]],n[g]],d=2;d--;)b=c[d],b&&(l.push(b),p=p.concat(b.f||[]));o=l}return p},k.on=function(a,b){if(a=String(a),"function"!=typeof b)return function(){};for(var c=a.split(f),d=j,e=0,g=c.length;g>e;e++)d=d.n,d=d.hasOwnProperty(c[e])&&d[c[e]]||(d[c[e]]={n:{}});for(d.f=d.f||[],e=0,g=d.f.length;g>e;e++)if(d.f[e]==b)return h;return d.f.push(b),function(a){+a==+a&&(b.zIndex=+a)}},k.f=function(a){var b=[].slice.call(arguments,1);return function(){k.apply(null,[a,null].concat(b).concat([].slice.call(arguments,0)))}},k.stop=function(){c=1},k.nt=function(a){return a?new RegExp("(?:\\.|\\/|^)"+a+"(?:\\.|\\/|$)").test(b):b},k.nts=function(){return b.split(f)},k.off=k.unbind=function(a,b){if(!a)return k._events=j={n:{}},void 0;var c,d,h,i,l,m,n,o=a.split(f),p=[j];for(i=0,l=o.length;l>i;i++)for(m=0;mi;i++)for(c=p[i];c.n;){if(b){if(c.f){for(m=0,n=c.f.length;n>m;m++)if(c.f[m]==b){c.f.splice(m,1);break}!c.f.length&&delete c.f}for(d in c.n)if(c.n[e](d)&&c.n[d].f){var q=c.n[d].f;for(m=0,n=q.length;n>m;m++)if(q[m]==b){q.splice(m,1);break}!q.length&&delete c.n[d].f}}else{delete c.f;for(d in c.n)c.n[e](d)&&c.n[d].f&&delete c.n[d].f}c=c.n}},k.once=function(a,b){var c=function(){return k.unbind(a,c),b.apply(this,arguments)};return k.on(a,c)},k.version=d,k.toString=function(){return"You are running Eve "+d},"undefined"!=typeof module&&module.exports?module.exports=k:"undefined"!=typeof define?define("eve",[],function(){return k}):a.eve=k}(this);var mina=function(a){var b={},c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,16)},d=Array.isArray||function(a){return a instanceof Array||"[object Array]"==Object.prototype.toString.call(a)},e=0,f="M"+(+new Date).toString(36),g=function(){return f+(e++).toString(36)},h=function(){return+new Date},i=function(a){var b=this;if(null==a)return b.s;var c=b.s-a;b.b+=b.dur*c,b.B+=b.dur*c,b.s=a},j=function(a){var b=this;return null==a?b.spd:(b.spd=a,void 0)},k=function(a){var b=this;return null==a?b.dur:(b.s=b.s*a/b.dur,b.dur=a,void 0)},l=function(){var c=this;delete b[c.id],a("mina.stop."+c.id,c)},m=function(){var a=this;a.pdif||(delete b[a.id],a.pdif=a.get()-a.b)},n=function(){var a=this;a.pdif&&(a.b=a.get()-a.pdif,delete a.pdif,b[a.id]=a)},o=function(){var e=0;for(var f in b)if(b.hasOwnProperty(f)){var g,h=b[f],i=h.get();if(e++,h.s=(i-h.b)/(h.dur/h.spd),h.s>=1&&(delete b[f],h.s=1,e--),d(h.start)){g=[];for(var j=0,k=h.start.length;k>j;j++)g[j]=h.start[j]+(h.end[j]-h.start[j])*h.easing(h.s)}else g=h.start+(h.end-h.start)*h.easing(h.s);h.set(g),1==h.s&&a("mina.finish."+h.id,h)}e&&c(o)},p=function(a,d,e,f,h,q,r){var s={id:g(),start:a,end:d,b:e,s:0,dur:f-e,spd:1,get:h,set:q,easing:r||p.linear,status:i,speed:j,duration:k,stop:l,pause:m,resume:n};b[s.id]=s;var t,u=0;for(t in b)if(b.hasOwnProperty(t)&&(u++,2==u))break;return 1==u&&c(o),s};return p.time=h,p.getById=function(a){return b[a]||null},p.linear=function(a){return a},p.easeout=function(a){return Math.pow(a,1.7)},p.easein=function(a){return Math.pow(a,.48)},p.easeinout=function(a){if(1==a)return 1;if(0==a)return 0;var b=.48-a/1.04,c=Math.sqrt(.1734+b*b),d=c-b,e=Math.pow(Math.abs(d),1/3)*(0>d?-1:1),f=-c-b,g=Math.pow(Math.abs(f),1/3)*(0>f?-1:1),h=e+g+.5;return 3*(1-h)*h*h+h*h*h},p.backin=function(a){if(1==a)return 1;var b=1.70158;return a*a*((b+1)*a-b)},p.backout=function(a){if(0==a)return 0;a-=1;var b=1.70158;return a*a*((b+1)*a+b)+1},p.elastic=function(a){return a==!!a?a:Math.pow(2,-10*a)*Math.sin((a-.075)*2*Math.PI/.3)+1},p.bounce=function(a){var b,c=7.5625,d=2.75;return 1/d>a?b=c*a*a:2/d>a?(a-=1.5/d,b=c*a*a+.75):2.5/d>a?(a-=2.25/d,b=c*a*a+.9375):(a-=2.625/d,b=c*a*a+.984375),b},p}("undefined"==typeof eve?function(){}:eve);!function(){function a(a){a=a||Object(a);for(var c,d,e=1,g=a.length+1,h=b(a,0);g>e;e++)c=d,d=h,h=b(a,e),this.raw+=d,f.call(this,d,h,c);return this._beforeEnd=function(){f.call(this,"","",d)},this}function b(a,b){return a&&(a.charAt?a.charAt(b):a[b])}function c(a,b){this.events=this.events||{},this.events[a]=this.events[a]||[],this.events[a].push(b)}function d(a,b,c){"function"==typeof eve&&eve("elemental."+a+(b?"."+b:""),null,b,c||"",this.raw);for(var d=this.events&&this.events[a],e=d&&d.length;e--;)try{this.events[a][e](b,c||"",this.raw)}catch(f){}this.raw=""}function e(){f.call(this,"eof"),this.event("eof")}function f(a,b,c){"\n"==a&&this.event("newline"),l[this.mode].call(this,a,b,c)}function g(b,f){var g=function(a){g.parse(a)};return g.mode="text",g.type=String(b||"html").toLowerCase(),g.textchunk="",g.raw="",g.parse=a,g.on=c,g.event=d,g.end=e,f&&(h=f),g}var h={lt:60,"lt;":60,"AMP;":38,AMP:38,"GT;":62,GT:62,"QUOT;":34,QUOT:34,"apos;":39,"bull;":8226,"bullet;":8226,"copy;":169,copy:169,"deg;":176,deg:176},i=/[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]/,j=function(a){var b;return"#"==a.charAt()&&(b="x"==a.charAt(1).toLowerCase()?parseInt(a.substring(2),16):parseInt(a.substring(1),10)),b=h[a],b?String.fromCharCode(b):"&"+a},k=function(){for(var a in this.attr)this.attr.hasOwnProperty(a)&&this.event("attr",a,{value:this.attr[a],tagname:this.tagname,attr:this.attr})},l={text:function(a){switch(a){case"<":case"eof":this.nodename="",this.attr={},this.mode="tag name start",this.raw=this.raw.slice(0,-1),this.textchunk&&this.event("text",this.textchunk),this.raw+=a,this.textchunk="";break;case"&":this.mode="entity",this.entity="";break;default:this.textchunk+=a}},entity:function(a){i.test(a)?(this.textchunk+=j(this.entity),this.mode="text"):";"==a?(this.textchunk+=j(this.entity+a),this.mode="text"):this.entity+=a},special:function(a,b,c){return"!"==c&&"-"==a&&"-"==b?(this.mode="comment start",void 0):"[CDATA"==this.textchunk&&"["==a?(this.mode="cdata",this.textchunk="",void 0):">"==a||"eof"==a?(this.event("special",this.textchunk),this.mode="text",this.textchunk="",void 0):(this.textchunk+=a,void 0)},cdata:function(a,b,c){return"]"==c&&"]"==a&&">"==b?(this.mode="cdata end",this.textchunk=this.textchunk.slice(0,-1),void 0):("eof"==a&&l["cdata end"].call(this),this.textchunk+=a,void 0)},"cdata end":function(){this.event("cdata",this.textchunk),this.textchunk="",this.mode="text"},"comment start":function(a,b){">"==b||"eof"==a?(this.event("comment",""),this.mode="skip"):this.mode="comment"},skip:function(){this.mode="text"},comment:function(a,b,c){"-"==a&&"-"==c&&">"==b?(this.mode="comment end",this.textchunk=this.textchunk.slice(0,-1)):"eof"==a?this.event("comment",this.textchunk):this.textchunk+=a},"comment end":function(){this.event("comment",this.textchunk),this.textchunk="",this.mode="text"},declaration:function(a,b){return"?"==a&&">"==b?(this.mode="declaration end",void 0):("eof"==a&&this.event("comment",this.textchunk),this.textchunk+=a,void 0)},"declaration end":function(){this.event("comment",this.textchunk),this.textchunk="",this.mode="text"},"tag name start":function(a,b,c){if("eof"==a)return this.event("text","<"),void 0;if(!i.test(a)){if(this.mode="tag name","/"==a)return this.mode="close tag name start",void 0;if("!"==a)return this.mode="special",this.textchunk="",void 0;if("?"==a)return this.mode="declaration",void 0;l[this.mode].call(this,a,b,c)}},"close tag name start":function(a,b,c){i.test(a)||(this.mode="close tag name",this.tagname="",this.nodename="",l[this.mode].call(this,a,b,c))},"close tag name":function(a){if(i.test(a))this.tagname=this.nodename;else switch(a){case">":this.event("/tag",this.tagname||this.nodename),this.mode="text";break;default:!this.tagname&&(this.nodename+=a)}},"tag name":function(a,b){if(i.test(a))this.tagname=this.nodename,this.nodename="",this.mode="attr start";else switch(a){case">":this.event("tag",this.nodename),this.mode="text";break;case"/":this.raw+=b,this.event("tag",this.nodename),this.event("/tag",this.nodename),this.mode="skip";break;default:this.nodename+=a}},"attr start":function(a,b,c){i.test(a)||(this.mode="attr",this.nodename="",l[this.mode].call(this,a,b,c))},attr:function(a){if(i.test(a)||"="==a)this.attr[this.nodename]="",this.mode="attr value start";else switch(a){case">":"/"==this.nodename?(delete this.attr["/"],this.event("tag",this.tagname,this.attr),k.call(this),this.event("/tag",this.tagname,!0)):(this.nodename&&(this.attr[this.nodename]=""),this.event("tag",this.tagname,this.attr),k.call(this)),this.mode="text";break;default:this.nodename+=a}},"attr value start":function(a,b,c){if(!i.test(a)){if(this.mode="attr value",this.quote=!1,"'"==a||'"'==a)return this.quote=a,void 0;l[this.mode].call(this,a,b,c)}},"attr value":function(a,b,c){if(i.test(a)&&!this.quote)this.mode="attr start";else if(">"!=a||this.quote)switch(a){case'"':case"'":this.quote==a&&"\\"!=c&&(this.mode="attr start");break;default:this.attr[this.nodename]+=a}else this.event("tag",this.tagname,this.attr),this.mode="text"}};g.version="0.2.4",("undefined"==typeof exports?this:exports).elemental=g}();var Savage=function(){function a(a,b){if(a){if(a.tagName)return v(a);if(a instanceof q)return a;if(null==b)return a=E.doc.querySelector(a),v(a)}return a=null==a?"100%":a,b=null==b?"100%":b,new u(a,b)}function b(a,c){if(c){if("string"==typeof a&&(a=b(a)),"string"==typeof c)return"xlink:"==c.substring(0,6)?a.getAttributeNS(cb,c.substring(6)):a.getAttribute(c);for(var d in c)if(c[F](d)){var e=G(c[d]);e?"xlink:"==d.substring(0,6)?a.setAttributeNS(cb,d.substring(6),e):a.setAttribute(d,e):a.removeAttribute(d)}}else a=E.doc.createElementNS("http://www.w3.org/2000/svg",a);return a}function c(a,b){return b=G.prototype.toLowerCase.call(b),"finite"==b?!S[F](+a):"array"==b&&(a instanceof Array||Array.isArray&&Array.isArray(a))?!0:"null"==b&&null===a||b==typeof a&&null!==a||"object"==b&&a===Object(a)||Q.call(a).slice(8,-1).toLowerCase()==b}function d(a){if("function"==typeof a||Object(a)!==a)return a;var b=new a.constructor;for(var c in a)a[F](c)&&(b[c]=d(a[c]));return b}function e(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return a.push(a.splice(c,1)[0])}function f(a,b,c){function d(){var f=Array.prototype.slice.call(arguments,0),g=f.join("␀"),h=d.cache=d.cache||{},i=d.count=d.count||[];return h[F](g)?(e(i,g),c?c(h[g]):h[g]):(i.length>=1e3&&delete h[i.shift()],i.push(g),h[g]=a.apply(b,f),c?c(h[g]):h[g])}return d}function g(a,b,c,d,e,f){if(null==e){var h=a-c,i=b-d;return h||i?(180+180*J.atan2(-i,-h)/N+360)%360:0}return g(a,b,e,f)-g(c,d,e,f)}function h(a){return a%360*N/180}function i(a){return 180*a/N%360}function j(){return this.x+P+this.y+P+this.width+" × "+this.height}function k(a,b,c,d,e,f){return null==b&&"[object SVGMatrix]"==Q.call(a)?(this.a=a.a,this.b=a.b,this.c=a.c,this.d=a.d,this.e=a.e,this.f=a.f,void 0):(null!=a?(this.a=+a,this.b=+b,this.c=+c,this.d=+d,this.e=+e,this.f=+f):(this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0),void 0)}function l(a){var b=[];return a=a.replace(/(?:^|\s)(\w+)\(([^)]+)\)/g,function(a,c,d){return d=d.split(/\s*,\s*/),"rotate"==c&&1==d.length&&d.push(0,0),"scale"==c&&(2==d.length&&d.push(0,0),1==d.length&&d.push(d[0],0,0)),"skewX"==c?b.push(["m",1,0,J.tan(h(d[0])),1,0,0]):"skewY"==c?b.push(["m",1,J.tan(h(d[0])),0,1,0,0]):b.push([c.charAt(0)].concat(d)),a}),b}function m(a,b){if(null==b){var c=!0;if(b="linearGradient"==a.type||"radialGradient"==a.type?a.node.getAttribute("gradientTransform"):"pattern"==a.type?a.node.getAttribute("patternTransform"):a.node.getAttribute("transform"),!b)return new k;b=l(b)}else b=mb.test(b)?G(b).replace(/\.{3}|\u2026/g,a._.transform||O):l(b);var d=lb(b),e=0,f=0,g=0,h=1,i=1,j=a._,m=new k;if(j.transform=d||[],d){for(var n=0,o=d.length;o>n;n++){var p,q,r,s,t,u=d[n],v=u.length,w=G(u[0]).toLowerCase(),x=u[0]!=w,y=x?m.invert():0;"t"==w&&3==v?x?(p=y.x(0,0),q=y.y(0,0),r=y.x(u[1],u[2]),s=y.y(u[1],u[2]),m.translate(r-p,s-q)):m.translate(u[1],u[2]):"r"==w?2==v?(t=t||a.getBBox(1),m.rotate(u[1],t.x+t.width/2,t.y+t.height/2),e+=u[1]):4==v&&(x?(r=y.x(u[2],u[3]),s=y.y(u[2],u[3]),m.rotate(u[1],r,s)):m.rotate(u[1],u[2],u[3]),e+=u[1]):"s"==w?2==v||3==v?(t=t||a.getBBox(1),m.scale(u[1],u[v-1],t.x+t.width/2,t.y+t.height/2),h*=u[1],i*=u[v-1]):5==v&&(x?(r=y.x(u[3],u[4]),s=y.y(u[3],u[4]),m.scale(u[1],u[2],r,s)):m.scale(u[1],u[2],u[3],u[4]),h*=u[1],i*=u[2]):"m"==w&&7==v&&m.add(u[1],u[2],u[3],u[4],u[5],u[6])}if(c)return m;j.dirtyT=1,a.matrix=m}a.matrix=m,j.sx=h,j.sy=i,j.deg=e,j.dx=f=m.e,j.dy=g=m.f,1==h&&1==i&&!e&&j.bbox?(j.bbox.x+=+f,j.bbox.y+=+g):j.dirtyT=1}function n(b){if(a._.someDefs)return a._.someDefs;var c=b.paper||b.node.parentNode&&a(b.node.parentNode)||a.select("svg")||a(0,0),d=c.select("defs").node;return d||(d=t("defs",c.node).node),a._.someDefs=d,d}function o(a,c,d){function e(a){return null==a?O:a==+a?a:(b(j,{width:a}),j.getBBox().width)}function f(a){return null==a?O:a==+a?a:(b(j,{height:a}),j.getBBox().height)}function g(b,e){null==c?i[b]=e(a.attr(b)):b==c&&(i=e(null==d?a.attr(b):d))}var h=n(a),i={},j=h.querySelector(".svg---mgr");switch(j||(j=b("rect"),b(j,{width:10,height:10,"class":"svg---mgr"}),h.appendChild(j)),a.type){case"rect":g("rx",e),g("ry",f);case"image":g("width",e),g("height",f);case"text":g("x",e),g("y",f);break;case"circle":g("cx",e),g("cy",f),g("r",e);break;case"ellipse":g("cx",e),g("cy",f),g("rx",e),g("ry",f);break;case"line":g("x1",e),g("x2",e),g("y1",f),g("y2",f);break;case"marker":g("refX",e),g("markerWidth",e),g("refY",f),g("markerHeight",f);break;case"radialGradient":g("fx",e),g("fy",f);break;case"tspan":g("dx",e),g("dy",f);break;default:i=null}return i}function p(a){c(a,"array")||(a=Array.prototype.slice.call(arguments,0));for(var b=0,d=0,e=this.node;this[b];)delete this[b++];for(b=0;bc;c++)if(b=b||a[c])return b}function s(a){this.node=a}function t(a,c){var d=b(a);c.appendChild(d);var e=v(d);return e.type=a,e}function u(a,c){var d,e,f,g=u.prototype;if(a&&"svg"==a.tagName){if(a.savage in db)return db[a.savage];d=new q(a),e=a.getElementsByTagName("desc")[0],f=a.getElementsByTagName("defs")[0],e||(e=b("desc"),e.appendChild(E.doc.createTextNode("Created with Savage")),d.node.appendChild(e)),f||(f=b("defs"),d.node.appendChild(f)),d.defs=f;for(var h in g)g[F](h)&&(d[h]=g[h]);d.paper=d.root=d}else d=t("svg",E.doc.body),b(d.node,{height:c,version:1.1,width:a,xmlns:"http://www.w3.org/2000/svg"});return d}function v(a){return a?a instanceof q||a instanceof s?a:"svg"==a.tagName?new u(a):new q(a):a}function w(){return this.selectAll("stop")}function x(c,d){var e=b("stop"),f={offset:+d+"%"};return c=a.color(c),f["stop-color"]=c.hex,c.opacity<1&&(f["stop-opacity"]=c.opacity),b(e,f),this.node.appendChild(e),this}function y(){if("linearGradient"==this.type){var c=b(this.node,"x1")||0,d=b(this.node,"x2")||1,e=b(this.node,"y1")||0,f=b(this.node,"y2")||0;return a._.box(c,e,J.abs(d-c),J.abs(f-e))}var g=this.node.cx||.5,h=this.node.cy||.5,i=this.node.r||0;return a._.box(g-i,h-i,2*i,2*i)}function z(a,c){function d(a,b){for(var c=(b-i)/(a-j),d=j;a>d;d++)g[d].offset=+(+i+c*(d-j)).toFixed(2);j=a,i=b}var e,f=r(eve("savage.util.grad.parse",null,c));if(!f)return null;f.params.unshift(a),e="l"==f.type.toLowerCase()?A.apply(0,f.params):B.apply(0,f.params),f.type!=f.type.toLowerCase()&&b(e.node,{gradientUnits:"userSpaceOnUse"});var g=f.stops,h=g.length,i=0,j=0;h--;for(var k=0;h>k;k++)"offset"in g[k]&&d(k,g[k].offset);for(g[h].offset=g[h].offset||100,d(h,g[h].offset),k=0;h>=k;k++){var l=g[k];e.addStop(l.color,l.offset)}return e}function A(a,c,d,e,f){var g=t("linearGradient",a);return g.stops=w,g.addStop=x,g.getBBox=y,null!=c&&b(g.node,{x1:c,y1:d,x2:e,y2:f}),g}function B(a,c,d,e,f,g){var h=t("radialGradient",a);return h.stops=w,h.addStop=x,h.getBBox=y,null!=c&&b(h.node,{cx:c,cy:d,r:e}),null!=f&&null!=g&&b(h.node,{fx:f,fy:g}),h}function C(c){return function(d){if(eve.stop(),d instanceof s&&1==d.node.childNodes.length&&("radialGradient"==d.node.firstChild.tagName||"linearGradient"==d.node.firstChild.tagName||"pattern"==d.node.firstChild.tagName)&&(d=d.node.firstChild,n(this).appendChild(d),d=v(d)),d instanceof q)if("radialGradient"==d.type||"linearGradient"==d.type||"pattern"==d.type){d.node.id||b(d.node,{id:d.id});var e="url(#"+d.node.id+")"}else e=d.attr(c);else if(e=a.color(d),e.error){var f=z(n(this),d);f?(f.node.id||b(f.node,{id:f.id}),e="url(#"+f.node.id+")"):e=d}else e=G(e);var g={};g[c]=e,b(this.node,g),this.node.style[c]=O}}function D(a){for(var b=[],c=a.childNodes,d=0,e=c.length;e>d;d++){var f=c[d];3==f.nodeType&&b.push(f.nodeValue),"tspan"==f.tagName&&(1==f.childNodes.length&&3==f.firstChild.nodeType?b.push(f.firstChild.nodeValue):b.push(D(f)))}return b}a.version="0.0.1",a.toString=function(){return"Savage v"+this.version},a._={};var E={win:window,doc:window.document};a._.glob=E;var F="hasOwnProperty",G=String,H=parseFloat,I=parseInt,J=Math,K=J.max,L=J.min,M=J.abs,N=(J.pow,J.PI),O=(J.round,""),P=" ",Q=Object.prototype.toString,R=/^\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,S={NaN:1,Infinity:1,"-Infinity":1},T=/^url\(#?([^)]+)\)$/,U="	\n\f\r   ᠎              \u2028\u2029",V=new RegExp("[,"+U+"]+"),W=(new RegExp("["+U+"]","g"),new RegExp("["+U+"]*,["+U+"]*")),X={hs:1,rg:1},Y=new RegExp("([a-z])["+U+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+U+"]*,?["+U+"]*)+)","ig"),Z=new RegExp("([rstm])["+U+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+U+"]*,?["+U+"]*)+)","ig"),$=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+U+"]*,?["+U+"]*","ig"),_=0,ab="S"+(+new Date).toString(36),bb=function(){return ab+(_++).toString(36)},cb="http://www.w3.org/1999/xlink",db={};a._.$=b,a._.id=bb,a.format=function(){var a=/\{([^\}]+)\}/g,b=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g,c=function(a,c,d){var e=d;return c.replace(b,function(a,b,c,d,f){b=b||d,e&&(b in e&&(e=e[b]),"function"==typeof e&&f&&(e=e()))}),e=(null==e||e==d?a:e)+""};return function(b,d){return G(b).replace(a,function(a,b){return c(a,b,d)})}}();var eb=function(){function a(){this.parentNode.removeChild(this)}return function(b,c){var d=E.doc.createElement("img"),e=E.doc.body;d.style.cssText="position:absolute;left:-9999em;top:-9999em",d.onload=function(){c.call(d),d.onload=d.onerror=null,e.removeChild(d)},d.onerror=a,e.appendChild(d),d.src=b}}();a._.clone=d,a._.cacher=f,a.rad=h,a.deg=i,a.angle=g,a.is=c,a.snapTo=function(a,b,d){if(d=c(d,"finite")?d:10,c(a,"array")){for(var e=a.length;e--;)if(M(a[e]-b)<=d)return a[e]}else{a=+a;var f=b%a;if(d>f)return b-f;if(f>a-d)return b-f+a}return b},function(a){function b(a){return a[0]*a[0]+a[1]*a[1]}function c(a){var c=J.sqrt(b(a));a[0]&&(a[0]/=c),a[1]&&(a[1]/=c)}a.add=function(a,b,c,d,e,f){var g,h,i,j,l=[[],[],[]],m=[[this.a,this.c,this.e],[this.b,this.d,this.f],[0,0,1]],n=[[a,c,e],[b,d,f],[0,0,1]];for(a&&a instanceof k&&(n=[[a.a,a.c,a.e],[a.b,a.d,a.f],[0,0,1]]),g=0;3>g;g++)for(h=0;3>h;h++){for(j=0,i=0;3>i;i++)j+=m[g][i]*n[i][h];l[g][h]=j}return this.a=l[0][0],this.b=l[1][0],this.c=l[0][1],this.d=l[1][1],this.e=l[0][2],this.f=l[1][2],this},a.invert=function(){var a=this,b=a.a*a.d-a.b*a.c;return new k(a.d/b,-a.b/b,-a.c/b,a.a/b,(a.c*a.f-a.d*a.e)/b,(a.b*a.e-a.a*a.f)/b)},a.clone=function(){return new k(this.a,this.b,this.c,this.d,this.e,this.f)},a.translate=function(a,b){return this.add(1,0,0,1,a,b)},a.scale=function(a,b,c,d){return null==b&&(b=a),(c||d)&&this.add(1,0,0,1,c,d),this.add(a,0,0,b,0,0),(c||d)&&this.add(1,0,0,1,-c,-d),this},a.rotate=function(a,b,c){a=h(a),b=b||0,c=c||0;var d=+J.cos(a).toFixed(9),e=+J.sin(a).toFixed(9);return this.add(d,e,-e,d,b,c),this.add(1,0,0,1,-b,-c)},a.x=function(a,b){return a*this.a+b*this.c+this.e},a.y=function(a,b){return a*this.b+b*this.d+this.f},a.get=function(a){return+this[G.fromCharCode(97+a)].toFixed(4)},a.toString=function(){return"matrix("+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)].join()+")"},a.offset=function(){return[this.e.toFixed(4),this.f.toFixed(4)]},a.split=function(){var a={};a.dx=this.e,a.dy=this.f;var d=[[this.a,this.c],[this.b,this.d]];a.scalex=J.sqrt(b(d[0])),c(d[0]),a.shear=d[0][0]*d[1][0]+d[0][1]*d[1][1],d[1]=[d[1][0]-d[0][0]*a.shear,d[1][1]-d[0][1]*a.shear],a.scaley=J.sqrt(b(d[1])),c(d[1]),a.shear/=a.scaley;var e=-d[0][1],f=d[1][1];return 0>f?(a.rotate=i(J.acos(f)),0>e&&(a.rotate=360-a.rotate)):a.rotate=i(J.asin(e)),a.isSimple=!(+a.shear.toFixed(9)||a.scalex.toFixed(9)!=a.scaley.toFixed(9)&&a.rotate),a.isSuperSimple=!+a.shear.toFixed(9)&&a.scalex.toFixed(9)==a.scaley.toFixed(9)&&!a.rotate,a.noRotation=!+a.shear.toFixed(9)&&!a.rotate,a},a.toTransformString=function(a){var b=a||this.split();return b.isSimple?(b.scalex=+b.scalex.toFixed(4),b.scaley=+b.scaley.toFixed(4),b.rotate=+b.rotate.toFixed(4),(b.dx||b.dy?"t"+[+b.dx.toFixed(4),+b.dy.toFixed(4)]:O)+(1!=b.scalex||1!=b.scaley?"s"+[b.scalex,b.scaley,0,0]:O)+(b.rotate?"r"+[+b.rotate.toFixed(4),0,0]:O)):"m"+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)]}}(k.prototype),a.Matrix=k,a.getRGB=f(function(b){if(!b||(b=G(b)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:ib};if("none"==b)return{r:-1,g:-1,b:-1,hex:"none",toString:ib};if(!(X[F](b.toLowerCase().substring(0,2))||"#"==b.charAt())&&(b=fb(b)),!b)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:ib};var d,e,f,g,h,i,j=b.match(R);return j?(j[2]&&(f=I(j[2].substring(5),16),e=I(j[2].substring(3,5),16),d=I(j[2].substring(1,3),16)),j[3]&&(f=I((h=j[3].charAt(3))+h,16),e=I((h=j[3].charAt(2))+h,16),d=I((h=j[3].charAt(1))+h,16)),j[4]&&(i=j[4].split(W),d=H(i[0]),"%"==i[0].slice(-1)&&(d*=2.55),e=H(i[1]),"%"==i[1].slice(-1)&&(e*=2.55),f=H(i[2]),"%"==i[2].slice(-1)&&(f*=2.55),"rgba"==j[1].toLowerCase().slice(0,4)&&(g=H(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100)),j[5]?(i=j[5].split(W),d=H(i[0]),"%"==i[0].slice(-1)&&(d/=100),e=H(i[1]),"%"==i[1].slice(-1)&&(e/=100),f=H(i[2]),"%"==i[2].slice(-1)&&(f/=100),("deg"==i[0].slice(-3)||"°"==i[0].slice(-1))&&(d/=360),"hsba"==j[1].toLowerCase().slice(0,4)&&(g=H(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100),a.hsb2rgb(d,e,f,g)):j[6]?(i=j[6].split(W),d=H(i[0]),"%"==i[0].slice(-1)&&(d/=100),e=H(i[1]),"%"==i[1].slice(-1)&&(e/=100),f=H(i[2]),"%"==i[2].slice(-1)&&(f/=100),("deg"==i[0].slice(-3)||"°"==i[0].slice(-1))&&(d/=360),"hsla"==j[1].toLowerCase().slice(0,4)&&(g=H(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100),a.hsl2rgb(d,e,f,g)):(d=L(J.round(d),255),e=L(J.round(e),255),f=L(J.round(f),255),g=L(K(g,0),1),j={r:d,g:e,b:f,toString:ib},j.hex="#"+(16777216|f|e<<8|d<<16).toString(16).slice(1),j.opacity=c(g,"finite")?g:1,j)):{r:-1,g:-1,b:-1,hex:"none",error:1,toString:ib}},a),a.hsb=f(function(b,c,d){return a.hsb2rgb(b,c,d).hex}),a.hsl=f(function(b,c,d){return a.hsl2rgb(b,c,d).hex}),a.rgb=f(function(a,b,d,e){if(c(e,"finite")){var f=J.round;return"rgba("+[f(a),f(b),f(d),+e.toFixed(2)]+")"}return"#"+(16777216|d|b<<8|a<<16).toString(16).slice(1)});var fb=function(a){var b=E.doc.getElementsByTagName("head")[0],c="rgb(255, 0, 0)";return fb=f(function(a){if("red"==a.toLowerCase())return c;b.style.color=c,b.style.color=a;var d=E.doc.defaultView.getComputedStyle(b,O).getPropertyValue("color");return d==c?null:d}),fb(a)},gb=function(){return"hsb("+[this.h,this.s,this.b]+")"},hb=function(){return"hsl("+[this.h,this.s,this.l]+")"},ib=function(){return 1==this.opacity||null==this.opacity?this.hex:"rgba("+[this.r,this.g,this.b,this.opacity]+")"},jb=function(b,d,e){if(null==d&&c(b,"object")&&"r"in b&&"g"in b&&"b"in b&&(e=b.b,d=b.g,b=b.r),null==d&&c(b,string)){var f=a.getRGB(b);b=f.r,d=f.g,e=f.b}return(b>1||d>1||e>1)&&(b/=255,d/=255,e/=255),[b,d,e]},kb=function(b,d,e,f){b=J.round(255*b),d=J.round(255*d),e=J.round(255*e);var g={r:b,g:d,b:e,opacity:c(f,"finite")?f:1,hex:a.rgb(b,d,e),toString:ib};return c(f,"finite")&&(g.opacity=f),g};a.color=function(b){var d;return c(b,"object")&&"h"in b&&"s"in b&&"b"in b?(d=a.hsb2rgb(b),b.r=d.r,b.g=d.g,b.b=d.b,b.opacity=1,b.hex=d.hex):c(b,"object")&&"h"in b&&"s"in b&&"l"in b?(d=a.hsl2rgb(b),b.r=d.r,b.g=d.g,b.b=d.b,b.opacity=1,b.hex=d.hex):(c(b,"string")&&(b=a.getRGB(b)),c(b,"object")&&"r"in b&&"g"in b&&"b"in b&&!("error"in b)?(d=a.rgb2hsl(b),b.h=d.h,b.s=d.s,b.l=d.l,d=a.rgb2hsb(b),b.v=d.b):(b={hex:"none"},b.r=b.g=b.b=b.h=b.s=b.v=b.l=-1,b.error=1)),b.toString=ib,b},a.hsb2rgb=function(a,b,d,e){c(a,"object")&&"h"in a&&"s"in a&&"b"in a&&(d=a.b,b=a.s,a=a.h,e=a.o),a*=360;var f,g,h,i,j;return a=a%360/60,j=d*b,i=j*(1-M(a%2-1)),f=g=h=d-j,a=~~a,f+=[j,i,0,0,i,j][a],g+=[i,j,j,i,0,0][a],h+=[0,0,i,j,j,i][a],kb(f,g,h,e)},a.hsl2rgb=function(a,b,d,e){c(a,"object")&&"h"in a&&"s"in a&&"l"in a&&(d=a.l,b=a.s,a=a.h),(a>1||b>1||d>1)&&(a/=360,b/=100,d/=100),a*=360;var f,g,h,i,j;return a=a%360/60,j=2*b*(.5>d?d:1-d),i=j*(1-M(a%2-1)),f=g=h=d-j/2,a=~~a,f+=[j,i,0,0,i,j][a],g+=[i,j,j,i,0,0][a],h+=[0,0,i,j,j,i][a],kb(f,g,h,e)},a.rgb2hsb=function(a,b,c){c=jb(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g;return f=K(a,b,c),g=f-L(a,b,c),d=0==g?null:f==a?(b-c)/g:f==b?(c-a)/g+2:(a-b)/g+4,d=60*((d+360)%6)/360,e=0==g?0:g/f,{h:d,s:e,b:f,toString:gb}},a.rgb2hsl=function(a,b,c){c=jb(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g,h,i;return g=K(a,b,c),h=L(a,b,c),i=g-h,d=0==i?null:g==a?(b-c)/i:g==b?(c-a)/i+2:(a-b)/i+4,d=60*((d+360)%6)/360,f=(g+h)/2,e=0==i?0:.5>f?i/(2*f):i/(2-2*f),{h:d,s:e,l:f,toString:hb}},a.parsePathString=function(b){if(!b)return null;var d=a.path(b);if(d.arr)return a.path.clone(d.arr);var e={a:7,c:6,o:2,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,u:3,z:0},f=[];return c(b,"array")&&c(b[0],"array")&&(f=a.path.clone(b)),f.length||G(b).replace(Y,function(a,b,c){var d=[],g=b.toLowerCase();if(c.replace($,function(a,b){b&&d.push(+b)}),"m"==g&&d.length>2&&(f.push([b].concat(d.splice(0,2))),g="l",b="m"==b?"l":"L"),"o"==g&&1==d.length&&f.push([b,d[0]]),"r"==g)f.push([b].concat(d));else for(;d.length>=e[g]&&(f.push([b].concat(d.splice(0,e[g]))),e[g]););}),f.toString=a.path.toString,d.arr=a.path.clone(f),f};var lb=a.parseTransformString=function(b){if(!b)return null;var d=[];return c(b,"array")&&c(b[0],"array")&&(d=a.path.clone(b)),d.length||G(b).replace(Z,function(a,b,c){var e=[];b.toLowerCase(),c.replace($,function(a,b){b&&e.push(+b)}),d.push([b].concat(e))}),d.toString=a.path.toString,d},mb=new RegExp("^[a-z]["+U+"]*-?\\.?\\d");a._unit2px=o,a._.getSomeDefs=n,a.select=function(a){return v(E.doc.querySelector(a))},a.selectAll=function(b){for(var c=E.doc.querySelectorAll(b),d=(a.set||Array)(),e=0;ej;j++){e=f[j],c(e,"fill"),c(e,"stroke"),c(e,"filter"),c(e,"mask"),c(e,"clip-path"),d(e);var l=b(e.node,"id");l&&(b(e.node,{id:e.id}),h.push({old:l,id:e.id}))}for(j=0,k=h.length;k>j;j++){var m=i[h[j].old];if(m)for(var n=0,o=m.length;o>n;n++)m[n](h[j].id)}}function f(a,b,c){return function(d){var e=d.slice(a,b);return 1==e.length&&(e=e[0]),c?c(e):e}}function g(a){return function(){var b=a?"<"+this.type:"",c=this.node.attributes,d=this.node.childNodes;if(a)for(var e=0,f=c.length;f>e;e++)b+=" "+c[e].name+'="'+c[e].value.replace(/"/g,'\\"')+'"';if(d.length){for(a&&(b+=">"),e=0,f=d.length;f>e;e++)3==d[e].nodeType?b+=d[e].nodeValue:1==d[e].nodeType&&(b+=v(d[e]).toString());a&&(b+="")}else a&&(b+="/>");return b}}d.attr=function(a,b){var d=this;if(d.node,!a)return d;if(c(a,"string")){if(!(arguments.length>1))return r(eve("savage.util.getattr."+a,d));var e={};e[a]=b,a=e}for(var f in a)a[F](f)&&eve("savage.util.attr."+f,d,a[f]);return d},d.getBBox=function(b){var c=this;if("use"==c.type&&(c=c.original),c.removed)return{};var d=c._;return b?((d.dirty||!d.bboxwt)&&(c.realPath=a.path.get[c.type](c),d.bboxwt=a.path.getBBox(c.realPath),d.bboxwt.toString=j,d.dirty=0),a._.box(d.bboxwt)):((d.dirty||d.dirtyT||!d.bbox)&&((d.dirty||!c.realPath)&&(d.bboxwt=0,c.realPath=a.path.get[c.type](c)),d.bbox=a.path.getBBox(a.path.map(c.realPath,c.matrix)),d.bbox.toString=j,d.dirty=d.dirtyT=0),a._.box(d.bbox))};var h=function(){return this.local};d.transform=function(a){var c=this._;if(null==a){var d=new k(this.node.getCTM()),e=m(this);return{string:G(c.transform)||"",globalMatrix:d,localMatrix:e,diffMatrix:d.clone().add(e.invert()),global:d.toTransformString(),local:e.toTransformString(),toString:h}}return a instanceof k&&(a=a.toTransformString()),m(this,a),this.node&&("linearGradient"==this.type||"radialGradient"==this.type?b(this.node,{gradientTransform:this.matrix}):"pattern"==this.type?b(this.node,{patternTransform:this.matrix}):b(this.node,{transform:this.matrix})),this},d.parent=function(){return v(this.node.parentNode)},d.append=d.add=function(a){if("set"==a.type){var b=this;return a.forEach(function(a){b.append(a)}),this}return a=v(a),this.node.appendChild(a.node),a.paper=this.paper,this},d.prepend=function(a){return a=v(a),this.node.insertBefore(a.node,this.node.firstChild),a.paper=this.paper,this},d.before=function(a){return a=v(a),this.node.parentNode.insertBefore(a.node,this.node),a.paper=this.paper,this},d.after=function(a){return a=v(a),this.node.parentNode.insertBefore(a.node,this.node.nextSibling),a.paper=this.paper,this},d.insertBefore=function(a){return a=v(a),a.node.parentNode.insertBefore(this.node,a.node),this.paper=a.paper,this},d.insertAfter=function(a){return a=v(a),a.node.parentNode.insertBefore(this.node,a.node.nextSibling),this.paper=a.paper,this},d.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),delete this.paper,this.removed=!0,this},d.select=function(a){return v(this.node.querySelector(a))},d.selectAll=function(b){for(var c=this.node.querySelectorAll(b),d=(a.set||Array)(),e=0;eb;b++)a[b].stop();return this},d.animate=function(a,b,d,e){"function"!=typeof d||d.length||(e=d,d=mina.linear),a instanceof i&&(e=a.callback,d=a.easing,b=d.dur,a=a.attr);var g,h,j,k,l=[],m=[],n={},o=this;for(var p in a)if(a[F](p)){o.equal?(k=o.equal(p,G(a[p])),g=k.from,h=k.to,j=k.f):(g=+o.attr(p),h=+a[p]);var q=c(g,"array")?g.length:1;n[p]=f(l.length,l.length+q,j),l=l.concat(g),m=m.concat(h)}var r=mina.time(),s=mina(l,m,r,r+b,mina.time,function(a){var b={};for(var c in n)n[F](c)&&(b[c]=n[c](a));o.attr(b)},d);return o.anims[s.id]=s,s._attrs=a,s._callback=e,eve.once("mina.finish."+s.id,function(){delete o.anims[s.id],e&&e.call(o)}),eve.once("mina.stop."+s.id,function(){delete o.anims[s.id]}),o};var l={};d.data=function(b,c){var d=l[this.id]=l[this.id]||{};if(1==arguments.length){if(a.is(b,"object")){for(var e in b)b[F](e)&&this.data(e,b[e]);return this}return eve("savage.data.get."+this.id,this,d[b],b),d[b]}return d[b]=c,eve("savage.data.set."+this.id,this,c,b),this},d.removeData=function(a){return null==a?l[this.id]={}:l[this.id]&&delete l[this.id][a],this},d.toString=g(1),d.innerSVG=g()}(q.prototype),a.parse=function(a){var c=E.doc.createDocumentFragment(),d=c;return eve.on("elemental.tag",function(a,c){var e=b(a);c&&b(e,c),d.appendChild(e),d=e}),eve.on("elemental.text",function(a){d.appendChild(E.doc.createTextNode(a))}),eve.on("elemental./tag",function(){d=d.parentNode}),eve.on("elemental.eof",function(){eve.off("elemental.*"),eve("savage.parsed",c)}),elemental().parse(a).end(),new s(c)},s.prototype.select=q.prototype.select,s.prototype.selectAll=q.prototype.selectAll,a.fragment=function(){for(var b=Array.prototype.slice.call(arguments,0),c=E.doc.createDocumentFragment(),d=0,e=b.length;e>d;d++){var f=b[d];f.node&&f.node.nodeType&&c.appendChild(f.node),f.nodeType&&c.appendChild(f),"string"==typeof f&&c.appendChild(a.parse(f).node)}return new s(c)},function(a){a.el=function(a,b){return t(a,this.node).attr(b)},a.rect=function(a,b,d,e,f,g){var h=t("rect",this.node);return null==g&&(g=f),c(a,"object")&&"x"in a?h.attr(a):null!=a&&(h.attr({x:a,y:b,width:d,height:e}),null!=f&&h.attr({rx:f,ry:g})),h},a.circle=function(a,b,d){var e=t("circle",this.node);return c(a,"object")&&"cx"in a?e.attr(a):null!=a&&e.attr({cx:a,cy:b,r:d}),e},a.image=function(a,d,e,f,g){var h=t("image",this.node);if(c(a,"object")&&"src"in a)h.attr(a);else if(null!=a){var i={"xlink:href":a,preserveAspectRatio:"none"};null!=d&&null!=e&&(i.x=d,i.y=e),null!=f&&null!=g?(i.width=f,i.height=g):eb(a,function(){b(h.node,{width:this.offsetWidth,height:this.offsetHeight})}),b(h.node,i)}return h},a.ellipse=function(a,b,d,e){var f=t("ellipse",this.node);return c(a,"object")&&"cx"in a?f.attr(a):null!=a&&f.attr({cx:a,cy:b,rx:d,ry:e}),f},a.path=function(a){var b=t("path",this.node);return c(a,"object")&&!c(a,"array")?b.attr(a):a&&b.attr({d:a}),b},a.group=a.g=function(b){var c=t("g",this.node);c.add=p;for(var d in a)a[F](d)&&(c[d]=a[d]);return 1==arguments.length&&b&&!b.type?c.attr(b):arguments.length&&c.add(Array.prototype.slice.call(arguments,0)),c},a.text=function(a,b,d){var e=t("text",this.node);return c(a,"object")?e.attr(a):null!=a&&e.attr({x:a,y:b,text:d||""}),e},a.line=function(a,b,d,e){var f=t("line",this.node);return c(a,"object")?f.attr(a):null!=a&&f.attr({x1:a,x2:d,y1:b,y2:e}),f},a.polyline=function(a){arguments.length>1&&(a=Array.prototype.slice.call(arguments,0));var b=t("polyline",this.node);return c(a,"object")&&!c(a,"array")?b.attr(a):null!=a&&b.attr({points:a}),b},a.polygon=function(a){arguments.length>1&&(a=Array.prototype.slice.call(arguments,0));var b=t("polygon",this.node);return c(a,"object")&&!c(a,"array")?b.attr(a):null!=a&&b.attr({points:a}),b},function(){a.gradient=function(a){return z(this.defs,a)},a.gradientLinear=function(a,b,c,d){return A(this.defs,a,b,c,d)},a.gradientRadial=function(a,b,c,d,e){return B(this.defs,a,b,c,d,e)},a.toString=function(){var a,c=E.doc.createDocumentFragment(),d=E.doc.createElement("div"),e=this.node.cloneNode(!0);return c.appendChild(d),d.appendChild(e),b(e,{xmlns:"http://www.w3.org/2000/svg"}),a=d.innerHTML,c.removeChild(c.firstChild),a}}()}(u.prototype),a.ajax=function(a,b,d,e){var f=new XMLHttpRequest,g=bb();if(f){if(c(b,"function"))e=d,d=b,b=null;else if(c(b,"object")){var h=[];for(var i in b)b.hasOwnProperty(i)&&h.push(encodeURIComponent(i)+"="+encodeURIComponent(b[i]));b=h.join("&")}return f.open(b?"POST":"GET",a,!0),f.setRequestHeader("X-Requested-With","XMLHttpRequest"),b&&f.setRequestHeader("Content-type","application/x-www-form-urlencoded"),d&&(eve.once("savage.ajax."+g+".0",d),eve.once("savage.ajax."+g+".200",d),eve.once("savage.ajax."+g+".304",d)),f.onreadystatechange=function(){4==f.readyState&&eve("savage.ajax."+g+"."+f.status,e,f)},4==f.readyState?f:(f.send(b),f)}},a.load=function(b,c,d){a.ajax(b,function(b){var e=a.parse(b.responseText);d?c.call(d,e):c(e)})},eve.on("savage.util.attr.mask",function(a){if(a instanceof q||a instanceof s){if(eve.stop(),a instanceof s&&1==a.node.childNodes.length&&(a=a.node.firstChild,n(this).appendChild(a),a=v(a)),"mask"==a.type)var c=a;else c=t("mask",n(this)),c.node.appendChild(a.node),!c.node.id&&b(c.node,{id:c.id});b(this.node,{mask:"url(#"+c.id+")"})}}),function(a){eve.on("savage.util.attr.clip",a),eve.on("savage.util.attr.clip-path",a),eve.on("savage.util.attr.clipPath",a)}(function(a){if(a instanceof q||a instanceof s){if(eve.stop(),"clipPath"==a.type)var c=a;else c=t("clipPath",n(this)),c.node.appendChild(a.node),!c.node.id&&b(c.node,{id:c.id});b(this.node,{"clip-path":"url(#"+c.id+")"})}}),eve.on("savage.util.attr.fill",C("fill")),eve.on("savage.util.attr.stroke",C("stroke"));var nb=/^([lr])(?:\(([^)]*)\))?(.*)$/i;eve.on("savage.util.grad.parse",function(a){a=G(a);var b=a.match(nb);if(!b)return null;var c=b[1],d=b[2],e=b[3];return d=d.split(/\s*,\s*/).map(function(a){return+a==a?+a:a}),1==d.length&&0==d[0]&&(d=[]),e=e.split("-"),e=e.map(function(a){a=a.split(":");var b={color:a[0]};return a[1]&&(b.offset=a[1]),b}),{type:c,params:d,stops:e}}),eve.on("savage.util.attr.d",function(d){eve.stop(),c(d,"array")&&c(d[0],"array")&&(d=a.path.toString.call(d)),d=G(d),d.match(/[ruo]/i)&&(d=a.path.toAbsolute(d)),b(this.node,{d:d})})(-1),eve.on("savage.util.attr.#text",function(a){eve.stop(),a=G(a);for(var b=E.doc.createTextNode(a);this.node.firstChild;)this.node.removeChild(this.node.firstChild);this.node.appendChild(b)})(-1),eve.on("savage.util.attr.path",function(a){eve.stop(),this.attr({d:a})})(-1),eve.on("savage.util.attr.viewBox",function(a){var d;d=c(a,"object")&&"x"in a?[a.x,a.y,a.width,a.height].join(" "):c(a,"array")?a.join(" "):a,b(this.node,{viewBox:d}),eve.stop()})(-1),eve.on("savage.util.attr.transform",function(a){this.transform(a),eve.stop()})(-1),eve.on("savage.util.attr.r",function(a){"rect"==this.type&&(eve.stop(),b(this.node,{rx:a,ry:a}))})(-1),eve.on("savage.util.attr.text",function(a){if("text"==this.type){for(var d=this.node,e=function(a){var d=b("tspan");if(c(a,"array"))for(var f=0;fr;r++){if(l=a[r],"M"==l[0])j=+l[1],k=+l[2];else{if(m=g(j,k,l[1],l[2],l[3],l[4],l[5],l[6]),q+m>f){if(d&&!p.start){if(n=g(j,k,l[1],l[2],l[3],l[4],l[5],l[6],f-q),o+=["C"+e(n.start.x),e(n.start.y),e(n.m.x),e(n.m.y),e(n.x),e(n.y)],h)return o;p.start=o,o=["M"+e(n.x),e(n.y)+"C"+e(n.n.x),e(n.n.y),e(n.end.x),e(n.end.y),e(l[5]),e(l[6])].join(),q+=m,j=+l[5],k=+l[6];continue}if(!c&&!d)return n=g(j,k,l[1],l[2],l[3],l[4],l[5],l[6],f-q)}q+=m,j=+l[5],k=+l[6]}o+=l.shift()+l}return p.end=o,n=c?q:d?p:i(j,k,l[0],l[1],l[2],l[3],l[4],l[5],1)},null,a._.clone)}function i(a,b,c,d,e,f,g,h,i){var j=1-i,k=S(j,3),l=S(j,2),m=i*i,n=m*i,o=k*a+3*l*i*c+3*j*i*i*e+n*g,p=k*b+3*l*i*d+3*j*i*i*f+n*h,q=a+2*i*(c-a)+m*(e-2*c+a),r=b+2*i*(d-b)+m*(f-2*d+b),s=c+2*i*(e-c)+m*(g-2*e+c),t=d+2*i*(f-d)+m*(h-2*f+d),u=j*a+i*c,v=j*b+i*d,w=j*e+i*g,x=j*f+i*h,y=90-180*O.atan2(q-s,r-t)/P;return{x:o,y:p,m:{x:q,y:r},n:{x:s,y:t},start:{x:u,y:v},end:{x:w,y:x},alpha:y}}function j(b,c,e,f,g,h,i,j){a.is(b,"array")||(b=[b,c,e,f,g,h,i,j]);var k=E.apply(null,b);return d(k.min.x,k.min.y,k.max.x-k.min.x,k.max.y-k.min.y)}function k(a,b,c){return b>=a.x&&b<=a.x+a.width&&c>=a.y&&c<=a.y+a.height}function l(a,b){return a=d(a),b=d(b),k(b,a.x,a.y)||k(b,a.x2,a.y)||k(b,a.x,a.y2)||k(b,a.x2,a.y2)||k(a,b.x,b.y)||k(a,b.x2,b.y)||k(a,b.x,b.y2)||k(a,b.x2,b.y2)||(a.xb.x||b.xa.x)&&(a.yb.y||b.ya.y)}function m(a,b,c,d,e){var f=-3*b+9*c-9*d+3*e,g=a*f+6*b-12*c+6*d;return a*g-3*b+3*c}function n(a,b,c,d,e,f,g,h,i){null==i&&(i=1),i=i>1?1:0>i?0:i;for(var j=i/2,k=12,l=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],n=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],o=0,p=0;k>p;p++){var q=j*l[p]+j,r=m(q,a,c,e,g),s=m(q,b,d,f,h),t=r*r+s*s;o+=n[p]*O.sqrt(t)}return j*o}function o(a,b,c,d,e,f,g,h,i){if(!(0>i||n(a,b,c,d,e,f,g,h)o;)l/=2,m+=(i>j?1:-1)*l,j=n(a,b,c,d,e,f,g,h,m);return m}}function p(a,b,c,d,e,f,g,h){if(!(R(a,c)R(e,g)||R(b,d)R(f,h))){var i=(a*d-b*c)*(e-g)-(a-c)*(e*h-f*g),j=(a*d-b*c)*(f-h)-(b-d)*(e*h-f*g),k=(a-c)*(f-h)-(b-d)*(e-g);if(k){var l=i/k,m=j/k,n=+l.toFixed(2),o=+m.toFixed(2);if(!(n<+Q(a,c).toFixed(2)||n>+R(a,c).toFixed(2)||n<+Q(e,g).toFixed(2)||n>+R(e,g).toFixed(2)||o<+Q(b,d).toFixed(2)||o>+R(b,d).toFixed(2)||o<+Q(f,h).toFixed(2)||o>+R(f,h).toFixed(2)))return{x:l,y:m}}}}function q(a,b,c){var d=j(a),e=j(b);if(!l(d,e))return c?0:[];for(var f=n.apply(0,a),g=n.apply(0,b),h=~~(f/5),k=~~(g/5),m=[],o=[],q={},r=c?0:[],s=0;h+1>s;s++){var t=i.apply(0,a.concat(s/h));m.push({x:t.x,y:t.y,t:s/h})}for(s=0;k+1>s;s++)t=i.apply(0,b.concat(s/k)),o.push({x:t.x,y:t.y,t:s/k});for(s=0;h>s;s++)for(var u=0;k>u;u++){var v=m[s],w=m[s+1],x=o[u],y=o[u+1],z=T(w.x-v.x)<.001?"y":"x",A=T(y.x-x.x)<.001?"y":"x",B=p(v.x,v.y,w.x,w.y,x.x,x.y,y.x,y.y);if(B){if(q[B.x.toFixed(4)]==B.y.toFixed(4))continue;q[B.x.toFixed(4)]=B.y.toFixed(4);var C=v.t+T((B[z]-v[z])/(w[z]-v[z]))*(w.t-v.t),D=x.t+T((B[A]-x[A])/(y[A]-x[A]))*(y.t-x.t);C>=0&&1>=C&&D>=0&&1>=D&&(c?r++:r.push({x:B.x,y:B.y,t1:C,t2:D}))}}return r}function r(a,b){return t(a,b)}function s(a,b){return t(a,b,1)}function t(a,b,c){a=F(a),b=F(b);for(var d,e,f,g,h,i,j,k,l,m,n=c?0:[],o=0,p=a.length;p>o;o++){var r=a[o];if("M"==r[0])d=h=r[1],e=i=r[2];else{"C"==r[0]?(l=[d,e].concat(r.slice(1)),d=l[6],e=l[7]):(l=[d,e,d,e,h,i,h,i],d=h,e=i);for(var s=0,t=b.length;t>s;s++){var u=b[s];if("M"==u[0])f=j=u[1],g=k=u[2];else{"C"==u[0]?(m=[f,g].concat(u.slice(1)),f=m[6],g=m[7]):(m=[f,g,f,g,j,k,j,k],f=j,g=k);var v=q(l,m,c);if(c)n+=v;else{for(var w=0,x=v.length;x>w;w++)v[w].segment1=o,v[w].segment2=s,v[w].bez1=l,v[w].bez2=m;n=n.concat(v)}}}}}return n}function u(a,b,c){var d=v(a);return k(d,b,c)&&1==t(a,[["M",b,c],["H",d.x2+10]],1)%2}function v(a){var b=c(a);if(b.bbox)return K(b.bbox);if(!a)return d();a=F(a);for(var e,f=0,g=0,h=[],i=[],j=0,k=a.length;k>j;j++)if(e=a[j],"M"==e[0])f=e[1],g=e[2],h.push(f),i.push(g);else{var l=E(f,g,e[1],e[2],e[3],e[4],e[5],e[6]);h=h.concat(l.min.x,l.max.x),i=i.concat(l.min.y,l.max.y),f=e[5],g=e[6]}var m=Q.apply(0,h),n=Q.apply(0,i),o=R.apply(0,h),p=R.apply(0,i),q=d(m,n,o-m,p-n);return b.bbox=K(q),q}function w(a,b,c,d,f){if(f)return[["M",a+f,b],["l",c-2*f,0],["a",f,f,0,0,1,f,f],["l",0,d-2*f],["a",f,f,0,0,1,-f,f],["l",2*f-c,0],["a",f,f,0,0,1,-f,-f],["l",0,2*f-d],["a",f,f,0,0,1,f,-f],["z"]];var g=[["M",a,b],["l",c,0],["l",0,d],["l",-c,0],["z"]];return g.toString=e,g}function x(a,b,c,d,f){if(null==f&&null==d&&(d=c),null!=f)var g=Math.PI/180,h=a+c*Math.cos(-d*g),i=a+c*Math.cos(-f*g),j=b+c*Math.sin(-d*g),k=b+c*Math.sin(-f*g),l=[["M",h,j],["A",c,c,0,+(f-d>180),0,i,k]];else l=[["M",a,b],["m",0,-d],["a",c,d,0,1,1,0,2*d],["a",c,d,0,1,1,0,-2*d],["z"]];return l.toString=e,l}function y(b){var d=c(b),g=String.prototype.toLowerCase;if(d.rel)return f(d.rel);a.is(b,"array")&&a.is(b&&b[0],"array")||(b=a.parsePathString(b));var h=[],i=0,j=0,k=0,l=0,m=0;"M"==b[0][0]&&(i=b[0][1],j=b[0][2],k=i,l=j,m++,h.push(["M",i,j]));for(var n=m,o=b.length;o>n;n++){var p=h[n]=[],q=b[n];if(q[0]!=g.call(q[0]))switch(p[0]=g.call(q[0]),p[0]){case"a":p[1]=q[1],p[2]=q[2],p[3]=q[3],p[4]=q[4],p[5]=q[5],p[6]=+(q[6]-i).toFixed(3),p[7]=+(q[7]-j).toFixed(3);break;case"v":p[1]=+(q[1]-j).toFixed(3);break;case"m":k=q[1],l=q[2];default:for(var r=1,s=q.length;s>r;r++)p[r]=+(q[r]-(r%2?i:j)).toFixed(3)}else{p=h[n]=[],"m"==q[0]&&(k=q[1]+i,l=q[2]+j);for(var t=0,u=q.length;u>t;t++)h[n][t]=q[t]}var v=h[n].length;switch(h[n][0]){case"z":i=k,j=l;break;case"h":i+=+h[n][v-1];break;case"v":j+=+h[n][v-1];break;default:i+=+h[n][v-2],j+=+h[n][v-1]}}return h.toString=e,d.rel=f(h),h}function z(b){var d=c(b);if(d.abs)return f(d.abs);if(J(b,"array")&&J(b&&b[0],"array")||(b=a.parsePathString(b)),!b||!b.length)return[["M",0,0]];var g,h=[],i=0,j=0,k=0,l=0,m=0;"M"==b[0][0]&&(i=+b[0][1],j=+b[0][2],k=i,l=j,m++,h[0]=["M",i,j]);for(var n,o,p=3==b.length&&"M"==b[0][0]&&"R"==b[1][0].toUpperCase()&&"Z"==b[2][0].toUpperCase(),q=m,r=b.length;r>q;q++){if(h.push(n=[]),o=b[q],g=o[0],g!=g.toUpperCase())switch(n[0]=g.toUpperCase(),n[0]){case"A":n[1]=o[1],n[2]=o[2],n[3]=o[3],n[4]=o[4],n[5]=o[5],n[6]=+(o[6]+i),n[7]=+(o[7]+j);break;case"V":n[1]=+o[1]+j;break;case"H":n[1]=+o[1]+i;break;case"R":for(var s=[i,j].concat(o.slice(1)),t=2,u=s.length;u>t;t++)s[t]=+s[t]+i,s[++t]=+s[t]+j;h.pop(),h=h.concat(H(s,p));break;case"O":h.pop(),s=x(i,j,o[1],o[2]),s.push(s[0]),h=h.concat(s);break;case"U":h.pop(),h=h.concat(x(i,j,o[1],o[2],o[3])),n=["U"].concat(h[h.length-1].slice(-2));break;case"M":k=+o[1]+i,l=+o[2]+j;default:for(t=1,u=o.length;u>t;t++)n[t]=+o[t]+(t%2?i:j)}else if("R"==g)s=[i,j].concat(o.slice(1)),h.pop(),h=h.concat(H(s,p)),n=["R"].concat(o.slice(-2));else if("O"==g)h.pop(),s=x(i,j,o[1],o[2]),s.push(s[0]),h=h.concat(s);else if("U"==g)h.pop(),h=h.concat(x(i,j,o[1],o[2],o[3])),n=["U"].concat(h[h.length-1].slice(-2));else for(var v=0,w=o.length;w>v;v++)n[v]=o[v];if(g=g.toUpperCase(),"O"!=g)switch(n[0]){case"Z":i=k,j=l;break;case"H":i=n[1];break;case"V":j=n[1];break;case"M":k=n[n.length-2],l=n[n.length-1];default:i=n[n.length-2],j=n[n.length-1]}}return h.toString=e,d.abs=f(h),h}function A(a,b,c,d){return[a,b,c,d,c,d]}function B(a,b,c,d,e,f){var g=1/3,h=2/3;return[g*a+h*c,g*b+h*d,g*e+h*c,g*f+h*d,e,f]}function C(b,c,d,e,f,g,h,i,j,k){var l,m=120*P/180,n=P/180*(+f||0),o=[],p=a._.cacher(function(a,b,c){var d=a*O.cos(c)-b*O.sin(c),e=a*O.sin(c)+b*O.cos(c);return{x:d,y:e}});if(k)y=k[0],z=k[1],w=k[2],x=k[3];else{l=p(b,c,-n),b=l.x,c=l.y,l=p(i,j,-n),i=l.x,j=l.y;var q=(O.cos(P/180*f),O.sin(P/180*f),(b-i)/2),r=(c-j)/2,s=q*q/(d*d)+r*r/(e*e);s>1&&(s=O.sqrt(s),d=s*d,e=s*e);var t=d*d,u=e*e,v=(g==h?-1:1)*O.sqrt(T((t*u-t*r*r-u*q*q)/(t*r*r+u*q*q))),w=v*d*r/e+(b+i)/2,x=v*-e*q/d+(c+j)/2,y=O.asin(((c-x)/e).toFixed(9)),z=O.asin(((j-x)/e).toFixed(9));y=w>b?P-y:y,z=w>i?P-z:z,0>y&&(y=2*P+y),0>z&&(z=2*P+z),h&&y>z&&(y-=2*P),!h&&z>y&&(z-=2*P)}var A=z-y;if(T(A)>m){var B=z,D=i,E=j;z=y+m*(h&&z>y?1:-1),i=w+d*O.cos(z),j=x+e*O.sin(z),o=C(i,j,d,e,f,0,h,D,E,[z,B,w,x])}A=z-y;var F=O.cos(y),G=O.sin(y),H=O.cos(z),I=O.sin(z),J=O.tan(A/4),K=4/3*d*J,L=4/3*e*J,M=[b,c],N=[b+K*G,c-L*F],Q=[i+K*I,j-L*H],R=[i,j];if(N[0]=2*M[0]-N[0],N[1]=2*M[1]-N[1],k)return[N,Q,R].concat(o);o=[N,Q,R].concat(o).join().split(",");for(var S=[],U=0,V=o.length;V>U;U++)S[U]=U%2?p(o[U-1],o[U],n).y:p(o[U],o[U+1],n).x;return S}function D(a,b,c,d,e,f,g,h,i){var j=1-i;return{x:S(j,3)*a+3*S(j,2)*i*c+3*j*i*i*e+S(i,3)*g,y:S(j,3)*b+3*S(j,2)*i*d+3*j*i*i*f+S(i,3)*h}}function E(a,b,c,d,e,f,g,h){var i,j=e-2*c+a-(g-2*e+c),k=2*(c-a)-2*(e-c),l=a-c,m=(-k+O.sqrt(k*k-4*j*l))/2/j,n=(-k-O.sqrt(k*k-4*j*l))/2/j,o=[b,h],p=[a,g];return T(m)>"1e12"&&(m=.5),T(n)>"1e12"&&(n=.5),m>0&&1>m&&(i=D(a,b,c,d,e,f,g,h,m),p.push(i.x),o.push(i.y)),n>0&&1>n&&(i=D(a,b,c,d,e,f,g,h,n),p.push(i.x),o.push(i.y)),j=f-2*d+b-(h-2*f+d),k=2*(d-b)-2*(f-d),l=b-d,m=(-k+O.sqrt(k*k-4*j*l))/2/j,n=(-k-O.sqrt(k*k-4*j*l))/2/j,T(m)>"1e12"&&(m=.5),T(n)>"1e12"&&(n=.5),m>0&&1>m&&(i=D(a,b,c,d,e,f,g,h,m),p.push(i.x),o.push(i.y)),n>0&&1>n&&(i=D(a,b,c,d,e,f,g,h,n),p.push(i.x),o.push(i.y)),{min:{x:Q.apply(0,p),y:Q.apply(0,o)},max:{x:R.apply(0,p),y:R.apply(0,o)}}}function F(a,b){var d=!b&&c(a);if(!b&&d.curve)return f(d.curve);for(var e=z(a),g=b&&z(b),h={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},j=(function(a,b){var c,d;if(!a)return["C",b.x,b.y,b.x,b.y,b.x,b.y];switch(!(a[0]in{T:1,Q:1})&&(b.qx=b.qy=null),a[0]){case"M":b.X=a[1],b.Y=a[2];break;case"A":a=["C"].concat(C.apply(0,[b.x,b.y].concat(a.slice(1))));break;case"S":c=b.x+(b.x-(b.bx||b.x)),d=b.y+(b.y-(b.by||b.y)),a=["C",c,d].concat(a.slice(1));break;case"T":b.qx=b.x+(b.x-(b.qx||b.x)),b.qy=b.y+(b.y-(b.qy||b.y)),a=["C"].concat(B(b.x,b.y,b.qx,b.qy,a[1],a[2]));break;case"Q":b.qx=a[1],b.qy=a[2],a=["C"].concat(B(b.x,b.y,a[1],a[2],a[3],a[4]));break;case"L":a=["C"].concat(A(b.x,b.y,a[1],a[2]));break;case"H":a=["C"].concat(A(b.x,b.y,a[1],b.y));break;case"V":a=["C"].concat(A(b.x,b.y,b.x,a[1]));break;case"Z":a=["C"].concat(A(b.x,b.y,b.X,b.Y))}return a}),k=function(a,b){if(a[b].length>7){a[b].shift();for(var c=a[b];c.length;)a.splice(b++,0,["C"].concat(c.splice(0,6)));a.splice(b,1),n=R(e.length,g&&g.length||0)}},l=function(a,b,c,d,f){a&&b&&"M"==a[f][0]&&"M"!=b[f][0]&&(b.splice(f,0,["M",d.x,d.y]),c.bx=0,c.by=0,c.x=a[f][1],c.y=a[f][2],n=R(e.length,g&&g.length||0))},m=0,n=R(e.length,g&&g.length||0);n>m;m++){e[m]=j(e[m],h),k(e,m),g&&(g[m]=j(g[m],i)),g&&k(g,m),l(e,g,h,i,m),l(g,e,i,h,m);var o=e[m],p=g&&g[m],q=o.length,r=g&&p.length;h.x=o[q-2],h.y=o[q-1],h.bx=N(o[q-4])||h.x,h.by=N(o[q-3])||h.y,i.bx=g&&(N(p[r-4])||i.x),i.by=g&&(N(p[r-3])||i.y),i.x=g&&p[r-2],i.y=g&&p[r-1]}return g||(d.curve=f(e)),g?[e,g]:e}function G(a,b){if(!b)return a;var c,d,e,f,g,h,i;for(a=F(a),e=0,g=a.length;g>e;e++)for(i=a[e],f=1,h=i.length;h>f;f+=2)c=b.x(i[f],i[f+1]),d=b.y(i[f],i[f+1]),i[f]=c,i[f+1]=d;return a}function H(a,b){for(var c=[],d=0,e=a.length;e-2*!b>d;d+=2){var f=[{x:+a[d-2],y:+a[d-1]},{x:+a[d],y:+a[d+1]},{x:+a[d+2],y:+a[d+3]},{x:+a[d+4],y:+a[d+5]}];b?d?e-4==d?f[3]={x:+a[0],y:+a[1]}:e-2==d&&(f[2]={x:+a[0],y:+a[1]},f[3]={x:+a[2],y:+a[3]}):f[0]={x:+a[e-2],y:+a[e-1]}:e-4==d?f[3]=f[2]:d||(f[0]={x:+a[d],y:+a[d+1]}),c.push(["C",(-f[0].x+6*f[1].x+f[2].x)/6,(-f[0].y+6*f[1].y+f[2].y)/6,(f[1].x+6*f[2].x-f[3].x)/6,(f[1].y+6*f[2].y-f[3].y)/6,f[2].x,f[2].y])}return c}var I=b.prototype,J=a.is,K=a._.clone,L="hasOwnProperty",M=/,?([a-z]),?/gi,N=parseFloat,O=Math,P=O.PI,Q=O.min,R=O.max,S=O.pow,T=O.abs,U=h(1),V=h(),W=h(0,1),X=a._unit2px,Y={path:function(a){return a.attr("path")},circle:function(a){var b=X(a);return x(b.cx,b.cy,b.r)},ellipse:function(a){var b=X(a);return x(b.cx,b.cy,b.rx,b.ry)},rect:function(a){var b=X(a);return w(b.x,b.y,b.width,b.height,b.rx,b.ry)},image:function(a){var b=X(a);return w(b.x,b.y,b.width,b.height)},text:function(a){var b=a.node.getBBox();return w(b.x,b.y,b.width,b.height)},g:function(a){var b=a.node.getBBox();return w(b.x,b.y,b.width,b.height)},symbol:function(a){var b=a.getBBox();return w(b.x,b.y,b.width,b.height)}};a.path=c,a.path.getTotalLength=U,a.path.getPointAtLength=V,a.path.getSubpath=function(a,b,c){if(this.getTotalLength(a)-c<1e-6)return W(a,b).end;var d=W(a,c,1);return b?W(d,b).end:d},I.getTotalLength=function(){return this.node.getTotalLength?this.node.getTotalLength():void 0},I.getPointAtLength=function(a){return V(this.attr("d"),a)},I.getSubpath=function(b,c){return a.path.getSubpath(this.attr("d"),b,c)},a._.box=d,a.path.findDotsAtSegment=i,a.path.bezierBBox=j,a.path.isPointInsideBBox=k,a.path.isBBoxIntersect=l,a.path.intersection=r,a.path.intersectionNumber=s,a.path.isPointInside=u,a.path.getBBox=v,a.path.get=Y,a.path.toRelative=y,a.path.toAbsolute=z,a.path.toCubic=F,a.path.map=G,a.path.toString=e,a.path.clone=f}),Savage.plugin(function(a){var b=Math.max,c=Math.min,d=function(a){if(this.items=[],this.length=0,this.type="set",a)for(var b=0,c=a.length;c>b;b++)a[b]&&(this[this.items.length]=this.items[this.items.length]=a[b],this.length++)},e=d.prototype;e.push=function(){for(var a,b,c=0,d=arguments.length;d>c;c++)a=arguments[c],a&&(b=this.items.length,this[b]=this.items[b]=a,this.length++);return this},e.pop=function(){return this.length&&delete this[this.length--],this.items.pop()},e.forEach=function(a,b){for(var c=0,d=this.items.length;d>c;c++)if(a.call(b,this.items[c],c)===!1)return this;return this},e.attr=function(a){for(var b=0,c=this.items.length;c>b;b++)this.items[b].attr(a);return this},e.clear=function(){for(;this.length;)this.pop()},e.splice=function(a,e){a=0>a?b(this.length+a,0):a,e=b(0,c(this.length-a,e));var f,g=[],h=[],i=[];for(f=2;ff;f++)h.push(this[a+f]);for(;ff?i[f]:g[f-j];for(f=this.items.length=this.length-=e-j;this[f];)delete this[f++];return new d(h)},e.exclude=function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]==a)return this.splice(b,1),!0;return!1},e.insertAfter=function(a){for(var b=this.items.length;b--;)this.items[b].insertAfter(a);return this},e.getBBox=function(){for(var a=[],d=[],e=[],f=[],g=this.items.length;g--;)if(!this.items[g].removed){var h=this.items[g].getBBox();a.push(h.x),d.push(h.y),e.push(h.x+h.width),f.push(h.y+h.height)}return a=c.apply(0,a),d=c.apply(0,d),e=b.apply(0,e),f=b.apply(0,f),{x:a,y:d,x2:e,y2:f,width:e-a,height:f-d,cx:a+(e-a)/2,cy:d+(f-d)/2}},e.clone=function(a){a=new d;for(var b=0,c=this.items.length;c>b;b++)a.push(this.items[b].clone());return a},e.toString=function(){return"Savage‘s set"},e.type="set",a.set=function(){var a=new d;return arguments.length&&a.push.apply(a,Array.prototype.slice.call(arguments,0)),a}}),Savage.plugin(function(a,b){function c(a){var b=a[0];switch(b.toLowerCase()){case"t":return[b,0,0];case"m":return[b,1,0,0,1,0,0];case"r":return 4==a.length?[b,0,a[2],a[3]]:[b,0];case"s":return 5==a.length?[b,1,1,a[3],a[4]]:3==a.length?[b,1,1]:[b,1]}}function d(b,d){d=l(d).replace(/\.{3}|\u2026/g,b),b=a.parseTransformString(b)||[],d=a.parseTransformString(d)||[];for(var e,f,g,j,k=Math.max(b.length,d.length),m=[],n=[],o=0;k>o;o++){if(g=b[o]||c(d[o]),j=d[o]||c(g),g[0]!=j[0]||"r"==g[0].toLowerCase()&&(g[2]!=j[2]||g[3]!=j[3])||"s"==g[0].toLowerCase()&&(g[3]!=j[3]||g[4]!=j[4]))return;for(m[o]=[],n[o]=[],e=0,f=Math.max(g.length,j.length);f>e;e++)e in g&&(m[o][e]=g[e]),e in j&&(n[o][e]=j[e])}return{from:i(m),to:i(n),f:h(m)}}function e(a){return a}function f(a){return function(b){return+b.toFixed(3)+a}}function g(b){return a.rgb(b[0],b[1],b[2])}function h(a){var b,c,d,e,f,g,h=0,i=[];for(b=0,c=a.length;c>b;b++){for(f="[",g=['"'+a[b][0]+'"'],d=1,e=a[b].length;e>d;d++)g[d]="val["+h++ +"]";f+=g+"]",i[b]=f}return Function("val","return Savage.path.toString.call(["+i+"])")}function i(a){for(var b=[],c=0,d=a.length;d>c;c++)for(var e=1,f=a[c].length;f>e;e++)b.push(a[c][e]);return b}var j={},k=/[a-z]+$/i,l=String;j.stroke=j.fill="colour",b.prototype.equal=function(b,c){var m,n,o=l(this.attr(b)||"");if(o==+o&&c==+c)return{from:+o,to:+c,f:e};if("colour"==j[b])return m=a.color(o),n=a.color(c),{from:[m.r,m.g,m.b,m.opacity],to:[n.r,n.g,n.b,n.opacity],f:g};if("transform"==b||"gradientTransform"==b||"patternTransform"==b)return d(o,c);if("d"==b||"path"==b)return m=a.path.toCubic(o,c),{from:i(m[0]),to:i(m[1]),f:h(m[0])};var p=o.match(k),q=c.match(k);return p&&p==q?{from:parseFloat(o),to:parseFloat(c),f:f(p)}:{from:this.asPX(b),to:this.asPX(b,c),f:e}}}),Savage.plugin(function(a,b,c,d){for(var e=b.prototype,f="hasOwnProperty",g=("createTouch"in d.doc),h=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","touchstart","touchmove","touchend","touchcancel"],i={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},j=function(a){var b="y"==a?"scrollTop":"scrollLeft";
    +return d.doc.documentElement[b]||d.doc.body[b]},k=function(){this.returnValue=!1},l=function(){return this.originalEvent.preventDefault()},m=function(){this.cancelBubble=!0},n=function(){return this.originalEvent.stopPropagation()},o=function(){return d.doc.addEventListener?function(a,b,c,d){var e=g&&i[b]?i[b]:b,h=function(e){var h=j("y"),k=j("x"),m=e.clientX+k,o=e.clientY+h;if(g&&i[f](b))for(var p=0,q=e.targetTouches&&e.targetTouches.length;q>p;p++)if(e.targetTouches[p].target==a){var r=e;e=e.targetTouches[p],e.originalEvent=r,e.preventDefault=l,e.stopPropagation=n;break}return c.call(d,e,m,o)};return a.addEventListener(e,h,!1),function(){return a.removeEventListener(e,h,!1),!0}}:d.doc.attachEvent?function(a,b,c,e){var f=function(a){a=a||d.win.event;var b=j("y"),f=j("x"),g=a.clientX+f,h=a.clientY+b;return a.preventDefault=a.preventDefault||k,a.stopPropagation=a.stopPropagation||m,c.call(e,a,g,h)};a.attachEvent("on"+b,f);var g=function(){return a.detachEvent("on"+b,f),!0};return g}:void 0}(),p=[],q=function(b){for(var c,d=b.clientX,e=b.clientY,f=j("y"),h=j("x"),i=p.length;i--;){if(c=p[i],g){for(var k,l=b.touches.length;l--;)if(k=b.touches[l],k.identifier==c.el._drag.id){d=k.clientX,e=k.clientY,(b.originalEvent?b.originalEvent:b).preventDefault();break}}else b.preventDefault();var m=c.el.node;a._.glob,m.nextSibling,m.parentNode,m.style.display,d+=h,e+=f,eve("savage.drag.move."+c.el.id,c.move_scope||c.el,d-c.el._drag.x,e-c.el._drag.y,d,e,b)}},r=function(b){a.unmousemove(q).unmouseup(r);for(var c,d=p.length;d--;)c=p[d],c.el._drag={},eve("savage.drag.end."+c.el.id,c.end_scope||c.start_scope||c.move_scope||c.el,b);p=[]},s=h.length;s--;)!function(b){a[b]=e[b]=function(c,e){return a.is(c,"function")&&(this.events=this.events||[],this.events.push({name:b,f:c,unbind:o(this.shape||this.node||d.doc,b,c,e||this)})),this},a["un"+b]=e["un"+b]=function(a){for(var c=this.events||[],d=c.length;d--;)if(c[d].name==b&&(c[d].f==a||!a))return c[d].unbind(),c.splice(d,1),!c.length&&delete this.events,this;return this}}(h[s]);e.hover=function(a,b,c,d){return this.mouseover(a,c).mouseout(b,d||c)},e.unhover=function(a,b){return this.unmouseover(a).unmouseout(b)};var t=[];e.drag=function(b,c,d,e,f,g){function h(h){(h.originalEvent||h).preventDefault();var i=j("y"),k=j("x");this._drag.x=h.clientX+k,this._drag.y=h.clientY+i,this._drag.id=h.identifier,!p.length&&a.mousemove(q).mouseup(r),p.push({el:this,move_scope:e,start_scope:f,end_scope:g}),c&&eve.on("savage.drag.start."+this.id,c),b&&eve.on("savage.drag.move."+this.id,b),d&&eve.on("savage.drag.end."+this.id,d),eve("savage.drag.start."+this.id,f||e||this,h.clientX+k,h.clientY+i,h)}if(!arguments.length){var i;return this.drag(function(a,b){this.attr({transform:i+(i?"T":"t")+[a,b]})},function(){i=this.transform().local})}return this._drag={},t.push({el:this,start:h}),this.mousedown(h),this},e.undrag=function(){for(var b=t.length;b--;)t[b].el==this&&(this.unmousedown(t[b].start),t.splice(b,1),eve.unbind("savage.drag.*."+this.id));return!t.length&&a.unmousemove(q).unmouseup(r),this}}),Savage.plugin(function(a,b,c){var d=(b.prototype,c.prototype),e=/^\s*url\((.+)\)/,f=String,g=a._.$;a.filter={},d.filter=function(c){var d=a.parse(f(c)),e=a._.id(),h=this.node.offsetWidth,i=this.node.offsetHeight,j=g("filter");return g(j,{id:e,filterUnits:"userSpaceOnUse",x:0,y:0,width:h,height:i}),j.appendChild(d.node),this.defs.appendChild(j),new b(j)},eve.on("savage.util.getattr.filter",function(){eve.stop();var b=g(this.node,"filter");if(b){var c=f(b).match(e);return c&&a.select(c[1])}}),eve.on("savage.util.attr.filter",function(a){if(a instanceof b&&"filter"==a.type){eve.stop();var c=a.node.id;c||(g(a.node,{id:a.id}),c=a.id),g(this.node,{filter:"url(#"+c+")"})}a&&"none"!=a||(eve.stop(),this.node.removeAttribute("filter"))}),a.filter.blur=function(b,c){null==b&&(b=2);var d=null==c?b:[b,c];return a.format('',{def:d})},a.filter.blur.toString=function(){return this()},a.filter.shadow=function(b,c,d,e){return e=e||"#000",null==d&&(d=4),"string"==typeof d&&(e=d,d=4),null==b&&(b=0,c=2),null==c&&(c=b),e=a.color(e),a.format('',{color:e,dx:b,dy:c,blur:d})},a.filter.shadow.toString=function(){return this()},a.filter.grayscale=function(b){return null==b&&(b=1),a.format('',{a:.2126+.7874*(1-b),b:.7152-.7152*(1-b),c:.0722-.0722*(1-b),d:.2126-.2126*(1-b),e:.7152+.2848*(1-b),f:.0722-.0722*(1-b),g:.2126-.2126*(1-b),h:.0722+.9278*(1-b)})},a.filter.grayscale.toString=function(){return this()},a.filter.sepia=function(b){return null==b&&(b=1),a.format('',{a:.393+.607*(1-b),b:.769-.769*(1-b),c:.189-.189*(1-b),d:.349-.349*(1-b),e:.686+.314*(1-b),f:.168-.168*(1-b),g:.272-.272*(1-b),h:.534-.534*(1-b),i:.131+.869*(1-b)})},a.filter.sepia.toString=function(){return this()},a.filter.saturate=function(b){return null==b&&(b=1),a.format('',{amount:1-b})},a.filter.saturate.toString=function(){return this()},a.filter.hueRotate=function(b){return b=b||0,a.format('',{angle:b})},a.filter.hueRotate.toString=function(){return this()},a.filter.invert=function(b){return null==b&&(b=1),a.format('',{amount:b,amount2:1-b})},a.filter.invert.toString=function(){return this()},a.filter.brightness=function(b){return null==b&&(b=1),a.format('',{amount:b})},a.filter.brightness.toString=function(){return this()},a.filter.contrast=function(b){return null==b&&(b=1),a.format('',{amount:b,amount2:.5-b/2})},a.filter.contrast.toString=function(){return this()}});
    \ No newline at end of file
    diff --git a/dist/savage.js b/dist/savage.js
    index 274827b..bf8804b 100644
    --- a/dist/savage.js
    +++ b/dist/savage.js
    @@ -28,7 +28,7 @@
     // See the License for the specific language governing permissions and
     // limitations under the License.
     // 
    -// build: 2013-09-17
    +// build: 2013-09-19
     // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
     // 
     // Licensed under the Apache License, Version 2.0 (the "License");
    @@ -479,6 +479,23 @@ var mina = (function (eve) {
             delete animations[a.id];
             eve("mina.stop." + a.id, a);
         },
    +    pause = function () {
    +        var a = this;
    +        if (a.pdif) {
    +            return;
    +        }
    +        delete animations[a.id];
    +        a.pdif = a.get() - a.b;
    +    },
    +    resume = function () {
    +        var a = this;
    +        if (!a.pdif) {
    +            return;
    +        }
    +        a.b = a.get() - a.pdif;
    +        delete a.pdif;
    +        animations[a.id] = a;
    +    },
         frame = function () {
             var len = 0;
             for (var i in animations) if (animations.hasOwnProperty(i)) {
    @@ -554,7 +571,9 @@ var mina = (function (eve) {
                 status: sta,
                 speed: speed,
                 duration: duration,
    -            stop: stopit
    +            stop: stopit,
    +            pause: pause,
    +            resume: resume
             };
             animations[anim.id] = anim;
             var len = 0, i;
    @@ -586,7 +605,7 @@ var mina = (function (eve) {
          = (object) See @mina
         \*/
         mina.getById = function (id) {
    -        return animations[anim.id] || null;
    +        return animations[id] || null;
         };
     
         /*\
    @@ -1323,6 +1342,18 @@ function cacher(f, scope, postprocessor) {
         return newf;
     }
     Savage._.cacher = cacher;
    +function angle(x1, y1, x2, y2, x3, y3) {
    +    if (x3 == null) {
    +        var x = x1 - x2,
    +            y = y1 - y2;
    +        if (!x && !y) {
    +            return 0;
    +        }
    +        return (180 + math.atan2(-y, -x) * 180 / PI + 360) % 360;
    +    } else {
    +        return angle(x1, y1, x3, y3) - angle(x2, y2, x3, y3);
    +    }
    +}
     function rad(deg) {
         return deg % 360 * PI / 180;
     }
    @@ -1354,6 +1385,21 @@ Savage.rad = rad;
      = (number) angle in degrees.
     \*/
     Savage.deg = deg;
    +/*\
    + * Savage.angle
    + [ method ]
    + **
    + * Returns angle between two or three points.
    + > Parameters
    + - x1 (number) x coord of first point
    + - y1 (number) y coord of first point
    + - x2 (number) x coord of second point
    + - y2 (number) y coord of second point
    + - x3 (number) #optional x coord of third point
    + - y3 (number) #optional y coord of third point
    + = (number) angle in degrees.
    +\*/
    +Savage.angle = angle;
     /*\
      * Savage.is
      [ method ]
    @@ -1433,7 +1479,7 @@ function Matrix(a, b, c, d, e, f) {
          - d (number)
          - e (number)
          - f (number)
    -     or
    +     * or
          - matrix (object) @Matrix
         \*/
         matrixproto.add = function (a, b, c, d, e, f) {
    @@ -2300,13 +2346,29 @@ function extractTransform(el, tstr) {
         }
     }
     Savage._unit2px = unit2px;
    +function getSomeDefs(el) {
    +    if (Savage._.someDefs) {
    +        return Savage._.someDefs;
    +    }
    +    var p = el.paper ||
    +            (el.node.parentNode && Savage(el.node.parentNode)) ||
    +            Savage.select("svg") ||
    +            Savage(0, 0),
    +        defs = p.select("defs").node;
    +    if (!defs) {
    +        defs = make("defs", p.node).node;
    +    }
    +    Savage._.someDefs = defs;
    +    return defs;
    +}
    +Savage._.getSomeDefs = getSomeDefs;
     function unit2px(el, name, value) {
    -    var defs = el.paper.defs,
    +    var defs = getSomeDefs(el),
             out = {},
    -        mgr = el.paper.measurer;
    +        mgr = defs.querySelector(".svg---mgr");
         if (!mgr) {
    -        el.paper.measurer = mgr = $("rect");
    -        $(mgr, {width: 10, height: 10});
    +        mgr = $("rect");
    +        $(mgr, {width: 10, height: 10, "class": "svg---mgr"});
             defs.appendChild(mgr);
         }
         function getW(val) {
    @@ -2545,25 +2607,29 @@ function arrayFirstValue(arr) {
          o }
         \*/
         elproto.getBBox = function (isWithoutTransform) {
    -        if (this.removed) {
    +        var el = this;
    +        if (el.type == "use") {
    +            el = el.original;
    +        }
    +        if (el.removed) {
                 return {};
             }
    -        var _ = this._;
    +        var _ = el._;
             if (isWithoutTransform) {
                 if (_.dirty || !_.bboxwt) {
    -                this.realPath = Savage.path.get[this.type](this);
    -                _.bboxwt = Savage.path.getBBox(this.realPath);
    +                el.realPath = Savage.path.get[el.type](el);
    +                _.bboxwt = Savage.path.getBBox(el.realPath);
                     _.bboxwt.toString = x_y_w_h;
                     _.dirty = 0;
                 }
                 return Savage._.box(_.bboxwt);
             }
             if (_.dirty || _.dirtyT || !_.bbox) {
    -            if (_.dirty || !this.realPath) {
    +            if (_.dirty || !el.realPath) {
                     _.bboxwt = 0;
    -                this.realPath = Savage.path.get[this.type](this);
    +                el.realPath = Savage.path.get[el.type](el);
                 }
    -            _.bbox = Savage.path.getBBox(Savage.path.map(this.realPath, this.matrix));
    +            _.bbox = Savage.path.getBBox(Savage.path.map(el.realPath, el.matrix));
                 _.bbox.toString = x_y_w_h;
                 _.dirty = _.dirtyT = 0;
             }
    @@ -2749,7 +2815,7 @@ function arrayFirstValue(arr) {
          = (Element) removed element
         \*/
         elproto.remove = function () {
    -        this.node.parentNode.removeChild(this.node);
    +        this.node.parentNode && this.node.parentNode.removeChild(this.node);
             delete this.paper;
             this.removed = true;
             return this;
    @@ -2825,6 +2891,7 @@ function arrayFirstValue(arr) {
             $(use.node, {
                 "xlink:href": "#" + id
             });
    +        use.original = this;
             return use;
         };
         /*\
    @@ -2906,6 +2973,19 @@ function arrayFirstValue(arr) {
             clone.insertAfter(this);
             return clone;
         };
    +    /*\
    +     * Element.toDefs
    +     [ method ]
    +     **
    +     * Moves element to the relative `` section.
    +     **
    +     = (Element) the clone
    +    \*/
    +    elproto.toDefs = function () {
    +        var defs = getSomeDefs(this);
    +        defs.appendChild(this.node);
    +        return this;
    +    };
         /*\
          * Element.pattern
          [ method ]
    @@ -2930,7 +3010,7 @@ function arrayFirstValue(arr) {
          | });
         \*/
         elproto.pattern = function (x, y, width, height) {
    -        var p = make("pattern", this.paper.defs);
    +        var p = make("pattern", getSomeDefs(this));
             if (x == null) {
                 x = this.getBBox();
             }
    @@ -2970,7 +3050,7 @@ function arrayFirstValue(arr) {
         \*/
         // TODO add usage for markers
         elproto.marker = function (x, y, width, height, refX, refY) {
    -        var p = make("marker", this.paper.defs);
    +        var p = make("marker", getSomeDefs(this));
             if (x == null) {
                 x = this.getBBox();
             }
    @@ -3363,6 +3443,20 @@ function Paper(w, h) {
             res = new Element(w);
             desc = w.getElementsByTagName("desc")[0];
             defs = w.getElementsByTagName("defs")[0];
    +        if (!desc) {
    +            desc = $("desc");
    +            desc.appendChild(glob.doc.createTextNode("Created with Savage"));
    +            res.node.appendChild(desc);
    +        }
    +        if (!defs) {
    +            defs = $("defs");
    +            res.node.appendChild(defs);
    +        }
    +        res.defs = defs;
    +        for (var key in proto) if (proto[has](key)) {
    +            res[key] = proto[key];
    +        }
    +        res.paper = res.root = res;
         } else {
             res = make("svg", glob.doc.body);
             $(res.node, {
    @@ -3372,20 +3466,6 @@ function Paper(w, h) {
                 xmlns: "http://www.w3.org/2000/svg"
             });
         }
    -    if (!desc) {
    -        desc = $("desc");
    -        desc.appendChild(glob.doc.createTextNode("Created with Savage"));
    -        res.node.appendChild(desc);
    -    }
    -    if (!defs) {
    -        defs = $("defs");
    -        res.node.appendChild(defs);
    -    }
    -    for (var key in proto) if (proto[has](key)) {
    -        res[key] = proto[key];
    -    }
    -    res.paper = res.root = res;
    -    res.defs = defs;
         return res;
     }
     function wrap(dom) {
    @@ -3400,6 +3480,115 @@ function wrap(dom) {
         }
         return new Element(dom);
     }
    +// gradients’ helpers
    +function Gstops() {
    +    return this.selectAll("stop");
    +}
    +function GaddStop(color, offset) {
    +    var stop = $("stop"),
    +        attr = {
    +            offset: +offset + "%"
    +        };
    +    color = Savage.color(color);
    +    attr["stop-color"] = color.hex;
    +    if (color.opacity < 1) {
    +        attr["stop-opacity"] = color.opacity;
    +    }
    +    $(stop, attr);
    +    this.node.appendChild(stop);
    +    return this;
    +}
    +function GgetBBox() {
    +    if (this.type == "linearGradient") {
    +        var x1 = $(this.node, "x1") || 0,
    +            x2 = $(this.node, "x2") || 1,
    +            y1 = $(this.node, "y1") || 0,
    +            y2 = $(this.node, "y2") || 0;
    +        return Savage._.box(x1, y1, math.abs(x2 - x1), math.abs(y2 - y1));
    +    } else {
    +        var cx = this.node.cx || .5,
    +            cy = this.node.cy || .5,
    +            r = this.node.r || 0;
    +        return Savage._.box(cx - r, cy - r, r * 2, r * 2);
    +    }
    +}
    +function gradient(defs, str) {
    +    var grad = arrayFirstValue(eve("savage.util.grad.parse", null, str)),
    +        el;
    +    if (!grad) {
    +        return null;
    +    }
    +    grad.params.unshift(defs);
    +    if (grad.type.toLowerCase() == "l") {
    +        el = gradientLinear.apply(0, grad.params);
    +    } else {
    +        el = gradientRadial.apply(0, grad.params);
    +    }
    +    if (grad.type != grad.type.toLowerCase()) {
    +        $(el.node, {
    +            gradientUnits: "userSpaceOnUse"
    +        });
    +    }
    +    var stops = grad.stops,
    +        len = stops.length,
    +        start = 0,
    +        j = 0;
    +    function seed(i, end) {
    +        var step = (end - start) / (i - j);
    +        for (var k = j; k < i; k++) {
    +            stops[k].offset = +(+start + step * (k - j)).toFixed(2);
    +        }
    +        j = i;
    +        start = end;
    +    }
    +    len--;
    +    for (var i = 0; i < len; i++) if ("offset" in stops[i]) {
    +        seed(i, stops[i].offset);
    +    }
    +    stops[len].offset = stops[len].offset || 100;
    +    seed(len, stops[len].offset);
    +    for (i = 0; i <= len; i++) {
    +        var stop = stops[i];
    +        el.addStop(stop.color, stop.offset);
    +    }
    +    return el;
    +}
    +function gradientLinear(defs, x1, y1, x2, y2) {
    +    var el = make("linearGradient", defs);
    +    el.stops = Gstops;
    +    el.addStop = GaddStop;
    +    el.getBBox = GgetBBox;
    +    if (x1 != null) {
    +        $(el.node, {
    +            x1: x1,
    +            y1: y1,
    +            x2: x2,
    +            y2: y2
    +        });
    +    }
    +    return el;
    +}
    +function gradientRadial(defs, cx, cy, r, fx, fy) {
    +    var el = make("radialGradient", defs);
    +    el.stops = Gstops;
    +    el.addStop = GaddStop;
    +    el.getBBox = GgetBBox;
    +    if (cx != null) {
    +        $(el.node, {
    +            cx: cx,
    +            cy: cy,
    +            r: r
    +        });
    +    }
    +    if (fx != null && fy != null) {
    +        $(el.node, {
    +            fx: fx,
    +            fy: fy
    +        });
    +    }
    +    return el;
    +}
    +// Paper prototype methods
     (function (proto) {
         /*\
          * Paper.el
    @@ -3801,105 +3990,13 @@ function wrap(dom) {
              = (object) Element object with type “gradient”
             \*/
             proto.gradient = function (str) {
    -            var grad = arrayFirstValue(eve("savage.util.grad.parse", null, str)),
    -                el;
    -            if (!grad) {
    -                return null;
    -            }
    -            if (grad.type.toLowerCase() == "l") {
    -                el = this.gradientLinear.apply(this, grad.params);
    -            } else {
    -                el = this.gradientRadial.apply(this, grad.params);
    -            }
    -            if (grad.type != grad.type.toLowerCase()) {
    -                $(el.node, {
    -                    gradientUnits: "userSpaceOnUse"
    -                });
    -            }
    -            var stops = grad.stops,
    -                len = stops.length,
    -                start = 0,
    -                j = 0;
    -            function seed(i, end) {
    -                var step = (end - start) / (i - j);
    -                for (var k = j; k < i; k++) {
    -                    stops[k].offset = +(+start + step * (k - j)).toFixed(2);
    -                }
    -                j = i;
    -                start = end;
    -            }
    -            len--;
    -            for (var i = 0; i < len; i++) if ("offset" in stops[i]) {
    -                seed(i, stops[i].offset);
    -            }
    -            stops[len].offset = stops[len].offset || 100;
    -            seed(len, stops[len].offset);
    -            for (i = 0; i <= len; i++) {
    -                var stop = stops[i];
    -                el.addStop(stop.color, stop.offset);
    -            }
    -            return el;
    +            return gradient(this.defs, str);
             };
    -        function stops() {
    -            return this.selectAll("stop");
    -        }
    -        function addStop(color, offset) {
    -            var stop = $("stop");
    -            $(stop, {
    -                "stop-color": color,
    -                offset: +offset + "%"
    -            });
    -            this.node.appendChild(stop);
    -            return this;
    -        }
    -        function getBBox() {
    -            if (this.type == "linearGradient") {
    -                var x1 = $(this.node, "x1") || 0,
    -                    x2 = $(this.node, "x2") || 1,
    -                    y1 = $(this.node, "y1") || 0,
    -                    y2 = $(this.node, "y2") || 0;
    -                return Savage._.box(x1, y1, math.abs(x2 - x1), math.abs(y2 - y1));
    -            } else {
    -                var cx = this.node.cx || .5,
    -                    cy = this.node.cy || .5,
    -                    r = this.node.r || 0;
    -                return Savage._.box(cx - r, cy - r, r * 2, r * 2);
    -            }
    -        }
             proto.gradientLinear = function (x1, y1, x2, y2) {
    -            var el = make("linearGradient", this.node);
    -            el.stops = stops;
    -            el.addStop = addStop;
    -            el.getBBox = getBBox;
    -            if (x1 != null) {
    -                $(el.node, {
    -                    x1: x1,
    -                    y1: y1,
    -                    x2: x2,
    -                    y2: y2
    -                });
    -            }
    -            return el;
    +            return gradientLinear(this.defs, x1, y1, x2, y2);
             };
             proto.gradientRadial = function (cx, cy, r, fx, fy) {
    -            var el = make("radialGradient", this.node);
    -            el.stops = stops;
    -            el.addStop = addStop;
    -            el.getBBox = getBBox;
    -            if (cx != null) {
    -                $(el.node, {
    -                    cx: cx,
    -                    cy: cy,
    -                    r: r
    -                });
    -            }
    -            if (fx != null && fy != null) {
    -                $(el.node, {
    -                    fx: fx,
    -                    fy: fy
    -                });
    -            }
    -            return el;
    +            return gradientRadial(this.defs, cx, cy, r, fx, fy);
             };
             /*\
              * Paper.toString
    @@ -3999,13 +4096,13 @@ eve.on("savage.util.attr.mask", function (value) {
             eve.stop();
             if (value instanceof Fragment && value.node.childNodes.length == 1) {
                 value = value.node.firstChild;
    -            this.paper.defs.appendChild(value);
    +            getSomeDefs(this).appendChild(value);
                 value = wrap(value);
             }
             if (value.type == "mask") {
                 var mask = value;
             } else {
    -            mask = make("mask", this.paper.defs);
    +            mask = make("mask", getSomeDefs(this));
                 mask.node.appendChild(value.node);
                 !mask.node.id && $(mask.node, {
                     id: mask.id
    @@ -4026,7 +4123,7 @@ eve.on("savage.util.attr.mask", function (value) {
             if (value.type == "clipPath") {
                 var clip = value;
             } else {
    -            clip = make("clipPath", this.paper.defs);
    +            clip = make("clipPath", getSomeDefs(this));
                 clip.node.appendChild(value.node);
                 !clip.node.id && $(clip.node, {
                     id: clip.id
    @@ -4045,7 +4142,7 @@ function fillStroke(name) {
                 value.node.firstChild.tagName == "linearGradient" ||
                 value.node.firstChild.tagName == "pattern")) {
                 value = value.node.firstChild;
    -            this.paper.defs.appendChild(value);
    +            getSomeDefs(this).appendChild(value);
                 value = wrap(value);
             }
             if (value instanceof Element) {
    @@ -4063,7 +4160,7 @@ function fillStroke(name) {
             } else {
                 fill = Savage.color(value);
                 if (fill.error) {
    -                var grad = this.paper.gradient(value);
    +                var grad = gradient(getSomeDefs(this), value);
                     if (grad) {
                         if (!grad.node.id) {
                             $(grad.node, {
    @@ -4806,7 +4903,7 @@ Savage.plugin(function (Savage, Element, Paper, glob) {
             function O(val) {
                 return +(+val).toFixed(3);
             }
    -        return function (path, length, onlystart) {
    +        return Savage._.cacher(function (path, length, onlystart) {
                 if (path instanceof Element) {
                     path = path.attr("d");
                 }
    @@ -4861,7 +4958,7 @@ Savage.plugin(function (Savage, Element, Paper, glob) {
                 subpaths.end = sp;
                 point = istotal ? len : subpath ? subpaths : findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1);
                 return point;
    -        };
    +        }, null, Savage._.clone);
         }
         var getTotalLength = getLengthFactory(1),
             getPointAtLength = getLengthFactory(),
    @@ -5242,7 +5339,8 @@ Savage.plugin(function (Savage, Element, Paper, glob) {
             }
         };
         function pathToRelative(pathArray) {
    -        var pth = paths(pathArray);
    +        var pth = paths(pathArray),
    +            lowerCase = String.prototype.toLowerCase;
             if (pth.rel) {
                 return pathClone(pth.rel);
             }
    @@ -6200,6 +6298,7 @@ Savage.plugin(function (Savage, Element, Paper, glob) {
                 this.splice(i, 1);
                 return true;
             }
    +        return false;
         };
         setproto.insertAfter = function (el) {
             var i = this.items.length;
    @@ -7005,6 +7104,10 @@ Savage.plugin(function (Savage, Element, Paper, glob) {
             if (blur == null) {
                 blur = 4;
             }
    +        if (typeof blur == "string") {
    +            color = blur;
    +            blur = 4;
    +        }
             if (dx == null) {
                 dx = 0;
                 dy = 2;
    @@ -7012,6 +7115,7 @@ Savage.plugin(function (Savage, Element, Paper, glob) {
             if (dy == null) {
                 dy = dx;
             }
    +        color = Savage.color(color);
             return Savage.format('', {
                 color: color,
                 dx: dx,
    diff --git a/src/set.js b/src/set.js
    index 08cd493..4860f19 100644
    --- a/src/set.js
    +++ b/src/set.js
    @@ -149,6 +149,7 @@ Savage.plugin(function (Savage, Element, Paper, glob) {
                 this.splice(i, 1);
                 return true;
             }
    +        return false;
         };
         setproto.insertAfter = function (el) {
             var i = this.items.length;
    diff --git a/src/svg.js b/src/svg.js
    index aec2aa2..ea59013 100644
    --- a/src/svg.js
    +++ b/src/svg.js
    @@ -245,6 +245,18 @@ function cacher(f, scope, postprocessor) {
         return newf;
     }
     Savage._.cacher = cacher;
    +function angle(x1, y1, x2, y2, x3, y3) {
    +    if (x3 == null) {
    +        var x = x1 - x2,
    +            y = y1 - y2;
    +        if (!x && !y) {
    +            return 0;
    +        }
    +        return (180 + math.atan2(-y, -x) * 180 / PI + 360) % 360;
    +    } else {
    +        return angle(x1, y1, x3, y3) - angle(x2, y2, x3, y3);
    +    }
    +}
     function rad(deg) {
         return deg % 360 * PI / 180;
     }
    @@ -276,6 +288,21 @@ Savage.rad = rad;
      = (number) angle in degrees.
     \*/
     Savage.deg = deg;
    +/*\
    + * Savage.angle
    + [ method ]
    + **
    + * Returns angle between two or three points.
    + > Parameters
    + - x1 (number) x coord of first point
    + - y1 (number) y coord of first point
    + - x2 (number) x coord of second point
    + - y2 (number) y coord of second point
    + - x3 (number) #optional x coord of third point
    + - y3 (number) #optional y coord of third point
    + = (number) angle in degrees.
    +\*/
    +Savage.angle = angle;
     /*\
      * Savage.is
      [ method ]
    @@ -355,7 +382,7 @@ function Matrix(a, b, c, d, e, f) {
          - d (number)
          - e (number)
          - f (number)
    -     or
    +     * or
          - matrix (object) @Matrix
         \*/
         matrixproto.add = function (a, b, c, d, e, f) {
    @@ -1222,13 +1249,29 @@ function extractTransform(el, tstr) {
         }
     }
     Savage._unit2px = unit2px;
    +function getSomeDefs(el) {
    +    if (Savage._.someDefs) {
    +        return Savage._.someDefs;
    +    }
    +    var p = el.paper ||
    +            (el.node.parentNode && Savage(el.node.parentNode)) ||
    +            Savage.select("svg") ||
    +            Savage(0, 0),
    +        defs = p.select("defs").node;
    +    if (!defs) {
    +        defs = make("defs", p.node).node;
    +    }
    +    Savage._.someDefs = defs;
    +    return defs;
    +}
    +Savage._.getSomeDefs = getSomeDefs;
     function unit2px(el, name, value) {
    -    var defs = el.paper.defs,
    +    var defs = getSomeDefs(el),
             out = {},
    -        mgr = el.paper.measurer;
    +        mgr = defs.querySelector(".svg---mgr");
         if (!mgr) {
    -        el.paper.measurer = mgr = $("rect");
    -        $(mgr, {width: 10, height: 10});
    +        mgr = $("rect");
    +        $(mgr, {width: 10, height: 10, "class": "svg---mgr"});
             defs.appendChild(mgr);
         }
         function getW(val) {
    @@ -1467,25 +1510,29 @@ function arrayFirstValue(arr) {
          o }
         \*/
         elproto.getBBox = function (isWithoutTransform) {
    -        if (this.removed) {
    +        var el = this;
    +        if (el.type == "use") {
    +            el = el.original;
    +        }
    +        if (el.removed) {
                 return {};
             }
    -        var _ = this._;
    +        var _ = el._;
             if (isWithoutTransform) {
                 if (_.dirty || !_.bboxwt) {
    -                this.realPath = Savage.path.get[this.type](this);
    -                _.bboxwt = Savage.path.getBBox(this.realPath);
    +                el.realPath = Savage.path.get[el.type](el);
    +                _.bboxwt = Savage.path.getBBox(el.realPath);
                     _.bboxwt.toString = x_y_w_h;
                     _.dirty = 0;
                 }
                 return Savage._.box(_.bboxwt);
             }
             if (_.dirty || _.dirtyT || !_.bbox) {
    -            if (_.dirty || !this.realPath) {
    +            if (_.dirty || !el.realPath) {
                     _.bboxwt = 0;
    -                this.realPath = Savage.path.get[this.type](this);
    +                el.realPath = Savage.path.get[el.type](el);
                 }
    -            _.bbox = Savage.path.getBBox(Savage.path.map(this.realPath, this.matrix));
    +            _.bbox = Savage.path.getBBox(Savage.path.map(el.realPath, el.matrix));
                 _.bbox.toString = x_y_w_h;
                 _.dirty = _.dirtyT = 0;
             }
    @@ -1671,7 +1718,7 @@ function arrayFirstValue(arr) {
          = (Element) removed element
         \*/
         elproto.remove = function () {
    -        this.node.parentNode.removeChild(this.node);
    +        this.node.parentNode && this.node.parentNode.removeChild(this.node);
             delete this.paper;
             this.removed = true;
             return this;
    @@ -1747,6 +1794,7 @@ function arrayFirstValue(arr) {
             $(use.node, {
                 "xlink:href": "#" + id
             });
    +        use.original = this;
             return use;
         };
         /*\
    @@ -1828,6 +1876,19 @@ function arrayFirstValue(arr) {
             clone.insertAfter(this);
             return clone;
         };
    +    /*\
    +     * Element.toDefs
    +     [ method ]
    +     **
    +     * Moves element to the relative `` section.
    +     **
    +     = (Element) the clone
    +    \*/
    +    elproto.toDefs = function () {
    +        var defs = getSomeDefs(this);
    +        defs.appendChild(this.node);
    +        return this;
    +    };
         /*\
          * Element.pattern
          [ method ]
    @@ -1852,7 +1913,7 @@ function arrayFirstValue(arr) {
          | });
         \*/
         elproto.pattern = function (x, y, width, height) {
    -        var p = make("pattern", this.paper.defs);
    +        var p = make("pattern", getSomeDefs(this));
             if (x == null) {
                 x = this.getBBox();
             }
    @@ -1892,7 +1953,7 @@ function arrayFirstValue(arr) {
         \*/
         // TODO add usage for markers
         elproto.marker = function (x, y, width, height, refX, refY) {
    -        var p = make("marker", this.paper.defs);
    +        var p = make("marker", getSomeDefs(this));
             if (x == null) {
                 x = this.getBBox();
             }
    @@ -2285,6 +2346,20 @@ function Paper(w, h) {
             res = new Element(w);
             desc = w.getElementsByTagName("desc")[0];
             defs = w.getElementsByTagName("defs")[0];
    +        if (!desc) {
    +            desc = $("desc");
    +            desc.appendChild(glob.doc.createTextNode("Created with Savage"));
    +            res.node.appendChild(desc);
    +        }
    +        if (!defs) {
    +            defs = $("defs");
    +            res.node.appendChild(defs);
    +        }
    +        res.defs = defs;
    +        for (var key in proto) if (proto[has](key)) {
    +            res[key] = proto[key];
    +        }
    +        res.paper = res.root = res;
         } else {
             res = make("svg", glob.doc.body);
             $(res.node, {
    @@ -2294,20 +2369,6 @@ function Paper(w, h) {
                 xmlns: "http://www.w3.org/2000/svg"
             });
         }
    -    if (!desc) {
    -        desc = $("desc");
    -        desc.appendChild(glob.doc.createTextNode("Created with Savage"));
    -        res.node.appendChild(desc);
    -    }
    -    if (!defs) {
    -        defs = $("defs");
    -        res.node.appendChild(defs);
    -    }
    -    for (var key in proto) if (proto[has](key)) {
    -        res[key] = proto[key];
    -    }
    -    res.paper = res.root = res;
    -    res.defs = defs;
         return res;
     }
     function wrap(dom) {
    @@ -2322,6 +2383,115 @@ function wrap(dom) {
         }
         return new Element(dom);
     }
    +// gradients’ helpers
    +function Gstops() {
    +    return this.selectAll("stop");
    +}
    +function GaddStop(color, offset) {
    +    var stop = $("stop"),
    +        attr = {
    +            offset: +offset + "%"
    +        };
    +    color = Savage.color(color);
    +    attr["stop-color"] = color.hex;
    +    if (color.opacity < 1) {
    +        attr["stop-opacity"] = color.opacity;
    +    }
    +    $(stop, attr);
    +    this.node.appendChild(stop);
    +    return this;
    +}
    +function GgetBBox() {
    +    if (this.type == "linearGradient") {
    +        var x1 = $(this.node, "x1") || 0,
    +            x2 = $(this.node, "x2") || 1,
    +            y1 = $(this.node, "y1") || 0,
    +            y2 = $(this.node, "y2") || 0;
    +        return Savage._.box(x1, y1, math.abs(x2 - x1), math.abs(y2 - y1));
    +    } else {
    +        var cx = this.node.cx || .5,
    +            cy = this.node.cy || .5,
    +            r = this.node.r || 0;
    +        return Savage._.box(cx - r, cy - r, r * 2, r * 2);
    +    }
    +}
    +function gradient(defs, str) {
    +    var grad = arrayFirstValue(eve("savage.util.grad.parse", null, str)),
    +        el;
    +    if (!grad) {
    +        return null;
    +    }
    +    grad.params.unshift(defs);
    +    if (grad.type.toLowerCase() == "l") {
    +        el = gradientLinear.apply(0, grad.params);
    +    } else {
    +        el = gradientRadial.apply(0, grad.params);
    +    }
    +    if (grad.type != grad.type.toLowerCase()) {
    +        $(el.node, {
    +            gradientUnits: "userSpaceOnUse"
    +        });
    +    }
    +    var stops = grad.stops,
    +        len = stops.length,
    +        start = 0,
    +        j = 0;
    +    function seed(i, end) {
    +        var step = (end - start) / (i - j);
    +        for (var k = j; k < i; k++) {
    +            stops[k].offset = +(+start + step * (k - j)).toFixed(2);
    +        }
    +        j = i;
    +        start = end;
    +    }
    +    len--;
    +    for (var i = 0; i < len; i++) if ("offset" in stops[i]) {
    +        seed(i, stops[i].offset);
    +    }
    +    stops[len].offset = stops[len].offset || 100;
    +    seed(len, stops[len].offset);
    +    for (i = 0; i <= len; i++) {
    +        var stop = stops[i];
    +        el.addStop(stop.color, stop.offset);
    +    }
    +    return el;
    +}
    +function gradientLinear(defs, x1, y1, x2, y2) {
    +    var el = make("linearGradient", defs);
    +    el.stops = Gstops;
    +    el.addStop = GaddStop;
    +    el.getBBox = GgetBBox;
    +    if (x1 != null) {
    +        $(el.node, {
    +            x1: x1,
    +            y1: y1,
    +            x2: x2,
    +            y2: y2
    +        });
    +    }
    +    return el;
    +}
    +function gradientRadial(defs, cx, cy, r, fx, fy) {
    +    var el = make("radialGradient", defs);
    +    el.stops = Gstops;
    +    el.addStop = GaddStop;
    +    el.getBBox = GgetBBox;
    +    if (cx != null) {
    +        $(el.node, {
    +            cx: cx,
    +            cy: cy,
    +            r: r
    +        });
    +    }
    +    if (fx != null && fy != null) {
    +        $(el.node, {
    +            fx: fx,
    +            fy: fy
    +        });
    +    }
    +    return el;
    +}
    +// Paper prototype methods
     (function (proto) {
         /*\
          * Paper.el
    @@ -2723,105 +2893,13 @@ function wrap(dom) {
              = (object) Element object with type “gradient”
             \*/
             proto.gradient = function (str) {
    -            var grad = arrayFirstValue(eve("savage.util.grad.parse", null, str)),
    -                el;
    -            if (!grad) {
    -                return null;
    -            }
    -            if (grad.type.toLowerCase() == "l") {
    -                el = this.gradientLinear.apply(this, grad.params);
    -            } else {
    -                el = this.gradientRadial.apply(this, grad.params);
    -            }
    -            if (grad.type != grad.type.toLowerCase()) {
    -                $(el.node, {
    -                    gradientUnits: "userSpaceOnUse"
    -                });
    -            }
    -            var stops = grad.stops,
    -                len = stops.length,
    -                start = 0,
    -                j = 0;
    -            function seed(i, end) {
    -                var step = (end - start) / (i - j);
    -                for (var k = j; k < i; k++) {
    -                    stops[k].offset = +(+start + step * (k - j)).toFixed(2);
    -                }
    -                j = i;
    -                start = end;
    -            }
    -            len--;
    -            for (var i = 0; i < len; i++) if ("offset" in stops[i]) {
    -                seed(i, stops[i].offset);
    -            }
    -            stops[len].offset = stops[len].offset || 100;
    -            seed(len, stops[len].offset);
    -            for (i = 0; i <= len; i++) {
    -                var stop = stops[i];
    -                el.addStop(stop.color, stop.offset);
    -            }
    -            return el;
    +            return gradient(this.defs, str);
             };
    -        function stops() {
    -            return this.selectAll("stop");
    -        }
    -        function addStop(color, offset) {
    -            var stop = $("stop");
    -            $(stop, {
    -                "stop-color": color,
    -                offset: +offset + "%"
    -            });
    -            this.node.appendChild(stop);
    -            return this;
    -        }
    -        function getBBox() {
    -            if (this.type == "linearGradient") {
    -                var x1 = $(this.node, "x1") || 0,
    -                    x2 = $(this.node, "x2") || 1,
    -                    y1 = $(this.node, "y1") || 0,
    -                    y2 = $(this.node, "y2") || 0;
    -                return Savage._.box(x1, y1, math.abs(x2 - x1), math.abs(y2 - y1));
    -            } else {
    -                var cx = this.node.cx || .5,
    -                    cy = this.node.cy || .5,
    -                    r = this.node.r || 0;
    -                return Savage._.box(cx - r, cy - r, r * 2, r * 2);
    -            }
    -        }
             proto.gradientLinear = function (x1, y1, x2, y2) {
    -            var el = make("linearGradient", this.node);
    -            el.stops = stops;
    -            el.addStop = addStop;
    -            el.getBBox = getBBox;
    -            if (x1 != null) {
    -                $(el.node, {
    -                    x1: x1,
    -                    y1: y1,
    -                    x2: x2,
    -                    y2: y2
    -                });
    -            }
    -            return el;
    +            return gradientLinear(this.defs, x1, y1, x2, y2);
             };
             proto.gradientRadial = function (cx, cy, r, fx, fy) {
    -            var el = make("radialGradient", this.node);
    -            el.stops = stops;
    -            el.addStop = addStop;
    -            el.getBBox = getBBox;
    -            if (cx != null) {
    -                $(el.node, {
    -                    cx: cx,
    -                    cy: cy,
    -                    r: r
    -                });
    -            }
    -            if (fx != null && fy != null) {
    -                $(el.node, {
    -                    fx: fx,
    -                    fy: fy
    -                });
    -            }
    -            return el;
    +            return gradientRadial(this.defs, cx, cy, r, fx, fy);
             };
             /*\
              * Paper.toString
    @@ -2921,13 +2999,13 @@ eve.on("savage.util.attr.mask", function (value) {
             eve.stop();
             if (value instanceof Fragment && value.node.childNodes.length == 1) {
                 value = value.node.firstChild;
    -            this.paper.defs.appendChild(value);
    +            getSomeDefs(this).appendChild(value);
                 value = wrap(value);
             }
             if (value.type == "mask") {
                 var mask = value;
             } else {
    -            mask = make("mask", this.paper.defs);
    +            mask = make("mask", getSomeDefs(this));
                 mask.node.appendChild(value.node);
                 !mask.node.id && $(mask.node, {
                     id: mask.id
    @@ -2948,7 +3026,7 @@ eve.on("savage.util.attr.mask", function (value) {
             if (value.type == "clipPath") {
                 var clip = value;
             } else {
    -            clip = make("clipPath", this.paper.defs);
    +            clip = make("clipPath", getSomeDefs(this));
                 clip.node.appendChild(value.node);
                 !clip.node.id && $(clip.node, {
                     id: clip.id
    @@ -2967,7 +3045,7 @@ function fillStroke(name) {
                 value.node.firstChild.tagName == "linearGradient" ||
                 value.node.firstChild.tagName == "pattern")) {
                 value = value.node.firstChild;
    -            this.paper.defs.appendChild(value);
    +            getSomeDefs(this).appendChild(value);
                 value = wrap(value);
             }
             if (value instanceof Element) {
    @@ -2985,7 +3063,7 @@ function fillStroke(name) {
             } else {
                 fill = Savage.color(value);
                 if (fill.error) {
    -                var grad = this.paper.gradient(value);
    +                var grad = gradient(getSomeDefs(this), value);
                     if (grad) {
                         if (!grad.node.id) {
                             $(grad.node, {