Add cubic bezier curve visual debug

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2025-01-14 10:26:35 +01:00
parent 77ea537c69
commit 028c397c0a
No known key found for this signature in database
4 changed files with 85 additions and 8 deletions

View file

@ -1,4 +1,4 @@
import type { Arc, Segment } from "../math";
import type { Arc, CubicBezier, Segment } from "../math";
import { isSegment, segment, pointFrom, type GlobalPoint } from "../math";
import { isBounds } from "./element/typeChecks";
import type { Bounds } from "./element/types";
@ -15,10 +15,24 @@ declare global {
export type DebugElement = {
color: string;
data: Segment<GlobalPoint> | Arc<GlobalPoint>;
data: Segment<GlobalPoint> | Arc<GlobalPoint> | CubicBezier<GlobalPoint>;
permanent: boolean;
};
export const debugDrawCubicBezier = (
c: CubicBezier<GlobalPoint>,
opts?: {
color?: string;
permanent?: boolean;
},
) => {
addToCurrentFrame({
color: opts?.color ?? "purple",
permanent: !!opts?.permanent,
data: c,
});
};
export const debugDrawArc = (
a: Arc<GlobalPoint>,
opts?: {