Skip to content

Commit

Permalink
dont render unnecessarily with opacity 0
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed May 15, 2024
1 parent 7269d30 commit 9f5c454
Show file tree
Hide file tree
Showing 6 changed files with 1,222 additions and 2 deletions.
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
Loading

0 comments on commit 9f5c454

Please sign in to comment.