Wednesday, 27 August 2014

Animation tree lab 2

void setup()

{

  size(500, 400);

  stroke(255);  

  frameRate(100);

}



float y = 200;
float x = 0;

void draw()

{


  if ((y > 0) && (x == 0)) {  y = y - 1; // y = 100 - 1>> 0 x = 0

  draw_tree(x, y, y);
  }
   if ((x < 200) && (y == 0)){  x = x + 1; // x = 0 +1 >>200

  draw_tree(x, x, x);
 }
  if ((y < 200) && (x > 199)) {  y = y + 1;  // y = 200 x = 200

  draw_tree(y, y, x);
  }

if (y == 200){  x = x - 1; // x = 200-1>> 0
  draw_tree(x, y, x);
 
 }

}
void draw_tree(float r, float g, float b){
background(10, 185, 255);
fill(b, r, g);
rect(165+x, 110+y, 40, 10);
rect(145+x, 80+y, 20, 90);

fill(r, g, b);
ellipse(135+x, 46+y, 100, 80);
ellipse(175+x, 46+y, 100, 80);
ellipse(155+x, 46+y, 100, 80);

fill(b, r, g);
rect(105+x, 80+y, 20, 90);
rect(65+x, 80+y, 20, 90);
fill(r, g, b);
ellipse(85+x, 46+y, 100, 80);
ellipse(125+x, 46+y, 100, 80);
ellipse(105+x, 46+y, 100, 80);
ellipse(65+x, 46+y, 100, 80);
fill(r*g/b);
rect(195+x, 95+y, 10, 20);
}




No comments:

Post a Comment