aboutsummaryrefslogtreecommitdiffstats
path: root/src/elements/Rect.js
blob: 465b52b72fdd8ec32263a167c7d25691a2e4d6f7 (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
34
35
import {
  extend,
  nodeOrNew,
  register,
  wrapWithAttrCheck
} from '../utils/adopter.js'
import { registerMethods } from '../utils/methods.js'
import { rx, ry } from '../modules/core/circled.js'
import Shape from './Shape.js'

export default class Rect extends Shape {

  // Initialize node
  constructor ( node ) {

    super( nodeOrNew( 'rect', node ), node )

  }

}

extend( Rect, { rx, ry } )

registerMethods( {
  Container: {
    // Create a rect element
    rect: wrapWithAttrCheck( function ( width, height ) {

      return this.put( new Rect() ).size( width, height )

    } )
  }
} )

register( Rect )