float angle = 0.0; float stepSize = 0.05; int halfHeight, thirdHeight, sixthHeight, interval, startX, endX; float proportion = 0.0; float anoise = 0.0; void setup() { size(640,480); lights(); noStroke(); halfHeight = height/2; thirdHeight = height/3; sixthHeight = height/6; interval = width/100; startX = 0; endX = width; } void loop() { //background(180,180,190); background(100); for (int i = startX; i < endX; i+=interval) { proportion = float(i)/width; anoise = 2*sin(proportion*PI); push(); translate(i,halfHeight); rotateX(angle*proportion); rotateY(angle-proportion); rotateZ(angle*proportion); translate(0,-anoise*sixthHeight); fill(255,255,200); box(3,3,3); translate(0,anoise*thirdHeight); fill(255,255,235); box(3,3,3); translate(0,-anoise*sixthHeight); translate(0,0,-anoise*sixthHeight); fill(255,245,230); box(3,3,3); translate(0,0,anoise*thirdHeight); fill(245,225,200); box(3,3,3); pop(); } if (!mousePressed) { angle+=stepSize*(mouseX-(width*0.5))/(width*0.5); } if (angle >= width*TWO_PI) { angle = 0.0; } } void mouseClicked() { stepSize*=-1.0; }