constants
This commit is contained in:
parent
909f9fc6c9
commit
918ad5d96e
2 changed files with 6 additions and 7 deletions
|
|
@ -1,7 +1,7 @@
|
|||
package d2sequence
|
||||
|
||||
// min horizontal pad for actors, or edge labels, to consider the min distance between them
|
||||
const MIN_HORIZONTAL_PAD = 50.
|
||||
// leaves at least 25 units of space on the left/right when computing the space required between actors
|
||||
const HORIZONTAL_PAD = 50.
|
||||
|
||||
const MIN_ACTOR_DISTANCE = 200.
|
||||
|
||||
|
|
|
|||
|
|
@ -12,16 +12,15 @@ import (
|
|||
)
|
||||
|
||||
func Layout(ctx context.Context, g *d2graph.Graph) (err error) {
|
||||
pad := MIN_HORIZONTAL_PAD
|
||||
edgeYStep := MIN_EDGE_DISTANCE
|
||||
actorXStep := MIN_ACTOR_DISTANCE
|
||||
maxActorHeight := 0.
|
||||
|
||||
for _, edge := range g.Edges {
|
||||
edgeYStep = math.Max(edgeYStep, float64(edge.LabelDimensions.Height)+pad)
|
||||
actorXStep = math.Max(actorXStep, float64(edge.LabelDimensions.Width)+pad)
|
||||
maxActorHeight = math.Max(maxActorHeight, edge.Src.Height+pad)
|
||||
maxActorHeight = math.Max(maxActorHeight, edge.Dst.Height+pad)
|
||||
edgeYStep = math.Max(edgeYStep, float64(edge.LabelDimensions.Height)+HORIZONTAL_PAD)
|
||||
actorXStep = math.Max(actorXStep, float64(edge.LabelDimensions.Width)+HORIZONTAL_PAD)
|
||||
maxActorHeight = math.Max(maxActorHeight, edge.Src.Height+HORIZONTAL_PAD)
|
||||
maxActorHeight = math.Max(maxActorHeight, edge.Dst.Height+HORIZONTAL_PAD)
|
||||
}
|
||||
|
||||
placeActors(g.Objects, maxActorHeight, actorXStep)
|
||||
|
|
|
|||
Loading…
Reference in a new issue