04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

translate(50, 50);<br />

fill(0, 255, 0);<br />

box(100, 100, 100);<br />

}<br />

Figure 13-4. Multiple Translations example<br />

So what happened? Translations are cumulative. Each time you call translate(), the<br />

entire drawing context of the display window is translated. For example, here’s a series of<br />

translations that move a box across the screen (see Figure 13-5):<br />

void setup(){<br />

size(400, 100, P3D);<br />

}<br />

void draw(){<br />

background(255);<br />

translate(10, height/2);<br />

for (int i=10; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!