This commit is contained in:
kolaflash
2026-01-04 19:34:15 +01:00
parent 415a0c6b6f
commit ead8f3ce5a
21 changed files with 244 additions and 46 deletions
+28
View File
@@ -0,0 +1,28 @@
import "./GraphBrowser.css";
import { type Component, createSignal, onMount } from "solid-js";
import { createGraph, type Edge, type Graph, type Node } from "#/lib/Graph.ts";
import type { Vector } from "#/lib/Vector.ts";
export const GraphBrowser: Component<{
graph: Graph<{ position: Vector; label: string }>;
}> = (props) => {
let canvasRef!: HTMLCanvasElement;
const [width, setWidth] = createSignal(100);
const [height, setHeight] = createSignal(100);
onMount(() => {
const ctx: CanvasRenderingContext2D = canvasRef.getContext("2d", {
alpha: false,
})!;
setWidth(canvasRef.parentElement!.offsetWidth);
setHeight(width());
});
return (
<div class="graph-browser">
<canvas ref={canvasRef} width={width()} height={height()}></canvas>
</div>
);
};