fix bounding boxes
This commit is contained in:
parent
642df43d34
commit
510c10227e
3 changed files with 14 additions and 7 deletions
|
|
@ -8,8 +8,8 @@ This release also gives more power to configure layouts. `width` and `height` ar
|
|||
|
||||
#### Features 🚀
|
||||
|
||||
- Tooltips can be set on shapes. See [https://d2lang.com/tour/tooltips](https://d2lang.com/tour/interactive). [#548](https://github.com/terrastruct/d2/pull/548)
|
||||
- Links can be set on shapes. See [https://d2lang.com/tour/tooltips](https://d2lang.com/tour/interactive). [#548](https://github.com/terrastruct/d2/pull/548)
|
||||
- Tooltips can be set on shapes. See [https://d2lang.com/tour/interactive](https://d2lang.com/tour/interactive). [#548](https://github.com/terrastruct/d2/pull/548)
|
||||
- Links can be set on shapes. See [https://d2lang.com/tour/interactive](https://d2lang.com/tour/interactive). [#548](https://github.com/terrastruct/d2/pull/548)
|
||||
- The `width` and `height` attributes are no longer restricted to images and can be applied to non-container shapes. [#498](https://github.com/terrastruct/d2/pull/498)
|
||||
- Layout engine options are exposed and configurable. See individual layout pages on [https://d2lang.com/tour/layouts](https://d2lang.com/tour/layouts) for list of configurations. [#563](https://github.com/terrastruct/d2/pull/563)
|
||||
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ func generateAppendix(diagram *d2target.Diagram, ruler *textmeasure.Ruler, svg s
|
|||
}
|
||||
}
|
||||
}
|
||||
totalHeight += SPACER
|
||||
|
||||
return fmt.Sprintf(`<g x="%d" y="%d" width="%d" height="100%%">%s</g>
|
||||
`, tl.X, br.Y, (br.X - tl.X), strings.Join(lines, "\n")), maxWidth, totalHeight
|
||||
|
|
@ -182,5 +183,5 @@ func generateLine(i, y int, text string, ruler *textmeasure.Ruler) (string, int,
|
|||
line += fmt.Sprintf(`<text class="text" x="%d" y="%d" style="font-size: %dpx;">%s</text>`,
|
||||
ICON_RADIUS*3, y, FONT_SIZE, d2svg.RenderText(text, ICON_RADIUS*3, float64(dims.Height)))
|
||||
|
||||
return line, dims.Width + ICON_RADIUS*3, dims.Height
|
||||
return line, dims.Width + ICON_RADIUS*3, go2.IntMax(dims.Height, ICON_RADIUS*2)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,10 +55,16 @@ func (diagram Diagram) BoundingBox() (topLeft, bottomRight Point) {
|
|||
y2 := int(math.MinInt32)
|
||||
|
||||
for _, targetShape := range diagram.Shapes {
|
||||
x1 = go2.Min(x1, targetShape.Pos.X)
|
||||
y1 = go2.Min(y1, targetShape.Pos.Y)
|
||||
x2 = go2.Max(x2, targetShape.Pos.X+targetShape.Width)
|
||||
y2 = go2.Max(y2, targetShape.Pos.Y+targetShape.Height)
|
||||
x1 = go2.Min(x1, targetShape.Pos.X-targetShape.StrokeWidth)
|
||||
y1 = go2.Min(y1, targetShape.Pos.Y-targetShape.StrokeWidth)
|
||||
x2 = go2.Max(x2, targetShape.Pos.X+targetShape.Width+targetShape.StrokeWidth)
|
||||
y2 = go2.Max(y2, targetShape.Pos.Y+targetShape.Height+targetShape.StrokeWidth)
|
||||
|
||||
if targetShape.Tooltip != "" || targetShape.Link != "" {
|
||||
// 16 is the icon radius
|
||||
y1 = go2.Min(y1, targetShape.Pos.Y-targetShape.StrokeWidth-16)
|
||||
x2 = go2.Max(x2, targetShape.Pos.X+targetShape.StrokeWidth+targetShape.Width+16)
|
||||
}
|
||||
|
||||
if targetShape.Label != "" {
|
||||
labelPosition := label.Position(targetShape.LabelPosition)
|
||||
|
|
|
|||
Loading…
Reference in a new issue