From 755135302ceca94e384ede1671492ddc3a5e2171 Mon Sep 17 00:00:00 2001 From: AMRITESH240304 Date: Fri, 4 Oct 2024 17:16:58 +0530 Subject: [PATCH] feat:add angle constrained freedraw --- packages/excalidraw/components/App.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsx index 8a976dd8bf..d8188c12c0 100644 --- a/packages/excalidraw/components/App.tsx +++ b/packages/excalidraw/components/App.tsx @@ -7993,8 +7993,17 @@ class App extends React.Component { if (newElement.type === "freedraw") { const points = newElement.points; - const dx = pointerCoords.x - newElement.x; - const dy = pointerCoords.y - newElement.y; + let dx = pointerCoords.x - newElement.x; + let dy = pointerCoords.y - newElement.y; + + if (shouldRotateWithDiscreteAngle(event)) { + ({ width: dx, height: dy } = getLockedLinearCursorAlignSize( + newElement.x, + newElement.y, + pointerCoords.x, + pointerCoords.y, + )); + } const lastPoint = points.length > 0 && points[points.length - 1]; const discardPoint =