From 068edfc1cd2b1411353e089b9e7d4a6e6211512a Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Mon, 13 Jan 2025 16:32:41 +1100 Subject: [PATCH] account for rotations for polygons --- packages/excalidraw/shapes.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/excalidraw/shapes.tsx b/packages/excalidraw/shapes.tsx index 601d6f59c..ef7aeb6cf 100644 --- a/packages/excalidraw/shapes.tsx +++ b/packages/excalidraw/shapes.tsx @@ -181,6 +181,12 @@ export const getElementShapes = ( // otherwise return the curve shape (and also the shape of its arrowheads) const arrowheadShapes: GeometricShape[] = []; + const transform = (p: Point): Point => + pointRotateRads( + pointFrom(p[0] + startingPoint[0], p[1] + startingPoint[1]), + center, + element.angle, + ); for (const arrowhead of arrowheads) { if (arrowhead.shape === "polygon") { @@ -191,9 +197,8 @@ export const getElementShapes = ( type: "polygon", data: polygonFromPoints( otherPoints.map((otherPoint) => - pointAdd( + transform( pointFrom(otherPoint.data[0], otherPoint.data[1]), - pointFrom(element.x, element.y), ), ), ),