Skip to content

Commit

Permalink
Merge pull request #1326 from LeonardsonCC/master
Browse files Browse the repository at this point in the history
fix: shadow cut when 0 padding
  • Loading branch information
gavin-ts authored May 16, 2023
2 parents 266e8ee + 36373c3 commit 0121efe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
- Improves grid layout performance when there are many similarly sized shapes. [#1315](https://github.com/terrastruct/d2/pull/1315)

#### Bugfixes ⛑️

- Shadow is cut off when `--pad` is 0 [#1326](https://github.com/terrastruct/d2/pull/1326)
6 changes: 6 additions & 0 deletions d2target/d2target.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (
DEFAULT_ICON_SIZE = 32
MAX_ICON_SIZE = 64

SHADOW_SIZE_X = 3
SHADOW_SIZE_Y = 5
THREE_DEE_OFFSET = 15
MULTIPLE_OFFSET = 10

Expand Down Expand Up @@ -171,6 +173,10 @@ func (diagram Diagram) BoundingBox() (topLeft, bottomRight Point) {
y1 = go2.Min(y1, targetShape.Pos.Y-targetShape.StrokeWidth-16)
x2 = go2.Max(x2, targetShape.Pos.X+targetShape.StrokeWidth+targetShape.Width+16)
}
if targetShape.Shadow {
y2 = go2.Max(y2, targetShape.Pos.Y+targetShape.Height+int(math.Ceil(float64(targetShape.StrokeWidth)/2.))+SHADOW_SIZE_Y)
x2 = go2.Max(x2, targetShape.Pos.X+targetShape.Width+int(math.Ceil(float64(targetShape.StrokeWidth)/2.))+SHADOW_SIZE_X)
}

if targetShape.ThreeDee {
y1 = go2.Min(y1, targetShape.Pos.Y-THREE_DEE_OFFSET-targetShape.StrokeWidth)
Expand Down
Loading

0 comments on commit 0121efe

Please sign in to comment.