From d23a2f64bdb5124260a08312234ac9b69f494e04 Mon Sep 17 00:00:00 2001 From: Ashelyn Rose Date: Tue, 1 Aug 2023 22:18:57 -0600 Subject: [PATCH] Use correct color for visualization (fixed in chrome) --- public/scripts/wasm-life-1/controller.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/scripts/wasm-life-1/controller.js b/public/scripts/wasm-life-1/controller.js index 10ff37d..d53c802 100644 --- a/public/scripts/wasm-life-1/controller.js +++ b/public/scripts/wasm-life-1/controller.js @@ -18,6 +18,7 @@ export async function setup(wasmModule) { const canvas = gameState.canvas = document.querySelector('#game') gameState.ctx = gameState.canvas.getContext("2d") + gameState.ctx.fillStyle = getComputedStyle(gameState.canvas).getPropertyValue('--foreground') const pixelSize = gameState.pixelSize = parseInt(canvas.getAttribute('data-pixelsize') || '2') gameState.width = Math.floor(parseInt(canvas.width) / pixelSize) @@ -57,6 +58,7 @@ export async function setup(wasmModule) { export async function onThemeChange() { drawBoard() + gameState.ctx.fillStyle = getComputedStyle(gameState.canvas).getPropertyValue('--foreground') } export async function cleanup() { @@ -120,7 +122,6 @@ function drawBoard() { const { gameExports, width, height, pixelSize, ctx, canvas } = gameState ctx.clearRect(0, 0, canvas.width, canvas.height) - ctx.fillStyle = 'currentColor' ctx.beginPath() for (let row = 0; row < height; row++) { for (let column = 0; column < width; column++) {