summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xCHANGELOG.md5
-rwxr-xr-xREADME.md50
-rwxr-xr-xdist/svg.js210
-rwxr-xr-xdist/svg.min.js4
-rwxr-xr-xsrc/fx.js174
-rwxr-xr-xsrc/parent.js4
-rwxr-xr-xsrc/set.js30
7 files changed, 263 insertions, 214 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a956d82..8b4f8b9 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,7 @@
- added `'random'` option and `randomize()` method to `SVG.Color` -> __TODO!__
- added `SVG.Title` and `SVG.Desc` -> __TODO!__
-# 1.0.0-rc.10 (?/07/2014)
+# 1.0.0-rc.10 (?/08/2014)
- implemented an SVG adoption system to be able to manipulate existing SVG's not created with svg.js
- changed `parent` reference on elements to `parent()` method
@@ -34,6 +34,9 @@
- fixed a bug in IE11 with `mouseenter` and `mouseleave` -> __TODO!__
- switched from Ruby's `rake` to Node's `gulp` for building [thanks to Alex Ewerlöf]
- added coding style description to README
+- changed `to()` method to `at()` method in `SVG.FX`
+- added reverse functionality for animations
+- documented the `situation` object in `SVG.FX`
# 1.0.0-rc.9 (17/06/2014)
diff --git a/README.md b/README.md
index dac5255..d4f181a 100755
--- a/README.md
+++ b/README.md
@@ -1735,13 +1735,13 @@ To make things easier a morphing function is passed as the second argument. This
var ellipse = draw.ellipse(100, 100).attr('cx', '20%').fill('#333')
rect.animate(3000).move(100, 100).during(function(pos, morph) {
- /* numeric values */
+ // numeric values
ellipse.size(morph(100, 200), morph(100, 50))
- /* unit strings */
+ // unit strings
ellipse.attr('cx', morph('20%', '80%'))
- /* hex color strings */
+ // hex color strings
ellipse.fill(morph('#333', '#ff0066'))
})
```
@@ -1758,9 +1758,19 @@ rect.animate(3000).move(100, 100).loop()
But the loop can also be a predefined number of times:
```javascript
-rect.animate(3000).move(100, 100).loop(5)
+rect.animate(3000).move(100, 100).loop(3)
```
+Loops go from beginning to end and start over again (`0->1.0->1.0->1.`).
+
+There is also a reverse flag that should be passed as the second argument:
+
+```javascript
+rect.animate(3000).move(100, 100).loop(3, true)
+```
+
+Loops will then be completely reversed before starting over (`0->1->0->1->0->1.`).
+
__`returns`: `SVG.FX`__
### after()
@@ -1776,24 +1786,48 @@ Note that the `after()` method will never be called if the animation is looping
__`returns`: `SVG.FX`__
-### to()
-Say you want to control the position of an animation with an external event, then the `to()` method will proove very useful:
+### at()
+Say you want to control the position of an animation with an external event, then the `at()` method will proove very useful:
```javascript
var animate = draw.rect(100, 100).move(50, 50).animate('=').move(200, 200)
document.onmousemove = function(event) {
- animate.to(event.clientX / 1000)
+ animate.at(event.clientX / 1000)
}
```
-In order to be able use the `to()` method the duration of the animation should be set to `'='`. The value passed as the first argument of `to()` should be a number between `0` and `1`, `0` being the beginning of the animation and `1` being the end. Note that any values below `0` and above `1` will be normalized.
+In order to be able use the `at()` method, the duration of the animation should be set to `'='`. The value passed as the first argument of `at()` should be a number between `0` and `1`, `0` being the beginning of the animation and `1` being the end. Note that any values below `0` and above `1` will be normalized.
_This functionality requires the fx.js module which is included in the default distribution._
__`returns`: `SVG.FX`__
+### situation
+The current situation of an animation is stored in the `situation` object:
+
+```javascript
+rect.animate(3000).move(100, 100)
+rect.fx.situation //-> everything is in here
+```
+
+Available values are:
+
+- `start` (start time as a number in milliseconds)
+- `play` (animation playing or not; `true` or `false`)
+- `pause` (time when the animation was last paused)
+- `duration` (the chosen duration of the animation)
+- `ease` (the chosen easing calculation)
+- `finish` (start + duration)
+- `loop` (the current loop; counting down if a number; `true`, `false` or a number)
+- `loops` (if a number, the total number loops; `true`, `false` or a number)
+- `reverse` (whether or not the loop should be reversed; `true` or `false`)
+- `reversing` (`true` if the loop is currently reversing, otherwise `false`)
+- `during` (the function that should be called on every keyframe)
+- `after` (the function that should be called after completion)
+
+
## Syntax sugar
Fill and stroke are used quite often. Therefore two convenience methods are provided:
diff --git a/dist/svg.js b/dist/svg.js
index 0742d27..cb39a09 100755
--- a/dist/svg.js
+++ b/dist/svg.js
@@ -6,7 +6,7 @@
* @copyright Wout Fierens <wout@impinc.co.uk>
* @license MIT
*
-* BUILT: Mon Jul 28 2014 19:09:36 GMT+0200 (CEST)
+* BUILT: Wed Jul 30 2014 11:04:18 GMT+0200 (CEST)
*/
;(function() {
// The main wrapping element
@@ -1120,31 +1120,32 @@ SVG.FX = SVG.invent({
akeys.push(key)
// make sure morphable elements are scaled, translated and morphed all together
- if (element.morphArray && (fx._plot || akeys.indexOf('points') > -1)) {
+ if (element.morphArray && (fx.destination.plot || akeys.indexOf('points') > -1)) {
// get destination
var box
- , p = new element.morphArray(fx._plot || fx.attrs.points || element.array)
+ , p = new element.morphArray(fx.destination.plot || fx.attrs.points || element.array)
// add size
- if (fx._size) p.size(fx._size.width.to, fx._size.height.to)
+ if (fx.destination.size)
+ p.size(fx.destination.size.width.to, fx.destination.size.height.to)
// add movement
box = p.bbox()
- if (fx._x) p.move(fx._x.to, box.y)
- else if (fx._cx) p.move(fx._cx.to - box.width / 2, box.y)
+ if (fx.destination.x)
+ p.move(fx.destination.x.to, box.y)
+ else if (fx.destination.cx)
+ p.move(fx.destination.cx.to - box.width / 2, box.y)
box = p.bbox()
- if (fx._y) p.move(box.x, fx._y.to)
- else if (fx._cy) p.move(box.x, fx._cy.to - box.height / 2)
-
- // delete element oriented changes
- delete fx._x
- delete fx._y
- delete fx._cx
- delete fx._cy
- delete fx._size
-
- fx._plot = element.array.morph(p)
+ if (fx.destination.y)
+ p.move(box.x, fx.destination.y.to)
+ else if (fx.destination.cy)
+ p.move(box.x, fx.destination.cy.to - box.height / 2)
+
+ // reset destination values
+ fx.destination = {
+ plot: element.array.morph(p)
+ }
}
}
@@ -1169,39 +1170,39 @@ SVG.FX = SVG.invent({
pos
// run plot function
- if (fx._plot) {
- element.plot(fx._plot.at(pos))
+ if (fx.destination.plot) {
+ element.plot(fx.destination.plot.at(pos))
} else {
// run all x-position properties
- if (fx._x)
- element.x(fx._x.at(pos))
- else if (fx._cx)
- element.cx(fx._cx.at(pos))
+ if (fx.destination.x)
+ element.x(fx.destination.x.at(pos))
+ else if (fx.destination.cx)
+ element.cx(fx.destination.cx.at(pos))
// run all y-position properties
- if (fx._y)
- element.y(fx._y.at(pos))
- else if (fx._cy)
- element.cy(fx._cy.at(pos))
+ if (fx.destination.y)
+ element.y(fx.destination.y.at(pos))
+ else if (fx.destination.cy)
+ element.cy(fx.destination.cy.at(pos))
// run all size properties
- if (fx._size)
- element.size(fx._size.width.at(pos), fx._size.height.at(pos))
+ if (fx.destination.size)
+ element.size(fx.destination.size.width.at(pos), fx.destination.size.height.at(pos))
}
// run all viewbox properties
- if (fx._viewbox)
+ if (fx.destination.viewbox)
element.viewbox(
- fx._viewbox.x.at(pos)
- , fx._viewbox.y.at(pos)
- , fx._viewbox.width.at(pos)
- , fx._viewbox.height.at(pos)
+ fx.destination.viewbox.x.at(pos)
+ , fx.destination.viewbox.y.at(pos)
+ , fx.destination.viewbox.width.at(pos)
+ , fx.destination.viewbox.height.at(pos)
)
// run leading property
- if (fx._leading)
- element.leading(fx._leading.at(pos))
+ if (fx.destination.leading)
+ element.leading(fx.destination.leading.at(pos))
// animate attributes
for (i = akeys.length - 1; i >= 0; i--)
@@ -1212,8 +1213,8 @@ SVG.FX = SVG.invent({
element.style(skeys[i], at(fx.styles[skeys[i]], pos))
// callback for each keyframe
- if (fx._during)
- fx._during.call(element, pos, function(from, to) {
+ if (fx.situation.during)
+ fx.situation.during.call(element, pos, function(from, to) {
return at({ from: from, to: to }, pos)
})
}
@@ -1224,13 +1225,11 @@ SVG.FX = SVG.invent({
var start = new Date().getTime()
// initialize situation object
- fx.situation = {
- interval: 1000 / 60
- , start: start
- , play: true
- , finish: start + d
- , duration: d
- }
+ fx.situation.start = start
+ fx.situation.play = true
+ fx.situation.finish = start + d
+ fx.situation.duration = d
+ fx.situation.ease = ease
// render function
fx.render = function() {
@@ -1239,21 +1238,37 @@ SVG.FX = SVG.invent({
// calculate pos
var time = new Date().getTime()
, pos = time > fx.situation.finish ? 1 : (time - fx.situation.start) / d
+
+ // reverse pos if animation is reversed
+ if (fx.situation.reversing)
+ pos = -pos + 1
// process values
fx.at(pos)
// finish off animation
if (time > fx.situation.finish) {
- if (fx._plot)
- element.plot(new SVG.PointArray(fx._plot.destination).settle())
-
- if (fx._loop === true || (typeof fx._loop == 'number' && fx._loop > 1)) {
- if (typeof fx._loop == 'number')
- --fx._loop
+ if (fx.destination.plot)
+ element.plot(new SVG.PointArray(fx.destination.plot.destination).settle())
+
+ if (fx.situation.loop === true || (typeof fx.situation.loop == 'number' && fx.situation.loop > 0)) {
+ // register reverse
+ if (fx.situation.reverse)
+ fx.situation.reversing = !fx.situation.reversing
+
+ if (typeof fx.situation.loop == 'number') {
+ // reduce loop count
+ if (!fx.situation.reverse || fx.situation.reversing)
+ --fx.situation.loop
+
+ // remove last loop if reverse is disabled
+ if (!fx.situation.reverse && fx.situation.loop == 1)
+ --fx.situation.loop
+ }
+
fx.animate(d, ease, delay)
} else {
- fx._after ? fx._after.apply(element, [fx]) : fx.stop()
+ fx.situation.after ? fx.situation.after.apply(element, [fx]) : fx.stop()
}
} else {
@@ -1313,25 +1328,25 @@ SVG.FX = SVG.invent({
}
// Animatable x-axis
, x: function(x) {
- this._x = new SVG.Number(this.target.x()).morph(x)
+ this.destination.x = new SVG.Number(this.target.x()).morph(x)
return this
}
// Animatable y-axis
, y: function(y) {
- this._y = new SVG.Number(this.target.y()).morph(y)
+ this.destination.y = new SVG.Number(this.target.y()).morph(y)
return this
}
// Animatable center x-axis
, cx: function(x) {
- this._cx = new SVG.Number(this.target.cx()).morph(x)
+ this.destination.cx = new SVG.Number(this.target.cx()).morph(x)
return this
}
// Animatable center y-axis
, cy: function(y) {
- this._cy = new SVG.Number(this.target.cy()).morph(y)
+ this.destination.cy = new SVG.Number(this.target.cy()).morph(y)
return this
}
@@ -1353,7 +1368,7 @@ SVG.FX = SVG.invent({
// animate bbox based size for all other elements
var box = this.target.bbox()
- this._size = {
+ this.destination.size = {
width: new SVG.Number(box.width).morph(width)
, height: new SVG.Number(box.height).morph(height)
}
@@ -1363,14 +1378,14 @@ SVG.FX = SVG.invent({
}
// Add animatable plot
, plot: function(p) {
- this._plot = p
+ this.destination.plot = p
return this
}
// Add leading method
, leading: function(value) {
- if (this.target._leading)
- this._leading = new SVG.Number(this.target._leading).morph(value)
+ if (this.target.destination.leading)
+ this.destination.leading = new SVG.Number(this.target.destination.leading).morph(value)
return this
}
@@ -1379,7 +1394,7 @@ SVG.FX = SVG.invent({
if (this.target instanceof SVG.Container) {
var box = this.target.viewbox()
- this._viewbox = {
+ this.destination.viewbox = {
x: new SVG.Number(box.x).morph(x)
, y: new SVG.Number(box.y).morph(y)
, width: new SVG.Number(box.width).morph(width)
@@ -1401,19 +1416,23 @@ SVG.FX = SVG.invent({
}
// Add callback for each keyframe
, during: function(during) {
- this._during = during
+ this.situation.during = during
return this
}
// Callback after animation
, after: function(after) {
- this._after = after
+ this.situation.after = after
return this
}
// Make loopable
- , loop: function(times) {
- this._loop = times || true
+ , loop: function(times, reverse) {
+ // store current loop and total loops
+ this.situation.loop = this.situation.loops = times || true
+
+ // make reversable
+ this.situation.reverse = !!reverse
return this
}
@@ -1424,31 +1443,18 @@ SVG.FX = SVG.invent({
this.animate(0)
- if (this._after)
- this._after.apply(this.target, [this])
+ if (this.situation.after)
+ this.situation.after.apply(this.target, [this])
} else {
// stop current animation
clearTimeout(this.timeout)
- // reset storage for properties that need animation
- this.attrs = {}
- this.trans = {}
- this.styles = {}
- this.situation = {}
-
- // delete destinations
- delete this._x
- delete this._y
- delete this._cx
- delete this._cy
- delete this._size
- delete this._plot
- delete this._loop
- delete this._after
- delete this._during
- delete this._leading
- delete this._viewbox
+ // reset storage for properties
+ this.attrs = {}
+ this.styles = {}
+ this.situation = {}
+ this.destination = {}
}
return this
@@ -2015,10 +2021,10 @@ SVG.Parent = SVG.invent({
// Add given element at a position
, add: function(element, i) {
if (!this.has(element)) {
- // Define insertion index if none given
+ // define insertion index if none given
i = i == null ? this.children().length : i
- // Add element references
+ // add element references
this.node.insertBefore(element.node, this.node.childNodes[i] || null)
}
@@ -3666,7 +3672,7 @@ SVG.Set = SVG.invent({
, remove: function(element) {
var i = this.index(element)
- /* remove given child */
+ // remove given child
if (i > -1)
this.members.splice(i, 1)
@@ -3681,7 +3687,7 @@ SVG.Set = SVG.invent({
}
// Restore to defaults
, clear: function() {
- /* initialize store */
+ // initialize store
this.members = []
return this
@@ -3714,11 +3720,11 @@ SVG.Set = SVG.invent({
, bbox: function(){
var box = new SVG.BBox()
- /* return an empty box of there are no members */
+ // return an empty box of there are no members
if (this.members.length == 0)
return box
- /* get the first rbox and update the target bbox */
+ // get the first rbox and update the target bbox
var rbox = this.members[0].rbox()
box.x = rbox.x
box.y = rbox.y
@@ -3726,7 +3732,7 @@ SVG.Set = SVG.invent({
box.height = rbox.height
this.each(function() {
- /* user rbox for correct position and visual representation */
+ // user rbox for correct position and visual representation
box = box.merge(this.rbox())
})
@@ -3743,10 +3749,10 @@ SVG.Set = SVG.invent({
}
})
-SVG.SetFX = SVG.invent({
+SVG.FX.Set = SVG.invent({
// Initialize node
create: function(set) {
- /* store reference to set */
+ // store reference to set
this.set = set
}
@@ -3757,33 +3763,33 @@ SVG.Set.inherit = function() {
var m
, methods = []
- /* gather shape methods */
+ // gather shape methods
for(var m in SVG.Shape.prototype)
if (typeof SVG.Shape.prototype[m] == 'function' && typeof SVG.Set.prototype[m] != 'function')
methods.push(m)
- /* apply shape aliasses */
+ // apply shape aliasses
methods.forEach(function(method) {
SVG.Set.prototype[method] = function() {
for (var i = 0, il = this.members.length; i < il; i++)
if (this.members[i] && typeof this.members[i][method] == 'function')
this.members[i][method].apply(this.members[i], arguments)
- return method == 'animate' ? (this.fx || (this.fx = new SVG.SetFX(this))) : this
+ return method == 'animate' ? (this.fx || (this.fx = new SVG.FX.Set(this))) : this
}
})
- /* clear methods for the next round */
+ // clear methods for the next round
methods = []
- /* gather fx methods */
+ // gather fx methods
for(var m in SVG.FX.prototype)
- if (typeof SVG.FX.prototype[m] == 'function' && typeof SVG.SetFX.prototype[m] != 'function')
+ if (typeof SVG.FX.prototype[m] == 'function' && typeof SVG.FX.Set.prototype[m] != 'function')
methods.push(m)
- /* apply fx aliasses */
+ // apply fx aliasses
methods.forEach(function(method) {
- SVG.SetFX.prototype[method] = function() {
+ SVG.FX.Set.prototype[method] = function() {
for (var i = 0, il = this.set.members.length; i < il; i++)
this.set.members[i].fx[method].apply(this.set.members[i].fx, arguments)
diff --git a/dist/svg.min.js b/dist/svg.min.js
index c1230fa..5465e35 100755
--- a/dist/svg.min.js
+++ b/dist/svg.min.js
@@ -1,2 +1,2 @@
-/*! SVG.js v1.0.0-rc.10 MIT*/(function(){function t(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function e(t){return t.charAt(0).toUpperCase()+t.slice(1)}function i(t){return 4==t.length?["#",t.substring(1,2),t.substring(1,2),t.substring(2,3),t.substring(2,3),t.substring(3,4),t.substring(3,4)].join(""):t}function n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(t,e,i){return null==i?i=t.height/t.width*e:null==e&&(e=t.width/t.height*i),{width:e,height:i}}function s(t,e,i){return{x:e*t.a+i*t.c+0,y:e*t.b+i*t.d+0}}function h(t){return{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}}function o(t){return t instanceof m.Matrix||(t=new m.Matrix(t)),t}function a(t){return t=t.replace(m.regex.whitespace,"").replace(m.regex.matrix,"").split(","),h(m.utils.map(t,function(t){return parseFloat(t)}))}function u(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof m.Color||t instanceof m.Number||t instanceof m.Matrix?t.at(e):1>e?t.from:t.to}function l(t){for(var e=0,i=t.length,n="";i>e;e++)n+=t[e][0],null!=t[e][1]&&(n+=t[e][1],null!=t[e][2]&&(n+=" ",n+=t[e][2],null!=t[e][3]&&(n+=" ",n+=t[e][3],n+=" ",n+=t[e][4],null!=t[e][5]&&(n+=" ",n+=t[e][5],n+=" ",n+=t[e][6],null!=t[e][7]&&(n+=" ",n+=t[e][7])))));return n+" "}function c(t){for(var e=t.childNodes.length-1;e>=0;e--)t.childNodes[e]instanceof SVGElement&&c(t.childNodes[e]);return m.adopt(t).id(m.eid(t.nodeName))}function f(t){return t.x2=t.x+t.width,t.y2=t.y+t.height,t.cx=t.x+t.width/2,t.cy=t.y+t.height/2,t}function d(t){var e=t.toString().match(m.regex.reference);return e?e[1]:void 0}function p(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}var m=this.SVG=function(t){return m.supported?(t=new m.Doc(t),m.parser||m.prepare(t),t):void 0};if(m.ns="http://www.w3.org/2000/svg",m.xmlns="http://www.w3.org/2000/xmlns/",m.xlink="http://www.w3.org/1999/xlink",m.supported=function(){return!!document.createElementNS&&!!document.createElementNS(m.ns,"svg").createSVGRect}(),!m.supported)return!1;m.did=1e3,m.eid=function(t){return"Svgjs"+e(t)+m.did++},m.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},m.extend=function(){var t,e,i,n;for(t=[].slice.call(arguments),e=t.pop(),n=t.length-1;n>=0;n--)if(t[n])for(i in e)t[n].prototype[i]=e[i];m.Set&&m.Set.inherit&&m.Set.inherit()},m.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,m.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&m.extend(e,t.extend),t.construct&&m.extend(t.parent||m.Container,t.construct),e},m.adopt=function(t){if(t.instance)return t.instance;var i;return i="svg"==t.nodeName?t.parentNode instanceof SVGElement?new m.Nested:new m.Doc:"lineairGradient"==t.nodeName?new m.Gradient("lineair"):"radialGradient"==t.nodeName?new m.Gradient("radial"):m[e(t.nodeName)]?new(m[e(t.nodeName)]):new m.Element(t),i.type=t.nodeName,i.node=t,t.instance=i,i instanceof m.Doc&&i.namespace().defs(),i},m.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new m.Doc(e):t.nested()).size(2,0),n=m.create("path");i.node.appendChild(n),m.parser={body:e||t.parent(),draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},m.regex={unit:/^(-?[\d\.]+)([a-z%]{0,2})$/,hex:/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,rgb:/rgb\((\d+),(\d+),(\d+)\)/,reference:/#([a-z0-9\-_]+)/i,matrix:/matrix\(|\)/g,whitespace:/\s/g,isHex:/^#[a-f0-9]{3,6}$/i,isRgb:/^rgb\(/,isCss:/[^:]+:[^;]+;?/,isBlank:/^(\s+)?$/,isNumber:/^-?[\d\.]+$/,isPercent:/^-?[\d\.]+%$/,isImage:/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i},m.utils={map:function(t,e){var i,n=t.length,r=[];for(i=0;n>i;i++)r.push(e(t[i]));return r},radians:function(t){return t%360*Math.PI/180},degrees:function(t){return 180*t/Math.PI%360}},m.defaults={attrs:{"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","font-size":16,"font-family":"Helvetica, Arial, sans-serif","text-anchor":"start"}},m.Color=function(t){var e;this.r=0,this.g=0,this.b=0,"string"==typeof t?m.regex.isRgb.test(t)?(e=m.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):m.regex.isHex.test(t)&&(e=m.regex.hex.exec(i(t)),this.r=parseInt(e[1],16),this.g=parseInt(e[2],16),this.b=parseInt(e[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},m.extend(m.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+n(this.r)+n(this.g)+n(this.b)},toRgb:function(){return"rgb("+[this.r,this.g,this.b].join()+")"},brightness:function(){return this.r/255*.3+this.g/255*.59+this.b/255*.11},morph:function(t){return this.destination=new m.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new m.Color({r:~~(this.r+(this.destination.r-this.r)*t),g:~~(this.g+(this.destination.g-this.g)*t),b:~~(this.b+(this.destination.b-this.b)*t)})):this}}),m.Color.test=function(t){return t+="",m.regex.isHex.test(t)||m.regex.isRgb.test(t)},m.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},m.Color.isColor=function(t){return m.Color.isRgb(t)||m.Color.test(t)},m.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},m.extend(m.Array,{morph:function(t){if(this.destination=this.parse(t),this.value.length!=this.destination.length){for(var e=this.value[this.value.length-1],i=this.destination[this.destination.length-1];this.value.length>this.destination.length;)this.destination.push(i);for(;this.value.length<this.destination.length;)this.value.push(e)}return this},settle:function(){for(var t=0,e=this.value.length,i=[];e>t;t++)-1==i.indexOf(this.value[t])&&i.push(this.value[t]);return this.value=i},at:function(t){if(!this.destination)return this;for(var e=0,i=this.value.length,n=[];i>e;e++)n.push(this.value[e]+(this.destination[e]-this.value[e])*t);return new m.Array(n)},toString:function(){return this.value.join(" ")},valueOf:function(){return this.value},parse:function(t){return t=t.valueOf(),Array.isArray(t)?t:this.split(t)},split:function(t){return t.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"").split(" ")},reverse:function(){return this.value.reverse(),this}}),m.PointArray=function(t,e){this.constructor.call(this,t,e||[[0,0]])},m.PointArray.prototype=new m.Array,m.extend(m.PointArray,{toString:function(){for(var t=0,e=this.value.length,i=[];e>t;t++)i.push(this.value[t].join(","));return i.join(" ")},toLine:function(){return{x1:this.value[0][0],y1:this.value[0][1],x2:this.value[1][0],y2:this.value[1][1]}},at:function(t){if(!this.destination)return this;for(var e=0,i=this.value.length,n=[];i>e;e++)n.push([this.value[e][0]+(this.destination[e][0]-this.value[e][0])*t,this.value[e][1]+(this.destination[e][1]-this.value[e][1])*t]);return new m.PointArray(n)},parse:function(t){if(t=t.valueOf(),Array.isArray(t))return t;t=this.split(t);for(var e,i=0,n=t.length,r=[];n>i;i++)e=t[i].split(","),r.push([parseFloat(e[0]),parseFloat(e[1])]);return r},move:function(t,e){var i=this.bbox();if(t-=i.x,e-=i.y,!isNaN(t)&&!isNaN(e))for(var n=this.value.length-1;n>=0;n--)this.value[n]=[this.value[n][0]+t,this.value[n][1]+e];return this},size:function(t,e){var i,n=this.bbox();for(i=this.value.length-1;i>=0;i--)this.value[i][0]=(this.value[i][0]-n.x)*t/n.width+n.x,this.value[i][1]=(this.value[i][1]-n.y)*e/n.height+n.y;return this},bbox:function(){return m.parser.poly.setAttribute("points",this.toString()),m.parser.poly.getBBox()}}),m.PathArray=function(t,e){this.constructor.call(this,t,e||[["M",0,0]])},m.PathArray.prototype=new m.Array,m.extend(m.PathArray,{toString:function(){return l(this.value)},move:function(t,e){var i=this.bbox();if(t-=i.x,e-=i.y,!isNaN(t)&&!isNaN(e))for(var n,r=this.value.length-1;r>=0;r--)n=this.value[r][0],"M"==n||"L"==n||"T"==n?(this.value[r][1]+=t,this.value[r][2]+=e):"H"==n?this.value[r][1]+=t:"V"==n?this.value[r][1]+=e:"C"==n||"S"==n||"Q"==n?(this.value[r][1]+=t,this.value[r][2]+=e,this.value[r][3]+=t,this.value[r][4]+=e,"C"==n&&(this.value[r][5]+=t,this.value[r][6]+=e)):"A"==n&&(this.value[r][6]+=t,this.value[r][7]+=e);return this},size:function(t,e){var i,n,r=this.bbox();for(i=this.value.length-1;i>=0;i--)n=this.value[i][0],"M"==n||"L"==n||"T"==n?(this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x,this.value[i][2]=(this.value[i][2]-r.y)*e/r.height+r.y):"H"==n?this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x:"V"==n?this.value[i][1]=(this.value[i][1]-r.y)*e/r.height+r.y:"C"==n||"S"==n||"Q"==n?(this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x,this.value[i][2]=(this.value[i][2]-r.y)*e/r.height+r.y,this.value[i][3]=(this.value[i][3]-r.x)*t/r.width+r.x,this.value[i][4]=(this.value[i][4]-r.y)*e/r.height+r.y,"C"==n&&(this.value[i][5]=(this.value[i][5]-r.x)*t/r.width+r.x,this.value[i][6]=(this.value[i][6]-r.y)*e/r.height+r.y)):"A"==n&&(this.value[i][1]=this.value[i][1]*t/r.width,this.value[i][2]=this.value[i][2]*e/r.height,this.value[i][6]=(this.value[i][6]-r.x)*t/r.width+r.x,this.value[i][7]=(this.value[i][7]-r.y)*e/r.height+r.y);return this},parse:function(t){if(t instanceof m.PathArray)return t.valueOf();var e,i,n,r,s,h,o,a,u,c,f,d=0,p=0;for(m.parser.path.setAttribute("d","string"==typeof t?t:l(t)),f=m.parser.path.pathSegList,e=0,i=f.numberOfItems;i>e;++e)c=f.getItem(e),u=c.pathSegTypeAsLetter,"M"==u||"L"==u||"H"==u||"V"==u||"C"==u||"S"==u||"Q"==u||"T"==u||"A"==u?("x"in c&&(d=c.x),"y"in c&&(p=c.y)):("x1"in c&&(s=d+c.x1),"x2"in c&&(o=d+c.x2),"y1"in c&&(h=p+c.y1),"y2"in c&&(a=p+c.y2),"x"in c&&(d+=c.x),"y"in c&&(p+=c.y),"m"==u?f.replaceItem(m.parser.path.createSVGPathSegMovetoAbs(d,p),e):"l"==u?f.replaceItem(m.parser.path.createSVGPathSegLinetoAbs(d,p),e):"h"==u?f.replaceItem(m.parser.path.createSVGPathSegLinetoHorizontalAbs(d),e):"v"==u?f.replaceItem(m.parser.path.createSVGPathSegLinetoVerticalAbs(p),e):"c"==u?f.replaceItem(m.parser.path.createSVGPathSegCurvetoCubicAbs(d,p,s,h,o,a),e):"s"==u?f.replaceItem(m.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(d,p,o,a),e):"q"==u?f.replaceItem(m.parser.path.createSVGPathSegCurvetoQuadraticAbs(d,p,s,h),e):"t"==u?f.replaceItem(m.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(d,p),e):"a"==u?f.replaceItem(m.parser.path.createSVGPathSegArcAbs(d,p,c.r1,c.r2,c.angle,c.largeArcFlag,c.sweepFlag),e):("z"==u||"Z"==u)&&(d=n,p=r)),("M"==u||"m"==u)&&(n=d,r=p);for(t=[],f=m.parser.path.pathSegList,e=0,i=f.numberOfItems;i>e;++e)c=f.getItem(e),u=c.pathSegTypeAsLetter,d=[u],"M"==u||"L"==u||"T"==u?d.push(c.x,c.y):"H"==u?d.push(c.x):"V"==u?d.push(c.y):"C"==u?d.push(c.x1,c.y1,c.x2,c.y2,c.x,c.y):"S"==u?d.push(c.x2,c.y2,c.x,c.y):"Q"==u?d.push(c.x1,c.y1,c.x,c.y):"A"==u&&d.push(c.r1,c.r2,c.angle,0|c.largeArcFlag,0|c.sweepFlag,c.x,c.y),t.push(d);return t},bbox:function(){return m.parser.path.setAttribute("d",this.toString()),m.parser.path.getBBox()}}),m.Number=m.invent({create:function(t){if(this.value=0,this.unit="","number"==typeof t)this.value=isNaN(t)?0:isFinite(t)?t:0>t?-3.4e38:3.4e38;else if("string"==typeof t){var e=t.match(m.regex.unit);e&&(this.value=parseFloat(e[1]),"%"==e[2]?this.value/=100:"s"==e[2]&&(this.value*=1e3),this.unit=e[2])}else t instanceof m.Number&&(this.value=t.value,this.unit=t.unit)},extend:{toString:function(){return("%"==this.unit?~~(1e8*this.value)/1e6:"s"==this.unit?this.value/1e3:this.value)+this.unit},valueOf:function(){return this.value},plus:function(t){return this.value=this+new m.Number(t),this},minus:function(t){return this.plus(-new m.Number(t))},times:function(t){return this.value=this*new m.Number(t),this},divide:function(t){return this.value=this/new m.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new m.Number(t),this},at:function(t){return this.destination?new m.Number(this.destination).minus(this).times(t).plus(this):this}}}),m.ViewBox=function(t){var e,i,n,r,s=1,h=1,o=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,l=t;for(n=new m.Number(t.width()),r=new m.Number(t.height());"%"==n.unit;)s*=n.value,n=new m.Number(u instanceof m.Doc?u.parent().offsetWidth:u.parent().width()),u=u.parent();for(;"%"==r.unit;)h*=r.value,r=new m.Number(l instanceof m.Doc?l.parent().offsetHeight:l.parent().height()),l=l.parent();this.x=o.x,this.y=o.y,this.width=n*s,this.height=r*h,this.zoom=1,a&&(e=parseFloat(a[0]),i=parseFloat(a[1]),n=parseFloat(a[2]),r=parseFloat(a[3]),this.zoom=this.width/this.height>n/r?this.height/r:this.width/n,this.x=e,this.y=i,this.width=n,this.height=r)},m.extend(m.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),m.Element=m.invent({create:function(t){this._stroke=m.defaults.attrs.stroke,(this.node=t)&&(this.type=t.nodeName,this.node.instance=this,this._stroke=t.getAttribute("stroke")||this._stroke)},extend:{x:function(t){return null!=t&&(t=new m.Number(t),t.value/=this.transform("scaleX")),this.attr("x",t)},y:function(t){return null!=t&&(t=new m.Number(t),t.value/=this.transform("scaleY")),this.attr("y",t)},cx:function(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)},cy:function(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},width:function(t){return this.attr("width",t)},height:function(t){return this.attr("height",t)},size:function(t,e){var i=r(this.bbox(),t,e);return this.width(new m.Number(i.width)).height(new m.Number(i.height))},clone:function(){return c(this.node.cloneNode(!0))},remove:function(){return this.parent()&&this.parent().removeElement(this),this},replace:function(t){return this.after(t).remove(),t},addTo:function(t){return t.put(this)},putIn:function(t){return t.add(this)},id:function(t){return this.attr("id",t)},inside:function(t,e){var i=this.bbox();return t>i.x&&e>i.y&&t<i.x+i.width&&e<i.y+i.height},show:function(){return this.style("display","")},hide:function(){return this.style("display","none")},visible:function(){return"none"!=this.style("display")},toString:function(){return this.attr("id")},classes:function(){var t=this.attr("class");return null==t?[]:t.trim().split(/\s+/)},hasClass:function(t){return-1!=this.classes().indexOf(t)},addClass:function(t){if(!this.hasClass(t)){var e=this.classes();e.push(t),this.attr("class",e.join(" "))}return this},removeClass:function(t){return this.hasClass(t)&&this.attr("class",this.classes().filter(function(e){return e!=t}).join(" ")),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t)},reference:function(t){return m.get(this.attr(t))},parent:function(t){var e=m.adopt(this.node.parentNode);if(t)for(;!(e instanceof t);)e=m.adopt(e.node.parentNode);return e},doc:function(t){return this.parent(t||m.Doc)},"native":function(){return this.node}}}),m.FX=m.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,s,h=this.target,o=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new m.Number(t).valueOf(),e=e||"<>",o.at=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(s in o.attrs)n.push(s);if(h.morphArray&&(o._plot||n.indexOf("points")>-1)){var a,l=new h.morphArray(o._plot||o.attrs.points||h.array);o._size&&l.size(o._size.width.to,o._size.height.to),a=l.bbox(),o._x?l.move(o._x.to,a.y):o._cx&&l.move(o._cx.to-a.width/2,a.y),a=l.bbox(),o._y?l.move(a.x,o._y.to):o._cy&&l.move(a.x,o._cy.to-a.height/2),delete o._x,delete o._y,delete o._cx,delete o._cy,delete o._size,o._plot=h.array.morph(l)}}if(null==r){r=[];for(s in o.styles)r.push(s)}for(t="<>"==e?-Math.cos(t*Math.PI)/2+.5:">"==e?Math.sin(t*Math.PI/2):"<"==e?-Math.cos(t*Math.PI/2)+1:"-"==e?t:"function"==typeof e?e(t):t,o._plot?h.plot(o._plot.at(t)):(o._x?h.x(o._x.at(t)):o._cx&&h.cx(o._cx.at(t)),o._y?h.y(o._y.at(t)):o._cy&&h.cy(o._cy.at(t)),o._size&&h.size(o._size.width.at(t),o._size.height.at(t))),o._viewbox&&h.viewbox(o._viewbox.x.at(t),o._viewbox.y.at(t),o._viewbox.width.at(t),o._viewbox.height.at(t)),o._leading&&h.leading(o._leading.at(t)),i=n.length-1;i>=0;i--)h.attr(n[i],u(o.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)h.style(r[i],u(o.styles[r[i]],t));o._during&&o._during.call(h,t,function(e,i){return u({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();o.situation={interval:1e3/60,start:n,play:!0,finish:n+t,duration:t},o.render=function(){if(o.situation.play===!0){var n=(new Date).getTime(),r=n>o.situation.finish?1:(n-o.situation.start)/t;o.at(r),n>o.situation.finish?(o._plot&&h.plot(new m.PointArray(o._plot.destination).settle()),o._loop===!0||"number"==typeof o._loop&&o._loop>1?("number"==typeof o._loop&&--o._loop,o.animate(t,e,i)):o._after?o._after.apply(h,[o]):o.stop()):requestAnimFrame(o.render)}else requestAnimFrame(o.render)},o.render()},new m.Number(i).valueOf())),this},bbox:function(){return this.target.bbox()},attr:function(t,e){if("object"==typeof t)for(var i in t)this.attr(i,t[i]);else{var n=this.target.attr(t);this.attrs[t]="transform"==t?this.target.ctm().morph(e):m.Color.isColor(n)?new m.Color(n).morph(e):m.regex.unit.test(n)?new m.Number(n).morph(e):{from:n,to:e}}return this},style:function(t,e){if("object"==typeof t)for(var i in t)this.style(i,t[i]);else this.styles[t]={from:this.target.style(t),to:e};return this},x:function(t){return this._x=new m.Number(this.target.x()).morph(t),this},y:function(t){return this._y=new m.Number(this.target.y()).morph(t),this},cx:function(t){return this._cx=new m.Number(this.target.cx()).morph(t),this},cy:function(t){return this._cy=new m.Number(this.target.cy()).morph(t),this},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},size:function(t,e){if(this.target instanceof m.Text)this.attr("font-size",t);else{var i=this.target.bbox();this._size={width:new m.Number(i.width).morph(t),height:new m.Number(i.height).morph(e)}}return this},plot:function(t){return this._plot=t,this},leading:function(t){return this.target._leading&&(this._leading=new m.Number(this.target._leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof m.Container){var r=this.target.viewbox();this._viewbox={x:new m.Number(r.x).morph(t),y:new m.Number(r.y).morph(e),width:new m.Number(r.width).morph(i),height:new m.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof m.Stop&&(null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new m.Number(t.offset))),this},during:function(t){return this._during=t,this},after:function(t){return this._after=t,this},loop:function(t){return this._loop=t||!0,this},stop:function(t){return t===!0?(this.animate(0),this._after&&this._after.apply(this.target,[this])):(clearTimeout(this.timeout),this.attrs={},this.trans={},this.styles={},this.situation={},delete this._x,delete this._y,delete this._cx,delete this._cy,delete this._size,delete this._plot,delete this._loop,delete this._after,delete this._during,delete this._leading,delete this._viewbox),this},pause:function(){return this.situation.play===!0&&(this.situation.play=!1,this.situation.pause=(new Date).getTime()),this},play:function(){if(this.situation.play===!1){var t=(new Date).getTime()-this.situation.pause;this.situation.finish+=t,this.situation.start+=t,this.situation.play=!0}return this}},parent:m.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new m.FX(this))).stop().animate(t,e,i)},stop:function(t){return this.fx&&this.fx.stop(t),this},pause:function(){return this.fx&&this.fx.pause(),this},play:function(){return this.fx&&this.fx.play(),this}}}),m.BBox=m.invent({create:function(t){var e;if(this.x=0,this.y=0,this.width=0,this.height=0,t){var i=new m.Matrix(t).extract();e=t.node.getBBox?t.node.getBBox():{x:t.node.clientLeft,y:t.node.clientTop,width:t.node.clientWidth,height:t.node.clientHeight},this.x=e.x+i.x,this.y=e.y+i.y,this.width=e.width*i.scaleX,this.height=e.height*i.scaleY}f(this)},parent:m.Element,construct:{bbox:function(){return new m.BBox(this)}}}),m.RBox=m.invent({create:function(t){var e={};if(this.x=0,this.y=0,this.width=0,this.height=0,t){var i=t.doc().parent(),n=1;for(e=t.node.getBoundingClientRect(),this.x=e.left,this.y=e.top,this.x-=i.offsetLeft,this.y-=i.offsetTop;i=i.offsetParent;)this.x-=i.offsetLeft,this.y-=i.offsetTop;for(i=t;i.parent&&(i=i.parent());)i.viewbox&&(n*=i.viewbox().zoom,this.x-=i.x()||0,this.y-=i.y()||0)}this.width=e.width/=n,this.height=e.height/=n,this.x+=window.scrollX,this.y+=window.scrollY,f(this)},parent:m.Element,construct:{rbox:function(){return new m.RBox(this)}}}),[m.BBox,m.RBox].forEach(function(t){m.extend(t,{merge:function(e){var i=new t;return i.x=Math.min(this.x,e.x),i.y=Math.min(this.y,e.y),i.width=Math.max(this.x+this.width,e.x+e.width)-i.x,i.height=Math.max(this.y+this.height,e.y+e.height)-i.y,f(i)}})}),m.Matrix=m.invent({create:function(t){var e,i=h([1,0,0,1,0,0]);for(t=t&&t.node&&t.node.getCTM?t.node.getCTM():"string"==typeof t?a(t):6==arguments.length?h([].slice.call(arguments)):"object"==typeof t?t:i,e=g.length-1;e>=0;e--)this[g[e]]="number"==typeof t[g[e]]?t[g[e]]:i[g[e]]},extend:{extract:function(){var t=s(this,0,1),e=s(this,1,0),i=180/Math.PI*Math.atan2(t.y,t.x)-90;return{x:this.e,y:this.f,skewX:-i,skewY:180/Math.PI*Math.atan2(e.y,e.x),scaleX:Math.sqrt(this.a*this.a+this.b*this.b),scaleY:Math.sqrt(this.c*this.c+this.d*this.d),rotation:i}},clone:function(){return new m.Matrix(this)},morph:function(t){return this.destination=new m.Matrix(t),this},at:function(t){return this.destination?new m.Matrix({a:this.a+(this.destination.a-this.a)*t,b:this.b+(this.destination.b-this.b)*t,c:this.c+(this.destination.c-this.c)*t,d:this.d+(this.destination.d-this.d)*t,e:this.e+(this.destination.e-this.e)*t,f:this.f+(this.destination.f-this.f)*t}):this},multiply:function(t){return new m.Matrix(this.native().multiply(o(t).native()))},add:function(t){return t=o(t),new m.Matrix({a:this.a+t.a-1,b:this.b+t.b,c:this.c+t.c,d:this.d+t.d-1,e:this.e+t.e,f:this.f+t.f})},inverse:function(){return new m.Matrix(this.native().inverse())},translate:function(t,e){return new m.Matrix(this.native().translate(t||0,e||0))},scale:function(t,e,i,n){return(1==arguments.length||3==arguments.length)&&(e=t),3==arguments.length&&(n=i,i=e),this.around(i,n,new m.Matrix(t,0,0,e,0,0))},rotate:function(t,e,i){return t=m.utils.radians(t),this.around(e,i,new m.Matrix(Math.cos(t),Math.sin(t),-Math.sin(t),Math.cos(t),0,0))},flip:function(t,e){return"x"==t?this.scale(-1,1,e,0):this.scale(1,-1,0,e)},skew:function(t,e,i,n){return this.around(i,n,this.native().skewX(t||0).skewY(e||0))},around:function(t,e,i){return this.multiply(new m.Matrix(1,0,0,1,t||0,e||0)).multiply(i).multiply(new m.Matrix(1,0,0,1,-t||0,-e||0))},"native":function(){for(var t=m.parser.draw.node.createSVGMatrix(),e=g.length-1;e>=0;e--)t[g[e]]=this[g[e]];return t},toString:function(){return"matrix("+[this.a,this.b,this.c,this.d,this.e,this.f].join()+")"}},parent:m.Element,construct:{ctm:function(){return new m.Matrix(this)}}}),m.extend(m.Element,{attr:function(t,e,i){if(null==t){for(t={},e=this.node.attributes,i=e.length-1;i>=0;i--)t[e[i].nodeName]=m.regex.isNumber.test(e[i].nodeValue)?parseFloat(e[i].nodeValue):e[i].nodeValue;return t}if("object"==typeof t)for(e in t)this.attr(e,t[e]);else if(null===e)this.node.removeAttribute(t);else{if(null==e)return e=this.node.getAttribute(t),null==e?m.defaults.attrs[t]:m.regex.isNumber.test(e)?parseFloat(e):e;"stroke-width"==t?this.attr("stroke",parseFloat(e)>0?this._stroke:null):"stroke"==t&&(this._stroke=e),("fill"==t||"stroke"==t)&&(m.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof m.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new m.Number(e):m.Color.isColor(e)?e=new m.Color(e):Array.isArray(e)&&(e=new m.Array(e)),"leading"==t?this.leading&&this.leading(e):"string"==typeof i?this.node.setAttributeNS(i,t,e.toString()):this.node.setAttribute(t,e.toString()),!this.rebuild||"font-size"!=t&&"x"!=t||this.rebuild(t,e)}return this}}),m.extend(m.Element,m.FX,{transform:function(t){var e=this.target||this;if(null==t)return e.ctm().extract();if("string"==typeof t)return e.ctm().extract()[t];var i=new m.Matrix(e);return null!=t.a?i=i.multiply(new m.Matrix(t)):t.rotation?i=i.rotate(t.rotation,null==t.cx?e.bbox().cx:t.cx,null==t.cy?e.bbox().cy:t.cy):null!=t.scale||null!=t.scaleX||null!=t.scaleY?i=i.scale(null!=t.scale?t.scale:null!=t.scaleX?t.scaleX:1,null!=t.scale?t.scale:null!=t.scaleY?t.scaleY:1,null==t.cx?e.bbox().x:t.cx,null==t.cy?e.bbox().y:t.cy):t.skewX||t.skewY?i=i.skew(t.skewX,t.skewY,null==t.cx?e.bbox().cx:t.cx,null==t.cy?e.bbox().cy:t.cy):t.flip?i=i.flip(t.flip,null==t.offset?e.bbox()["c"+t.flip]:t.offset):(t.x||t.y)&&(i=i.translate(t.x,t.y)),this.attr("transform",i)}}),m.extend(m.Element,{untransform:function(){return this.attr("transform",null)}}),m.extend(m.Element,{style:function(e,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof e)for(i in e)this.style(i,e[i]);else{if(!m.regex.isCss.test(e))return this.node.style[t(e)];e=e.split(";");for(var n=0;n<e.length;n++)i=e[n].split(":"),this.style(i[0].replace(/\s+/g,""),i[1])}else this.node.style[t(e)]=null===i||m.regex.isBlank.test(i)?"":i;return this}}),m.Parent=m.invent({create:function(t){this.constructor.call(this,t)},inherit:m.Element,extend:{children:function(){return m.utils.map(this.node.childNodes,function(t){return m.adopt(t)})},add:function(t,e){return this.has(t)||(e=null==e?this.children().length:e,this.node.insertBefore(t.node,this.node.childNodes[e]||null)),this},put:function(t,e){return this.add(t,e),t},has:function(t){return this.index(t)>=0},index:function(t){return this.children().indexOf(t)},get:function(t){return this.children()[t]},first:function(){return this.children()[0]},last:function(){return this.children()[this.children().length-1]},each:function(t,e){var i,n,r=this.children();for(i=0,n=r.length;n>i;i++)r[i]instanceof m.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof m.Container&&r[i].each(t,e);return this},removeElement:function(t){return this.node.removeChild(t.node),this},clear:function(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return delete this._defs,this},defs:function(){return this.doc().defs()}}}),m.Container=m.invent({create:function(t){this.constructor.call(this,t)},inherit:m.Parent,extend:{viewbox:function(t){return 0==arguments.length?new m.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),m.extend(m.Parent,m.Text,{svg:function(t){var e=document.createElement("div");if(t){t=t.replace(/\n/,"").replace(/<(\w+)([^<]+?)\/>/g,"<$1$2></$1>"),e.innerHTML="<svg>"+t+"</svg>";for(var i=e.firstChild.childNodes.length-1;i>=0;i--)1==e.firstChild.childNodes[i].nodeType&&this.node.appendChild(e.firstChild.childNodes[i]);return this}var n=this.node.cloneNode(!0);return e.appendChild(n),e.innerHTML}}),m.extend(m.Element,m.FX,{dx:function(t){return this.x((this.target||this).x()+t)},dy:function(t){return this.y((this.target||this).y()+t)},dmove:function(t,e){return this.dx(t).dy(e)}}),["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){m.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),m.events={},m.listeners={},m.registerEvent=function(t){m.events[t]||(m.events[t]=new p(t))},m.on=function(t,e,i){var n=i.bind(t.instance||t);m.listeners[i]=n,t.addEventListener(e,n,!1)},m.off=function(t,e,i){t.removeEventListener(e,m.listeners[i],!1),delete m.listeners[i]},m.extend(m.Element,{on:function(t,e){return m.on(this.node,t,e),this},off:function(t,e){return m.off(this.node,t,e),this},fire:function(t,e){return m.events[t].detail=e,this.node.dispatchEvent(m.events[t]),delete m.events[t].detail,this}}),m.Defs=m.invent({create:"defs",inherit:m.Container}),m.G=m.invent({create:"g",inherit:m.Container,extend:{x:function(t){return this.transform(null==t?"x":{x:-this.x()+t})},y:function(t){return this.transform(null==t?"y":{y:-this.y()+t})},cx:function(t){return null==t?this.bbox().cx:this.x(t-this.bbox().width/2)},cy:function(t){return null==t?this.bbox().cy:this.y(t-this.bbox().height/2)}},construct:{group:function(){return this.put(new m.G)}}}),m.extend(m.Element,{siblings:function(){return this.parent().children()},position:function(){return this.parent().index(this)},next:function(){return this.siblings()[this.position()+1]},previous:function(){return this.siblings()[this.position()-1]},forward:function(){var t=this.position()+1,e=this.parent();return e.removeElement(this).add(this,t),e instanceof m.Doc&&e.node.appendChild(e.defs().node),this},backward:function(){var t=this.position();return t>0&&this.parent().removeElement(this).add(this,t-1),this},front:function(){var t=this.parent();return t.node.appendChild(this.node),t instanceof m.Doc&&t.node.appendChild(t.defs().node),this},back:function(){return this.position()>0&&this.parent().removeElement(this).add(this,0),this},before:function(t){t.remove();var e=this.position();return this.parent().add(t,e),this},after:function(t){t.remove();var e=this.position();return this.parent().add(t,e+1),this}}),m.Mask=m.invent({create:function(){this.constructor.call(this,m.create("mask")),this.targets=[]},inherit:m.Container,extend:{remove:function(){for(var t=this.targets.length-1;t>=0;t--)this.targets[t]&&this.targets[t].unmask();return delete this.targets,this.parent().removeElement(this),this}},construct:{mask:function(){return this.defs().put(new m.Mask)}}}),m.extend(m.Element,{maskWith:function(t){return this.masker=t instanceof m.Mask?t:this.parent().mask().add(t),this.masker.targets.push(this),this.attr("mask",'url("#'+this.masker.attr("id")+'")')},unmask:function(){return delete this.masker,this.attr("mask",null)}}),m.ClipPath=m.invent({create:function(){this.constructor.call(this,m.create("clipPath")),this.targets=[]},inherit:m.Container,extend:{remove:function(){for(var t=this.targets.length-1;t>=0;t--)this.targets[t]&&this.targets[t].unclip();return delete this.targets,this.parent().removeElement(this),this}},construct:{clip:function(){return this.defs().put(new m.ClipPath)}}}),m.extend(m.Element,{clipWith:function(t){return this.clipper=t instanceof m.ClipPath?t:this.parent().clip().add(t),this.clipper.targets.push(this),this.attr("clip-path",'url("#'+this.clipper.attr("id")+'")')},unclip:function(){return delete this.clipper,this.attr("clip-path",null)}}),m.Gradient=m.invent({create:function(t){this.constructor.call(this,m.create(t+"Gradient")),this.type=t},inherit:m.Container,extend:{at:function(t,e,i){return this.put(new m.Stop).update(t,e,i)},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},fill:function(){return"url(#"+this.id()+")"},toString:function(){return this.fill()}},construct:{gradient:function(t,e){return this.defs().gradient(t,e)}}}),m.extend(m.Gradient,m.FX,{from:function(t,e){return this.attr("radial"==(this.target||this).type?{fx:new m.Number(t),fy:new m.Number(e)}:{x1:new m.Number(t),y1:new m.Number(e)})},to:function(t,e){return this.attr("radial"==(this.target||this).type?{cx:new m.Number(t),cy:new m.Number(e)}:{x2:new m.Number(t),y2:new m.Number(e)})}}),m.extend(m.Defs,{gradient:function(t,e){return this.put(new m.Gradient(t)).update(e)}}),m.Stop=m.invent({create:"stop",inherit:m.Element,extend:{update:function(t){return("number"==typeof t||t instanceof m.Number)&&(t={offset:arguments[0],color:arguments[1],opacity:arguments[2]}),null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new m.Number(t.offset)),this
-}}}),m.Pattern=m.invent({create:"pattern",inherit:m.Container,extend:{fill:function(){return"url(#"+this.id()+")"},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},toString:function(){return this.fill()}},construct:{pattern:function(t,e,i){return this.defs().pattern(t,e,i)}}}),m.extend(m.Defs,{pattern:function(t,e,i){return this.put(new m.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),m.Doc=m.invent({create:function(t){t&&(t="string"==typeof t?document.getElementById(t):t,"svg"==t.nodeName?this.constructor.call(this,t):(this.constructor.call(this,m.create("svg")),t.appendChild(this.node)),this.namespace().size("100%","100%").defs())},inherit:m.Container,extend:{namespace:function(){return this.attr({xmlns:m.ns,version:"1.1"}).attr("xmlns:xlink",m.xlink,m.xmlns)},defs:function(){if(!this._defs){var t;this._defs=(t=this.node.getElementsByTagName("defs")[0])?m.adopt(t):new m.Defs,this.node.appendChild(this._defs.node)}return this._defs},parent:function(){return"#document"==this.node.parentNode.nodeName?null:this.node.parentNode}}}),m.extend(m.Doc,{spof:function(){if(this.doSpof){var t=this.node.getScreenCTM();t&&this.style("left",-t.e%1+"px").style("top",-t.f%1+"px")}return this},fixSubPixelOffset:function(){var t=this;return this.doSpof=!0,m.on(window,"resize",function(){t.spof()}),this.spof()}}),m.Shape=m.invent({create:function(t){this.constructor.call(this,t)},inherit:m.Element}),m.Symbol=m.invent({create:"symbol",inherit:m.Container,construct:{symbol:function(){return this.defs().put(new m.Symbol)}}}),m.Use=m.invent({create:"use",inherit:m.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,m.xlink)}},construct:{use:function(t){return this.put(new m.Use).element(t)}}}),m.Rect=m.invent({create:"rect",inherit:m.Shape,construct:{rect:function(t,e){return this.put((new m.Rect).size(t,e))}}}),m.Circle=m.invent({create:"circle",inherit:m.Shape,construct:{circle:function(t){return this.put(new m.Circle).rx(new m.Number(t).divide(2)).move(0,0)}}}),m.extend(m.Circle,m.FX,{rx:function(t){return this.attr("r",t)},ry:function(t){return this.rx(t)}}),m.Ellipse=m.invent({create:"ellipse",inherit:m.Shape,construct:{ellipse:function(t,e){return this.put(new m.Ellipse).size(t,e).move(0,0)}}}),m.extend(m.Ellipse,m.Rect,m.FX,{rx:function(t){return this.attr("rx",t)},ry:function(t){return this.attr("ry",t)}}),m.extend(m.Circle,m.Ellipse,{x:function(t){return null==t?this.cx()-this.rx():this.cx(t+this.rx())},y:function(t){return null==t?this.cy()-this.ry():this.cy(t+this.ry())},cx:function(t){return null==t?this.attr("cx"):this.attr("cx",new m.Number(t).divide(this.transform("scaleX")))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new m.Number(t).divide(this.transform("scaleY")))},width:function(t){return null==t?2*this.rx():this.rx(new m.Number(t).divide(2))},height:function(t){return null==t?2*this.ry():this.ry(new m.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e);return this.rx(new m.Number(i.width).divide(2)).ry(new m.Number(i.height).divide(2))}}),m.Line=m.invent({create:"line",inherit:m.Shape,extend:{array:function(){return new m.PointArray([[this.attr("x1"),this.attr("y1")],[this.attr("x2"),this.attr("y2")]])},plot:function(t,e,i,n){return t=4==arguments.length?{x1:t,y1:e,x2:i,y2:n}:new m.PointArray(t).toLine(),this.attr(t)},move:function(t,e){return this.attr(this.array().move(t,e).toLine())},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr(this.array().size(i.width,i.height).toLine())}},construct:{line:function(t,e,i,n){return this.put(new m.Line).plot(t,e,i,n)}}}),m.Polyline=m.invent({create:"polyline",inherit:m.Shape,construct:{polyline:function(t){return this.put(new m.Polyline).plot(t)}}}),m.Polygon=m.invent({create:"polygon",inherit:m.Shape,construct:{polygon:function(t){return this.put(new m.Polygon).plot(t)}}}),m.extend(m.Polyline,m.Polygon,{array:function(){return this._array||(this._array=new m.PointArray(this.attr("points")))},plot:function(t){return this.attr("points",this._array=new m.PointArray(t))},move:function(t,e){return this.attr("points",this.array().move(t,e))},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr("points",this.array().size(i.width,i.height))}}),m.extend(m.Line,m.Polyline,m.Polygon,{morphArray:m.PointArray,x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},width:function(t){var e=this.bbox();return null==t?e.width:this.size(t,e.height)},height:function(t){var e=this.bbox();return null==t?e.height:this.size(e.width,t)}}),m.Path=m.invent({create:"path",inherit:m.Shape,extend:{morphArray:m.PathArray,array:function(){return this._array||(this._array=new m.PathArray(this.attr("d")))},plot:function(t){return this.attr("d",this._array=new m.PathArray(t))},move:function(t,e){return this.attr("d",this.array().move(t,e))},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr("d",this.array().size(i.width,i.height))},width:function(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)},height:function(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}},construct:{path:function(t){return this.put(new m.Path).plot(t)}}}),m.Image=m.invent({create:"image",inherit:m.Shape,extend:{load:function(t){if(!t)return this;var e=this,i=document.createElement("img");return i.onload=function(){var n=e.doc(m.Pattern);0==e.width()&&0==e.height()&&e.size(i.width,i.height),n&&0==n.width()&&0==n.height()&&n.size(e.width(),e.height()),"function"==typeof e._loaded&&e._loaded.call(e,{width:i.width,height:i.height,ratio:i.width/i.height,url:t})},this.attr("href",i.src=this.src=t,m.xlink)},loaded:function(t){return this._loaded=t,this}},construct:{image:function(t,e,i){return this.put(new m.Image).load(t).size(e||0,i||e||0)}}}),m.Text=m.invent({create:function(){this.constructor.call(this,m.create("text")),this._leading=new m.Number(1.3),this._rebuild=!0,this._build=!1,this.attr("font-family",m.defaults.attrs["font-family"])},inherit:m.Shape,extend:{x:function(t){return null==t?this.attr("x"):(this.textPath||this.lines.each(function(){this.newLined&&this.x(t)}),this.attr("x",t))},y:function(t){var e=this.attr("y"),i="number"==typeof e?e-this.bbox().y:0;return null==t?"number"==typeof e?e-i:e:this.attr("y","number"==typeof t?t+i:t)},cx:function(t){return null==t?this.bbox().cx:this.x(t-this.bbox().width/2)},cy:function(t){return null==t?this.bbox().cy:this.y(t-this.bbox().height/2)},text:function(t){if("undefined"==typeof t)return this.content;if(this.clear().build(!0),"function"==typeof t)t.call(this,this);else{t=(this.content=t).split("\n");for(var e=0,i=t.length;i>e;e++)this.tspan(t[e]).newLine()}return this.build(!1).rebuild()},size:function(t){return this.attr("font-size",t).rebuild()},leading:function(t){return null==t?this._leading:(this._leading=new m.Number(t),this.rebuild())},rebuild:function(t){if("boolean"==typeof t&&(this._rebuild=t),this._rebuild){var e=this;this.lines.each(function(){this.newLined&&(this.textPath||this.attr("x",e.attr("x")),this.attr("dy",e._leading*new m.Number(e.attr("font-size"))))}),this.fire("rebuild")}return this},build:function(t){return this._build=!!t,this}},construct:{text:function(t){return this.put(new m.Text).text(t)},plain:function(t){return this.put(new m.Text).plain(t)}}}),m.Tspan=m.invent({create:"tspan",inherit:m.Shape,extend:{text:function(t){return"function"==typeof t?t.call(this,this):this.plain(t),this},dx:function(t){return this.attr("dx",t)},dy:function(t){return this.attr("dy",t)},newLine:function(){var t=this.doc(m.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),m.extend(m.Text,m.Tspan,{plain:function(t){return this._build===!1&&this.clear(),this.node.appendChild(document.createTextNode(this.content=t)),this},tspan:function(t){var e=(this.textPath||this).node,i=new m.Tspan;return this._build===!1&&this.clear(),e.appendChild(i.node),this instanceof m.Text&&this.lines.add(i),i.text(t)},clear:function(){for(var t=(this.textPath||this).node;t.hasChildNodes();)t.removeChild(t.lastChild);return this instanceof m.Text&&(delete this.lines,this.lines=new m.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),m.registerEvent("rebuild"),m.TextPath=m.invent({create:"textPath",inherit:m.Element,parent:m.Text,construct:{path:function(t){for(this.textPath=new m.TextPath;this.node.hasChildNodes();)this.textPath.node.appendChild(this.node.firstChild);return this.node.appendChild(this.textPath.node),this.track=this.doc().defs().path(t),this.textPath.parent=this,this.textPath.attr("href","#"+this.track,m.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),m.Nested=m.invent({create:function(){this.constructor.call(this,m.create("svg")),this.style("overflow","visible")},inherit:m.Container,construct:{nested:function(){return this.put(new m.Nested)}}}),m.A=m.invent({create:"a",inherit:m.Container,extend:{to:function(t){return this.attr("href",t,m.xlink)},show:function(t){return this.attr("show",t,m.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new m.A).to(t)}}}),m.extend(m.Element,{linkTo:function(t){var e=new m.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent().put(e).put(this)}}),m.Marker=m.invent({create:"marker",inherit:m.Container,extend:{width:function(t){return this.attr("markerWidth",t)},height:function(t){return this.attr("markerHeight",t)},ref:function(t,e){return this.attr("refX",t).attr("refY",e)},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},toString:function(){return"url(#"+this.id()+")"}},construct:{marker:function(t,e,i){return this.defs().marker(t,e,i)}}}),m.extend(m.Defs,{marker:function(t,e,i){return this.put(new m.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),m.extend(m.Line,m.Polyline,m.Polygon,m.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof m.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var x={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||m.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=x[t].length-1;e>=0;e--)null!=i[x[t][e]]&&this.attr(x.prefix(t,x[t][e]),i[x[t][e]]);return this},m.extend(m.Element,m.FX,i)}),m.extend(m.Element,m.FX,{rotate:function(t,e,i){return this.transform({rotation:t,cx:e,cy:i})},skew:function(t,e,i,n){return this.transform({skewX:t,skewY:e,cx:i,cy:n})},scale:function(t,e,i,n){return this.transform(1==arguments.length||3==arguments.length?{scale:t,cx:e,cy:i}:{scaleX:t,scaleY:e,cx:i,cy:n})},translate:function(t,e){return this.transform({x:t,y:e})},flip:function(t,e){return this.transform({flip:t,offset:e})},matrix:function(t){return this.attr("transform",new m.Matrix(t))},opacity:function(t){return this.attr("opacity",t)}}),m.extend(m.Rect,m.Ellipse,m.Circle,m.Gradient,m.FX,{radius:function(t,e){return"radial"==(this.target||this).type?this.attr({r:new m.Number(t)}):this.rx(t).ry(null==e?t:e)}}),m.extend(m.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),m.extend(m.Parent,m.Text,m.FX,{font:function(t){for(var e in t)"leading"==e?this.leading(t[e]):"anchor"==e?this.attr("text-anchor",t[e]):"size"==e||"family"==e||"weight"==e||"stretch"==e||"variant"==e||"style"==e?this.attr("font-"+e,t[e]):this.attr(e,t[e]);return this}}),m.Set=m.invent({create:function(t){Array.isArray(t)?this.members=t:this.clear()},extend:{add:function(){var t,e,i=[].slice.call(arguments);for(t=0,e=i.length;e>t;t++)this.members.push(i[t]);return this},remove:function(t){var e=this.index(t);return e>-1&&this.members.splice(e,1),this},each:function(t){for(var e=0,i=this.members.length;i>e;e++)t.apply(this.members[e],[e,this.members]);return this},clear:function(){return this.members=[],this},has:function(t){return this.index(t)>=0},index:function(t){return this.members.indexOf(t)},get:function(t){return this.members[t]},first:function(){return this.get(0)},last:function(){return this.get(this.members.length-1)},valueOf:function(){return this.members},bbox:function(){var t=new m.BBox;if(0==this.members.length)return t;var e=this.members[0].rbox();return t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height,this.each(function(){t=t.merge(this.rbox())}),t}},construct:{set:function(t){return new m.Set(t)}}}),m.SetFX=m.invent({create:function(t){this.set=t}}),m.Set.inherit=function(){var t,e=[];for(var t in m.Shape.prototype)"function"==typeof m.Shape.prototype[t]&&"function"!=typeof m.Set.prototype[t]&&e.push(t);e.forEach(function(t){m.Set.prototype[t]=function(){for(var e=0,i=this.members.length;i>e;e++)this.members[e]&&"function"==typeof this.members[e][t]&&this.members[e][t].apply(this.members[e],arguments);return"animate"==t?this.fx||(this.fx=new m.SetFX(this)):this}}),e=[];for(var t in m.FX.prototype)"function"==typeof m.FX.prototype[t]&&"function"!=typeof m.SetFX.prototype[t]&&e.push(t);e.forEach(function(t){m.SetFX.prototype[t]=function(){for(var e=0,i=this.set.members.length;i>e;e++)this.set.members[e].fx[t].apply(this.set.members[e].fx,arguments);return this}})},m.extend(m.Element,{data:function(t,e,i){if("object"==typeof t)for(e in t)this.data(e,t[e]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+t))}catch(n){return this.attr("data-"+t)}else this.attr("data-"+t,null===e?null:i===!0||"string"==typeof e||"number"==typeof e?e:JSON.stringify(e));return this}}),m.extend(m.Element,{remember:function(t,e){if("object"==typeof arguments[0])for(var e in t)this.remember(e,t[e]);else{if(1==arguments.length)return this.memory()[t];this.memory()[t]=e}return this},forget:function(){if(0==arguments.length)this._memory={};else for(var t=arguments.length-1;t>=0;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory||(this._memory={})}}),m.get=function(t){var e=document.getElementById(d(t)||t);return e?m.adopt(e):void 0},m.select=function(t,e){return new m.Set(m.utils.map((e||document).querySelectorAll(t),function(t){return m.adopt(t)}))},m.extend(m.Parent,{select:function(t){return m.select(t,this.node)}}),"function"==typeof define&&define.amd?define(function(){return m}):"undefined"!=typeof exports&&(exports.SVG=m);var g="abcdef".split("");window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}(),"function"!=typeof p&&(p.prototype=window.Event.prototype,window.CustomEvent=p)}).call(this); \ No newline at end of file
+/*! SVG.js v1.0.0-rc.10 MIT*/(function(){function t(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function e(t){return t.charAt(0).toUpperCase()+t.slice(1)}function i(t){return 4==t.length?["#",t.substring(1,2),t.substring(1,2),t.substring(2,3),t.substring(2,3),t.substring(3,4),t.substring(3,4)].join(""):t}function n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(t,e,i){return null==i?i=t.height/t.width*e:null==e&&(e=t.width/t.height*i),{width:e,height:i}}function s(t,e,i){return{x:e*t.a+i*t.c+0,y:e*t.b+i*t.d+0}}function o(t){return{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}}function h(t){return t instanceof m.Matrix||(t=new m.Matrix(t)),t}function a(t){return t=t.replace(m.regex.whitespace,"").replace(m.regex.matrix,"").split(","),o(m.utils.map(t,function(t){return parseFloat(t)}))}function u(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof m.Color||t instanceof m.Number||t instanceof m.Matrix?t.at(e):1>e?t.from:t.to}function l(t){for(var e=0,i=t.length,n="";i>e;e++)n+=t[e][0],null!=t[e][1]&&(n+=t[e][1],null!=t[e][2]&&(n+=" ",n+=t[e][2],null!=t[e][3]&&(n+=" ",n+=t[e][3],n+=" ",n+=t[e][4],null!=t[e][5]&&(n+=" ",n+=t[e][5],n+=" ",n+=t[e][6],null!=t[e][7]&&(n+=" ",n+=t[e][7])))));return n+" "}function c(t){for(var e=t.childNodes.length-1;e>=0;e--)t.childNodes[e]instanceof SVGElement&&c(t.childNodes[e]);return m.adopt(t).id(m.eid(t.nodeName))}function f(t){return t.x2=t.x+t.width,t.y2=t.y+t.height,t.cx=t.x+t.width/2,t.cy=t.y+t.height/2,t}function d(t){var e=t.toString().match(m.regex.reference);return e?e[1]:void 0}function p(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}var m=this.SVG=function(t){return m.supported?(t=new m.Doc(t),m.parser||m.prepare(t),t):void 0};if(m.ns="http://www.w3.org/2000/svg",m.xmlns="http://www.w3.org/2000/xmlns/",m.xlink="http://www.w3.org/1999/xlink",m.supported=function(){return!!document.createElementNS&&!!document.createElementNS(m.ns,"svg").createSVGRect}(),!m.supported)return!1;m.did=1e3,m.eid=function(t){return"Svgjs"+e(t)+m.did++},m.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},m.extend=function(){var t,e,i,n;for(t=[].slice.call(arguments),e=t.pop(),n=t.length-1;n>=0;n--)if(t[n])for(i in e)t[n].prototype[i]=e[i];m.Set&&m.Set.inherit&&m.Set.inherit()},m.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,m.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&m.extend(e,t.extend),t.construct&&m.extend(t.parent||m.Container,t.construct),e},m.adopt=function(t){if(t.instance)return t.instance;var i;return i="svg"==t.nodeName?t.parentNode instanceof SVGElement?new m.Nested:new m.Doc:"lineairGradient"==t.nodeName?new m.Gradient("lineair"):"radialGradient"==t.nodeName?new m.Gradient("radial"):m[e(t.nodeName)]?new(m[e(t.nodeName)]):new m.Element(t),i.type=t.nodeName,i.node=t,t.instance=i,i instanceof m.Doc&&i.namespace().defs(),i},m.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new m.Doc(e):t.nested()).size(2,0),n=m.create("path");i.node.appendChild(n),m.parser={body:e||t.parent(),draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},m.regex={unit:/^(-?[\d\.]+)([a-z%]{0,2})$/,hex:/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,rgb:/rgb\((\d+),(\d+),(\d+)\)/,reference:/#([a-z0-9\-_]+)/i,matrix:/matrix\(|\)/g,whitespace:/\s/g,isHex:/^#[a-f0-9]{3,6}$/i,isRgb:/^rgb\(/,isCss:/[^:]+:[^;]+;?/,isBlank:/^(\s+)?$/,isNumber:/^-?[\d\.]+$/,isPercent:/^-?[\d\.]+%$/,isImage:/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i},m.utils={map:function(t,e){var i,n=t.length,r=[];for(i=0;n>i;i++)r.push(e(t[i]));return r},radians:function(t){return t%360*Math.PI/180},degrees:function(t){return 180*t/Math.PI%360}},m.defaults={attrs:{"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","font-size":16,"font-family":"Helvetica, Arial, sans-serif","text-anchor":"start"}},m.Color=function(t){var e;this.r=0,this.g=0,this.b=0,"string"==typeof t?m.regex.isRgb.test(t)?(e=m.regex.rgb.exec(t.replace(/\s/g,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):m.regex.isHex.test(t)&&(e=m.regex.hex.exec(i(t)),this.r=parseInt(e[1],16),this.g=parseInt(e[2],16),this.b=parseInt(e[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b)},m.extend(m.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+n(this.r)+n(this.g)+n(this.b)},toRgb:function(){return"rgb("+[this.r,this.g,this.b].join()+")"},brightness:function(){return this.r/255*.3+this.g/255*.59+this.b/255*.11},morph:function(t){return this.destination=new m.Color(t),this},at:function(t){return this.destination?(t=0>t?0:t>1?1:t,new m.Color({r:~~(this.r+(this.destination.r-this.r)*t),g:~~(this.g+(this.destination.g-this.g)*t),b:~~(this.b+(this.destination.b-this.b)*t)})):this}}),m.Color.test=function(t){return t+="",m.regex.isHex.test(t)||m.regex.isRgb.test(t)},m.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},m.Color.isColor=function(t){return m.Color.isRgb(t)||m.Color.test(t)},m.Array=function(t,e){t=(t||[]).valueOf(),0==t.length&&e&&(t=e.valueOf()),this.value=this.parse(t)},m.extend(m.Array,{morph:function(t){if(this.destination=this.parse(t),this.value.length!=this.destination.length){for(var e=this.value[this.value.length-1],i=this.destination[this.destination.length-1];this.value.length>this.destination.length;)this.destination.push(i);for(;this.value.length<this.destination.length;)this.value.push(e)}return this},settle:function(){for(var t=0,e=this.value.length,i=[];e>t;t++)-1==i.indexOf(this.value[t])&&i.push(this.value[t]);return this.value=i},at:function(t){if(!this.destination)return this;for(var e=0,i=this.value.length,n=[];i>e;e++)n.push(this.value[e]+(this.destination[e]-this.value[e])*t);return new m.Array(n)},toString:function(){return this.value.join(" ")},valueOf:function(){return this.value},parse:function(t){return t=t.valueOf(),Array.isArray(t)?t:this.split(t)},split:function(t){return t.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"").split(" ")},reverse:function(){return this.value.reverse(),this}}),m.PointArray=function(t,e){this.constructor.call(this,t,e||[[0,0]])},m.PointArray.prototype=new m.Array,m.extend(m.PointArray,{toString:function(){for(var t=0,e=this.value.length,i=[];e>t;t++)i.push(this.value[t].join(","));return i.join(" ")},toLine:function(){return{x1:this.value[0][0],y1:this.value[0][1],x2:this.value[1][0],y2:this.value[1][1]}},at:function(t){if(!this.destination)return this;for(var e=0,i=this.value.length,n=[];i>e;e++)n.push([this.value[e][0]+(this.destination[e][0]-this.value[e][0])*t,this.value[e][1]+(this.destination[e][1]-this.value[e][1])*t]);return new m.PointArray(n)},parse:function(t){if(t=t.valueOf(),Array.isArray(t))return t;t=this.split(t);for(var e,i=0,n=t.length,r=[];n>i;i++)e=t[i].split(","),r.push([parseFloat(e[0]),parseFloat(e[1])]);return r},move:function(t,e){var i=this.bbox();if(t-=i.x,e-=i.y,!isNaN(t)&&!isNaN(e))for(var n=this.value.length-1;n>=0;n--)this.value[n]=[this.value[n][0]+t,this.value[n][1]+e];return this},size:function(t,e){var i,n=this.bbox();for(i=this.value.length-1;i>=0;i--)this.value[i][0]=(this.value[i][0]-n.x)*t/n.width+n.x,this.value[i][1]=(this.value[i][1]-n.y)*e/n.height+n.y;return this},bbox:function(){return m.parser.poly.setAttribute("points",this.toString()),m.parser.poly.getBBox()}}),m.PathArray=function(t,e){this.constructor.call(this,t,e||[["M",0,0]])},m.PathArray.prototype=new m.Array,m.extend(m.PathArray,{toString:function(){return l(this.value)},move:function(t,e){var i=this.bbox();if(t-=i.x,e-=i.y,!isNaN(t)&&!isNaN(e))for(var n,r=this.value.length-1;r>=0;r--)n=this.value[r][0],"M"==n||"L"==n||"T"==n?(this.value[r][1]+=t,this.value[r][2]+=e):"H"==n?this.value[r][1]+=t:"V"==n?this.value[r][1]+=e:"C"==n||"S"==n||"Q"==n?(this.value[r][1]+=t,this.value[r][2]+=e,this.value[r][3]+=t,this.value[r][4]+=e,"C"==n&&(this.value[r][5]+=t,this.value[r][6]+=e)):"A"==n&&(this.value[r][6]+=t,this.value[r][7]+=e);return this},size:function(t,e){var i,n,r=this.bbox();for(i=this.value.length-1;i>=0;i--)n=this.value[i][0],"M"==n||"L"==n||"T"==n?(this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x,this.value[i][2]=(this.value[i][2]-r.y)*e/r.height+r.y):"H"==n?this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x:"V"==n?this.value[i][1]=(this.value[i][1]-r.y)*e/r.height+r.y:"C"==n||"S"==n||"Q"==n?(this.value[i][1]=(this.value[i][1]-r.x)*t/r.width+r.x,this.value[i][2]=(this.value[i][2]-r.y)*e/r.height+r.y,this.value[i][3]=(this.value[i][3]-r.x)*t/r.width+r.x,this.value[i][4]=(this.value[i][4]-r.y)*e/r.height+r.y,"C"==n&&(this.value[i][5]=(this.value[i][5]-r.x)*t/r.width+r.x,this.value[i][6]=(this.value[i][6]-r.y)*e/r.height+r.y)):"A"==n&&(this.value[i][1]=this.value[i][1]*t/r.width,this.value[i][2]=this.value[i][2]*e/r.height,this.value[i][6]=(this.value[i][6]-r.x)*t/r.width+r.x,this.value[i][7]=(this.value[i][7]-r.y)*e/r.height+r.y);return this},parse:function(t){if(t instanceof m.PathArray)return t.valueOf();var e,i,n,r,s,o,h,a,u,c,f,d=0,p=0;for(m.parser.path.setAttribute("d","string"==typeof t?t:l(t)),f=m.parser.path.pathSegList,e=0,i=f.numberOfItems;i>e;++e)c=f.getItem(e),u=c.pathSegTypeAsLetter,"M"==u||"L"==u||"H"==u||"V"==u||"C"==u||"S"==u||"Q"==u||"T"==u||"A"==u?("x"in c&&(d=c.x),"y"in c&&(p=c.y)):("x1"in c&&(s=d+c.x1),"x2"in c&&(h=d+c.x2),"y1"in c&&(o=p+c.y1),"y2"in c&&(a=p+c.y2),"x"in c&&(d+=c.x),"y"in c&&(p+=c.y),"m"==u?f.replaceItem(m.parser.path.createSVGPathSegMovetoAbs(d,p),e):"l"==u?f.replaceItem(m.parser.path.createSVGPathSegLinetoAbs(d,p),e):"h"==u?f.replaceItem(m.parser.path.createSVGPathSegLinetoHorizontalAbs(d),e):"v"==u?f.replaceItem(m.parser.path.createSVGPathSegLinetoVerticalAbs(p),e):"c"==u?f.replaceItem(m.parser.path.createSVGPathSegCurvetoCubicAbs(d,p,s,o,h,a),e):"s"==u?f.replaceItem(m.parser.path.createSVGPathSegCurvetoCubicSmoothAbs(d,p,h,a),e):"q"==u?f.replaceItem(m.parser.path.createSVGPathSegCurvetoQuadraticAbs(d,p,s,o),e):"t"==u?f.replaceItem(m.parser.path.createSVGPathSegCurvetoQuadraticSmoothAbs(d,p),e):"a"==u?f.replaceItem(m.parser.path.createSVGPathSegArcAbs(d,p,c.r1,c.r2,c.angle,c.largeArcFlag,c.sweepFlag),e):("z"==u||"Z"==u)&&(d=n,p=r)),("M"==u||"m"==u)&&(n=d,r=p);for(t=[],f=m.parser.path.pathSegList,e=0,i=f.numberOfItems;i>e;++e)c=f.getItem(e),u=c.pathSegTypeAsLetter,d=[u],"M"==u||"L"==u||"T"==u?d.push(c.x,c.y):"H"==u?d.push(c.x):"V"==u?d.push(c.y):"C"==u?d.push(c.x1,c.y1,c.x2,c.y2,c.x,c.y):"S"==u?d.push(c.x2,c.y2,c.x,c.y):"Q"==u?d.push(c.x1,c.y1,c.x,c.y):"A"==u&&d.push(c.r1,c.r2,c.angle,0|c.largeArcFlag,0|c.sweepFlag,c.x,c.y),t.push(d);return t},bbox:function(){return m.parser.path.setAttribute("d",this.toString()),m.parser.path.getBBox()}}),m.Number=m.invent({create:function(t){if(this.value=0,this.unit="","number"==typeof t)this.value=isNaN(t)?0:isFinite(t)?t:0>t?-3.4e38:3.4e38;else if("string"==typeof t){var e=t.match(m.regex.unit);e&&(this.value=parseFloat(e[1]),"%"==e[2]?this.value/=100:"s"==e[2]&&(this.value*=1e3),this.unit=e[2])}else t instanceof m.Number&&(this.value=t.value,this.unit=t.unit)},extend:{toString:function(){return("%"==this.unit?~~(1e8*this.value)/1e6:"s"==this.unit?this.value/1e3:this.value)+this.unit},valueOf:function(){return this.value},plus:function(t){return this.value=this+new m.Number(t),this},minus:function(t){return this.plus(-new m.Number(t))},times:function(t){return this.value=this*new m.Number(t),this},divide:function(t){return this.value=this/new m.Number(t),this},to:function(t){return"string"==typeof t&&(this.unit=t),this},morph:function(t){return this.destination=new m.Number(t),this},at:function(t){return this.destination?new m.Number(this.destination).minus(this).times(t).plus(this):this}}}),m.ViewBox=function(t){var e,i,n,r,s=1,o=1,h=t.bbox(),a=(t.attr("viewBox")||"").match(/-?[\d\.]+/g),u=t,l=t;for(n=new m.Number(t.width()),r=new m.Number(t.height());"%"==n.unit;)s*=n.value,n=new m.Number(u instanceof m.Doc?u.parent().offsetWidth:u.parent().width()),u=u.parent();for(;"%"==r.unit;)o*=r.value,r=new m.Number(l instanceof m.Doc?l.parent().offsetHeight:l.parent().height()),l=l.parent();this.x=h.x,this.y=h.y,this.width=n*s,this.height=r*o,this.zoom=1,a&&(e=parseFloat(a[0]),i=parseFloat(a[1]),n=parseFloat(a[2]),r=parseFloat(a[3]),this.zoom=this.width/this.height>n/r?this.height/r:this.width/n,this.x=e,this.y=i,this.width=n,this.height=r)},m.extend(m.ViewBox,{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}}),m.Element=m.invent({create:function(t){this._stroke=m.defaults.attrs.stroke,(this.node=t)&&(this.type=t.nodeName,this.node.instance=this,this._stroke=t.getAttribute("stroke")||this._stroke)},extend:{x:function(t){return null!=t&&(t=new m.Number(t),t.value/=this.transform("scaleX")),this.attr("x",t)},y:function(t){return null!=t&&(t=new m.Number(t),t.value/=this.transform("scaleY")),this.attr("y",t)},cx:function(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)},cy:function(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},width:function(t){return this.attr("width",t)},height:function(t){return this.attr("height",t)},size:function(t,e){var i=r(this.bbox(),t,e);return this.width(new m.Number(i.width)).height(new m.Number(i.height))},clone:function(){return c(this.node.cloneNode(!0))},remove:function(){return this.parent()&&this.parent().removeElement(this),this},replace:function(t){return this.after(t).remove(),t},addTo:function(t){return t.put(this)},putIn:function(t){return t.add(this)},id:function(t){return this.attr("id",t)},inside:function(t,e){var i=this.bbox();return t>i.x&&e>i.y&&t<i.x+i.width&&e<i.y+i.height},show:function(){return this.style("display","")},hide:function(){return this.style("display","none")},visible:function(){return"none"!=this.style("display")},toString:function(){return this.attr("id")},classes:function(){var t=this.attr("class");return null==t?[]:t.trim().split(/\s+/)},hasClass:function(t){return-1!=this.classes().indexOf(t)},addClass:function(t){if(!this.hasClass(t)){var e=this.classes();e.push(t),this.attr("class",e.join(" "))}return this},removeClass:function(t){return this.hasClass(t)&&this.attr("class",this.classes().filter(function(e){return e!=t}).join(" ")),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t)},reference:function(t){return m.get(this.attr(t))},parent:function(t){var e=m.adopt(this.node.parentNode);if(t)for(;!(e instanceof t);)e=m.adopt(e.node.parentNode);return e},doc:function(t){return this.parent(t||m.Doc)},"native":function(){return this.node}}}),m.FX=m.invent({create:function(t){this.target=t},extend:{animate:function(t,e,i){var n,r,s,o=this.target,h=this;return"object"==typeof t&&(i=t.delay,e=t.ease,t=t.duration),t="="==t?t:null==t?1e3:new m.Number(t).valueOf(),e=e||"<>",h.at=function(t){var i;if(t=0>t?0:t>1?1:t,null==n){n=[];for(s in h.attrs)n.push(s);if(o.morphArray&&(h.destination.plot||n.indexOf("points")>-1)){var a,l=new o.morphArray(h.destination.plot||h.attrs.points||o.array);h.destination.size&&l.size(h.destination.size.width.to,h.destination.size.height.to),a=l.bbox(),h.destination.x?l.move(h.destination.x.to,a.y):h.destination.cx&&l.move(h.destination.cx.to-a.width/2,a.y),a=l.bbox(),h.destination.y?l.move(a.x,h.destination.y.to):h.destination.cy&&l.move(a.x,h.destination.cy.to-a.height/2),h.destination={plot:o.array.morph(l)}}}if(null==r){r=[];for(s in h.styles)r.push(s)}for(t="<>"==e?-Math.cos(t*Math.PI)/2+.5:">"==e?Math.sin(t*Math.PI/2):"<"==e?-Math.cos(t*Math.PI/2)+1:"-"==e?t:"function"==typeof e?e(t):t,h.destination.plot?o.plot(h.destination.plot.at(t)):(h.destination.x?o.x(h.destination.x.at(t)):h.destination.cx&&o.cx(h.destination.cx.at(t)),h.destination.y?o.y(h.destination.y.at(t)):h.destination.cy&&o.cy(h.destination.cy.at(t)),h.destination.size&&o.size(h.destination.size.width.at(t),h.destination.size.height.at(t))),h.destination.viewbox&&o.viewbox(h.destination.viewbox.x.at(t),h.destination.viewbox.y.at(t),h.destination.viewbox.width.at(t),h.destination.viewbox.height.at(t)),h.destination.leading&&o.leading(h.destination.leading.at(t)),i=n.length-1;i>=0;i--)o.attr(n[i],u(h.attrs[n[i]],t));for(i=r.length-1;i>=0;i--)o.style(r[i],u(h.styles[r[i]],t));h.situation.during&&h.situation.during.call(o,t,function(e,i){return u({from:e,to:i},t)})},"number"==typeof t&&(this.timeout=setTimeout(function(){var n=(new Date).getTime();h.situation.start=n,h.situation.play=!0,h.situation.finish=n+t,h.situation.duration=t,h.situation.ease=e,h.render=function(){if(h.situation.play===!0){var n=(new Date).getTime(),r=n>h.situation.finish?1:(n-h.situation.start)/t;h.situation.reversing&&(r=-r+1),h.at(r),n>h.situation.finish?(h.destination.plot&&o.plot(new m.PointArray(h.destination.plot.destination).settle()),h.situation.loop===!0||"number"==typeof h.situation.loop&&h.situation.loop>0?(h.situation.reverse&&(h.situation.reversing=!h.situation.reversing),"number"==typeof h.situation.loop&&((!h.situation.reverse||h.situation.reversing)&&--h.situation.loop,h.situation.reverse||1!=h.situation.loop||--h.situation.loop),h.animate(t,e,i)):h.situation.after?h.situation.after.apply(o,[h]):h.stop()):requestAnimFrame(h.render)}else requestAnimFrame(h.render)},h.render()},new m.Number(i).valueOf())),this},bbox:function(){return this.target.bbox()},attr:function(t,e){if("object"==typeof t)for(var i in t)this.attr(i,t[i]);else{var n=this.target.attr(t);this.attrs[t]="transform"==t?this.target.ctm().morph(e):m.Color.isColor(n)?new m.Color(n).morph(e):m.regex.unit.test(n)?new m.Number(n).morph(e):{from:n,to:e}}return this},style:function(t,e){if("object"==typeof t)for(var i in t)this.style(i,t[i]);else this.styles[t]={from:this.target.style(t),to:e};return this},x:function(t){return this.destination.x=new m.Number(this.target.x()).morph(t),this},y:function(t){return this.destination.y=new m.Number(this.target.y()).morph(t),this},cx:function(t){return this.destination.cx=new m.Number(this.target.cx()).morph(t),this},cy:function(t){return this.destination.cy=new m.Number(this.target.cy()).morph(t),this},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},size:function(t,e){if(this.target instanceof m.Text)this.attr("font-size",t);else{var i=this.target.bbox();this.destination.size={width:new m.Number(i.width).morph(t),height:new m.Number(i.height).morph(e)}}return this},plot:function(t){return this.destination.plot=t,this},leading:function(t){return this.target.destination.leading&&(this.destination.leading=new m.Number(this.target.destination.leading).morph(t)),this},viewbox:function(t,e,i,n){if(this.target instanceof m.Container){var r=this.target.viewbox();this.destination.viewbox={x:new m.Number(r.x).morph(t),y:new m.Number(r.y).morph(e),width:new m.Number(r.width).morph(i),height:new m.Number(r.height).morph(n)}}return this},update:function(t){return this.target instanceof m.Stop&&(null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new m.Number(t.offset))),this},during:function(t){return this.situation.during=t,this},after:function(t){return this.situation.after=t,this},loop:function(t,e){return this.situation.loop=this.situation.loops=t||!0,this.situation.reverse=!!e,this},stop:function(t){return t===!0?(this.animate(0),this.situation.after&&this.situation.after.apply(this.target,[this])):(clearTimeout(this.timeout),this.attrs={},this.styles={},this.situation={},this.destination={}),this},pause:function(){return this.situation.play===!0&&(this.situation.play=!1,this.situation.pause=(new Date).getTime()),this},play:function(){if(this.situation.play===!1){var t=(new Date).getTime()-this.situation.pause;this.situation.finish+=t,this.situation.start+=t,this.situation.play=!0}return this}},parent:m.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new m.FX(this))).stop().animate(t,e,i)},stop:function(t){return this.fx&&this.fx.stop(t),this},pause:function(){return this.fx&&this.fx.pause(),this},play:function(){return this.fx&&this.fx.play(),this}}}),m.BBox=m.invent({create:function(t){var e;if(this.x=0,this.y=0,this.width=0,this.height=0,t){var i=new m.Matrix(t).extract();e=t.node.getBBox?t.node.getBBox():{x:t.node.clientLeft,y:t.node.clientTop,width:t.node.clientWidth,height:t.node.clientHeight},this.x=e.x+i.x,this.y=e.y+i.y,this.width=e.width*i.scaleX,this.height=e.height*i.scaleY}f(this)},parent:m.Element,construct:{bbox:function(){return new m.BBox(this)}}}),m.RBox=m.invent({create:function(t){var e={};if(this.x=0,this.y=0,this.width=0,this.height=0,t){var i=t.doc().parent(),n=1;for(e=t.node.getBoundingClientRect(),this.x=e.left,this.y=e.top,this.x-=i.offsetLeft,this.y-=i.offsetTop;i=i.offsetParent;)this.x-=i.offsetLeft,this.y-=i.offsetTop;for(i=t;i.parent&&(i=i.parent());)i.viewbox&&(n*=i.viewbox().zoom,this.x-=i.x()||0,this.y-=i.y()||0)}this.width=e.width/=n,this.height=e.height/=n,this.x+=window.scrollX,this.y+=window.scrollY,f(this)},parent:m.Element,construct:{rbox:function(){return new m.RBox(this)}}}),[m.BBox,m.RBox].forEach(function(t){m.extend(t,{merge:function(e){var i=new t;return i.x=Math.min(this.x,e.x),i.y=Math.min(this.y,e.y),i.width=Math.max(this.x+this.width,e.x+e.width)-i.x,i.height=Math.max(this.y+this.height,e.y+e.height)-i.y,f(i)}})}),m.Matrix=m.invent({create:function(t){var e,i=o([1,0,0,1,0,0]);for(t=t&&t.node&&t.node.getCTM?t.node.getCTM():"string"==typeof t?a(t):6==arguments.length?o([].slice.call(arguments)):"object"==typeof t?t:i,e=g.length-1;e>=0;e--)this[g[e]]="number"==typeof t[g[e]]?t[g[e]]:i[g[e]]},extend:{extract:function(){var t=s(this,0,1),e=s(this,1,0),i=180/Math.PI*Math.atan2(t.y,t.x)-90;return{x:this.e,y:this.f,skewX:-i,skewY:180/Math.PI*Math.atan2(e.y,e.x),scaleX:Math.sqrt(this.a*this.a+this.b*this.b),scaleY:Math.sqrt(this.c*this.c+this.d*this.d),rotation:i}},clone:function(){return new m.Matrix(this)},morph:function(t){return this.destination=new m.Matrix(t),this},at:function(t){return this.destination?new m.Matrix({a:this.a+(this.destination.a-this.a)*t,b:this.b+(this.destination.b-this.b)*t,c:this.c+(this.destination.c-this.c)*t,d:this.d+(this.destination.d-this.d)*t,e:this.e+(this.destination.e-this.e)*t,f:this.f+(this.destination.f-this.f)*t}):this},multiply:function(t){return new m.Matrix(this.native().multiply(h(t).native()))},add:function(t){return t=h(t),new m.Matrix({a:this.a+t.a-1,b:this.b+t.b,c:this.c+t.c,d:this.d+t.d-1,e:this.e+t.e,f:this.f+t.f})},inverse:function(){return new m.Matrix(this.native().inverse())},translate:function(t,e){return new m.Matrix(this.native().translate(t||0,e||0))},scale:function(t,e,i,n){return(1==arguments.length||3==arguments.length)&&(e=t),3==arguments.length&&(n=i,i=e),this.around(i,n,new m.Matrix(t,0,0,e,0,0))},rotate:function(t,e,i){return t=m.utils.radians(t),this.around(e,i,new m.Matrix(Math.cos(t),Math.sin(t),-Math.sin(t),Math.cos(t),0,0))},flip:function(t,e){return"x"==t?this.scale(-1,1,e,0):this.scale(1,-1,0,e)},skew:function(t,e,i,n){return this.around(i,n,this.native().skewX(t||0).skewY(e||0))},around:function(t,e,i){return this.multiply(new m.Matrix(1,0,0,1,t||0,e||0)).multiply(i).multiply(new m.Matrix(1,0,0,1,-t||0,-e||0))},"native":function(){for(var t=m.parser.draw.node.createSVGMatrix(),e=g.length-1;e>=0;e--)t[g[e]]=this[g[e]];return t},toString:function(){return"matrix("+[this.a,this.b,this.c,this.d,this.e,this.f].join()+")"}},parent:m.Element,construct:{ctm:function(){return new m.Matrix(this)}}}),m.extend(m.Element,{attr:function(t,e,i){if(null==t){for(t={},e=this.node.attributes,i=e.length-1;i>=0;i--)t[e[i].nodeName]=m.regex.isNumber.test(e[i].nodeValue)?parseFloat(e[i].nodeValue):e[i].nodeValue;return t}if("object"==typeof t)for(e in t)this.attr(e,t[e]);else if(null===e)this.node.removeAttribute(t);else{if(null==e)return e=this.node.getAttribute(t),null==e?m.defaults.attrs[t]:m.regex.isNumber.test(e)?parseFloat(e):e;"stroke-width"==t?this.attr("stroke",parseFloat(e)>0?this._stroke:null):"stroke"==t&&(this._stroke=e),("fill"==t||"stroke"==t)&&(m.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof m.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new m.Number(e):m.Color.isColor(e)?e=new m.Color(e):Array.isArray(e)&&(e=new m.Array(e)),"leading"==t?this.leading&&this.leading(e):"string"==typeof i?this.node.setAttributeNS(i,t,e.toString()):this.node.setAttribute(t,e.toString()),!this.rebuild||"font-size"!=t&&"x"!=t||this.rebuild(t,e)}return this}}),m.extend(m.Element,m.FX,{transform:function(t){var e=this.target||this;if(null==t)return e.ctm().extract();if("string"==typeof t)return e.ctm().extract()[t];var i=new m.Matrix(e);return null!=t.a?i=i.multiply(new m.Matrix(t)):t.rotation?i=i.rotate(t.rotation,null==t.cx?e.bbox().cx:t.cx,null==t.cy?e.bbox().cy:t.cy):null!=t.scale||null!=t.scaleX||null!=t.scaleY?i=i.scale(null!=t.scale?t.scale:null!=t.scaleX?t.scaleX:1,null!=t.scale?t.scale:null!=t.scaleY?t.scaleY:1,null==t.cx?e.bbox().x:t.cx,null==t.cy?e.bbox().y:t.cy):t.skewX||t.skewY?i=i.skew(t.skewX,t.skewY,null==t.cx?e.bbox().cx:t.cx,null==t.cy?e.bbox().cy:t.cy):t.flip?i=i.flip(t.flip,null==t.offset?e.bbox()["c"+t.flip]:t.offset):(t.x||t.y)&&(i=i.translate(t.x,t.y)),this.attr("transform",i)}}),m.extend(m.Element,{untransform:function(){return this.attr("transform",null)}}),m.extend(m.Element,{style:function(e,i){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof e)for(i in e)this.style(i,e[i]);else{if(!m.regex.isCss.test(e))return this.node.style[t(e)];e=e.split(";");for(var n=0;n<e.length;n++)i=e[n].split(":"),this.style(i[0].replace(/\s+/g,""),i[1])}else this.node.style[t(e)]=null===i||m.regex.isBlank.test(i)?"":i;return this}}),m.Parent=m.invent({create:function(t){this.constructor.call(this,t)},inherit:m.Element,extend:{children:function(){return m.utils.map(this.node.childNodes,function(t){return m.adopt(t)})},add:function(t,e){return this.has(t)||(e=null==e?this.children().length:e,this.node.insertBefore(t.node,this.node.childNodes[e]||null)),this},put:function(t,e){return this.add(t,e),t},has:function(t){return this.index(t)>=0},index:function(t){return this.children().indexOf(t)},get:function(t){return this.children()[t]},first:function(){return this.children()[0]},last:function(){return this.children()[this.children().length-1]},each:function(t,e){var i,n,r=this.children();for(i=0,n=r.length;n>i;i++)r[i]instanceof m.Element&&t.apply(r[i],[i,r]),e&&r[i]instanceof m.Container&&r[i].each(t,e);return this},removeElement:function(t){return this.node.removeChild(t.node),this},clear:function(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return delete this._defs,this},defs:function(){return this.doc().defs()}}}),m.Container=m.invent({create:function(t){this.constructor.call(this,t)},inherit:m.Parent,extend:{viewbox:function(t){return 0==arguments.length?new m.ViewBox(this):(t=1==arguments.length?[t.x,t.y,t.width,t.height]:[].slice.call(arguments),this.attr("viewBox",t))}}}),m.extend(m.Parent,m.Text,{svg:function(t){var e=document.createElement("div");if(t){t=t.replace(/\n/,"").replace(/<(\w+)([^<]+?)\/>/g,"<$1$2></$1>"),e.innerHTML="<svg>"+t+"</svg>";for(var i=e.firstChild.childNodes.length-1;i>=0;i--)1==e.firstChild.childNodes[i].nodeType&&this.node.appendChild(e.firstChild.childNodes[i]);return this}var n=this.node.cloneNode(!0);return e.appendChild(n),e.innerHTML}}),m.extend(m.Element,m.FX,{dx:function(t){return this.x((this.target||this).x()+t)},dy:function(t){return this.y((this.target||this).y()+t)},dmove:function(t,e){return this.dx(t).dy(e)}}),["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){m.Element.prototype[t]=function(e){var i=this;return this.node["on"+t]="function"==typeof e?function(){return e.apply(i,arguments)}:null,this}}),m.events={},m.listeners={},m.registerEvent=function(t){m.events[t]||(m.events[t]=new p(t))},m.on=function(t,e,i){var n=i.bind(t.instance||t);m.listeners[i]=n,t.addEventListener(e,n,!1)},m.off=function(t,e,i){t.removeEventListener(e,m.listeners[i],!1),delete m.listeners[i]},m.extend(m.Element,{on:function(t,e){return m.on(this.node,t,e),this},off:function(t,e){return m.off(this.node,t,e),this},fire:function(t,e){return m.events[t].detail=e,this.node.dispatchEvent(m.events[t]),delete m.events[t].detail,this}}),m.Defs=m.invent({create:"defs",inherit:m.Container}),m.G=m.invent({create:"g",inherit:m.Container,extend:{x:function(t){return this.transform(null==t?"x":{x:-this.x()+t})},y:function(t){return this.transform(null==t?"y":{y:-this.y()+t})},cx:function(t){return null==t?this.bbox().cx:this.x(t-this.bbox().width/2)},cy:function(t){return null==t?this.bbox().cy:this.y(t-this.bbox().height/2)}},construct:{group:function(){return this.put(new m.G)}}}),m.extend(m.Element,{siblings:function(){return this.parent().children()},position:function(){return this.parent().index(this)},next:function(){return this.siblings()[this.position()+1]},previous:function(){return this.siblings()[this.position()-1]},forward:function(){var t=this.position()+1,e=this.parent();return e.removeElement(this).add(this,t),e instanceof m.Doc&&e.node.appendChild(e.defs().node),this},backward:function(){var t=this.position();return t>0&&this.parent().removeElement(this).add(this,t-1),this},front:function(){var t=this.parent();return t.node.appendChild(this.node),t instanceof m.Doc&&t.node.appendChild(t.defs().node),this},back:function(){return this.position()>0&&this.parent().removeElement(this).add(this,0),this},before:function(t){t.remove();var e=this.position();return this.parent().add(t,e),this},after:function(t){t.remove();var e=this.position();return this.parent().add(t,e+1),this}}),m.Mask=m.invent({create:function(){this.constructor.call(this,m.create("mask")),this.targets=[]},inherit:m.Container,extend:{remove:function(){for(var t=this.targets.length-1;t>=0;t--)this.targets[t]&&this.targets[t].unmask();return delete this.targets,this.parent().removeElement(this),this}},construct:{mask:function(){return this.defs().put(new m.Mask)}}}),m.extend(m.Element,{maskWith:function(t){return this.masker=t instanceof m.Mask?t:this.parent().mask().add(t),this.masker.targets.push(this),this.attr("mask",'url("#'+this.masker.attr("id")+'")')},unmask:function(){return delete this.masker,this.attr("mask",null)}}),m.ClipPath=m.invent({create:function(){this.constructor.call(this,m.create("clipPath")),this.targets=[]},inherit:m.Container,extend:{remove:function(){for(var t=this.targets.length-1;t>=0;t--)this.targets[t]&&this.targets[t].unclip();return delete this.targets,this.parent().removeElement(this),this}},construct:{clip:function(){return this.defs().put(new m.ClipPath)}}}),m.extend(m.Element,{clipWith:function(t){return this.clipper=t instanceof m.ClipPath?t:this.parent().clip().add(t),this.clipper.targets.push(this),this.attr("clip-path",'url("#'+this.clipper.attr("id")+'")')},unclip:function(){return delete this.clipper,this.attr("clip-path",null)}}),m.Gradient=m.invent({create:function(t){this.constructor.call(this,m.create(t+"Gradient")),this.type=t},inherit:m.Container,extend:{at:function(t,e,i){return this.put(new m.Stop).update(t,e,i)},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},fill:function(){return"url(#"+this.id()+")"
+},toString:function(){return this.fill()}},construct:{gradient:function(t,e){return this.defs().gradient(t,e)}}}),m.extend(m.Gradient,m.FX,{from:function(t,e){return this.attr("radial"==(this.target||this).type?{fx:new m.Number(t),fy:new m.Number(e)}:{x1:new m.Number(t),y1:new m.Number(e)})},to:function(t,e){return this.attr("radial"==(this.target||this).type?{cx:new m.Number(t),cy:new m.Number(e)}:{x2:new m.Number(t),y2:new m.Number(e)})}}),m.extend(m.Defs,{gradient:function(t,e){return this.put(new m.Gradient(t)).update(e)}}),m.Stop=m.invent({create:"stop",inherit:m.Element,extend:{update:function(t){return("number"==typeof t||t instanceof m.Number)&&(t={offset:arguments[0],color:arguments[1],opacity:arguments[2]}),null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new m.Number(t.offset)),this}}}),m.Pattern=m.invent({create:"pattern",inherit:m.Container,extend:{fill:function(){return"url(#"+this.id()+")"},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},toString:function(){return this.fill()}},construct:{pattern:function(t,e,i){return this.defs().pattern(t,e,i)}}}),m.extend(m.Defs,{pattern:function(t,e,i){return this.put(new m.Pattern).update(i).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),m.Doc=m.invent({create:function(t){t&&(t="string"==typeof t?document.getElementById(t):t,"svg"==t.nodeName?this.constructor.call(this,t):(this.constructor.call(this,m.create("svg")),t.appendChild(this.node)),this.namespace().size("100%","100%").defs())},inherit:m.Container,extend:{namespace:function(){return this.attr({xmlns:m.ns,version:"1.1"}).attr("xmlns:xlink",m.xlink,m.xmlns)},defs:function(){if(!this._defs){var t;this._defs=(t=this.node.getElementsByTagName("defs")[0])?m.adopt(t):new m.Defs,this.node.appendChild(this._defs.node)}return this._defs},parent:function(){return"#document"==this.node.parentNode.nodeName?null:this.node.parentNode}}}),m.extend(m.Doc,{spof:function(){if(this.doSpof){var t=this.node.getScreenCTM();t&&this.style("left",-t.e%1+"px").style("top",-t.f%1+"px")}return this},fixSubPixelOffset:function(){var t=this;return this.doSpof=!0,m.on(window,"resize",function(){t.spof()}),this.spof()}}),m.Shape=m.invent({create:function(t){this.constructor.call(this,t)},inherit:m.Element}),m.Symbol=m.invent({create:"symbol",inherit:m.Container,construct:{symbol:function(){return this.defs().put(new m.Symbol)}}}),m.Use=m.invent({create:"use",inherit:m.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,m.xlink)}},construct:{use:function(t){return this.put(new m.Use).element(t)}}}),m.Rect=m.invent({create:"rect",inherit:m.Shape,construct:{rect:function(t,e){return this.put((new m.Rect).size(t,e))}}}),m.Circle=m.invent({create:"circle",inherit:m.Shape,construct:{circle:function(t){return this.put(new m.Circle).rx(new m.Number(t).divide(2)).move(0,0)}}}),m.extend(m.Circle,m.FX,{rx:function(t){return this.attr("r",t)},ry:function(t){return this.rx(t)}}),m.Ellipse=m.invent({create:"ellipse",inherit:m.Shape,construct:{ellipse:function(t,e){return this.put(new m.Ellipse).size(t,e).move(0,0)}}}),m.extend(m.Ellipse,m.Rect,m.FX,{rx:function(t){return this.attr("rx",t)},ry:function(t){return this.attr("ry",t)}}),m.extend(m.Circle,m.Ellipse,{x:function(t){return null==t?this.cx()-this.rx():this.cx(t+this.rx())},y:function(t){return null==t?this.cy()-this.ry():this.cy(t+this.ry())},cx:function(t){return null==t?this.attr("cx"):this.attr("cx",new m.Number(t).divide(this.transform("scaleX")))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new m.Number(t).divide(this.transform("scaleY")))},width:function(t){return null==t?2*this.rx():this.rx(new m.Number(t).divide(2))},height:function(t){return null==t?2*this.ry():this.ry(new m.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e);return this.rx(new m.Number(i.width).divide(2)).ry(new m.Number(i.height).divide(2))}}),m.Line=m.invent({create:"line",inherit:m.Shape,extend:{array:function(){return new m.PointArray([[this.attr("x1"),this.attr("y1")],[this.attr("x2"),this.attr("y2")]])},plot:function(t,e,i,n){return t=4==arguments.length?{x1:t,y1:e,x2:i,y2:n}:new m.PointArray(t).toLine(),this.attr(t)},move:function(t,e){return this.attr(this.array().move(t,e).toLine())},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr(this.array().size(i.width,i.height).toLine())}},construct:{line:function(t,e,i,n){return this.put(new m.Line).plot(t,e,i,n)}}}),m.Polyline=m.invent({create:"polyline",inherit:m.Shape,construct:{polyline:function(t){return this.put(new m.Polyline).plot(t)}}}),m.Polygon=m.invent({create:"polygon",inherit:m.Shape,construct:{polygon:function(t){return this.put(new m.Polygon).plot(t)}}}),m.extend(m.Polyline,m.Polygon,{array:function(){return this._array||(this._array=new m.PointArray(this.attr("points")))},plot:function(t){return this.attr("points",this._array=new m.PointArray(t))},move:function(t,e){return this.attr("points",this.array().move(t,e))},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr("points",this.array().size(i.width,i.height))}}),m.extend(m.Line,m.Polyline,m.Polygon,{morphArray:m.PointArray,x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},width:function(t){var e=this.bbox();return null==t?e.width:this.size(t,e.height)},height:function(t){var e=this.bbox();return null==t?e.height:this.size(e.width,t)}}),m.Path=m.invent({create:"path",inherit:m.Shape,extend:{morphArray:m.PathArray,array:function(){return this._array||(this._array=new m.PathArray(this.attr("d")))},plot:function(t){return this.attr("d",this._array=new m.PathArray(t))},move:function(t,e){return this.attr("d",this.array().move(t,e))},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr("d",this.array().size(i.width,i.height))},width:function(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)},height:function(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}},construct:{path:function(t){return this.put(new m.Path).plot(t)}}}),m.Image=m.invent({create:"image",inherit:m.Shape,extend:{load:function(t){if(!t)return this;var e=this,i=document.createElement("img");return i.onload=function(){var n=e.doc(m.Pattern);0==e.width()&&0==e.height()&&e.size(i.width,i.height),n&&0==n.width()&&0==n.height()&&n.size(e.width(),e.height()),"function"==typeof e._loaded&&e._loaded.call(e,{width:i.width,height:i.height,ratio:i.width/i.height,url:t})},this.attr("href",i.src=this.src=t,m.xlink)},loaded:function(t){return this._loaded=t,this}},construct:{image:function(t,e,i){return this.put(new m.Image).load(t).size(e||0,i||e||0)}}}),m.Text=m.invent({create:function(){this.constructor.call(this,m.create("text")),this._leading=new m.Number(1.3),this._rebuild=!0,this._build=!1,this.attr("font-family",m.defaults.attrs["font-family"])},inherit:m.Shape,extend:{x:function(t){return null==t?this.attr("x"):(this.textPath||this.lines.each(function(){this.newLined&&this.x(t)}),this.attr("x",t))},y:function(t){var e=this.attr("y"),i="number"==typeof e?e-this.bbox().y:0;return null==t?"number"==typeof e?e-i:e:this.attr("y","number"==typeof t?t+i:t)},cx:function(t){return null==t?this.bbox().cx:this.x(t-this.bbox().width/2)},cy:function(t){return null==t?this.bbox().cy:this.y(t-this.bbox().height/2)},text:function(t){if("undefined"==typeof t)return this.content;if(this.clear().build(!0),"function"==typeof t)t.call(this,this);else{t=(this.content=t).split("\n");for(var e=0,i=t.length;i>e;e++)this.tspan(t[e]).newLine()}return this.build(!1).rebuild()},size:function(t){return this.attr("font-size",t).rebuild()},leading:function(t){return null==t?this._leading:(this._leading=new m.Number(t),this.rebuild())},rebuild:function(t){if("boolean"==typeof t&&(this._rebuild=t),this._rebuild){var e=this;this.lines.each(function(){this.newLined&&(this.textPath||this.attr("x",e.attr("x")),this.attr("dy",e._leading*new m.Number(e.attr("font-size"))))}),this.fire("rebuild")}return this},build:function(t){return this._build=!!t,this}},construct:{text:function(t){return this.put(new m.Text).text(t)},plain:function(t){return this.put(new m.Text).plain(t)}}}),m.Tspan=m.invent({create:"tspan",inherit:m.Shape,extend:{text:function(t){return"function"==typeof t?t.call(this,this):this.plain(t),this},dx:function(t){return this.attr("dx",t)},dy:function(t){return this.attr("dy",t)},newLine:function(){var t=this.doc(m.Text);return this.newLined=!0,this.dy(t._leading*t.attr("font-size")).attr("x",t.x())}}}),m.extend(m.Text,m.Tspan,{plain:function(t){return this._build===!1&&this.clear(),this.node.appendChild(document.createTextNode(this.content=t)),this},tspan:function(t){var e=(this.textPath||this).node,i=new m.Tspan;return this._build===!1&&this.clear(),e.appendChild(i.node),this instanceof m.Text&&this.lines.add(i),i.text(t)},clear:function(){for(var t=(this.textPath||this).node;t.hasChildNodes();)t.removeChild(t.lastChild);return this instanceof m.Text&&(delete this.lines,this.lines=new m.Set,this.content=""),this},length:function(){return this.node.getComputedTextLength()}}),m.registerEvent("rebuild"),m.TextPath=m.invent({create:"textPath",inherit:m.Element,parent:m.Text,construct:{path:function(t){for(this.textPath=new m.TextPath;this.node.hasChildNodes();)this.textPath.node.appendChild(this.node.firstChild);return this.node.appendChild(this.textPath.node),this.track=this.doc().defs().path(t),this.textPath.parent=this,this.textPath.attr("href","#"+this.track,m.xlink),this},plot:function(t){return this.track&&this.track.plot(t),this}}}),m.Nested=m.invent({create:function(){this.constructor.call(this,m.create("svg")),this.style("overflow","visible")},inherit:m.Container,construct:{nested:function(){return this.put(new m.Nested)}}}),m.A=m.invent({create:"a",inherit:m.Container,extend:{to:function(t){return this.attr("href",t,m.xlink)},show:function(t){return this.attr("show",t,m.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new m.A).to(t)}}}),m.extend(m.Element,{linkTo:function(t){var e=new m.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent().put(e).put(this)}}),m.Marker=m.invent({create:"marker",inherit:m.Container,extend:{width:function(t){return this.attr("markerWidth",t)},height:function(t){return this.attr("markerHeight",t)},ref:function(t,e){return this.attr("refX",t).attr("refY",e)},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},toString:function(){return"url(#"+this.id()+")"}},construct:{marker:function(t,e,i){return this.defs().marker(t,e,i)}}}),m.extend(m.Defs,{marker:function(t,e,i){return this.put(new m.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(i)}}),m.extend(m.Line,m.Polyline,m.Polygon,m.Path,{marker:function(t,e,i,n){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof m.Marker?arguments[1]:this.doc().marker(e,i,n),this.attr(r,t)}});var x={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};["fill","stroke"].forEach(function(t){var e,i={};i[t]=function(i){if("string"==typeof i||m.Color.isRgb(i)||i&&"function"==typeof i.fill)this.attr(t,i);else for(e=x[t].length-1;e>=0;e--)null!=i[x[t][e]]&&this.attr(x.prefix(t,x[t][e]),i[x[t][e]]);return this},m.extend(m.Element,m.FX,i)}),m.extend(m.Element,m.FX,{rotate:function(t,e,i){return this.transform({rotation:t,cx:e,cy:i})},skew:function(t,e,i,n){return this.transform({skewX:t,skewY:e,cx:i,cy:n})},scale:function(t,e,i,n){return this.transform(1==arguments.length||3==arguments.length?{scale:t,cx:e,cy:i}:{scaleX:t,scaleY:e,cx:i,cy:n})},translate:function(t,e){return this.transform({x:t,y:e})},flip:function(t,e){return this.transform({flip:t,offset:e})},matrix:function(t){return this.attr("transform",new m.Matrix(t))},opacity:function(t){return this.attr("opacity",t)}}),m.extend(m.Rect,m.Ellipse,m.Circle,m.Gradient,m.FX,{radius:function(t,e){return"radial"==(this.target||this).type?this.attr({r:new m.Number(t)}):this.rx(t).ry(null==e?t:e)}}),m.extend(m.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),m.extend(m.Parent,m.Text,m.FX,{font:function(t){for(var e in t)"leading"==e?this.leading(t[e]):"anchor"==e?this.attr("text-anchor",t[e]):"size"==e||"family"==e||"weight"==e||"stretch"==e||"variant"==e||"style"==e?this.attr("font-"+e,t[e]):this.attr(e,t[e]);return this}}),m.Set=m.invent({create:function(t){Array.isArray(t)?this.members=t:this.clear()},extend:{add:function(){var t,e,i=[].slice.call(arguments);for(t=0,e=i.length;e>t;t++)this.members.push(i[t]);return this},remove:function(t){var e=this.index(t);return e>-1&&this.members.splice(e,1),this},each:function(t){for(var e=0,i=this.members.length;i>e;e++)t.apply(this.members[e],[e,this.members]);return this},clear:function(){return this.members=[],this},has:function(t){return this.index(t)>=0},index:function(t){return this.members.indexOf(t)},get:function(t){return this.members[t]},first:function(){return this.get(0)},last:function(){return this.get(this.members.length-1)},valueOf:function(){return this.members},bbox:function(){var t=new m.BBox;if(0==this.members.length)return t;var e=this.members[0].rbox();return t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height,this.each(function(){t=t.merge(this.rbox())}),t}},construct:{set:function(t){return new m.Set(t)}}}),m.FX.Set=m.invent({create:function(t){this.set=t}}),m.Set.inherit=function(){var t,e=[];for(var t in m.Shape.prototype)"function"==typeof m.Shape.prototype[t]&&"function"!=typeof m.Set.prototype[t]&&e.push(t);e.forEach(function(t){m.Set.prototype[t]=function(){for(var e=0,i=this.members.length;i>e;e++)this.members[e]&&"function"==typeof this.members[e][t]&&this.members[e][t].apply(this.members[e],arguments);return"animate"==t?this.fx||(this.fx=new m.FX.Set(this)):this}}),e=[];for(var t in m.FX.prototype)"function"==typeof m.FX.prototype[t]&&"function"!=typeof m.FX.Set.prototype[t]&&e.push(t);e.forEach(function(t){m.FX.Set.prototype[t]=function(){for(var e=0,i=this.set.members.length;i>e;e++)this.set.members[e].fx[t].apply(this.set.members[e].fx,arguments);return this}})},m.extend(m.Element,{data:function(t,e,i){if("object"==typeof t)for(e in t)this.data(e,t[e]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+t))}catch(n){return this.attr("data-"+t)}else this.attr("data-"+t,null===e?null:i===!0||"string"==typeof e||"number"==typeof e?e:JSON.stringify(e));return this}}),m.extend(m.Element,{remember:function(t,e){if("object"==typeof arguments[0])for(var e in t)this.remember(e,t[e]);else{if(1==arguments.length)return this.memory()[t];this.memory()[t]=e}return this},forget:function(){if(0==arguments.length)this._memory={};else for(var t=arguments.length-1;t>=0;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory||(this._memory={})}}),m.get=function(t){var e=document.getElementById(d(t)||t);return e?m.adopt(e):void 0},m.select=function(t,e){return new m.Set(m.utils.map((e||document).querySelectorAll(t),function(t){return m.adopt(t)}))},m.extend(m.Parent,{select:function(t){return m.select(t,this.node)}}),"function"==typeof define&&define.amd?define(function(){return m}):"undefined"!=typeof exports&&(exports.SVG=m);var g="abcdef".split("");window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}(),"function"!=typeof p&&(p.prototype=window.Event.prototype,window.CustomEvent=p)}).call(this); \ No newline at end of file
diff --git a/src/fx.js b/src/fx.js
index ddbbcd0..a2903fe 100755
--- a/src/fx.js
+++ b/src/fx.js
@@ -38,31 +38,32 @@ SVG.FX = SVG.invent({
akeys.push(key)
// make sure morphable elements are scaled, translated and morphed all together
- if (element.morphArray && (fx._plot || akeys.indexOf('points') > -1)) {
+ if (element.morphArray && (fx.destination.plot || akeys.indexOf('points') > -1)) {
// get destination
var box
- , p = new element.morphArray(fx._plot || fx.attrs.points || element.array)
+ , p = new element.morphArray(fx.destination.plot || fx.attrs.points || element.array)
// add size
- if (fx._size) p.size(fx._size.width.to, fx._size.height.to)
+ if (fx.destination.size)
+ p.size(fx.destination.size.width.to, fx.destination.size.height.to)
// add movement
box = p.bbox()
- if (fx._x) p.move(fx._x.to, box.y)
- else if (fx._cx) p.move(fx._cx.to - box.width / 2, box.y)
+ if (fx.destination.x)
+ p.move(fx.destination.x.to, box.y)
+ else if (fx.destination.cx)
+ p.move(fx.destination.cx.to - box.width / 2, box.y)
box = p.bbox()
- if (fx._y) p.move(box.x, fx._y.to)
- else if (fx._cy) p.move(box.x, fx._cy.to - box.height / 2)
-
- // delete element oriented changes
- delete fx._x
- delete fx._y
- delete fx._cx
- delete fx._cy
- delete fx._size
-
- fx._plot = element.array.morph(p)
+ if (fx.destination.y)
+ p.move(box.x, fx.destination.y.to)
+ else if (fx.destination.cy)
+ p.move(box.x, fx.destination.cy.to - box.height / 2)
+
+ // reset destination values
+ fx.destination = {
+ plot: element.array.morph(p)
+ }
}
}
@@ -87,39 +88,39 @@ SVG.FX = SVG.invent({
pos
// run plot function
- if (fx._plot) {
- element.plot(fx._plot.at(pos))
+ if (fx.destination.plot) {
+ element.plot(fx.destination.plot.at(pos))
} else {
// run all x-position properties
- if (fx._x)
- element.x(fx._x.at(pos))
- else if (fx._cx)
- element.cx(fx._cx.at(pos))
+ if (fx.destination.x)
+ element.x(fx.destination.x.at(pos))
+ else if (fx.destination.cx)
+ element.cx(fx.destination.cx.at(pos))
// run all y-position properties
- if (fx._y)
- element.y(fx._y.at(pos))
- else if (fx._cy)
- element.cy(fx._cy.at(pos))
+ if (fx.destination.y)
+ element.y(fx.destination.y.at(pos))
+ else if (fx.destination.cy)
+ element.cy(fx.destination.cy.at(pos))
// run all size properties
- if (fx._size)
- element.size(fx._size.width.at(pos), fx._size.height.at(pos))
+ if (fx.destination.size)
+ element.size(fx.destination.size.width.at(pos), fx.destination.size.height.at(pos))
}
// run all viewbox properties
- if (fx._viewbox)
+ if (fx.destination.viewbox)
element.viewbox(
- fx._viewbox.x.at(pos)
- , fx._viewbox.y.at(pos)
- , fx._viewbox.width.at(pos)
- , fx._viewbox.height.at(pos)
+ fx.destination.viewbox.x.at(pos)
+ , fx.destination.viewbox.y.at(pos)
+ , fx.destination.viewbox.width.at(pos)
+ , fx.destination.viewbox.height.at(pos)
)
// run leading property
- if (fx._leading)
- element.leading(fx._leading.at(pos))
+ if (fx.destination.leading)
+ element.leading(fx.destination.leading.at(pos))
// animate attributes
for (i = akeys.length - 1; i >= 0; i--)
@@ -130,8 +131,8 @@ SVG.FX = SVG.invent({
element.style(skeys[i], at(fx.styles[skeys[i]], pos))
// callback for each keyframe
- if (fx._during)
- fx._during.call(element, pos, function(from, to) {
+ if (fx.situation.during)
+ fx.situation.during.call(element, pos, function(from, to) {
return at({ from: from, to: to }, pos)
})
}
@@ -142,13 +143,11 @@ SVG.FX = SVG.invent({
var start = new Date().getTime()
// initialize situation object
- fx.situation = {
- interval: 1000 / 60
- , start: start
- , play: true
- , finish: start + d
- , duration: d
- }
+ fx.situation.start = start
+ fx.situation.play = true
+ fx.situation.finish = start + d
+ fx.situation.duration = d
+ fx.situation.ease = ease
// render function
fx.render = function() {
@@ -157,21 +156,37 @@ SVG.FX = SVG.invent({
// calculate pos
var time = new Date().getTime()
, pos = time > fx.situation.finish ? 1 : (time - fx.situation.start) / d
+
+ // reverse pos if animation is reversed
+ if (fx.situation.reversing)
+ pos = -pos + 1
// process values
fx.at(pos)
// finish off animation
if (time > fx.situation.finish) {
- if (fx._plot)
- element.plot(new SVG.PointArray(fx._plot.destination).settle())
-
- if (fx._loop === true || (typeof fx._loop == 'number' && fx._loop > 1)) {
- if (typeof fx._loop == 'number')
- --fx._loop
+ if (fx.destination.plot)
+ element.plot(new SVG.PointArray(fx.destination.plot.destination).settle())
+
+ if (fx.situation.loop === true || (typeof fx.situation.loop == 'number' && fx.situation.loop > 0)) {
+ // register reverse
+ if (fx.situation.reverse)
+ fx.situation.reversing = !fx.situation.reversing
+
+ if (typeof fx.situation.loop == 'number') {
+ // reduce loop count
+ if (!fx.situation.reverse || fx.situation.reversing)
+ --fx.situation.loop
+
+ // remove last loop if reverse is disabled
+ if (!fx.situation.reverse && fx.situation.loop == 1)
+ --fx.situation.loop
+ }
+
fx.animate(d, ease, delay)
} else {
- fx._after ? fx._after.apply(element, [fx]) : fx.stop()
+ fx.situation.after ? fx.situation.after.apply(element, [fx]) : fx.stop()
}
} else {
@@ -231,25 +246,25 @@ SVG.FX = SVG.invent({
}
// Animatable x-axis
, x: function(x) {
- this._x = new SVG.Number(this.target.x()).morph(x)
+ this.destination.x = new SVG.Number(this.target.x()).morph(x)
return this
}
// Animatable y-axis
, y: function(y) {
- this._y = new SVG.Number(this.target.y()).morph(y)
+ this.destination.y = new SVG.Number(this.target.y()).morph(y)
return this
}
// Animatable center x-axis
, cx: function(x) {
- this._cx = new SVG.Number(this.target.cx()).morph(x)
+ this.destination.cx = new SVG.Number(this.target.cx()).morph(x)
return this
}
// Animatable center y-axis
, cy: function(y) {
- this._cy = new SVG.Number(this.target.cy()).morph(y)
+ this.destination.cy = new SVG.Number(this.target.cy()).morph(y)
return this
}
@@ -271,7 +286,7 @@ SVG.FX = SVG.invent({
// animate bbox based size for all other elements
var box = this.target.bbox()
- this._size = {
+ this.destination.size = {
width: new SVG.Number(box.width).morph(width)
, height: new SVG.Number(box.height).morph(height)
}
@@ -281,14 +296,14 @@ SVG.FX = SVG.invent({
}
// Add animatable plot
, plot: function(p) {
- this._plot = p
+ this.destination.plot = p
return this
}
// Add leading method
, leading: function(value) {
- if (this.target._leading)
- this._leading = new SVG.Number(this.target._leading).morph(value)
+ if (this.target.destination.leading)
+ this.destination.leading = new SVG.Number(this.target.destination.leading).morph(value)
return this
}
@@ -297,7 +312,7 @@ SVG.FX = SVG.invent({
if (this.target instanceof SVG.Container) {
var box = this.target.viewbox()
- this._viewbox = {
+ this.destination.viewbox = {
x: new SVG.Number(box.x).morph(x)
, y: new SVG.Number(box.y).morph(y)
, width: new SVG.Number(box.width).morph(width)
@@ -319,19 +334,23 @@ SVG.FX = SVG.invent({
}
// Add callback for each keyframe
, during: function(during) {
- this._during = during
+ this.situation.during = during
return this
}
// Callback after animation
, after: function(after) {
- this._after = after
+ this.situation.after = after
return this
}
// Make loopable
- , loop: function(times) {
- this._loop = times || true
+ , loop: function(times, reverse) {
+ // store current loop and total loops
+ this.situation.loop = this.situation.loops = times || true
+
+ // make reversable
+ this.situation.reverse = !!reverse
return this
}
@@ -342,31 +361,18 @@ SVG.FX = SVG.invent({
this.animate(0)
- if (this._after)
- this._after.apply(this.target, [this])
+ if (this.situation.after)
+ this.situation.after.apply(this.target, [this])
} else {
// stop current animation
clearTimeout(this.timeout)
- // reset storage for properties that need animation
- this.attrs = {}
- this.trans = {}
- this.styles = {}
- this.situation = {}
-
- // delete destinations
- delete this._x
- delete this._y
- delete this._cx
- delete this._cy
- delete this._size
- delete this._plot
- delete this._loop
- delete this._after
- delete this._during
- delete this._leading
- delete this._viewbox
+ // reset storage for properties
+ this.attrs = {}
+ this.styles = {}
+ this.situation = {}
+ this.destination = {}
}
return this
diff --git a/src/parent.js b/src/parent.js
index bde35da..1954259 100755
--- a/src/parent.js
+++ b/src/parent.js
@@ -18,10 +18,10 @@ SVG.Parent = SVG.invent({
// Add given element at a position
, add: function(element, i) {
if (!this.has(element)) {
- // Define insertion index if none given
+ // define insertion index if none given
i = i == null ? this.children().length : i
- // Add element references
+ // add element references
this.node.insertBefore(element.node, this.node.childNodes[i] || null)
}
diff --git a/src/set.js b/src/set.js
index a4690bf..8c055cf 100755
--- a/src/set.js
+++ b/src/set.js
@@ -20,7 +20,7 @@ SVG.Set = SVG.invent({
, remove: function(element) {
var i = this.index(element)
- /* remove given child */
+ // remove given child
if (i > -1)
this.members.splice(i, 1)
@@ -35,7 +35,7 @@ SVG.Set = SVG.invent({
}
// Restore to defaults
, clear: function() {
- /* initialize store */
+ // initialize store
this.members = []
return this
@@ -68,11 +68,11 @@ SVG.Set = SVG.invent({
, bbox: function(){
var box = new SVG.BBox()
- /* return an empty box of there are no members */
+ // return an empty box of there are no members
if (this.members.length == 0)
return box
- /* get the first rbox and update the target bbox */
+ // get the first rbox and update the target bbox
var rbox = this.members[0].rbox()
box.x = rbox.x
box.y = rbox.y
@@ -80,7 +80,7 @@ SVG.Set = SVG.invent({
box.height = rbox.height
this.each(function() {
- /* user rbox for correct position and visual representation */
+ // user rbox for correct position and visual representation
box = box.merge(this.rbox())
})
@@ -97,10 +97,10 @@ SVG.Set = SVG.invent({
}
})
-SVG.SetFX = SVG.invent({
+SVG.FX.Set = SVG.invent({
// Initialize node
create: function(set) {
- /* store reference to set */
+ // store reference to set
this.set = set
}
@@ -111,33 +111,33 @@ SVG.Set.inherit = function() {
var m
, methods = []
- /* gather shape methods */
+ // gather shape methods
for(var m in SVG.Shape.prototype)
if (typeof SVG.Shape.prototype[m] == 'function' && typeof SVG.Set.prototype[m] != 'function')
methods.push(m)
- /* apply shape aliasses */
+ // apply shape aliasses
methods.forEach(function(method) {
SVG.Set.prototype[method] = function() {
for (var i = 0, il = this.members.length; i < il; i++)
if (this.members[i] && typeof this.members[i][method] == 'function')
this.members[i][method].apply(this.members[i], arguments)
- return method == 'animate' ? (this.fx || (this.fx = new SVG.SetFX(this))) : this
+ return method == 'animate' ? (this.fx || (this.fx = new SVG.FX.Set(this))) : this
}
})
- /* clear methods for the next round */
+ // clear methods for the next round
methods = []
- /* gather fx methods */
+ // gather fx methods
for(var m in SVG.FX.prototype)
- if (typeof SVG.FX.prototype[m] == 'function' && typeof SVG.SetFX.prototype[m] != 'function')
+ if (typeof SVG.FX.prototype[m] == 'function' && typeof SVG.FX.Set.prototype[m] != 'function')
methods.push(m)
- /* apply fx aliasses */
+ // apply fx aliasses
methods.forEach(function(method) {
- SVG.SetFX.prototype[method] = function() {
+ SVG.FX.Set.prototype[method] = function() {
for (var i = 0, il = this.set.members.length; i < il; i++)
this.set.members[i].fx[method].apply(this.set.members[i].fx, arguments)