diff --git a/d2exporter/export.go b/d2exporter/export.go index 418e71370..4aa15f976 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -129,6 +129,11 @@ func toShape(obj *d2graph.Object, theme *d2themes.Theme) d2target.Shape { shape.Color = text.GetColor(theme, shape.Italic) applyStyles(shape, obj) + if obj.IsSequenceDiagramGroup() { + shape.StrokeWidth = 0 + shape.Blend = true + } + switch obj.Attributes.Shape.Value { case d2target.ShapeCode, d2target.ShapeText: shape.Language = obj.Attributes.Language @@ -147,6 +152,9 @@ func toShape(obj *d2graph.Object, theme *d2themes.Theme) d2target.Shape { shape.LabelHeight = text.Dimensions.Height if obj.LabelPosition != nil { shape.LabelPosition = *obj.LabelPosition + if obj.IsSequenceDiagramGroup() { + shape.LabelFill = shape.Fill + } } shape.Tooltip = obj.Attributes.Tooltip @@ -163,7 +171,6 @@ func toConnection(edge *d2graph.Edge, theme *d2themes.Theme) d2target.Connection connection := d2target.BaseConnection() connection.ID = edge.AbsID() connection.ZIndex = edge.ZIndex - // edge.Edge.ID = go2.StringToIntHash(connection.ID) text := edge.Text() if edge.SrcArrow { diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 546ec2740..c3faf9f23 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -986,9 +986,20 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske fontColor = targetShape.Color } textStyle := fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "middle", targetShape.FontSize, fontColor) + x := labelTL.X + float64(targetShape.LabelWidth)/2. // text is vertically positioned at its baseline which is at labelTL+FontSize y := labelTL.Y + float64(targetShape.FontSize) + + // background does not exist for , so draw a rectangle behind it + if targetShape.LabelFill != "" { + fmt.Fprintf(writer, ``, + labelTL.X, labelTL.Y, + targetShape.LabelWidth, targetShape.LabelHeight, + targetShape.LabelFill, + ) + } + fmt.Fprintf(writer, `%s`, fontClass, x, y, diff --git a/d2target/d2target.go b/d2target/d2target.go index b5325d07e..a9647f8e8 100644 --- a/d2target/d2target.go +++ b/d2target/d2target.go @@ -236,8 +236,9 @@ type Text struct { Bold bool `json:"bold"` Underline bool `json:"underline"` - LabelWidth int `json:"labelWidth"` - LabelHeight int `json:"labelHeight"` + LabelWidth int `json:"labelWidth"` + LabelHeight int `json:"labelHeight"` + LabelFill string `json:"labelFill,omitempty"` } func BaseShape() *Shape {