วันอาทิตย์ที่ 13 กันยายน พ.ศ. 2558

balloon_lab4


void setup(){
  size(500, 500);
}
void draw(){
  background(#FFFFFF);

  int y=mouseY;

  if(y>400){
   fill(#04D605);//green
   background(#7C7C7C);//gray
  }
  else if(y<100){
    fill(#EDE202);//yellow
    background(#E517E5);//pink
  }
  else{
    fill(#ED1A1A);//red
    background(#3C17E5);//blue
  }
  draw_balloon(width/2,y,2);
}
  void draw_balloon(int x,int y,int n){
  int r=100;
  int string_length=200;
  int count=1,count1=0;
  //int n=2;
  int l=(r/2)+20;
  int l1=0;
  while(count<=n){
   
  line(x-count1,l1+y,x,y+string_length);//left rope
  line(count1+x,l1+y,x,y+string_length);
 
  ellipse(x-count1,l1+y,r,r);//left balloon
  ellipse(count1+x,y+l1,r,r);
  l1=l1+20;
  count1=count1+l;
  count++;
  }
}

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

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