feat: Ovoids

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs
2026-01-05 10:25:40 +00:00
parent c158187f20
commit 9616e63e23
4 changed files with 356 additions and 3 deletions
+11 -2
View File
@@ -63,6 +63,7 @@ import {
getElementAbsoluteCoords,
} from "./bounds";
import { shouldTestInside } from "./collision";
import { generateFreeDrawOvoidSvgPath } from "./freedraw";
import type {
ExcalidrawElement,
@@ -78,6 +79,10 @@ import type {
import type { Drawable, Options } from "roughjs/bin/core";
import type { Point as RoughPoint } from "roughjs/bin/geometry";
// Toggle between old (perfect-freehand) and new (ovoid-union) freedraw rendering
// Set to true to use the new ovoid-based implementation
export const USE_NEW_FREEDRAW_RENDERER = true;
export class ShapeCache {
private static rg = new RoughGenerator();
private static cache = new WeakMap<
@@ -852,8 +857,12 @@ const _generateElementShape = (
);
}
// (2) stroke
shapes.push(getFreeDrawSvgPath(element));
// (2) stroke - use new ovoid renderer or legacy perfect-freehand
if (USE_NEW_FREEDRAW_RENDERER) {
shapes.push(generateFreeDrawOvoidSvgPath(element) as SVGPathString);
} else {
shapes.push(getFreeDrawSvgPath(element));
}
return shapes;
}