<aside> 👷♂️
Link: https://editor.p5js.org/kc5049/sketches/skXlwv65j
</aside>

This week we learned about functions.
When I read the prompt about functions as units of labor, I started thinking about labor more literally. That made me think of the construction of pyramids, which required a huge amount of human labor. In my sketch, the pyramid is built by loops and functions instead. Each function is responsible for a different kind of work, such as drawing the sky, the ground, the pyramid, the blocks, and the eyes.
I liked the contrast between physical labor and computational labor. Instead of many people repeatedly placing blocks, a loop can repeat the same action automatically. The labor is still there, but it becomes hidden inside the code. Functions divide the work into smaller jobs, and the program performs them over and over again.
The main goal for me was to keep setup() and draw() as clean as possible. I separated the sketch into functions such as drawSky(), drawGround(), drawPyramid(), drawBlocks(), and drawEyes(). Each function has one specific job, so just by looking at the function names I can roughly understand how the whole sketch is built. If I comment out drawGround(), the ground disappears. If I comment out drawPyramid(), the entire pyramid disappears. This made the code feel much easier to read compared to putting everything directly inside draw().
I also tried to make drawBlocks() reusable. Instead of writing the code for every block separately, I pass the x and y position into the function and use it again for every block in the pyramid. I later added a small interaction to make the sketch less static. When I click on a block, it turns black and two red eyes appear for three seconds before it changes back into a normal block. The eye drawing is also separated into its own drawEyes() function, while another function checks which block was clicked and another keeps track of how long the effect should stay visible.
I think the biggest thing I understood from this exercise is that functions are not only a way to shorten code. They also make it easier to think about the sketch as a group of smaller tasks. The pyramid itself is made from many repeated blocks, and the program is also made from many smaller pieces of labor working together.