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

290<br />

One interesting thing to do with both the bezier() <strong>and</strong> curve() functions is to create<br />

elliptical plots, where the control points can be manipulated to create various interconnected<br />

curve patterns. The following example (shown in Figure 7-34) allows you to click<br />

the screen to generate a r<strong>and</strong>om ellipse pattern. I’ve also a coded a more advanced, highly<br />

interactive version of the example (shown in Figure 7-35), entitled Interactive Bézier<br />

Ellipse, which you can download from the Download section on the friends of ED site<br />

(www.friendsofed.com).<br />

/*<br />

Bézier Ellipse<br />

Ira Greenberg, December 19, 2005<br />

Revised: November 15, 2006<br />

*/<br />

// arrays to hold ellipse coordinate data<br />

float[] px, py, cx, cy, cx2, cy2;<br />

// global variable - points in ellipse<br />

int pts = 4;<br />

color controlPtCol = #222222;<br />

color anchorPtCol = #BBBBBB;<br />

void setup(){<br />

size(600, 600);<br />

setEllipse(pts, 130, 130);<br />

}<br />

void draw(){<br />

background(145);<br />

drawEllipse();<br />

}<br />

// draw ellipse with anchor/control points<br />

void drawEllipse(){<br />

strokeWeight(1.125);<br />

stroke(255);<br />

noFill();<br />

// create ellipse<br />

for (int i=0; i

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

Saved successfully!

Ooh no, something went wrong!