From dfdf119f7f72c88baa841ef95fc607c7e84f9017 Mon Sep 17 00:00:00 2001 From: Drew Slobodnjak <60050885+drew08t@users.noreply.github.com> Date: Thu, 9 May 2024 14:38:43 -0700 Subject: [PATCH] Canvas: Improve connection vertex logic (#87580) Canvas: Prevent machine error causing logic swap --- .../components/connections/ConnectionSVG.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/public/app/plugins/panel/canvas/components/connections/ConnectionSVG.tsx b/public/app/plugins/panel/canvas/components/connections/ConnectionSVG.tsx index ddc32fe04dc..0850b62cd4f 100644 --- a/public/app/plugins/panel/canvas/components/connections/ConnectionSVG.tsx +++ b/public/app/plugins/panel/canvas/components/connections/ConnectionSVG.tsx @@ -272,10 +272,10 @@ export const ConnectionSVG = ({ } // Calculate arc control points const lDelta = lSegment - lHalfArc; - xa = lDelta * Math.cos(angle1) + x1; - ya = lDelta * Math.sin(angle1) + y1; - xb = lHalfArc * Math.cos(angle2) + X; - yb = lHalfArc * Math.sin(angle2) + Y; + xa = Math.round(lDelta * Math.cos(angle1) + x1); + ya = Math.round(lDelta * Math.sin(angle1) + y1); + xb = Math.round(lHalfArc * Math.cos(angle2) + X); + yb = Math.round(lHalfArc * Math.sin(angle2) + Y); // Check if arc control points are inside of segment, otherwise swap sign if ((xa > X && xa > x1) || (xa < X && xa < x1)) { @@ -321,10 +321,10 @@ export const ConnectionSVG = ({ // Calculate arc control points const lDelta = lSegment - lHalfArc; - xa = lDelta * Math.cos(angle1) + Xp; - ya = lDelta * Math.sin(angle1) + Yp; - xb = lHalfArc * Math.cos(angle2) + X; - yb = lHalfArc * Math.sin(angle2) + Y; + xa = Math.round(lDelta * Math.cos(angle1) + Xp); + ya = Math.round(lDelta * Math.sin(angle1) + Yp); + xb = Math.round(lHalfArc * Math.cos(angle2) + X); + yb = Math.round(lHalfArc * Math.sin(angle2) + Y); // Check if arc control points are inside of segment, otherwise swap sign if ((xa > X && xa > Xp) || (xa < X && xa < Xp)) {