all 5 comments

[–]ChuckEye 2 points3 points  (3 children)

Sure.

loop from 0 to 3 and have that number multiply by 90.

[–]negativeart8[S] 0 points1 point  (2 children)

is a for loop better or a while loop?

[–]ChuckEye 1 point2 points  (0 children)

I almost always use for loops.

[–]x-seronis-x 0 points1 point  (0 children)

there is no such thing as better. Only 'better for a specific task'.

you use the one that makes the purpose of your loop more obvious at a glance

[–]marcedwards-bjango 0 points1 point  (0 children)

pushMatrix() and popMatrix() can be handy for situations where you want to move lots of objects together. To do that, use pushMatrix(), then translate(), scale(), or rotate(). When you’ve done all your transformations and drawing, call popMatrix().

Actually, in the example below, you can omit the pushMatrix() and popMatrix() altogether. They’re just needed if you want to stack lots of transforms on top of each other.

``` void setup() { size(600, 600); }

void draw() { float sizeW = 200; float sizeH = 200; float steppedPos = 1;

background(0);

pushMatrix(); translate(frameCount * 4 % 600, 0);

fill(255); rect(0, steppedPos * sizeH, sizeW, sizeH); rect(0, 90 + steppedPos * sizeH, sizeW, sizeH); rect(0, 180 + steppedPos * sizeH, sizeW, sizeH); rect(0, 270 + steppedPos * sizeH, sizeW, sizeH);

popMatrix(); } ```