// Nine walls make up each of the 9 more complex buildings.
// Click and drag the mouse to move the vanishing point.
// There are two parameters for building position,
// and one each for wall height and depth.
// (Loosely inspired by Zaha Hadid's design
// for the Cincinnati Museum of Art)
int LVPx;
int RVPx;
int VPy;
int rw;
int lw;
int rh1;
int rh2;
int lh1;
int lh2;
void setup () {
size(400, 400);
background(104);
smooth();
fill(255, 40);
stroke(30);
strokeWeight(1);
}
void draw () {
background(102, 184, 47);
for (int a = 30; a <290; a +=125) {
for (int b = 20; b < 280; b += 125) {
building(a, b);
}
}
}
void mouseDragged() {
LVPx = constrain( mouseX-200, -50, 50);
RVPx = 410;
VPy = mouseY;
}
void building(int bordx, int bordy) {
float f = 0.24;
wall (bordx + 100 *f, bordy + 130 *f, 40 *f);
wall (bordx + 100 *f, bordy + 230 *f, 20 *f);
wall (bordx + 100 *f, bordy + 330 *f, 70 *f);
wall (bordx + 200 *f, bordy + 80 *f, 50 *f);
wall (bordx + 200 *f, bordy + 180 *f, 90 *f);
wall (bordx + 200 *f, bordy + 280 *f, 60 *f);
wall (bordx + 300 *f, bordy + 110 *f, 50 *f);
wall (bordx + 300 *f, bordy + 210 *f, 80 *f);
wall (bordx + 300 *f, bordy + 310 *f, 30 *f);
}
void wall(float x, float y, float bHeight) {
fill(240, 255-2*bHeight);
float ld = bHeight/100;
println(bHeight/100);
float rd = (0.3-ld);
rw = int( lerp(x, RVPx, rd));
rh1 = int (lerp (y -bHeight/2- VPy, VPy, rd));
rh2 = int (lerp (bHeight/2 + y - VPy, VPy, rd));
lw = int( lerp(x, LVPx, ld));
lh1 = int (lerp (y -bHeight/2- VPy, VPy, ld));
lh2 = int (lerp (bHeight/2 + y - VPy, VPy, ld));
quad(x, y - bHeight/2, x, y +bHeight/2, rw, VPy + rh2, rw, VPy + rh1);
quad(x, y - bHeight/2, x, y + bHeight/2, lw, VPy + lh2, lw, VPy + lh1);
}Tiffany - I
on Wednesday, Oct 22, 2008 – 2:30 am