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

LED

void setup() {
  size(screen.width, screen.height);
}
void draw() {
  frameRate(10);
  LED f=new LED(5, 5, 10);
  f.display();
}

class LED {
  int a;
  int b;
  int size1;
  LED(int x, int y, int s) {
    this.a=x;
    this.b=y;
    this.size1=s;
  }
  void colour() {
    float c =random(0, 2);
    if (c>1) {
      fill(0);
    }
    else {
      fill(255);
    }
  }
  void display() {
    ellipse(this.a, this.b, this.size1, this.size1);
    colour();
  }
}

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

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