account for rotations for polygons

This commit is contained in:
Ryan Di 2025-01-13 16:32:41 +11:00
parent 4672bb948c
commit 068edfc1cd

View File

@ -181,6 +181,12 @@ export const getElementShapes = <Point extends GlobalPoint | LocalPoint>(
// otherwise return the curve shape (and also the shape of its arrowheads) // otherwise return the curve shape (and also the shape of its arrowheads)
const arrowheadShapes: GeometricShape<Point>[] = []; const arrowheadShapes: GeometricShape<Point>[] = [];
const transform = (p: Point): Point =>
pointRotateRads(
pointFrom(p[0] + startingPoint[0], p[1] + startingPoint[1]),
center,
element.angle,
);
for (const arrowhead of arrowheads) { for (const arrowhead of arrowheads) {
if (arrowhead.shape === "polygon") { if (arrowhead.shape === "polygon") {
@ -191,9 +197,8 @@ export const getElementShapes = <Point extends GlobalPoint | LocalPoint>(
type: "polygon", type: "polygon",
data: polygonFromPoints( data: polygonFromPoints(
otherPoints.map((otherPoint) => otherPoints.map((otherPoint) =>
pointAdd( transform(
pointFrom<Point>(otherPoint.data[0], otherPoint.data[1]), pointFrom<Point>(otherPoint.data[0], otherPoint.data[1]),
pointFrom<Point>(element.x, element.y),
), ),
), ),
), ),