feat: Remove GA code from binding (#9042)

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
Márk Tolmács 2025-02-25 22:52:06 +01:00 committed by GitHub
parent 31e8476c78
commit 0ffeaeaecf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 2112 additions and 1832 deletions

View file

@ -1,3 +1,4 @@
import type { Curve } from "../math";
import {
isLineSegment,
lineSegment,
@ -6,7 +7,7 @@ import {
type LocalPoint,
} from "../math";
import type { LineSegment } from "../utils";
import type { BoundingBox, Bounds } from "./element/bounds";
import type { Bounds } from "./element/bounds";
import { isBounds } from "./element/typeChecks";
// The global data holder to collect the debug operations
@ -16,17 +17,29 @@ declare global {
data: DebugElement[][];
currentFrame?: number;
};
debugDrawPoint: typeof debugDrawPoint;
debugDrawLine: typeof debugDrawLine;
}
}
export type DebugElement = {
color: string;
data: LineSegment<GlobalPoint>;
data: LineSegment<GlobalPoint> | Curve<GlobalPoint>;
permanent: boolean;
};
export const debugDrawCubicBezier = (
c: Curve<GlobalPoint>,
opts?: {
color?: string;
permanent?: boolean;
},
) => {
addToCurrentFrame({
color: opts?.color ?? "purple",
permanent: !!opts?.permanent,
data: c,
});
};
export const debugDrawLine = (
segment: LineSegment<GlobalPoint> | LineSegment<GlobalPoint>[],
opts?: {
@ -80,41 +93,6 @@ export const debugDrawPoint = (
);
};
export const debugDrawBoundingBox = (
box: BoundingBox | BoundingBox[],
opts?: {
color?: string;
permanent?: boolean;
},
) => {
(Array.isArray(box) ? box : [box]).forEach((bbox) =>
debugDrawLine(
[
lineSegment(
pointFrom<GlobalPoint>(bbox.minX, bbox.minY),
pointFrom<GlobalPoint>(bbox.maxX, bbox.minY),
),
lineSegment(
pointFrom<GlobalPoint>(bbox.maxX, bbox.minY),
pointFrom<GlobalPoint>(bbox.maxX, bbox.maxY),
),
lineSegment(
pointFrom<GlobalPoint>(bbox.maxX, bbox.maxY),
pointFrom<GlobalPoint>(bbox.minX, bbox.maxY),
),
lineSegment(
pointFrom<GlobalPoint>(bbox.minX, bbox.maxY),
pointFrom<GlobalPoint>(bbox.minX, bbox.minY),
),
],
{
color: opts?.color ?? "cyan",
permanent: opts?.permanent,
},
),
);
};
export const debugDrawBounds = (
box: Bounds | Bounds[],
opts?: {