Three concepts that build intuition, then a sandbox to experiment.
When you call rotate(), p5.js spins everything around the origin —
which starts at the top-left corner of the canvas.
This is usually not what you want.
The fix: move the origin to the center of the canvas using
translate(width/2, height/2) before rotating.
Now rotation happens around the center.
translate() first, then rotate(),
then draw your shape.
rotate() takes an angle in radians, not degrees.
A full circle is TWO_PI (≈ 6.28). Use fractions of PI:
See how the radian value and degrees relate as you rotate the square.