diff options
Diffstat (limited to 'js/pixel-art/pixel/app.js')
-rw-r--r-- | js/pixel-art/pixel/app.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/js/pixel-art/pixel/app.js b/js/pixel-art/pixel/app.js index 3e37db8..d3a0d28 100644 --- a/js/pixel-art/pixel/app.js +++ b/js/pixel-art/pixel/app.js @@ -68,9 +68,25 @@ function drawGrid() { ctx.strokeStyle = '#888888'; for (let x = 0; x < gridWidth; x++) { for (let y = 0; y < gridHeight; y++) { + const cellX = x * cellSize + offsetX; + const cellY = y * cellSize + offsetY; + + // Fill cell background ctx.fillStyle = grid[x][y] || '#f7f7f7'; - ctx.fillRect(x * cellSize + offsetX, y * cellSize + offsetY, cellSize, cellSize); - ctx.strokeRect(x * cellSize + offsetX, y * cellSize + offsetY, cellSize, cellSize); + ctx.fillRect(cellX, cellY, cellSize, cellSize); + + // Draw cell border + ctx.strokeRect(cellX, cellY, cellSize, cellSize); + + // Draw diagonal line for empty cells + if (!grid[x][y]) { + ctx.beginPath(); + ctx.strokeStyle = '#bfbfbf'; + ctx.moveTo(cellX, cellY); + ctx.lineTo(cellX + cellSize, cellY + cellSize); + ctx.stroke(); + ctx.strokeStyle = '#888888'; // Reset stroke style for borders + } } } } |