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.

Figure 10-9. Finished Nematode sketch<br />

There’s so much more that could be done with the nematode, but I’ll leave that to you.<br />

However, I’ll include one more nematode image, shown in Figure 10-10, on a dark background<br />

with some minor changes to a few of the stroke values. Since the nematode image<br />

is translucent, when you add a dark background, the image takes on an interesting look<br />

<strong>and</strong> feel, resembling a film negative or X-ray.<br />

Figure 10-10. Finished Inverted Nematode sketch<br />

Setting the color mode<br />

So far, this chapter has been using the fill() <strong>and</strong> stroke() functions with the default<br />

RGB color mode. Using this mode, each of the R, G, <strong>and</strong> B color components can be<br />

assigned an int or float value from 0 to 255. However, <strong>Processing</strong> has an alternative HSB<br />

color mode, which can be set by calling colorMode(HSB). HSB st<strong>and</strong>s for hue, saturation,<br />

<strong>and</strong> brightness. These components correlate to the three color properties of hue, chromatic<br />

intensity, <strong>and</strong> value, which I discussed earlier in the “Color theory” section of the<br />

chapter. By default, RGB <strong>and</strong> HSB modes use a value range of 0 to 255 for each of<br />

the three components. In the next example, I create the six primary <strong>and</strong> secondary colors<br />

<strong>and</strong> cyan using both modes (see Figure 10-11):<br />

COLOR AND IMAGING<br />

415<br />

10

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

Saved successfully!

Ooh no, something went wrong!