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

Lab 4 : favorite song (loop)


int colour1;
int colour2;
int colour3;
int colour4;
int colour_passenger;
int colour_LetHerGo;

void setup() {
  size(600, 360);
}
void draw() {
  background(#B7F8FF);
  text_PASSENGER(140, 60);
  text_LetHerGo(200, 170);
  draw_loop();
}
void draw_FerrisWheel(int x, int y) {
  //Ferris wheel
  noFill();
  stroke(255);
  strokeWeight(3);
  //wheel_1
  ellipse(100+x, 100+y, 200, 200);
  //wheel_2
  ellipse(100+x, 100+y, 180, 180);
  //wheel_3
  ellipse(100+x, 100+y, 100, 100);
  //wheel_4
  fill(255);
  ellipse(100+x, 100+y, 30, 30);
  //pole
  stroke(255);
  strokeWeight(6);
  //poleL
  line(85+x, 100+y, 0+x, 350+y);
  //poleR
  line(115+x, 100+y, 200+x, 350+y);
}
void draw_bench(int x, int y) {
  //bench
  noStroke();
  //bench-1
  fill(colour1);
  ellipse(50+x, 20+y, 10, 10);
  ellipse(50+x, 40+y, 40, 40);
  //bench-2
  fill(colour2);
  ellipse(180+x, 50+y, 10, 10);
  ellipse(180+x, 70+y, 40, 40);
  //bench-3
  fill(colour3);
  ellipse(160+x, 175+y, 10, 10);
  ellipse(160+x, 195+y, 40, 40);
  //bench-4
  fill(colour4);
  ellipse(20+x, 150+y, 10, 10);
  ellipse(20+x, 170+y, 40, 40);
}
void text_PASSENGER(int x, int y) {
  //text"PASSENGER"
  fill(colour_passenger);
  textSize(60);
  text("PASSENGER", x, y);
}
void text_LetHerGo(int x, int y) {
  fill(colour_LetHerGo);
  textSize(100);
  //text"LET"
  text("LET", x+10, y);
  //text"HER"
  text("HER", x, 80+y);
  //text"GO"
  text("GO", x+20, 160+y);
}
void keyPressed() {
  colour1 = color(random(0, 225), random(0, 225), random(0, 225));
  colour2 = color(random(0, 225), random(0, 225), random(0, 225));
  colour3 = color(random(0, 225), random(0, 225), random(0, 225));
  colour4 = color(random(0, 225), random(0, 225), random(0, 225));
  colour_passenger = color(random(0, 225), random(0, 225), random(0, 225));
  colour_LetHerGo = color(random(0, 225), random(0, 225), random(0, 225));
}
void draw_loop() {
  int n=0;
  int m=0;
  while (n<3) {
    draw_FerrisWheel(mouseX+m, mouseY);
    draw_bench(mouseX+m, mouseY);
    n++;
    m+=200;
  }
}

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

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