Chapter 9. Functions
Functions are the basic building blocks for p5.js programs. They have appeared in every example we’ve presented. For instance, we’ve frequently used the createCanvas() function, the line() function, and the fill() function. This chapter shows how to write new functions to extend the capabilities of p5.js beyond its built-in features.
The power of functions is modularity. Functions are independent software units that are used to build more complex programs—like LEGO bricks, where each type of brick serves a specific purpose, and making a complex model requires using the different parts together. As with functions, the true power of these bricks is the ability to build many different forms from the same set of elements. The ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access