Checkerboard background to signal transparency

This commit is contained in:
Kalekki 2022-11-21 13:40:44 +02:00
parent 32904051aa
commit 4381642e88

View file

@ -429,7 +429,7 @@ function mouseMove(evt) {
ovCtx.drawImage(arbitraryImage, finalX, finalY); ovCtx.drawImage(arbitraryImage, finalX, finalY);
} else if (!paintMode) { } else if (!paintMode) {
// draw targeting square reticle thingy cursor // draw targeting square reticle thingy cursor
ovCtx.strokeStyle = "#00000077"; ovCtx.strokeStyle = "#FFFFFF";
snapOffsetX = 0; snapOffsetX = 0;
snapOffsetY = 0; snapOffsetY = 0;
if (snapToGrid) { if (snapToGrid) {
@ -816,18 +816,14 @@ function isCanvasBlank(x, y, w, h, specifiedCanvas) {
} }
function drawBackground() { function drawBackground() {
bgCtx.lineWidth = 1; // Checkerboard
bgCtx.strokeStyle = "#999"; let darkTileColor = "#333";
var gridbox = bgCanvas.getBoundingClientRect(); let lightTileColor = "#555";
for (var i = 0; i < gridbox.width; i += 64) { for (var x = 0; x < bgCanvas.width; x += 64) {
bgCtx.moveTo(i, 0); for (var y = 0; y < bgCanvas.height; y += 64) {
bgCtx.lineTo(i, bgCanvas.height); bgCtx.fillStyle = (x + y) % 128 === 0 ? lightTileColor : darkTileColor;
bgCtx.stroke(); bgCtx.fillRect(x, y, 64, 64);
} }
for (var i = 0; i < gridbox.height; i += 64) {
bgCtx.moveTo(0, i);
bgCtx.lineTo(gridbox.width, i);
bgCtx.stroke();
} }
} }