-
Notifications
You must be signed in to change notification settings - Fork 0
/
LED.pde
49 lines (36 loc) · 835 Bytes
/
LED.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class LED{
int posX, posY;
color c;
LED(int posX, int posY){
this.posX = posX;
this.posY = posY;
}
LED(JSONObject json){
fromJson(json);
}
void draw(){
imageMode(CENTER);
tint(c);
image(LED_Sprite, posX, posY);
}
void setColor(int r, int g, int b, int a){
c = color(r,g,b,a);
}
void setColor(color c){
this.c = c;
}
JSONObject toJson(){
JSONObject out = new JSONObject();
if(posX < 536) out.setInt("posX", posX);
else out.setInt("posX", posX+170);
out.setInt("posY", posY);
out.setInt("c", c);
return out;
}
void fromJson(JSONObject json){
if(json.getInt("posX") < 536) posX = json.getInt("posX");
else posX = json.getInt("posX")-170;
posY = json.getInt("posY");
c = json.getInt("c");
}
}