summaryrefslogtreecommitdiffstats
path: root/src/elements/Circle.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-06 13:48:05 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-06 13:48:05 +0100
commita0b13ebcacfd74b9f521110c7225bb404325bcd3 (patch)
treea07c5cc422645e31d7dfef81ce4e54f03f0945f6 /src/elements/Circle.js
parent9f2696e8a2cf7e4eebc1cc7e31027fe2070094fa (diff)
downloadsvg.js-a0b13ebcacfd74b9f521110c7225bb404325bcd3.tar.gz
svg.js-a0b13ebcacfd74b9f521110c7225bb404325bcd3.zip
reordered modules, add es6 build
Diffstat (limited to 'src/elements/Circle.js')
-rw-r--r--src/elements/Circle.js40
1 files changed, 40 insertions, 0 deletions
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)