09.04.2016 Views

www.ebook777.com

Make_Getting_Started_with_Processing_Second_Edition

Make_Getting_Started_with_Processing_Second_Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

150 Getting Started with Processing<br />

<strong>www</strong>.<strong>ebook777.com</strong><br />

float x1 = -20;<br />

float x2 = 20;<br />

void setup() {<br />

size(240, 120);<br />

noStroke();<br />

}<br />

void draw() {<br />

background(0);<br />

x1 += 0.5;<br />

x2 += 0.5;<br />

arc(x1, 30, 40, 40, 0.52, 5.76);<br />

arc(x2, 90, 40, 40, 0.52, 5.76);<br />

}<br />

Example 11-2: Too Many Variables<br />

The code for the previous example is still manageable, but what<br />

if we want to have five circles? We need to add three more variables<br />

to the two we already have:<br />

float x1 = -10;<br />

float x2 = 10;<br />

float x3 = 35;<br />

float x4 = 18;<br />

float x5 = 30;<br />

void setup() {<br />

size(240, 120);<br />

noStroke();<br />

}<br />

void draw() {<br />

background(0);<br />

x1 += 0.5;<br />

x2 += 0.5;<br />

x3 += 0.5;

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

Saved successfully!

Ooh no, something went wrong!