/* SpinningBroccoli by Mike Godwin * an experiment produced in conjunction with Prof. Legrady's * Aesthetics of the Algorithmic Image course -- Fall 2005 */ //import processing.opengl.*; int branchLength = 88; float a; float angle; void setup() { size(600, 600, P3D); // size(600, 600, OPENGL); stroke(10); framerate(30); angle = PI; // camera(300,-300,500,width/2,height/2,0,0,1,0); } void draw(){ background(150); if(!keyPressed) a += .02; if(a > TWO_PI) a = 0.0; translate(width/2, height/2); rotateY(a); rotateZ(-a); rotateX(a); createBranch(branchLength, PI, PI, 0, 200, 0); createBranch(branchLength, 2*PI, 2*PI, 0, -200, 0); } void createBranch(int branchLength, float xDirection, float yDirection, int startX, int startY, int startZ) { int endX = int((sin(xDirection) * branchLength) + startX); int endY = int((cos(xDirection) * branchLength) + startY); int endZ = int((sin(yDirection) * branchLength) + startZ); if (branchLength > 2){ strokeWeight(int(branchLength/7)+1); //width stroke(0, constrain(branchLength*3,0,255), 50); // Pretty colors line(startX, startY, startZ, endX, endY, endZ); createBranch((branchLength - 11), xDirection-(PI/8), -angle, endX, endY, endZ); createBranch((branchLength - 11), xDirection+(PI/8), angle, endX, endY, endZ); createBranch((branchLength - 11), xDirection, 2 ,endX, endY, endZ); } }