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

116<br />

<strong>and</strong> so forth typically utilize a line screen, composed of dots that lay a dot pattern down<br />

when they print. The frequency of the line screen is measured in lines per inch, or LPI. As<br />

long as the line screen is fine enough, the dot pattern is not noticeable. However, tighter<br />

line screens also require papers that bleed less <strong>and</strong> can hold the distinct dot pattern. There<br />

is a formula you can use to calculate required dpi, based on the line screen frequency <strong>and</strong><br />

image size. A simpler rule, however, is to just double the frequency of the line screen to<br />

determine image dpi. So for grainy newspaper printing, a line screen frequency might be<br />

85 LPI, but for a coffee table art book, the frequency might be 200 LPI; thus the image<br />

would need to be around 170 dpi <strong>and</strong> 400 dpi, respectively. You would also need to make<br />

sure that your image was at the actual printing size at that resolution. That being said, I<br />

recommend that when you l<strong>and</strong> that huge print job, you discuss the image <strong>and</strong> printing<br />

resolution issues with the printer.<br />

Vector graphics<br />

Vector graphics are typically used for simple illustrations, logos, <strong>and</strong> images that require<br />

distinct <strong>and</strong> precise contours. Computer text is vector-based, normally just wrapped in a<br />

text-based object that includes certain methods for editing the text. In vector-based<br />

graphics applications like Illustrator, FreeH<strong>and</strong>, <strong>and</strong> Flash, you can create outlines from<br />

text objects, or break them apart <strong>and</strong> get down to the vector information. Vector graphics<br />

are made up of vertices (points) <strong>and</strong> strokes. The lines can be straight or curved, <strong>and</strong> are<br />

generated mathematically. Straight lines are simple linear equations, like y = 4x + 3. In<br />

<strong>Processing</strong>, you don’t need to worry about the math; you can simply use the line function<br />

to generate a line:<br />

line(x1, y1, x2, y2)<br />

The first two coordinates in the function are the starting point <strong>and</strong> the last two coordinates<br />

are the line’s endpoint. <strong>Processing</strong> <strong>and</strong> Java utilize internal drawing methods that<br />

h<strong>and</strong>le the algebra <strong>and</strong> draw the line. Curves are a little more complex <strong>and</strong> require higherdegree<br />

polynomials (don’t scream). The preceding linear equation is a first-degree polynomial,<br />

so a second-degree would just have x to the 2nd power. For example, y = 2x 2 +<br />

3x – 4 is a simple second-degree polynomial, also called a quadratic equation. (Is this ringing<br />

some dusty old bells?) So I’m bugging you with all this math because second-degree<br />

(quadratic) <strong>and</strong> third-degree (cubic) polynomials are used to generate the smooth curves<br />

that are made with the common Bézier pen tools found in all major graphics applications.<br />

But again, all you have to do is put in the points <strong>and</strong> <strong>Processing</strong> will crank out the math<br />

<strong>and</strong> curves; it is actually a little more complicated than that, but not much. I’ll discuss the<br />

actual implementation in the next few chapters.<br />

The pixels contained within the bounds of the vector shapes do not need to be stored in<br />

memory as they would for raster graphics, because the shapes, including color fills <strong>and</strong><br />

strokes, are calculated during runtime (when the program runs). Because vector graphics<br />

are just plots of a set of vertices, they can be moved or transformed very easily. It is no<br />

sweat for the computer to take in the list of coordinates <strong>and</strong> perform some calculations<br />

on the data <strong>and</strong> redraw the shapes with the updated vertices. However, since the vertices

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

Saved successfully!

Ooh no, something went wrong!