-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGallerySpace.pde
More file actions
executable file
·112 lines (87 loc) · 2.38 KB
/
Copy pathGallerySpace.pde
File metadata and controls
executable file
·112 lines (87 loc) · 2.38 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
class GallerySpace {
PVector myPos;// = new PVector(0,0);
PVector myCentroid;// = new PVector(0,0);
int [] myMinoLayout;// = null;
float mySize;
float tileSize;
String t;// = "";
boolean selected;// = false;
GallerySpace(int x, int y, float gssize, String s) {
myPos = new PVector(0,0);
myCentroid = new PVector(0,0);
myMinoLayout = null;
t = "";
selected = false;
myPos.x = x;
myPos.y = y;
mySize = gssize;
tileSize = mySize/(minoSize+1);
t = s;
}
void display() {
rectMode(CORNER);
fill(0,0,50);
if (selected) {
fill(hue2,100,50);
stroke(hue2,100,100);
strokeWeight(2);
rect(myPos.x,myPos.y,mySize-2,mySize-2);
} else {
stroke(0,0,15);
}
if (over() && !carrying) {
strokeWeight(2);
stroke(15,100,80);
// textAlign(RIGHT, BOTTOM);
// fill(hue1,100,100);
// text(t,width,myPos.y+mySize+textAscent()+textDescent());
// noFill();
// fill(0,0,50);
}
strokeWeight(2);
rect(myPos.x,myPos.y,mySize-2,mySize-2);
strokeWeight(1);
stroke(0,0,15);
if (myMinoLayout != null) drawMyMino();
}
void drawMyMino() {
fill(hue1,satHI,80);
// int tileSize = mySize/(minoSize);
// findMyCentroid();
rectMode(CENTER);
pushMatrix();
translate(myPos.x+mySize/2-myCentroid.x,myPos.y+mySize/2-myCentroid.y);
for (int j=0; j<minoSize; j++) {
String row = binary(myMinoLayout[j]);
for (int i=0; i<row.length(); i++) {
if (row.charAt(i) == "1") {
rect(tileSize*(i+minoSize-row.length()),tileSize*j,tileSize,tileSize);
}
}
}
popMatrix();
}
void findMyCentroid() {
float x = 0;
float y = 0;
for (int j=0; j<minoSize; j++) {
String row = binary(myMinoLayout[j]);
for (int i=0; i<row.length(); i++) {
if (row.charAt(i) == "1") {
x += i+minoSize-row.length();
y += j;
}
}
}
myCentroid.x = tileSize * x/float(minoSize);
myCentroid.y = tileSize * y/float(minoSize);
//println("\n"+myCentroid.x+" "+myCentroid.y);
}
boolean over() {
if(mouseX>myPos.x && mouseX<(myPos.x+mySize) && mouseY>myPos.y && mouseY<(myPos.y+mySize)) {
return true;
} else {
return false;
}
}
}