From a0b13ebcacfd74b9f521110c7225bb404325bcd3 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Tue, 6 Nov 2018 13:48:05 +0100 Subject: reordered modules, add es6 build --- src/elements/Circle.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/elements/Circle.js (limited to 'src/elements/Circle.js') diff --git a/src/elements/Circle.js b/src/elements/Circle.js new file mode 100644 index 0000000..c296885 --- /dev/null +++ b/src/elements/Circle.js @@ -0,0 +1,40 @@ +import { cx, cy, height, size, 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' +import Shape from './Shape.js' + +export default class Circle extends Shape { + constructor (node) { + super(nodeOrNew('circle', node), Circle) + } + + radius (r) { + return this.attr('r', r) + } + + // Radius x value + rx (rx) { + return this.attr('r', rx) + } + + // Alias radius x value + ry (ry) { + return this.rx(ry) + } +} + +extend(Circle, { x, y, cx, cy, width, height, size }) + +registerMethods({ + Element: { + // Create circle element + circle (size) { + return this.put(new Circle()) + .radius(new SVGNumber(size).divide(2)) + .move(0, 0) + } + } +}) + +register(Circle) -- cgit v1.2.3