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

392<br />

//component reference variables<br />

Door door;<br />

Window window;<br />

Roof roof;<br />

//optional autosize variable<br />

boolean AutoSizeComponents = false;<br />

//door placement<br />

int doorLoc = 0;<br />

//constants<br />

final static int MIDDLE_DOOR = 0;<br />

final static int LEFT_DOOR = 1;<br />

final static int RIGHT_DOOR = 2;<br />

//constructor<br />

House(int w, int h, Door door, Window window, Roof roof, ➥<br />

int doorLoc) {<br />

this.w = w;<br />

this.h = h;<br />

this.door = door;<br />

this.window = window;<br />

this.roof = roof;<br />

this.doorLoc = doorLoc;<br />

}<br />

void drawHouse(int x, int y, boolean AutoSizeComponents) {<br />

this.x = x;<br />

this.y =y;<br />

this.AutoSizeComponents = AutoSizeComponents;<br />

//automatically sizes doors <strong>and</strong> windows<br />

if(AutoSizeComponents){<br />

//autosize door<br />

door.h = h/4;<br />

door.w = door.h/2;<br />

//autosize windows<br />

window.h = h/3;<br />

window.w = window.h/2;<br />

}<br />

// draw bldg block<br />

rect(x, y, w, h);<br />

// draw door<br />

switch(doorLoc){<br />

case 0:

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

Saved successfully!

Ooh no, something went wrong!