Draws a quadrilateral (four-sided shape).
Quadrilaterals include rectangles, squares, rhombuses, and trapezoids. The first pair of parameters (x1, y1)
sets the quad's first point. The next three pairs of parameters set the coordinates for its next three points (x2, y2)
, (x3, y3)
, and (x4, y4)
. Points should be added in either clockwise or counter-clockwise order.
The version of quad()
with twelve parameters allows the quad to be drawn in 3D space. Doing so requires adding the WEBGL
argument to createCanvas().
The thirteenth and fourteenth parameters are optional. In WebGL mode, they set the number of segments used to draw the quadrilateral in the x- and y-directions. They're both 2 by default.
Examples
Syntax
quad(x1, y1, x2, y2, x3, y3, x4, y4, [detailX], [detailY])
quad(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, [detailX], [detailY])
Parameters
the x-coordinate of the first point.
the y-coordinate of the first point.
the x-coordinate of the second point.
the y-coordinate of the second point.
the x-coordinate of the third point.
the y-coordinate of the third point.
the x-coordinate of the fourth point.
the y-coordinate of the fourth point.
number of segments in the x-direction.
number of segments in the y-direction.
the z-coordinate of the first point.
the z-coordinate of the second point.
the z-coordinate of the third point.
the z-coordinate of the fourth point.