Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bounding box for multiple #685

Merged
merged 3 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +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)
- Bounding box was not accounting for dimensions added by `multiple` and `3d` keywords, which made them look cut off with 0 padding. [#684](https://github.com/terrastruct/d2/pull/684), [#685](https://github.com/terrastruct/d2/pull/685)
- 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)
Expand Down
6 changes: 3 additions & 3 deletions d2renderers/d2sketch/testdata/twitter/sketch.exp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions d2renderers/d2svg/d2svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ const (
appendixIconRadius = 16
)

var multipleOffset = geo.NewVector(10, -10)

//go:embed tooltip.svg
var TooltipIcon string

Expand Down Expand Up @@ -689,7 +687,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske

var multipleTL *geo.Point
if targetShape.Multiple {
multipleTL = tl.AddVector(multipleOffset)
multipleTL = tl.AddVector(geo.NewVector(d2target.MULTIPLE_OFFSET, -d2target.MULTIPLE_OFFSET))
}

switch targetShape.Type {
Expand Down
5 changes: 5 additions & 0 deletions d2target/d2target.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
MAX_ICON_SIZE = 64

THREE_DEE_OFFSET = 15
MULTIPLE_OFFSET = 10
)

type Diagram struct {
Expand Down Expand Up @@ -73,6 +74,10 @@ func (diagram Diagram) BoundingBox() (topLeft, bottomRight Point) {
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.Multiple {
y1 = go2.Min(y1, targetShape.Pos.Y-MULTIPLE_OFFSET-targetShape.StrokeWidth)
x2 = go2.Max(x2, targetShape.Pos.X+MULTIPLE_OFFSET+targetShape.Width+targetShape.StrokeWidth)
}

if targetShape.Label != "" {
labelPosition := label.Position(targetShape.LabelPosition)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.