Learn creative coding writing simple programs

35. A grid of rotating objects creates a wave of rectangles

This is the second time we create a grid of objects.

In the previous episode we used a while loop inside a while loop. Those loops increased two variables which were used to place rectangles in the screen.

In this episode we use again two nested while loops, but instead of counting pixels to fill the whole screen, we count how many rectangles we want to draw. Then we use a function from previous episodes that creates rotating rectangles.

We try different things: all rectangles rotating with exactly the same angle, using a different angle for rectangles depending on the column, depending on the row, and finally we give a different rotation angle for each rectangle in the screen depending on the column, the row and a variable that constantly increases to make them spin.

Tags: rotation, grid, while, loop, spinning

Code editor

You can make changes to the code below. Then
Questions and comments are welcome! :) But please try to stay close to the topic of this episode. Use the Processing forums for help with your Processing projects (or hire me for help ;-)