summaryrefslogtreecommitdiffstats
path: root/src/types
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-08 16:06:39 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-08 16:06:39 +0100
commit8c81fb7c2e6e9842570d27a84b1a1c600c82c16b (patch)
treeb5de85d617f5761db7cdfdce70d8a0f7cc059aba /src/types
parentf7f6c4b801172ce119d4ea9a650c543670474784 (diff)
downloadsvg.js-8c81fb7c2e6e9842570d27a84b1a1c600c82c16b.tar.gz
svg.js-8c81fb7c2e6e9842570d27a84b1a1c600c82c16b.zip
added possibility to pass attribues into a constructor like: `new SVG.Rect({width:100})`
Diffstat (limited to 'src/types')
-rw-r--r--src/types/Point.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/types/Point.js b/src/types/Point.js
index 0adcd90..685240b 100644
--- a/src/types/Point.js
+++ b/src/types/Point.js
@@ -3,9 +3,13 @@ import parser from '../modules/core/parser.js'
export default class Point {
// Initialize
- constructor (x, y, base) {
+ constructor (...args) {
+ this.init(...args)
+ }
+
+ init (x, y) {
let source
- base = base || { x: 0, y: 0 }
+ let base = { x: 0, y: 0 }
// ensure source as object
source = Array.isArray(x) ? { x: x[0], y: x[1] }
@@ -42,6 +46,10 @@ export default class Point {
// Return the required point
return new Point(x, y)
}
+
+ toArray () {
+ return [this.x, this.y]
+ }
}
registerMethods({