Congratulations! You now know how to draw and color shapes using p5.js! They are the building blocks of the p5.js library and soon you will be adding many more dynamic interactions to them. Let’s review what you’ve learned in this lesson:
- The p5.js library has many built-in functions to draw 2D shapes to the canvas:
- There are style functions that must be called before drawing shapes:
- p5.js allows for many ways to specify color:
- gray value (0 - 255)
- RGB values (0 - 255)
- Named CSS color (like
- 3 or 6 digit hexadecimal values (like
forloops make it easy to draw many shapes at once.
In the next lesson, you will learn more about the
draw() loop and how to turn our static p5.js drawings into animations!
Play with the sketch to the right. Try changing some of the arguments of shape and style functions to see how small changes can produce very different designs. When you’re ready, click Next.