วันเสาร์ที่ 12 กันยายน พ.ศ. 2558

Lab 4 : balloons (loop)


int radius = 50;
int string_length = radius*2;
int posY=0;
int colour;
void setup() {
  size(300, 300);
}
void draw() {
  background(#BBEEFA);
  frameRate(20);
  int posX = radius/2;
  draw_balloon(posX, 300-posX);
  posY=(posY-10)%(height+125);
}
void draw_balloon(int x, int y) {
  //int radius = 50;
  int n=0;
  int space=0;
  while (n<7) {
    fill(colour);
    ellipse(x+space, y+posY, radius, radius);
    stroke(0);
    line(x+space, y+(radius/2)+posY, x+space, y + string_length+posY);
    n++;
    space+=radius;
  }
}
void mouseMoved() {
  colour = color(random(0, 225), random(0, 225), random(0, 225));
}

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

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