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

LAB 3 Ninja eye

void setup(){
  size(600,600);
}

void draw(){
  background(random(100,150));
  frameRate(30);
  eyeNinja(500,150);
 
}

// make function draw eyeninja
void eyeNinja(int radiuse,int pointEye){
  lineEye();
  circle(radiuse);
  circle(radiuse-200);
  eye(pointEye,HALF_PI-HALF_PI/2.5);
  eye(pointEye,-HALF_PI/1.5);
  eye(pointEye,PI);
}

//function draw a circle of eye
void circle(int radiuse){
  fill(255,0,0);
  stroke(0);
  ellipse(width/2,height/2,radiuse,radiuse);
}

//function draw black eye
void eye(int pointEye,float pi){
  stroke(0);
  fill(0);
  ellipse(width/2,height/2,100,100);
  ellipse((width/2)+(pointEye*cos(angle(pi))),(height/2)+(pointEye*sin(angle(pi))),60,60);

}

//function for set angle
float angle(float Pi){
  float angle;
  angle = map(count(),0,300,0,TWO_PI)+Pi;
  return angle;
}

// set base value
int countNum=0;

//make function for make counting
int count(){
  if(key=='+'){
    countNum++;
  }
  if(countNum==301){
    countNum=0;
  }
  return countNum;
}

//make eye liner
void lineEye(){
  fill(255);
  arc(width/2,height/2,800,500,0,TWO_PI);
}
 

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

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