boxes/js/main.mjs

28 lines
634 B
JavaScript

import * as graphics from "./graphics.mjs";
import { range } from "./utils/range.mjs";
const canvas = document.getElementById("canvas");
const canvas_context = canvas.getContext("2d");
graphics.set_size(canvas.width, canvas.height);
const BOX_SIZE = 9;
const SCALE = 64;
function draw_tile (x, y) {
graphics.fill_rect(x * SCALE, y * SCALE, SCALE, SCALE);
}
function draw_box_floor () {
graphics.clear("#888");
graphics.set_color("#aaa");
for (const x in range(0, BOX_SIZE)) {
for (const y in range(0, BOX_SIZE)) {
if (((x ^ y) & 1) === 0)
draw_tile(x, y);
}
}
}
draw_box_floor();
graphics.render(canvas_context);