Learn creative coding writing simple programs
32. Use a function to simplify a program
In this episode we simplify the program created on episode 30, with the four rotating rectangles. We write a function that creates a rotating rectangle. The function takes several parameters to modify it's behaviour. This way, the function can be used to create rectangles on different locations and with different sizes.
Code editor
You can make changes to the code below. Then
Reference
background
draw
fill
float
noStroke
rect
rectMode
resetMatrix
rotate
setup
size
translate
void
background
draw
fill
float
noStroke
rect
rectMode
resetMatrix
rotate
setup
size
translate
void
Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)
To indicate that a word in your comment is code, use the `backtick`. Example
Do `float` and `int` smell similar?
To highlight code blocks, surround it with ``` code-fences ``` like this:``` void setup() { size(600, 600); } ```