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.

x, y, pts, rad1, rad2 args<br />

void makePoly(float x, float y, int pts, float rad1, float rad2){<br />

// call main makePoly function<br />

makePoly(x, y, pts, rad1, rad2, 45, #777777, 4, #AAAAAA, ➥<br />

SQUARE, MITER);<br />

}<br />

// x, y, pts, rad1, rad2,, initRot, strokeCol, strokeWt, fillCol args<br />

void makePoly(float x, float y, int pts, float rad1, float rad2, ➥<br />

float initRot, color strokeCol, float strokeWt, color fillCol){<br />

// call main makePoly function<br />

makePoly(x, y, pts, rad1, rad2, initRot, strokeCol, strokeWt, ➥<br />

fillCol, SQUARE, MITER);<br />

}<br />

// main function - called by other overloaded functions/methods<br />

void makePoly(float x, float y, int pts, float rad1, float rad2, ➥<br />

float initRot, color strokeCol, float strokeWt, ➥<br />

color fillCol, int endCap, int endJoin){<br />

float px = 0, py = 0, angle = initRot;<br />

stroke(strokeCol);<br />

strokeWeight(strokeWt);<br />

strokeCap(endCap);<br />

strokeJoin(endJoin);<br />

fill(fillCol);<br />

beginShape();<br />

for (int i = 0; i< pts; i++){<br />

if (i%2 == 0){<br />

px = x+cos(radians(angle))*rad1;<br />

py = y+sin(radians(angle))*rad1;<br />

}<br />

else {<br />

px = x+cos(radians(angle))*rad2;<br />

py = y+sin(radians(angle))*rad2;<br />

}<br />

vertex(px, py);<br />

angle+=360/pts;<br />

}<br />

endShape(CLOSE);<br />

}<br />

SHAPES<br />

361<br />

9

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

Saved successfully!

Ooh no, something went wrong!