Name

CRC.rect() — adds a rectangle subpath to the path

Synopsis

void rect(float x, float y,
          float width, float height)

Arguments

x, y

The coordinates of the upper-left corner of the rectangle

width, height

The dimensions of the rectangle

Description

This method adds a rectangle to the path. This rectangle is in a subpath of its own and is not connected to any other subpaths in the path. When this method returns, the current position is (x,y). A call to this method is equivalent to the following sequence of calls:

c.moveTo(x,y);
c.lineTo(x+w, y);
c.lineTo(x+w, y+h);
c.lineTo(x, y+h);
c.closePath();

Get Canvas Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.