Add Edge Rendering with Toggle Button

This commit is contained in:
Marty Oehme 2018-07-08 19:01:14 +02:00
parent a71d442b45
commit 8fc3f35321
3 changed files with 18 additions and 0 deletions

View file

@ -12,6 +12,8 @@ class Grid {
final List<List<Cell>> map;
bool _dirty = true;
bool _renderEdges = true;
int _startingSeed;
int _x;
int _y;
@ -174,8 +176,14 @@ class Grid {
int brickW = (canvas.width ~/ map[0].length);
int brickH = (canvas.height ~/ map.length);
ctx.clearRect(0, 0, canvas.width, canvas.height);
for (int y = 0; y < map.length; y++) {
for (int x = 0; x < map[y].length; x++) {
if(_renderEdges) {
ctx.setStrokeColorRgb(100, 100, 100);
ctx.strokeRect(x * brickW, y * brickH, brickW, brickH);
}
Cell c = map[y][x];
if (c.state == true)
ctx.setFillColorRgb(155, 155, 255);
@ -187,4 +195,9 @@ class Grid {
_dirty = false;
}
void switchEdgeRendering([bool on]) {
_renderEdges = on ?? !_renderEdges;
_dirty = true;
}
}