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.

Figure 13-1. Spinning Cube 1<br />

Man, that was even easier than using code-free 3D animation software.<br />

In the preceding example, the cube only spun around the y-axis. The following code creates<br />

a cube that spins around the x- <strong>and</strong> y-axes (see Figure 13-2):<br />

void setup(){<br />

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

}<br />

void draw(){<br />

background(0);<br />

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

rotateY(frameCount*PI/60);<br />

rotateX(frameCount*PI/60);<br />

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

}<br />

Figure 13-2. Spinning Cube 2<br />

3D<br />

617<br />

13

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

Saved successfully!

Ooh no, something went wrong!