-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Cell.pde
55 lines (47 loc) · 1.12 KB
/
Cell.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
50
51
52
53
54
55
class Cell {
int col, row;
float x, y;
boolean generationClaimed;
int containedShapes = 0;
Cell(int col, int row) {
this.col = col;
this.row = row;
this.generationClaimed = false;
calcPos();
}
void calcPos() {
if (isLandscape()) {
this.x = (width-cellSize*GRID_COLUMNS)/2 + cellSize * col;
this.y = cellSize * row + GRID_PADDING;
} else {
this.x = (width-cellSize*GRID_COLUMNS)/2 + cellSize * col;
this.y = cellSize * row + GRID_PADDING;
}
}
void render() {
calcPos();
float sw = max(cellSize / 50, 1);
strokeWeight(sw);
render(color(255));
if (debug) {
fill(0);
textSize(cellSize);
textAlign(CENTER, CENTER);
text(containedShapes, x + cellSize/2, y + cellSize/2);
}
}
void render(color colour) {
stroke(0);
fill(colour, debug ? 100 : 255);
rect(x, y, cellSize, cellSize);
}
void renderOverlap() {
if (containedShapes > 1 && !mousePressed) {
stroke(100, 0, 0);
float sw = max(cellSize / 15, 1);
strokeWeight(sw);
noFill();
rect(x, y, cellSize, cellSize);
}
}
}