grid resizing and auto reset

This commit is contained in:
MaxRobinsonTheGreat
2020-07-19 17:33:09 -06:00
parent ebb39df34a
commit a5a559e61b
7 changed files with 411 additions and 34 deletions

View File

@@ -5,8 +5,7 @@ class Renderer {
this.cell_size = cell_size;
this.canvas = document.getElementById(canvas_id);
this.ctx = this.canvas.getContext("2d");
this.canvas.width = $('#'+container_id).width();
this.canvas.height = $('#'+container_id).height();
this.fillWindow(container_id)
this.height = this.canvas.height;
this.width = this.canvas.width;
this.cells_to_render = new Set();
@@ -14,6 +13,17 @@ class Renderer {
this.highlighted_cells = new Set();
}
fillWindow(container_id) {
this.fillShape($('#'+container_id).height(), $('#'+container_id).width());
}
fillShape(height, width) {
this.canvas.width = width;
this.canvas.height = height;
this.height = this.canvas.height;
this.width = this.canvas.width;
}
clear() {
this.ctx.fillStyle = 'white';
this.ctx.fillRect(0, 0, this.height, this.width);