diff options
Diffstat (limited to 'src/elements')
-rw-r--r-- | src/elements/Circle.js | 10 | ||||
-rw-r--r-- | src/elements/Ellipse.js | 10 |
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) |