WIP WIP WIP

This commit is contained in:
Schluffe
2026-03-16 00:18:11 +01:00
parent a1c4dd8401
commit 6e95c538fb
6 changed files with 84 additions and 46 deletions
+1 -46
View File
@@ -1,53 +1,8 @@
import { createPolygon, type Polygon } from "#/engine/Polygon.ts";
import { defineScene } from "#/engine/Scene.ts";
import { createVector, type Vector } from "#/engine/Vector.ts";
import data from "./data.json";
const { process, linkScenes } = defineScene(data);
linkScenes(["testScene"] as const);
const polygon = createPolygon(createVector(32, 32), [
createVector(0, 0),
createVector(0, 16),
createVector(16, 16),
]);
function drawPoint(
ctx: CanvasRenderingContext2D,
position: Vector,
radius: number = 2,
color: string = "#fff",
): void {
ctx.beginPath();
ctx.arc(position.x, position.y, radius, 0, 2 * Math.PI);
ctx.fillStyle = color;
ctx.fill();
}
function drawPoly(
ctx: CanvasRenderingContext2D,
poly: Polygon,
trigger: boolean = false,
): void {
drawPoint(ctx, poly.position);
ctx.beginPath();
ctx.moveTo(
poly.points[0].x + poly.position.x + 0.5,
poly.points[0].y + poly.position.y + 0.5,
);
for (let i = poly.points.length - 1; i >= 0; i--) {
ctx.lineTo(
poly.points[i].x + poly.position.x + 0.5,
poly.points[i].y + poly.position.y + 0.5,
);
}
ctx.strokeStyle = trigger ? "red" : "orange";
ctx.stroke();
}
process((ctx, _delta) => {
drawPoly(ctx, polygon);
});
process((_ctx, _delta) => {});