วันอาทิตย์ที่ 31 สิงหาคม พ.ศ. 2557

L.? tree


int locationtree_x = 150;
int locationtree_y = 0;
float locationleaf_x = 150;
float update = 0.1;
void setup()
{
  size(323, 200);
  stroke(255);
  frameRate(30);
}  

void draw() {
  background(255);
  draw_tree(locationtree_x, locationtree_y, locationleaf_x);
  draw_tree(locationtree_x-310, locationtree_y, locationleaf_x-310);
  draw_tree(locationtree_x-210, locationtree_y, locationleaf_x-210);
  draw_tree(locationtree_x-100, locationtree_y, locationleaf_x-100);
  draw_tree(locationtree_x-160, locationtree_y-10, locationleaf_x-160);
  draw_tree(locationtree_x-50, locationtree_y-10, locationleaf_x-50);
  draw_tree(locationtree_x-260, locationtree_y-10, locationleaf_x-260);
  locationleaf_x = locationleaf_x - update;
  if (locationleaf_x < 148 || locationleaf_x > 150) { 
    update = update*-1 ;
  }
}

void draw_tree(int locationtree_x, int locationtree_y, float locationleaf_x)
{
  noStroke();

  fill(204, 102, 0);
  rect(155+locationtree_x, 120+locationtree_y, 18, 80);
  triangle(152+locationtree_x, 215+locationtree_y, 164+locationtree_x, 100+locationtree_y, 176+locationtree_x, 215+locationtree_y);
  triangle(152+locationtree_x, 151+locationtree_y, 164+locationtree_x, 200+locationtree_y, 176+locationtree_x, 151+locationtree_y);
  leaf(locationleaf_x, locationtree_y);
}
void leaf(float locationleaf_x, int locationleaf_y) {
  fill(0, 95, 0);
  ellipse(135+locationleaf_x, 65+locationleaf_y, 30, 30);
  ellipse(165+locationleaf_x, 132+locationleaf_y, 30, 30);
  ellipse(195+locationleaf_x, 65+locationleaf_y, 30, 30);
  ellipse(120+locationleaf_x, 120+locationleaf_y, 30, 30);
  ellipse(150+locationleaf_x, 130+locationleaf_y, 30, 30);
  ellipse(135+locationleaf_x, 132+locationleaf_y, 30, 30);
  ellipse(145+locationleaf_x, 138+locationleaf_y, 30, 30);
  ellipse(185+locationleaf_x, 138+locationleaf_y, 30, 30);
  ellipse(155+locationleaf_x, 136+locationleaf_y, 30, 30);
  ellipse(175+locationleaf_x, 136+locationleaf_y, 30, 30);

  fill(0, 135, 0);
  ellipse(210+locationleaf_x, 120+locationleaf_y, 30, 30);
  ellipse(150+locationleaf_x, 100+locationleaf_y, 30, 30);
  ellipse(220+locationleaf_x, 105+locationleaf_y, 30, 30);
  ellipse(150+locationleaf_x, 55+locationleaf_y, 30, 30);

  fill(0, 125, 0);
  ellipse(180+locationleaf_x, 100+locationleaf_y, 30, 30);
  ellipse(165+locationleaf_x, 110+locationleaf_y, 30, 30);
  ellipse(135+locationleaf_x, 110+locationleaf_y, 30, 30);
  ellipse(180+locationleaf_x, 55+locationleaf_y, 30, 30);
  ellipse(115+locationleaf_x, 105+locationleaf_y, 30, 30);
  ellipse(195+locationleaf_x, 132+locationleaf_y, 30, 30);

  fill(0, 145, 0);
  ellipse(195+locationleaf_x, 110+locationleaf_y, 30, 30);
  ellipse(165+locationleaf_x, 85+locationleaf_y, 30, 30);
  ellipse(135+locationleaf_x, 75+locationleaf_y, 30, 30);
  ellipse(165+locationleaf_x, 50+locationleaf_y, 30, 30);

  fill(0, 155, 0);
  ellipse(195+locationleaf_x, 75+locationleaf_y, 30, 30);
  ellipse(120+locationleaf_x, 85+locationleaf_y, 30, 30);
  ellipse(210+locationleaf_x, 85+locationleaf_y, 30, 30);
  ellipse(155+locationleaf_x, 70+locationleaf_y, 30, 30);
  ellipse(180+locationleaf_x, 130+locationleaf_y, 30, 30);

  fill(0, 165, 0);
  ellipse(175+locationleaf_x, 70+locationleaf_y, 30, 30);
  ellipse(165+locationleaf_x, 65+locationleaf_y, 30, 30);
  ellipse(135+locationleaf_x, 85+locationleaf_y, 30, 30);
  ellipse(195+locationleaf_x, 85+locationleaf_y, 30, 30);
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น