วันเสาร์ที่ 29 สิงหาคม พ.ศ. 2558

LAB 2 test Function

//=====set up size=====
void setup(){
  size (600,500);
  frameRate(10);
 
}


int click1=0,click2=0,click3=0; //value for set colour black and white

void draw(){
  background(255);
  stroke(255);
  click();
  fill(0+click1);
  Rect(0,0); // paper1
  fill(0+click2);
  Rect(200,0); //paper 2
  fill(0+click3);
  Rect(400,0); //paper 3
 
  //draw day in paper
  fill(255);
  text("Saturday",50,50);
  text("Sunday",50,100);
  text("Thursday",50,150);
  text("Friday",50,200);
 
  text("Saturday",250,50);
  text("Sunday",250,100);
  text("Wednesday",250,150);
  text("Tuesday",250,200);
 
  text("Monday",450,50);
  text("Sunday",450,100);
  text("Wednesday",450,150);
  text("Friday",450,200);
 
  fill(255,0,0);
  textSize(30);
  showDay(value_day());
  //draw pad number
  text("1",10,30);
  text("2",210,30);
  text("3",410,30);
 
 
  fill(0);
  textSize(15);
  text(" Please Thing a number in your mind",150,350);
  text("And Choose a paper Without that Day With number pad1-3",80,400);
 
}

//=====function for draw paper====
 
void Rect(int X,int Y){
  rect(X,Y,200,300);
}

  int count_limit_click1;
  int count_limit_click2;
  int count_limit_click3;
 
 
 
 
//====function for set value of click

void click(){

  click_one(); //use value that return from click_one
  click_two(); //use value that return from click_two
  click_three(); //use value that return from click_three
}



//===set rule for setup value click number 1===
int click_one(){
  if(keyPressed){
  if(key=='1')
  {
    count_limit_click1++;
    if(count_limit_click1==1){
    click1=255;
  }
    else{
      click1=0;
    }
   
    if(count_limit_click1==2){
      count_limit_click1=0;
    }
  }
  }
  return click1;
}

//===set rule for setup value click number 2====

int click_two(){
  if(keyPressed){
  if(key=='2')
  {
    count_limit_click2++;
    if(count_limit_click2==1){
    click2=255;
    }
    else{
      click2=0;
    }
    if(count_limit_click2==2){
      count_limit_click2=0;
    }
  }
  }
  return click2;
}


//===set rule for setup value click number 3===
int click_three(){
  if(keyPressed){
  if(key=='3')
  {
    count_limit_click3++;
    if(count_limit_click3==1){
    click3=255;
    }
      else{
      click3=0;
    }
    }
    if(count_limit_click3==2){
      count_limit_click3=0;
    }
  }
 
  return click3;
}

//====make groble variable====
int number_bit1;
int number_bit2;
int number_bit3;




//===set up rule for fine value bit===
int value_day(){
  int value_bit;

  // set up from click1
  if(click1==255){
    number_bit1=0;
  }
  if(click1==0){
      number_bit1=1;}
     
  // set up from click2
   if(click2==255){
    number_bit2=0;
  }
  if(click2==0){
      number_bit2=1;}
     
   // set up from click3
   if(click3==255){
    number_bit3=0;
  }
  if(click3==0){
      number_bit3=1;}
 
  value_bit=((4*number_bit1)+(2*number_bit2)+(1*number_bit3)); // calculate a value
  return value_bit;
}


//===set rule for trasnfrom bit to day===
void showDay(int value_day)
{

  if(value_day()==7){
  text("That day is sunday",180,450);
  }
  if(value_day==6){
      text("That day is Saturday",180,450);
  }
   if(value_day==5){
      text("That day is friday",180,450);
  }
  if(value_day==4){
     text("That day is Thursday",180,450);
  }
  if(value_day==3){
    text("That day is Wednesday",180,450);
  }
  if(value_day==2){
      text("That day is  Tuesday",180,450);
  }
  if(value_day==1){
      text("That day is Monday",180,450);
  }
  if(value_day==0){
      text("You lie Me",200,450);
  }
}



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

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