Skip to content

Commit

Permalink
Merge pull request #2326 from alixander/fix-connection-gradient
Browse files Browse the repository at this point in the history
d2svg: parse connection label fill gradients
  • Loading branch information
alixander authored Feb 3, 2025
2 parents 7b140e7 + 5978587 commit 5778bb9
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 180 deletions.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
- Globs: fixes edge case where globs with imported boards would create empty boards [#2247](https://github.com/terrastruct/d2/pull/2247)
- Sequence diagrams: fixes alignment of notes when self messages are above it [#2264](https://github.com/terrastruct/d2/pull/2264)
- Null: fixes `null`ing a connection with absolute syntax [#2318](https://github.com/terrastruct/d2/issues/2318)
- Gradients: works with connection fills [#2326](https://github.com/terrastruct/d2/pull/2326)
3 changes: 3 additions & 0 deletions d2renderers/d2svg/d2svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,9 @@ func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error) {
if color.IsGradient(c.Stroke) {
defineGradients(buf, c.Stroke)
}
if color.IsGradient(c.Fill) {
defineGradients(buf, c.Fill)
}
}

// Apply hash on IDs for targeting, to be specific for this diagram
Expand Down
23 changes: 12 additions & 11 deletions e2etests/testdata/txtar/gradient/dagre/board.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

171 changes: 91 additions & 80 deletions e2etests/testdata/txtar/gradient/dagre/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.
17 changes: 9 additions & 8 deletions e2etests/testdata/txtar/gradient/elk/board.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

171 changes: 91 additions & 80 deletions e2etests/testdata/txtar/gradient/elk/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.
2 changes: 1 addition & 1 deletion e2etests/txtar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ colors: {
style.stroke: "linear-gradient(to right, red, blue, green)"
style.font-color: "linear-gradient(to bottom right, red 0%, yellow 25%, green 50%, cyan 75%, blue 100%)"
}
gradient -> colors
gradient -> colors: foobar {style.font-color: red; style.stroke: red; style.fill: "radial-gradient(#ffffff, #000000)"}

-- var_in_markdown --
vars: {
Expand Down

0 comments on commit 5778bb9

Please sign in to comment.