O.O LeD กระพริบปริ๊บๆ O.O
~ ~ LeD ~
LeD Processing.js code
int m = 6;
int n = 2;
int l = 25;
void setup() {
size((m*(n*2)*l)+l,(m*n*l)+l);
//m*l*3+l-d, n*l+l-d
frameRate(5);
}
Panal a = new Panal(20,m,n,l);
//Matrix s = new Matrix(20,6,25);
void draw() {
background(0);
a.PaDisplay();
//s.Display();
}
class LED {
int x,y,d,m,n,l;
float on;
LED(int d){
this.d = d;
}
void display(int x, int y) {
noStroke();
co();
ellipse(x, y, d, d);
}
void co() {
on = random(0, 2);
if (on<1) {
fill(42,111,13);
}
else if (on>=1) {
fill(87,242,22);
}
}
}
class Matrix extends LED {
int Xpos,Ypos;
Matrix(int d,int m, int l){
super(d);
this.Xpos = (m*l)/2+l;
this.Ypos = (m*l)/2+l;
this.m = m;
this.l = l;
this.x = Xpos-(m/2*l);
this.y = Ypos-(m/2*l);
}
void Display() {
for (int i=0;i<m;i++) {
for (int j=0;j<m;j++) {
display(x, y);
x=x+l;
}
y=y+l;
x=x-m*l;
}
this.x = Xpos-(m/2*l);
this.y = Ypos-(m/2*l);
}
}
class Panal extends Matrix {
int Xpanal,Ypanal;
int lo;
Panal( int d,int m, int n, int l) {
super(d,m,l);
this.lo = m*l;
this.Xpanal = n*2;
this.Ypanal = n;
}
void PaDisplay() {
for (int i=0;i<Ypanal;i++) {
for (int j=0;j<Xpanal;j++) {
Display();
Xpos = Xpos+lo;
}
Xpos = (m*l)/2+l;
Ypos = Ypos+lo;
}
this.Xpos = (m*l)/2+l;
this.Ypos = (m*l)/2+l;
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น