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

battery_lab3


int resize;
int countL;
int countD;
int a;
void setup() {
  size(600, 450);
}
void draw() {
  background(#EAE49C);
  draw_battery(220, 175, 200, 75);
  //draw_positionSign(15, 3);
  //draw_negativeSign(260);
  println(resize);
  println(mouseX);
  println("CountL"+countL);
  println("CountD"+countD);
  println("Press"+mousePressed);
}
void draw_battery(int x,int y,int w,int h) {

  fill(#EAE49C);
  stroke(#384D12);
  strokeWeight(5);
  rect(x, y, w, h, 7); //case
  fill(#384D12);
  //depolarized
  rect(x-10, y+15, w-190, h-30, 2);
  //in case
  resize=(resize+3)%180;
  rect(((x+191)-resize), y+9, resize, h-17, 1);

  ////////// POS /////////////


  fill(#ED0C0C);
  stroke(#ED0C0C);
  rect(x-45, y+34, w-185, h-72);//horizontal
  rect(x-39, y+28, w-197, h-60);//vertical

  //////////// NEG //////////
   fill(#ED0C0C);
  stroke(#ED0C0C);
  rect(x+215, y+34, w-185, h-72);//horizontal


  if (mouseX<100 || mouseX>500) {
    rect(x+172, y+9, w-181, h-17, 1);
    resize=0;
    textSize(50);
    text("Low Battery", x-45, y+135);
    countL++;
    if(countL>20){//50
      countD++;
      fill(#EAE49C);
      stroke(#EAE49C);
      strokeWeight(5);
      rect(x+172, y+9, w-181, h-17, 1);
      if(countD>20){
        countL=0;
        countD=0;
        }    
      }
    }
}


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

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