summaryrefslogtreecommitdiffstats
path: root/src/Rect.js
blob: 535f5621ee818251273516737a3dca7edc839998 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import Shape from './Shape.js'
import { nodeOrNew } from './tools.js'
import { register } from './adopter.js'
import { registerMethods } from './methods.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)