|
|
@@ -1,13 +1,13 @@ |
|
|
|
/*! |
|
|
|
* svg.js - A lightweight library for manipulating and animating SVG. |
|
|
|
* @version 2.7.1 |
|
|
|
* https://svgdotjs.github.io/ |
|
|
|
* |
|
|
|
* @copyright Wout Fierens <wout@mick-wout.com> |
|
|
|
* @license MIT |
|
|
|
* |
|
|
|
* BUILT: Fri Nov 30 2018 10:01:55 GMT+0100 (GMT+01:00) |
|
|
|
*/; |
|
|
|
/*!
|
|
|
|
* svg.js - A lightweight library for manipulating and animating SVG.
|
|
|
|
* @version 2.7.1
|
|
|
|
* https://svgdotjs.github.io/
|
|
|
|
*
|
|
|
|
* @copyright Wout Fierens <wout@mick-wout.com>
|
|
|
|
* @license MIT
|
|
|
|
*
|
|
|
|
* BUILT: Fri Nov 30 2018 10:01:55 GMT+0100 (GMT+01:00)
|
|
|
|
*/;
|
|
|
|
(function(root, factory) {
|
|
|
|
/* istanbul ignore next */
|
|
|
|
if (typeof define === 'function' && define.amd) {
|
|
|
@@ -177,7 +177,7 @@ document.addEventListener('DOMContentLoaded', function() { |
|
|
|
if(!SVG.parser.draw)
|
|
|
|
SVG.prepare()
|
|
|
|
}, false)
|
|
|
|
|
|
|
|
|
|
|
|
// Storage for regular expressions
|
|
|
|
SVG.regex = {
|
|
|
|
// Parse unit value
|
|
|
@@ -239,7 +239,7 @@ SVG.regex = { |
|
|
|
// matches .
|
|
|
|
, dots: /\./g
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SVG.utils = {
|
|
|
|
// Map function
|
|
|
|
map: function(array, block) {
|
|
|
@@ -280,7 +280,7 @@ SVG.utils = { |
|
|
|
return this.filter( nodes, function(el) { return el instanceof window.SVGElement })
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
|
|
|
}
|
|
|
|
|
|
|
|
SVG.defaults = {
|
|
|
|
// Default attribute values
|
|
|
@@ -316,7 +316,7 @@ SVG.defaults = { |
|
|
|
, 'text-anchor': 'start'
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
|
|
|
}
|
|
|
|
// Module for color convertions
|
|
|
|
SVG.Color = function(color) {
|
|
|
|
var match
|
|
|
@@ -424,7 +424,7 @@ SVG.Color.isRgb = function(color) { |
|
|
|
// Test if given value is a color
|
|
|
|
SVG.Color.isColor = function(color) {
|
|
|
|
return SVG.Color.isRgb(color) || SVG.Color.test(color)
|
|
|
|
} |
|
|
|
}
|
|
|
|
// Module for array conversion
|
|
|
|
SVG.Array = function(array, fallback) {
|
|
|
|
array = (array || []).valueOf()
|
|
|
@@ -508,7 +508,7 @@ SVG.extend(SVG.Array, { |
|
|
|
clone.value = array_clone(this.value)
|
|
|
|
return clone
|
|
|
|
}
|
|
|
|
}) |
|
|
|
})
|
|
|
|
// Poly points array
|
|
|
|
SVG.PointArray = function(array, fallback) {
|
|
|
|
SVG.Array.call(this, array, fallback || [[0,0]])
|
|
|
@@ -615,7 +615,7 @@ SVG.extend(SVG.PointArray, { |
|
|
|
return SVG.parser.poly.getBBox()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
var pathHandlers = {
|
|
|
|
M: function(c, p, p0) {
|
|
|
|
p.x = p0.x = c[0]
|
|
|
@@ -913,7 +913,7 @@ SVG.extend(SVG.PathArray, { |
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Module for unit convertions
|
|
|
|
SVG.Number = SVG.invent({
|
|
|
|
// Initialize
|
|
|
@@ -1024,7 +1024,7 @@ SVG.Number = SVG.invent({ |
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Element = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
@@ -1296,7 +1296,7 @@ SVG.Element = SVG.invent({ |
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.easing = {
|
|
|
|
'-': function(pos){return pos}
|
|
|
|
, '<>':function(pos){return -Math.cos(pos * Math.PI) / 2 + 0.5}
|
|
|
@@ -2217,7 +2217,7 @@ SVG.extend(SVG.FX, { |
|
|
|
return this
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Box = SVG.invent({
|
|
|
|
create: function(x, y, width, height) {
|
|
|
|
if (typeof x == 'object' && !(x instanceof SVG.Element)) {
|
|
|
@@ -2296,10 +2296,13 @@ SVG.BBox = SVG.invent({ |
|
|
|
while (topParent.parentNode){
|
|
|
|
topParent = topParent.parentNode
|
|
|
|
}
|
|
|
|
if (topParent != document) throw new Exception('Element not in the dom')
|
|
|
|
if (topParent != document || !(topParent instanceof ShadowRoot))
|
|
|
|
throw new Exception('Element not in the dom')
|
|
|
|
} else {
|
|
|
|
// the element is NOT in the dom, throw error
|
|
|
|
if(!document.documentElement.contains(element.node)) throw new Exception('Element not in the dom')
|
|
|
|
if(!document.documentElement.contains(element.node) &&
|
|
|
|
!(element.node.getRootNode() instanceof ShadowRoot))
|
|
|
|
throw new Exception('Element not in the dom')
|
|
|
|
}
|
|
|
|
|
|
|
|
// find native bbox
|
|
|
@@ -2386,7 +2389,7 @@ SVG.RBox = SVG.invent({ |
|
|
|
})
|
|
|
|
|
|
|
|
SVG.RBox.prototype.constructor = SVG.RBox
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Matrix = SVG.invent({
|
|
|
|
// Initialize
|
|
|
|
create: function(source) {
|
|
|
@@ -2590,7 +2593,7 @@ SVG.Matrix = SVG.invent({ |
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Point = SVG.invent({
|
|
|
|
// Initialize
|
|
|
|
create: function(x,y) {
|
|
|
@@ -2663,7 +2666,7 @@ SVG.extend(SVG.Element, { |
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.extend(SVG.Element, {
|
|
|
|
// Set svg element attribute
|
|
|
|
attr: function(a, v, n) {
|
|
|
@@ -2742,7 +2745,7 @@ SVG.extend(SVG.Element, { |
|
|
|
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.extend(SVG.Element, {
|
|
|
|
// Add transformations
|
|
|
|
transform: function(o, relative) {
|
|
|
@@ -3113,7 +3116,7 @@ SVG.Skew = SVG.invent({ |
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.extend(SVG.Element, {
|
|
|
|
// Dynamic style generator
|
|
|
|
style: function(s, v) {
|
|
|
@@ -3148,7 +3151,7 @@ SVG.extend(SVG.Element, { |
|
|
|
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.Parent = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: function(element) {
|
|
|
@@ -3239,7 +3242,7 @@ SVG.Parent = SVG.invent({ |
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.extend(SVG.Parent, {
|
|
|
|
|
|
|
|
ungroup: function(parent, depth) {
|
|
|
@@ -3263,7 +3266,7 @@ SVG.extend(SVG.Parent, { |
|
|
|
return this.ungroup(parent, depth)
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.Container = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: function(element) {
|
|
|
@@ -3273,7 +3276,7 @@ SVG.Container = SVG.invent({ |
|
|
|
// Inherit from
|
|
|
|
, inherit: SVG.Parent
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
|
|
|
|
SVG.ViewBox = SVG.invent({
|
|
|
|
|
|
|
@@ -3400,7 +3403,7 @@ SVG.ViewBox = SVG.invent({ |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
// Add events to elements
|
|
|
|
|
|
|
|
;[ 'click',
|
|
|
@@ -3541,7 +3544,7 @@ SVG.extend(SVG.Element, { |
|
|
|
return this._event
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Defs = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
@@ -3550,7 +3553,7 @@ SVG.Defs = SVG.invent({ |
|
|
|
// Inherit from
|
|
|
|
, inherit: SVG.Container
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.G = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'g'
|
|
|
@@ -3601,7 +3604,7 @@ SVG.G = SVG.invent({ |
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Doc = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: function(element) {
|
|
|
@@ -3717,7 +3720,7 @@ SVG.Doc = SVG.invent({ |
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// ### This module adds backward / forward functionality to elements.
|
|
|
|
|
|
|
|
//
|
|
|
@@ -3802,7 +3805,7 @@ SVG.extend(SVG.Element, { |
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.Mask = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: function() {
|
|
|
@@ -3861,7 +3864,7 @@ SVG.extend(SVG.Element, { |
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.ClipPath = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: function() {
|
|
|
@@ -3919,7 +3922,7 @@ SVG.extend(SVG.Element, { |
|
|
|
return this.attr('clip-path', null)
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.Gradient = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: function(type) {
|
|
|
@@ -4027,7 +4030,7 @@ SVG.Stop = SVG.invent({ |
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Pattern = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'pattern'
|
|
|
@@ -4085,7 +4088,7 @@ SVG.extend(SVG.Defs, { |
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.Shape = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: function(element) {
|
|
|
@@ -4095,7 +4098,7 @@ SVG.Shape = SVG.invent({ |
|
|
|
// Inherit from
|
|
|
|
, inherit: SVG.Element
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
|
|
|
|
SVG.Bare = SVG.invent({
|
|
|
|
// Initialize
|
|
|
@@ -4136,7 +4139,7 @@ SVG.extend(SVG.Parent, { |
|
|
|
return this.put(new SVG.Bare(element, inherit))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Symbol = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'symbol'
|
|
|
@@ -4151,7 +4154,7 @@ SVG.Symbol = SVG.invent({ |
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Use = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'use'
|
|
|
@@ -4175,7 +4178,7 @@ SVG.Use = SVG.invent({ |
|
|
|
return this.put(new SVG.Use).element(element, file)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.Rect = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'rect'
|
|
|
@@ -4190,7 +4193,7 @@ SVG.Rect = SVG.invent({ |
|
|
|
return this.put(new SVG.Rect()).size(width, height)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.Circle = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'circle'
|
|
|
@@ -4279,7 +4282,7 @@ SVG.extend(SVG.Circle, SVG.Ellipse, { |
|
|
|
.rx(new SVG.Number(p.width).divide(2))
|
|
|
|
.ry(new SVG.Number(p.height).divide(2))
|
|
|
|
}
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.Line = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'line'
|
|
|
@@ -4332,7 +4335,7 @@ SVG.Line = SVG.invent({ |
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Polyline = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'polyline'
|
|
|
@@ -4396,7 +4399,7 @@ SVG.extend(SVG.Polyline, SVG.Polygon, { |
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// unify all point to point elements
|
|
|
|
SVG.extend(SVG.Line, SVG.Polyline, SVG.Polygon, {
|
|
|
|
// Define morphable array
|
|
|
@@ -4421,7 +4424,7 @@ SVG.extend(SVG.Line, SVG.Polyline, SVG.Polygon, { |
|
|
|
|
|
|
|
return height == null ? b.height : this.size(b.width, height)
|
|
|
|
}
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.Path = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'path'
|
|
|
@@ -4486,7 +4489,7 @@ SVG.Path = SVG.invent({ |
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Image = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'image'
|
|
|
@@ -4559,7 +4562,7 @@ SVG.Image = SVG.invent({ |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.Text = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: function() {
|
|
|
@@ -4809,7 +4812,7 @@ SVG.extend(SVG.Text, SVG.Tspan, { |
|
|
|
return this.node.getComputedTextLength()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.TextPath = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'textPath'
|
|
|
@@ -4872,7 +4875,7 @@ SVG.TextPath = SVG.invent({ |
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Nested = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: function() {
|
|
|
@@ -4891,7 +4894,7 @@ SVG.Nested = SVG.invent({ |
|
|
|
return this.put(new SVG.Nested)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.A = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'a'
|
|
|
@@ -4937,7 +4940,7 @@ SVG.extend(SVG.Element, { |
|
|
|
return this.parent().put(link).put(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.Marker = SVG.invent({
|
|
|
|
// Initialize node
|
|
|
|
create: 'marker'
|
|
|
@@ -5017,7 +5020,7 @@ SVG.extend(SVG.Line, SVG.Polyline, SVG.Polygon, SVG.Path, { |
|
|
|
return this.attr(attr, marker)
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
// Define list of available attributes for stroke and fill
|
|
|
|
var sugar = {
|
|
|
|
stroke: ['color', 'width', 'opacity', 'linecap', 'linejoin', 'miterlimit', 'dasharray', 'dashoffset']
|
|
|
@@ -5135,7 +5138,7 @@ SVG.extend(SVG.Parent, SVG.Text, SVG.Tspan, SVG.FX, { |
|
|
|
this.attr(a, v)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
SVG.Set = SVG.invent({
|
|
|
|
// Initialize
|
|
|
|
create: function(members) {
|
|
|
@@ -5284,7 +5287,7 @@ SVG.Set.inherit = function() { |
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SVG.extend(SVG.Element, {
|
|
|
|
// Store data values on svg nodes
|
|
|
@@ -5313,7 +5316,7 @@ SVG.extend(SVG.Element, { |
|
|
|
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
}) |
|
|
|
})
|
|
|
|
SVG.extend(SVG.Element, {
|
|
|
|
// Remember arbitrary data
|
|
|
|
remember: function(k, v) {
|
|
|
@@ -5349,7 +5352,7 @@ SVG.extend(SVG.Element, { |
|
|
|
return this._memory || (this._memory = {})
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
// Method for getting an element by id
|
|
|
|
SVG.get = function(id) {
|
|
|
|
var node = document.getElementById(idFromReference(id) || id)
|
|
|
@@ -5371,7 +5374,7 @@ SVG.extend(SVG.Parent, { |
|
|
|
return SVG.select(query, this.node)
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
|
})
|
|
|
|
function pathRegReplace(a, b, c, d) {
|
|
|
|
return c + d.replace(SVG.regex.dots, ' .')
|
|
|
|
}
|
|
|
@@ -5550,7 +5553,7 @@ function float32String(v) { |
|
|
|
|
|
|
|
// Create matrix array for looping
|
|
|
|
var abcdef = 'abcdef'.split('')
|
|
|
|
|
|
|
|
|
|
|
|
// Add CustomEvent to IE9 and IE10
|
|
|
|
if (typeof window.CustomEvent !== 'function') {
|
|
|
|
// Code from: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
|
|
|
@@ -5598,4 +5601,4 @@ if (typeof window.CustomEvent !== 'function') { |
|
|
|
|
|
|
|
return SVG
|
|
|
|
|
|
|
|
}));
|
|
|
|
}));
|