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.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

390<br />

// default constructor<br />

Roof(){<br />

}<br />

// constructor 2<br />

Roof(int style){<br />

this.style = style;<br />

}<br />

// draw the roof<br />

void drawRoof(int x, int y, int w, int h) {<br />

switch(style){<br />

case 0:<br />

beginShape();<br />

vertex(x, y);<br />

vertex(x+w/2, y-h/3);<br />

vertex(x+w, y);<br />

endShape(CLOSE);<br />

break;<br />

case 1:<br />

beginShape();<br />

vertex(x, y);<br />

vertex(x+w/7, y-h/5);<br />

vertex(x+w/2, y-h/2.75);<br />

vertex(x+(w-w/7), y-h/5);<br />

vertex(x+w, y);<br />

endShape(CLOSE);<br />

break;<br />

case 2:<br />

ellipseMode(CORNER);<br />

arc(x, y-h/2, w, h, PI, TWO_PI);<br />

line(x, y, x+w, y);<br />

break;<br />

}<br />

}<br />

// set roof style<br />

void setStyle(int style){<br />

this.style = style;<br />

}<br />

}

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

Saved successfully!

Ooh no, something went wrong!