import { createCanvas } from "@common/display/canvas";
import { BSP } from "@common/level/bsp";
import { stringHash } from "@common/utils";

const S = 512;

export default async function main() {
    const canvas = createCanvas(S, S);

    const ctx = canvas.getContext("2d");
    if (!ctx) return;

    BSP.generateLevel(S, S, (x, y, node) => {
        ctx.fillStyle = node?.id ? `hsl(${stringHash(node.id) % 360}, 100%, 20%)`: 'black';
        ctx.fillRect(x, y, 1, 1);
    }, { depth: 16, minWidth: 8, minHeight: 8 });

    console.log('done');
}
