diff --git a/d2exporter/export.go b/d2exporter/export.go index eb163b1dc..ed746b867 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -296,7 +296,7 @@ func toConnection(edge *d2graph.Edge, theme *d2themes.Theme) d2target.Connection connection.LabelPosition = *edge.LabelPosition } if edge.LabelPercentage != nil { - connection.LabelPercentage = *edge.LabelPercentage + connection.LabelPercentage = float64(float32(*edge.LabelPercentage)) } connection.Route = make([]*geo.Point, 0, len(edge.Route)) for i := range edge.Route { diff --git a/d2layouts/d2dagrelayout/layout.go b/d2layouts/d2dagrelayout/layout.go index aa0e95156..e66a09de5 100644 --- a/d2layouts/d2dagrelayout/layout.go +++ b/d2layouts/d2dagrelayout/layout.go @@ -244,8 +244,8 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err // dagre gives center of node obj.TopLeft = geo.NewPoint(math.Round(dn.X-dn.Width/2), math.Round(dn.Y-dn.Height/2)) - obj.Width = dn.Width - obj.Height = dn.Height + obj.Width = math.Ceil(dn.Width) + obj.Height = math.Ceil(dn.Height) if obj.HasLabel() { if len(obj.ChildrenArray) > 0 { @@ -501,7 +501,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err if start.X > edge.Src.TopLeft.X+d2target.THREE_DEE_OFFSET && start.Y < edge.Src.TopLeft.Y+edge.Src.Height-float64(offsetY) { edge.Src.TopLeft.X += d2target.THREE_DEE_OFFSET - edge.Src.TopLeft.Y -= d2target.THREE_DEE_OFFSET + edge.Src.TopLeft.Y -= float64(offsetY) } } else if edge.Src.IsMultiple() { // if the edge is on the multiple part, use the multiple's box for tracing to border @@ -519,7 +519,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err if end.X > edge.Dst.TopLeft.X+d2target.THREE_DEE_OFFSET && end.Y < edge.Dst.TopLeft.Y+edge.Dst.Height-float64(offsetY) { edge.Dst.TopLeft.X += d2target.THREE_DEE_OFFSET - edge.Dst.TopLeft.Y -= d2target.THREE_DEE_OFFSET + edge.Dst.TopLeft.Y -= float64(offsetY) } } else if edge.Dst.IsMultiple() { // if the edge is on the multiple part, use the multiple's box for tracing to border diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index e45165a3e..3cd8121bc 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -412,8 +412,8 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err parentY = parent.TopLeft.Y } obj.TopLeft = geo.NewPoint(parentX+n.X, parentY+n.Y) - obj.Width = n.Width - obj.Height = n.Height + obj.Width = math.Ceil(n.Width) + obj.Height = math.Ceil(n.Height) if obj.HasLabel() { if len(obj.ChildrenArray) > 0 { @@ -512,7 +512,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err if start.X > edge.Src.TopLeft.X+d2target.THREE_DEE_OFFSET && start.Y < edge.Src.TopLeft.Y+edge.Src.Height-float64(offsetY) { edge.Src.TopLeft.X += d2target.THREE_DEE_OFFSET - edge.Src.TopLeft.Y -= d2target.THREE_DEE_OFFSET + edge.Src.TopLeft.Y -= float64(offsetY) } } else if edge.Src.IsMultiple() { // if the edge is on the multiple part, use the multiple's box for tracing to border @@ -530,7 +530,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err if end.X > edge.Dst.TopLeft.X+d2target.THREE_DEE_OFFSET && end.Y < edge.Dst.TopLeft.Y+edge.Dst.Height-float64(offsetY) { edge.Dst.TopLeft.X += d2target.THREE_DEE_OFFSET - edge.Dst.TopLeft.Y -= d2target.THREE_DEE_OFFSET + edge.Dst.TopLeft.Y -= float64(offsetY) } } else if edge.Dst.IsMultiple() { // if the edge is on the multiple part, use the multiple's box for tracing to border diff --git a/lib/shape/shape.go b/lib/shape/shape.go index 2eb83cd21..29bbdc36e 100644 --- a/lib/shape/shape.go +++ b/lib/shape/shape.go @@ -218,6 +218,7 @@ func TraceToShapeBorder(shape Shape, rectBorderPoint, prevPoint *geo.Point) *geo } } + closestPoint.TruncateFloat32() return geo.NewPoint(math.Round(closestPoint.X), math.Round(closestPoint.Y)) }