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

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

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

lerpColor() uses the same approach as lerp(), but applies it to blending colors. It also<br />

requires three arguments: two colors <strong>and</strong> an interpolation value. Here’s a lerpColor()<br />

example (see Figure 10-15):<br />

// lerpColor()<br />

size(400, 400);<br />

noStroke();<br />

color c1 = color(255, 255, 0);<br />

color c2 = color(150, 0, 150);<br />

// change these values to alter gradient<br />

float stepsH = 16;<br />

float stepsW = 16;<br />

/* ratio to remap any number of<br />

cells into 0 - 1.0 range for<br />

lerpColor interpolation argument */<br />

float remapFactor = 100.0/(stepsH*stepsW);<br />

float cellW = width/stepsW;<br />

float cellH = height/stepsH;<br />

int cellCounter = 0;<br />

for (int i=0; i

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

Saved successfully!

Ooh no, something went wrong!