Merge pull request #685 from alixander/multiple-bounding

fix bounding box for multiple
This commit is contained in:
Alexander Wang 2023-01-19 13:01:19 -08:00 committed by GitHub
commit 5a727071ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 13 deletions

View file

@ -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)

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 388 KiB

After

Width:  |  Height:  |  Size: 388 KiB

View file

@ -42,8 +42,6 @@ const (
appendixIconRadius = 16
)
var multipleOffset = geo.NewVector(10, -10)
//go:embed tooltip.svg
var TooltipIcon string
@ -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 {

View file

@ -23,6 +23,7 @@ const (
MAX_ICON_SIZE = 64
THREE_DEE_OFFSET = 15
MULTIPLE_OFFSET = 10
)
type Diagram struct {
@ -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)

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 339 KiB

After

Width:  |  Height:  |  Size: 339 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 338 KiB

After

Width:  |  Height:  |  Size: 338 KiB