วันอาทิตย์ที่ 30 สิงหาคม พ.ศ. 2558

Lab2 CLOCK

void setup() {
  size(200, 200);
  clock = new clock(45, width/2, height/2+15);
}

void draw() {
  background(0);
  clock.time();
  clock.display();
}

class clock extends Clock {
  int fontSize;
  float x, y;
 
  clock(int _fontSize, float _x, float _y) {
    fontSize = _fontSize;
    x = _x;
    y = _y;
  }
 
//หน้าปัด
  void display() {
    textSize(fontSize);
    textAlign(CENTER);
    text (nf(h,2) + ":" + nf(m, 2) + ":" + nf(s, 2), x, y);
  }
}

class Clock {
  int h, m, s;
  Clock() {
  }
//เวลา
  void time() {
    h = hour();
    m = minute();
    s = second();
  }
}

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

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