From b4518cdb03ba2cdbb4f8e039f804832193a1435d Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Tue, 14 Mar 2023 17:54:05 -0700 Subject: [PATCH] fix rounding hopefully --- d2layouts/d2elklayout/layout.go | 8 ++++---- .../TestCLI_E2E/internal_linked_pdf.exp.pdf | Bin 81564 -> 81564 bytes 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index b26579a82..0a8a426a7 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -478,7 +478,7 @@ func deleteBends(g *d2graph.Graph) { endpoint = e.Dst } - isHorizontal := math.Round(start.Y) == math.Round(corner.Y) + isHorizontal := math.Ceil(start.Y) == math.Ceil(corner.Y) // Make sure it's still attached if isHorizontal { @@ -575,7 +575,7 @@ func deleteBends(g *d2graph.Graph) { // These concern two segments var newCorner *geo.Point - if math.Round(start.X) == math.Round(corner.X) { + if math.Ceil(start.X) == math.Ceil(corner.X) { newCorner = geo.NewPoint(end.X, start.Y) // not ladder if (end.X > start.X) != (start.X > before.X) { @@ -663,7 +663,7 @@ func countObjectIntersects(g *d2graph.Graph, src, dst *d2graph.Object, s geo.Seg // countEdgeIntersects counts both crossings AND getting too close to a parallel segment func countEdgeIntersects(g *d2graph.Graph, sEdge *d2graph.Edge, s geo.Segment) (int, int, int, int) { - isHorizontal := math.Round(s.Start.Y) == math.Round(s.End.Y) + isHorizontal := math.Ceil(s.Start.Y) == math.Ceil(s.End.Y) crossingsCount := 0 overlapsCount := 0 closeOverlapsCount := 0 @@ -675,7 +675,7 @@ func countEdgeIntersects(g *d2graph.Graph, sEdge *d2graph.Edge, s geo.Segment) ( for i := 0; i < len(e.Route)-1; i++ { otherS := geo.NewSegment(e.Route[i], e.Route[i+1]) - otherIsHorizontal := math.Round(otherS.Start.Y) == math.Round(otherS.End.Y) + otherIsHorizontal := math.Ceil(otherS.Start.Y) == math.Ceil(otherS.End.Y) if isHorizontal == otherIsHorizontal { if s.Overlaps(*otherS, !isHorizontal, 0.) { if isHorizontal { diff --git a/e2etests-cli/testdata/TestCLI_E2E/internal_linked_pdf.exp.pdf b/e2etests-cli/testdata/TestCLI_E2E/internal_linked_pdf.exp.pdf index d3973b9eb9d84de96a73efc32c0ebc13a4265ad5..605b355cbd6405d9690eff06ba30e5e04cc60a4a 100644 GIT binary patch delta 50 zcmbR9mu1dhmWC~i3#}DQ4Gm2-x%7SWQ(O{DQWZ2@tc(ndj17zpO$^OJa@!ADGu~zb E0II7GQUCw| delta 50 zcmbR9mu1dhmWC~i3#}E5&5g}9x%7SWQ(O{DQWZ2@tc(ndj17zpO$>oD#^&1(S~K2e F0syQF4`KiS