This commit is contained in:
Gavin Nishizawa 2023-05-25 16:37:41 -07:00
parent 78ee09f915
commit ee70180a87
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD
4 changed files with 10 additions and 9 deletions

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -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))
}