aboutsummaryrefslogtreecommitdiffstats
path: root/src/sugar.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-10-25 23:28:12 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-10-25 23:28:12 +0200
commitcfdfcc529dedff770dc54e78d2900d9a790f5766 (patch)
tree7b59c282a7823ded1d182aca95da5d55815456b2 /src/sugar.js
parent464af8b747389b7fdb569a933591c863b9be0f6b (diff)
downloadsvg.js-cfdfcc529dedff770dc54e78d2900d9a790f5766.tar.gz
svg.js-cfdfcc529dedff770dc54e78d2900d9a790f5766.zip
convert everything to es6 classes and imports
Diffstat (limited to 'src/sugar.js')
-rw-r--r--src/sugar.js26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/sugar.js b/src/sugar.js
index ad991af..e33fb10 100644
--- a/src/sugar.js
+++ b/src/sugar.js
@@ -1,3 +1,5 @@
+import {Color, Element, Runner} from './classes.js'
+
// Define list of available attributes for stroke and fill
var sugar = {
stroke: ['color', 'width', 'opacity', 'linecap', 'linejoin', 'miterlimit', 'dasharray', 'dashoffset'],
@@ -16,7 +18,7 @@ var sugar = {
if (typeof o === 'undefined') {
return this
}
- if (typeof o === 'string' || SVG.Color.isRgb(o) || (o && typeof o.fill === 'function')) {
+ if (typeof o === 'string' || Color.isRgb(o) || (o && typeof o.fill === 'function')) {
this.attr(m, o)
} else {
// set all attributes from sugar.fill and sugar.stroke list
@@ -30,19 +32,19 @@ var sugar = {
return this
}
- SVG.extend([SVG.Element, SVG.Timeline], extension)
+ extend([Element, Runner], extension)
})
-SVG.extend([SVG.Element, SVG.Timeline], {
+extend([Element, Runner], {
// Let the user set the matrix directly
matrix: function (mat, b, c, d, e, f) {
// Act as a getter
if (mat == null) {
- return new SVG.Matrix(this)
+ return new Matrix(this)
}
// Act as a setter, the user can pass a matrix or a set of numbers
- return this.attr('transform', new SVG.Matrix(mat, b, c, d, e, f))
+ return this.attr('transform', new Matrix(mat, b, c, d, e, f))
},
// Map rotation to transform
@@ -98,12 +100,12 @@ SVG.extend([SVG.Element, SVG.Timeline], {
// Relative move over x axis
dx: function (x) {
- return this.x(new SVG.Number(x).plus(this instanceof SVG.Timeline ? 0 : this.x()), true)
+ return this.x(new SVGNumber(x).plus(this instanceof Runner ? 0 : this.x()), true)
},
// Relative move over y axis
dy: function (y) {
- return this.y(new SVG.Number(y).plus(this instanceof SVG.Timeline ? 0 : this.y()), true)
+ return this.y(new SVGNumber(y).plus(this instanceof Runner ? 0 : this.y()), true)
},
// Relative move over x and y axes
@@ -112,28 +114,28 @@ SVG.extend([SVG.Element, SVG.Timeline], {
}
})
-SVG.extend([SVG.Rect, SVG.Ellipse, SVG.Circle, SVG.Gradient, SVG.Timeline], {
+extend([Rect, Ellipse, Circle, Gradient, Runner], {
// Add x and y radius
radius: function (x, y) {
var type = (this._target || this).type
return type === 'radialGradient' || type === 'radialGradient'
- ? this.attr('r', new SVG.Number(x))
+ ? this.attr('r', new SVGNumber(x))
: this.rx(x).ry(y == null ? x : y)
}
})
-SVG.extend(SVG.Path, {
+extend(Path, {
// Get path length
length: function () {
return this.node.getTotalLength()
},
// Get point at length
pointAt: function (length) {
- return new SVG.Point(this.node.getPointAtLength(length))
+ return new Point(this.node.getPointAtLength(length))
}
})
-SVG.extend([SVG.Parent, SVG.Text, SVG.Tspan, SVG.Timeline], {
+extend([Parent, Text, Tspan, Runner], {
// Set font
font: function (a, v) {
if (typeof a === 'object') {