returns itself
animate yes

Set the size of an element to a given width and height:

rect.size(200, 300)

Proportional resizing is also possible by leaving out height:


Or by passing null as the value for width:

rect.size(null, 200)

As with positioning, the size of an element could be set by using attr(). But because every type of element is handles its size differently the size() method is much more convenient.

There is one exception though: for SVG.Text elements, this method takes only one argument and applies the given value to the font-size attribute.

width() as setter

returns itself
animate yes

Set the width of an element:


width() as getter

returns value

var width = rect.width()

height() as setter

returns itself
animate yes

Set the height of an element:


height() as getter

returns value



returns itself
animate yes

Circles, ellipses, and rects may use the radius() method. On rects, it defines rounded corners.

For a circle, the argument sets the r attribute.


For ellipses and rects, pass two arguments to set the rx and ry attributes individually. Or, pass a single argument, to make the two attributes equal.

ellipse.radius(10, 20)
Fork me on GitHub