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.

(second-degree) curve has one turning point <strong>and</strong> a cubic (third-degree) curve can have<br />

either zero or two turning points. This info will become more relevant when you get to<br />

Chapter 7 <strong>and</strong> see how curves are actually generated in <strong>Processing</strong>. Here are two little<br />

<strong>Processing</strong> sketches that generate the quadratic <strong>and</strong> cubic curves shown in Figures 4-6 <strong>and</strong><br />

4-7, respectively:<br />

/*<br />

Simple Quadratic Curve<br />

equation: f(x) = x*x - 20x + 200<br />

Ira Greenberg, October 10, 2005<br />

*/<br />

float x, y;<br />

// adjusts y to fit in sketch window coordinate space<br />

float curveFittingFactor = .03;<br />

void setup(){<br />

size(400, 400);<br />

background(255);<br />

fill(0);<br />

for (int i=-102; i

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

Saved successfully!

Ooh no, something went wrong!