fullscreen
ID02_FinalProgress5_2.pdePlant.pdeSegment.pdeStructure.pde
/*
ACCD Summer 2012
ID02
Final Progress
Charlene Chen
08/17/2012
Instructor: Michael Kontopoulos
TA: Kit Cheong
*/
Structure s;
float angle;
void setup() {
size(900, 600);
smooth();
s = new Structure( 0, 0);
}
void draw() {
background(255);
pushMatrix();
translate(width/2, height/2);
angle += random(0.001);
rotate(angle);
s.display();
s.update();
popMatrix();
}
/*
ACCD Summer 2012
ID02
Final Progress
Charlene Chen
08/17/2012
Instructor: Michael Kontopoulos
TA: Kit Cheong
*/
class Plant {
float dia;
float rx, ry;
float angle;
float xpos, ypos;
Plant(float _xpos, float _ypos, float _dia) {
xpos = _xpos;
ypos = _ypos;
dia = _dia;
}
void display() {
fill(112, 157, 94, 50);
noStroke();
ellipse(xpos, ypos, dia, dia);
}
void update() {
rx = random(-1, 1);
ry = random(-1, 1);
xpos += rx;
ypos += ry;
}
}
/*
ACCD Summer 2012
ID02
Final Progress
Charlene Chen
08/17/2012
Instructor: Michael Kontopoulos
TA: Kit Cheong
*/
class Segment {
Plant[] plants1;
int numPlants;
float inc;
float xpos, ypos;
float angle;
float rx, ry;
Segment(float _xpos, float _ypos) {
xpos = _xpos;
ypos = _ypos;
numPlants = int(10);
inc = TWO_PI / numPlants;
plants1 = new Plant[numPlants];
for (int i = 0; i < plants1.length; i++) {
float angle = random(0,TWO_PI); //i*inc;
float tempx = xpos + cos(angle) * 50;
float tempy = ypos + sin(angle) * 50;
plants1[i] = new Plant(tempx, tempy, random(5, 20)); //Plant(random(segX-100, segX+100), random(segY-100, segY+100), random(10, 100));
}
}
void display() {
for (int i = 0; i< plants1.length; i++) {
plants1[i].display();
stroke(112, 157, 94, 50);
line(plants1[i].xpos, plants1[i].ypos, this.xpos, this.ypos);
stroke(0, 10);
line(plants1[i].xpos, plants1[i].ypos, 0, 0);
//plants1[i].update();
}
}
void update() {
pushMatrix();
rx = random(-1, 1);
ry = random(-1, 1);
xpos += rx;
ypos += ry;
for (int i = 0; i< plants1.length; i++) {
plants1[i].update();
}
popMatrix();
}
}
/*
ACCD Summer 2012
ID02
Final Progress
Charlene Chen
08/17/2012
Instructor: Michael Kontopoulos
TA: Kit Cheong
*/
class Structure {
Segment[] segments;
Plant[] plants1;
int numSegments;
float inc;
float xpos, ypos;
float angle;
Structure(float _xpos, float _ypos) {
xpos = _xpos;
ypos = _ypos;
numSegments = int(12);
inc = TWO_PI / numSegments;
segments = new Segment[numSegments];
for (int i = 0; i < segments.length; i++) {
float angle = random(0,TWO_PI); //i*inc;
float tempx = xpos + cos(angle) * 200;
float tempy = ypos + sin(angle) * 200;
segments[i] = new Segment(tempx, tempy); //Plant(random(segX-100, segX+100), random(segY-100, segY+100), random(10, 100));
}
}
void display() {
for (int i = 0; i< segments.length; i++) {
segments[i].display();
stroke(112, 157, 94);
line(segments[i].xpos, segments[i].ypos, this.xpos, this.ypos);
//segments[i].update();
}
// for (int i = 0; i< plants1.length; i++) {
// plants1[i].display();
// stroke(112, 157, 94);
// line(plants1[i].xpos, plants1[i].ypos, this.xpos, this.ypos);
// //plants1[i].update();
// }
}
void update() {
pushMatrix();
angle += 0.003;
rotate(angle);
for(int i = 0; i< segments.length; i++) {
segments[i].update();
}
popMatrix();
}
}