9 Functions and Periodic Motion

As your programs grow more complex, your line counts will increase, and you’ll begin repeating the same or similar code. By using functions, you can divide your programs into named blocks of reusable code. This makes your code more modular, allowing you to reuse lines without needing to rewrite them.

You’ve already used many Processing functions, like size(), print(), and rect(), and in this chapter, you’ll learn how to define your own functions. As an example, Processing has no function for drawing diamonds, but you can create one. You decide what to name this function and what arguments it will accept. ...

Get Learn Python Visually now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.