วันพุธที่ 2 กันยายน พ.ศ. 2558

Lab03 : Movie

int c=-1;
int count=0;
void setup() {
  background(51); 
  size(600, 600);
  show_tab();
}
void draw()
{
  if (keyPressed && (key=='c' || key=='C')) {
    background(51);
    show_tab();
    count=0;
  }
}
void mousePressed() {
  c=(c+1)%3;
  doraemon(mouseX, mouseY, 250, 250, c, color(random(255), random(255), random(255)));
  count++;
  show_tab();
}

void show_tab() {
  textSize(15);
  fill(255);
  rect(0, 550, 600, 50);
  fill(51);
  text(count, 580, height-10);
  text("CLICK MOUSE TO DRAW DORAEMON | PRESS 'C' TO CLEAR", 2, height-10);
}
void doraemon(int posX, int posY, int w, int h, int eye, color colors) {
  strokeWeight(4);
  //face
  fill(colors);
  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==0) {
    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 if (eye==1)
  {
    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);
  } else if (eye==2)
  {
    fill(0);
    rectMode(CENTER);
    rect(posX-w*0.11, posY-h*0.3, 0.03*w, 0.001*h);
    rect(posX+w*0.11, posY-h*0.3, 0.03*w, 0.001*h);
    rectMode(CORNER);
  }
  //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 ขึ...