If you're seeing this message, it means we're having trouble loading external resources for Khan Academy.
If you're behind a web filter, please make sure that the domains
*.kastatic.org and *.kasandbox.org are unblocked.
Make your code more re-usable by grouping it into functions, and then make those functions accept parameters and return values.
Pamela explains how you can write your own custom functions to group your code and make it more reusable.
Pamela shows how you can pass parameters into custom functions, so that they can behave differently each time you call them.
Pamela explains how to return values from functions, especially useful in doing calculations.
Pamela explains the difference between "local" and "global" variables, a tricky concept in programming.
Pamela explains the special predefined ProcessingJS functions that we use for drawing and interaction, like `draw()` and `mouseMoved()`.
This program draws a single fish. Poor lonely fish! For this project, you'll use functions to accompany him with more fish of all different shapes and colors. Create a custom function (like drawFish) that draws a fish at a given x and y ...