rotate()function. This function takes one argument, which is the number of degrees that you want to rotate.
angleMode = "radians";at the top of your program.
Rotating the correct way
- Translate the coordinate system’s origin (0, 0) to where you want the upper left of the square to be.
- Rotate the grid 45° (π/4 radians)
- Draw the square at the origin.
translate(40, 40);and then
rect(**0, 0,** 40, 40);in place of just
rect(**40, 40,** 40, 40);.