The last two drawing functions we’ll learn are triangle()
and quad()
, which are closely related to the line()
function in that they take the coordinates of each corner of the shape as arguments. These arguments are used to define the perimeter of the shape.
The triangle()
function takes a total of six arguments or three pairs of x and y coordinates.
The quadrilateral shape function, quad()
, needs eight arguments, or four pairs of x and y coordinates for each of its four points.
Instructions
Use the triangle()
function to draw a triangle to the p5.js sketch. You can use any coordinates for each of the three vertices of the triangle!
The arguments for the triangle()
function represent the vertices of the triangle. Draw a second triangle that shares one vertex with the first triangle you drew.
Next, draw a quadrilateral using the quad()
function. You can use any coordinates for each of the four vertices of the quadrilateral!
Draw a second quadrilateral that shares one vertex with the first quadrilateral you drew.