Rectangles
A rectangle in jCanvas is, essentially, a rectangle of any width or height.
Basic Usage
You can draw a rectangle using the drawRect()
method. The size of a rectangle is determined by its width
and height
properties.
Positioning
The fromCenter
property (used above) determines if a rectangle’s x
and y
properties lie at its center (as opposed to its top-left corner). This property is true
by default.
For example, consider the following rectangles. They both have the same x
and y
property values, but only one has its fromCenter
property set to false
.
If you want to make fromCenter
false
by default for all shapes, do so using the $.jCanvas.defaults
object.
Rounded Corners
You may round the corners of a rectangle using the cornerRadius
property.