Skip to content

Commit

Permalink
Merge pull request #1940 from alixander/opacity-label-mask
Browse files Browse the repository at this point in the history
renderer: dont render label & icon unnecessarily with opacity 0
  • Loading branch information
alixander committed May 15, 2024
2 parents 7269d30 + 4274f10 commit d791085
Show file tree
Hide file tree
Showing 7 changed files with 1,224 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#### Improvements 🧹

- Opacity 0 shapes no longer have a label mask which made any segment of connections going through them lower opacity [#1940](https://github.com/terrastruct/d2/pull/1940)

#### Bugfixes ⛑️

- Local relative icons are relative to the d2 file instead of CLI invoke path [#1924](https://github.com/terrastruct/d2/pull/1924)
Expand Down
4 changes: 2 additions & 2 deletions d2renderers/d2svg/d2svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ func drawShape(writer, appendixWriter io.Writer, diagramHash string, targetShape
// Closes the class=shape
fmt.Fprint(writer, `</g>`)

if targetShape.Icon != nil && targetShape.Type != d2target.ShapeImage {
if targetShape.Icon != nil && targetShape.Type != d2target.ShapeImage && targetShape.Opacity != 0 {
iconPosition := label.FromString(targetShape.IconPosition)
var box *geo.Box
if iconPosition.IsOutside() {
Expand All @@ -1234,7 +1234,7 @@ func drawShape(writer, appendixWriter io.Writer, diagramHash string, targetShape
)
}

if targetShape.Label != "" {
if targetShape.Label != "" && targetShape.Opacity != 0 {
labelPosition := label.FromString(targetShape.LabelPosition)
var box *geo.Box
if labelPosition.IsOutside() {
Expand Down
18 changes: 18 additions & 0 deletions e2etests/testdata/txtar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,21 @@ ok: {
}
dog1 -> dog3
}

-- opacity-zero-route --
grid: {
*.style.opacity: 0
grid-columns: 3
a
b
c
d
e
f
g
h

d.style.opacity: 1
}

out -> grid.d

0 comments on commit d791085

Please sign in to comment.