aboutsummaryrefslogtreecommitdiffstats
path: root/src/elements
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-08 12:04:13 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-08 12:04:13 +0100
commit6cebf3bf0e5d3cade7b0a7dc9c8feb191b2eb91f (patch)
tree3f511399ec23f9d653f2c08f9c62afb4412f0542 /src/elements
parent24111571324badc5282cf835c6565576d7fcb90f (diff)
downloadsvg.js-6cebf3bf0e5d3cade7b0a7dc9c8feb191b2eb91f.tar.gz
svg.js-6cebf3bf0e5d3cade7b0a7dc9c8feb191b2eb91f.zip
size function of circle now only accepts one argument (#788)
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/Circle.js10
-rw-r--r--src/elements/Ellipse.js10
2 files changed, 17 insertions, 3 deletions
diff --git a/src/elements/Circle.js b/src/elements/Circle.js
index c296885..52aaa3d 100644
--- a/src/elements/Circle.js
+++ b/src/elements/Circle.js
@@ -1,4 +1,4 @@
-import { cx, cy, height, size, width, x, y } from '../modules/core/circled.js'
+import { cx, cy, height, width, x, y } from '../modules/core/circled.js'
import { extend, nodeOrNew, register } from '../utils/adopter.js'
import { registerMethods } from '../utils/methods.js'
import SVGNumber from '../types/SVGNumber.js'
@@ -22,16 +22,20 @@ export default class Circle extends Shape {
ry (ry) {
return this.rx(ry)
}
+
+ size (size) {
+ return this.radius(new SVGNumber(size).divide(2))
+ }
}
-extend(Circle, { x, y, cx, cy, width, height, size })
+extend(Circle, { x, y, cx, cy, width, height })
registerMethods({
Element: {
// Create circle element
circle (size) {
return this.put(new Circle())
- .radius(new SVGNumber(size).divide(2))
+ .size(size)
.move(0, 0)
}
}
diff --git a/src/elements/Ellipse.js b/src/elements/Ellipse.js
index 40b9369..b0ee4bf 100644
--- a/src/elements/Ellipse.js
+++ b/src/elements/Ellipse.js
@@ -1,5 +1,7 @@
import { extend, nodeOrNew, register } from '../utils/adopter.js'
+import { proportionalSize } from '../utils/utils.js'
import { registerMethods } from '../utils/methods.js'
+import SVGNumber from '../types/SVGNumber.js'
import Shape from './Shape.js'
import * as circled from '../modules/core/circled.js'
@@ -7,6 +9,14 @@ export default class Ellipse extends Shape {
constructor (node) {
super(nodeOrNew('ellipse', node), Ellipse)
}
+
+ size (width, height) {
+ var p = proportionalSize(this, width, height)
+
+ return this
+ .rx(new SVGNumber(p.width).divide(2))
+ .ry(new SVGNumber(p.height).divide(2))
+ }
}
extend(Ellipse, circled)