Learn creative coding writing simple programs
97. Interacting with many rectangles (I)
This time we create five arrays to store information about a collection of rectangles. The five arrays are used to store the color and the left, top, right and bottom borders of each rectangle.
By storing this information in arrays we can draw those rectangles as many times as we want, and also calculate if the mouse is inside or outside of each rectangle.
No new concepts are introduced this time. Episode 98 continues where this one ends.
Code editor
You can make changes to the code below. Then
Reference
background
color
colorMode
draw
fill
for
height
int
new
noStroke
random
rect
rectMode
setup
size
void
width
background
color
colorMode
draw
fill
for
height
int
new
noStroke
random
rect
rectMode
setup
size
void
width
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); } ```