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 />

444<br />

To access the red, green, blue, <strong>and</strong> alpha components from a color c, use the following<br />

syntax:<br />

int a = c >> 24 & 0xFF;<br />

int r = c >> 16 & 0xFF;<br />

int g = c >> 8 & 0xFF;<br />

int b = c & 0xFF;<br />

To combine the individual color components back into a color, use:<br />

// combine components back into a 32-bit integer<br />

c = (a > 8 & 0xFF;<br />

int b = c & 0xFF;<br />

int a = c >> 24 & 0xFF;<br />

// alter component values<br />

r += 100;<br />

g -= 50;<br />

b += 100;<br />

// combine components back into a 32-bit integer<br />

c = (a

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

Saved successfully!

Ooh no, something went wrong!