diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 9dda6efa4..63c239108 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -17,6 +17,7 @@ - Fixes attributes being ignored for `sql_table` to `sql_table` connections. [#658](https://github.com/terrastruct/d2/pull/658) - Fixes tooltip/link attributes being ignored for `sql_table` and `class`. [#658](https://github.com/terrastruct/d2/pull/658) - Fixes arrowheads sometimes appearing broken with sketch on. [#656](https://github.com/terrastruct/d2/pull/656) +- Bounding box was not account for 3d offsets, which made them look cut off with 0 padding. [#684](https://github.com/terrastruct/d2/pull/684) - Fixes code snippets not being tall enough with leading newlines. [#664](https://github.com/terrastruct/d2/pull/664) - Opacity was not being applied to labels of shapes (and other edge cases). [#677](https://github.com/terrastruct/d2/pull/677) - Icon URLs that needed escaping (e.g. with ampersands) are handled correctly by CLI. [#666](https://github.com/terrastruct/d2/pull/666) diff --git a/d2target/d2target.go b/d2target/d2target.go index bf0d90c0e..a95324d91 100644 --- a/d2target/d2target.go +++ b/d2target/d2target.go @@ -69,6 +69,11 @@ func (diagram Diagram) BoundingBox() (topLeft, bottomRight Point) { x2 = go2.Max(x2, targetShape.Pos.X+targetShape.StrokeWidth+targetShape.Width+16) } + if targetShape.ThreeDee { + y1 = go2.Min(y1, targetShape.Pos.Y-THREE_DEE_OFFSET-targetShape.StrokeWidth) + x2 = go2.Max(x2, targetShape.Pos.X+THREE_DEE_OFFSET+targetShape.Width+targetShape.StrokeWidth) + } + if targetShape.Label != "" { labelPosition := label.Position(targetShape.LabelPosition) if !labelPosition.IsOutside() { @@ -90,11 +95,6 @@ func (diagram Diagram) BoundingBox() (topLeft, bottomRight Point) { x2 = go2.Max(x2, int(labelTL.X)+targetShape.LabelWidth) y2 = go2.Max(y2, int(labelTL.Y)+targetShape.LabelHeight) } - - if targetShape.ThreeDee { - y1 = go2.Min(y1, targetShape.Pos.Y-THREE_DEE_OFFSET-targetShape.StrokeWidth) - x2 = go2.Max(x2, targetShape.Pos.X+THREE_DEE_OFFSET+targetShape.Width+targetShape.StrokeWidth) - } } for _, connection := range diagram.Connections { diff --git a/e2etests/testdata/stable/square_3d/dagre/sketch.exp.svg b/e2etests/testdata/stable/square_3d/dagre/sketch.exp.svg index 166969dbe..b80e43dda 100644 --- a/e2etests/testdata/stable/square_3d/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/square_3d/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="375" height="584" viewBox="-102 -102 375 584">