summaryrefslogtreecommitdiffstats
path: root/src/elements/Rect.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/elements/Rect.js')
-rw-r--r--src/elements/Rect.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/elements/Rect.js b/src/elements/Rect.js
new file mode 100644
index 0000000..9d6163c
--- /dev/null
+++ b/src/elements/Rect.js
@@ -0,0 +1,32 @@
+import { nodeOrNew, register } from '../utils/adopter.js'
+import { registerMethods } from '../utils/methods.js'
+import Shape from './Shape.js'
+
+export default class Rect extends Shape {
+ // Initialize node
+ constructor (node) {
+ super(nodeOrNew('rect', node), Rect)
+ }
+
+ // FIXME: unify with circle
+ // Radius x value
+ rx (rx) {
+ return this.attr('rx', rx)
+ }
+
+ // Radius y value
+ ry (ry) {
+ return this.attr('ry', ry)
+ }
+}
+
+registerMethods({
+ Container: {
+ // Create a rect element
+ rect (width, height) {
+ return this.put(new Rect()).size(width, height)
+ }
+ }
+})
+
+register(Rect)