|
|
@ -18,6 +18,7 @@ export async function setup(wasmModule) {
|
|
|
|
|
|
|
|
|
|
|
|
const canvas = gameState.canvas = document.querySelector('#game')
|
|
|
|
const canvas = gameState.canvas = document.querySelector('#game')
|
|
|
|
gameState.ctx = gameState.canvas.getContext("2d")
|
|
|
|
gameState.ctx = gameState.canvas.getContext("2d")
|
|
|
|
|
|
|
|
gameState.ctx.fillStyle = getComputedStyle(gameState.canvas).getPropertyValue('--foreground')
|
|
|
|
|
|
|
|
|
|
|
|
const pixelSize = gameState.pixelSize = parseInt(canvas.getAttribute('data-pixelsize') || '2')
|
|
|
|
const pixelSize = gameState.pixelSize = parseInt(canvas.getAttribute('data-pixelsize') || '2')
|
|
|
|
gameState.width = Math.floor(parseInt(canvas.width) / pixelSize)
|
|
|
|
gameState.width = Math.floor(parseInt(canvas.width) / pixelSize)
|
|
|
@ -57,6 +58,7 @@ export async function setup(wasmModule) {
|
|
|
|
|
|
|
|
|
|
|
|
export async function onThemeChange() {
|
|
|
|
export async function onThemeChange() {
|
|
|
|
drawBoard()
|
|
|
|
drawBoard()
|
|
|
|
|
|
|
|
gameState.ctx.fillStyle = getComputedStyle(gameState.canvas).getPropertyValue('--foreground')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export async function cleanup() {
|
|
|
|
export async function cleanup() {
|
|
|
@ -120,7 +122,6 @@ function drawBoard() {
|
|
|
|
const { gameExports, width, height, pixelSize, ctx, canvas } = gameState
|
|
|
|
const { gameExports, width, height, pixelSize, ctx, canvas } = gameState
|
|
|
|
|
|
|
|
|
|
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
|
|
ctx.fillStyle = 'currentColor'
|
|
|
|
|
|
|
|
ctx.beginPath()
|
|
|
|
ctx.beginPath()
|
|
|
|
for (let row = 0; row < height; row++) {
|
|
|
|
for (let row = 0; row < height; row++) {
|
|
|
|
for (let column = 0; column < width; column++) {
|
|
|
|
for (let column = 0; column < width; column++) {
|
|
|
|