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.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

404<br />

In the next example, I use the color data type to create some arrays in conjunction with<br />

the fill() comm<strong>and</strong>. Hopefully, the output in Figure 10-3 looks familiar.<br />

/*<br />

Subtractive Color Wheel<br />

Ira Greenberg, January 4, 2005<br />

primaries (r, y, b)<br />

secondaries(g, p, o)<br />

tertiaries(y-o, r-o, r-p, b-p, b-g, y-g)<br />

*/<br />

int segs = 12;<br />

float rotAdjust = radians(360/segs/2);<br />

float radius = 175.0;<br />

float ratio = .65;<br />

float interval = TWO_PI/segs;<br />

int SHADE = 0;<br />

int TINT = 1;<br />

void setup(){<br />

size(800, 400);<br />

background(0);<br />

smooth();<br />

ellipseMode(CENTER_RADIUS);<br />

noStroke();<br />

createWheel(width/4, height/2, SHADE);<br />

createWheel(width - width/4, height/2, TINT);<br />

}<br />

void createWheel(int x, int y, int valueShift){<br />

radius = 175;<br />

ratio = .65;<br />

if (valueShift == SHADE){<br />

// left wheel<br />

for (int j=1; j

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

Saved successfully!

Ooh no, something went wrong!