06.01.2013 Views

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

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.

18.4<br />

diameter = diameter_;<br />

}<br />

// True or False if point is inside circle<br />

boolean rollover(int mx, int my) {<br />

if (dist(mx,my,x,y) < diameter/2) {<br />

return true;<br />

} else {<br />

return false;<br />

}<br />

}<br />

// Change Bubble variables<br />

void change() {<br />

r = constrain(r + random(–10,10),0,255);<br />

g = constrain(g + random(–10,10),0,255);<br />

diameter = constrain(diameter + random(–2,4),4,72);<br />

}<br />

// Display Bubble<br />

void display() {<br />

stroke(0);<br />

fill(r,g,255,150);<br />

ellipse(x,y,diameter,diameter);<br />

}<br />

// Bubble drifts upwards<br />

void drift() {<br />

y + = random(–3,–0.1);<br />

x + = random(–1,1);<br />

if (y < -diameter*2) {<br />

y = height + diameter*2;<br />

}<br />

}<br />

}<br />

Text Parsing<br />

Data Input 335<br />

Exercise 18-7: Create a sketch that visualizes the following data. Feel free <strong>to</strong> add <strong>to</strong> and<br />

change the text.<br />

Now that we are comfortable with how loadStrings( ) works for text fi les s<strong>to</strong>red locally, we can start <strong>to</strong><br />

examine what we might do with textual data we retrieve from other sources such as a URL.<br />

String[] lines = loadStrings( " http://www.yahoo.com " );

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

Saved successfully!

Ooh no, something went wrong!