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.

the color. Up to this point in the book, I’ve been passing single integer arguments to the<br />

fill() <strong>and</strong> stroke() functions, generating grayscale values. However, to generate color,<br />

you can pass three (or four) arguments to the fill()/stroke() calls, representing red,<br />

green, <strong>and</strong> blue (<strong>and</strong> alpha); or combine the three values into a color variable, as I did in<br />

the example. Thus, the following two fill() calls are equivalent:<br />

color swatch = color(100, 100, 120);<br />

fill(swatch);<br />

fill(100, 100, 120);<br />

Here’s a simple example using r<strong>and</strong>om stroke colors, shown in Figure 10-2:<br />

//Rotated Triangle<br />

size(350, 350);<br />

background(255);<br />

smooth();<br />

strokeWeight(3);<br />

noFill();<br />

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

for (int i=0; i

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

Saved successfully!

Ooh no, something went wrong!