วันศุกร์ที่ 11 กันยายน พ.ศ. 2558

Lab04 : Movie

int x=0, z=30;
void setup() {
  background(0, 255, 255); 
  size(500, 500);
}
void draw()
{
  fill(x, 50);
  rect(0, 0, width, height);
  if (x<=255) {
    x++; 
    if (x>=255)
      x=255;
  }
  while (z<width && mousePressed) {
    if (mouseButton==RIGHT)
      doraemon(mouseX+30+z, mouseY+30, 30, 30, (z+1)%2);
    else
      doraemon(mouseX+30-z, mouseY+30, 30, 30, (z+1)%2);
    z+=30;
  }
  if (!mousePressed)
    z=0;
  doraemon(mouseX+30, mouseY+30, 30, 30, 1);
}

void doraemon(int posX, int posY, int w, int h, int eye) {
  strokeWeight(0);
  //face
  fill(0, 153, 255);
  ellipse(posX, posY, w, h);
  fill(255);
  ellipse(posX, posY+h*0.0875, 0.82*w, 0.825*h);

  //eye
  ellipse(posX-w*0.11, posY-h*0.3, w*0.175, h*0.2125);
  ellipse(posX+w*0.11, posY-h*0.3, w*0.175, h*0.2125);
  fill(0);
  noFill();
  if (eye==1) {
    arc(posX-w*0.11, posY-h*0.3, 0.05*w, 0.05*h, PI, 2*PI);
    arc(posX+w*0.11, posY-h*0.3, 0.05*w, 0.05*h, PI, 2*PI);
  } else
  {
    fill(0);
    ellipse(posX-w*0.11, posY-h*0.3, 0.03*w, 0.05*h);
    ellipse(posX+w*0.11, posY-h*0.3, 0.03*w, 0.05*h);
    fill(255);
    ellipse(posX-w*0.11, posY-h*0.3, 0.02*w, 0.03*h);
    ellipse(posX+w*0.11, posY-h*0.3, 0.02*w, 0.03*h);
  }
  //nose
  fill(204, 51, 0);
  ellipse(posX, posY-0.175*h, 0.0875*w, 0.0875*h);
  line(posX, posY-0.1325*h, posX, posY+w*0.075);

  //mus left
  line(posX-w*0.05, posY-h*0.0875, posX-w*0.25, posY-h*0.125);
  line(posX-w*0.05, posY-h*0.0375, posX-w*0.25, posY-h*0.0375);
  line(posX-w*0.05, posY+h*0.0125, posX-w*0.25, posY+h*0.0375);

  //mus right
  line(posX+w*0.05, posY-h*0.0875, posX+w*0.25, posY-h*0.125);
  line(posX+w*0.05, posY-h*0.0375, posX+w*0.25, posY-h*0.0375);
  line(posX+w*0.05, posY+h*0.0125, posX+w*0.25, posY+h*0.0375);



  //mouth
  noFill();
  arc(posX-w*0.1, posY+h*0.1125, 0.075*w, 0.075*h, PI/2, PI+PI/2);
  fill(255);
  arc(posX, posY+h*0.15, w*0.2, w*0.2, 0, PI);
  line (posX-w*0.1, posY+h*0.15, posX+w*0.1, posY+h*0.15);
}


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

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

commit เพิ่มเติม : เพื่ม userstory, bookmark

>>  add userstory ทำการเพิ่ม userstory ใน functional tests >>  add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...