Przygotowanie protytypu

This commit is contained in:
Robert Bendun 2021-03-15 18:31:22 +01:00
parent 28d3ce6cc3
commit 58b92fc8fb
2 changed files with 13 additions and 5 deletions

View File

@ -1,6 +1,7 @@
const Grid = function(canvas) { const Grid = function(canvas) {
let grid = [[]]; let grid = [[]];
let ctx; let ctx;
let storages = []
this.setCanvasSize = (canvas) => { this.setCanvasSize = (canvas) => {
canvas.width = 2000; canvas.width = 2000;
@ -27,15 +28,21 @@ const Grid = function(canvas) {
} }
} }
this.neonRect = (x, y, w, h) => { this.neonRect = (x, y, w, h, clr = '#fff', lw = 5) => {
this.ctx.globalCompositeOperation = 'lighter'; this.ctx.globalCompositeOperation = 'darker';
this.ctx.shadowColor = "#fff"; this.ctx.shadowColor = clr;
this.ctx.shadowBlur = 10; this.ctx.shadowBlur = 10;
this.ctx.strokeStyle= "#fff"; this.ctx.strokeStyle= clr;
this.ctx.lineWidth = 5; this.ctx.lineWidth = lw;
this.ctx.strokeRect(x, y, w, h); this.ctx.strokeRect(x, y, w, h);
} }
this.addStorageCenter = (x, y) => {
this.neonRect(x * 100, y * 100, 100, 100, '#ff0000', 10);
}
this.getStorageCenters = () => storages
this.ctx = canvas.getContext('2d'); this.ctx = canvas.getContext('2d');
this.setCanvasSize(canvas); this.setCanvasSize(canvas);
this.processGrid(); this.processGrid();

View File

@ -1,4 +1,5 @@
window.addEventListener('DOMContentLoaded', () => { window.addEventListener('DOMContentLoaded', () => {
const gridCanvas = document.getElementById('canvas-grid'); const gridCanvas = document.getElementById('canvas-grid');
const grid = new Grid(gridCanvas); const grid = new Grid(gridCanvas);
grid.addStorageCenter(9, 0);
}); });