fix sequence diagram actor shape scaling

This commit is contained in:
Gavin Nishizawa 2023-01-23 20:39:57 -08:00
parent 162227e196
commit b2036e8bdf
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD

View file

@ -105,6 +105,12 @@ func newSequenceDiagram(objects []*d2graph.Object, messages []*d2graph.Edge) *se
sd.objectRank[actor] = rank sd.objectRank[actor] = rank
if actor.Width < MIN_ACTOR_WIDTH { if actor.Width < MIN_ACTOR_WIDTH {
dslShape := strings.ToLower(actor.Attributes.Shape.Value)
switch dslShape {
case d2target.ShapePerson, d2target.ShapeSquare, d2target.ShapeCircle:
// scale shape up to min width uniformly
actor.Height *= MIN_ACTOR_WIDTH / actor.Width
}
actor.Width = MIN_ACTOR_WIDTH actor.Width = MIN_ACTOR_WIDTH
} }
sd.maxActorHeight = math.Max(sd.maxActorHeight, actor.Height) sd.maxActorHeight = math.Max(sd.maxActorHeight, actor.Height)