Skip to content

Commit

Permalink
Merge pull request #1763 from gavin-ts/fix-sketched-unfilled-triangle
Browse files Browse the repository at this point in the history
Fix sketched unfilled triangle
  • Loading branch information
gavin-ts authored Dec 7, 2023
2 parents 84a3ca0 + f46bc34 commit 8d51666
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 2 deletions.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
#### Bugfixes ⛑️

- Fix importing files that override an existing value with an array. [#1762](https://github.com/terrastruct/d2/pull/1762)
- Fixed missing unfilled triangle arrowheads when sketch flag is on. [#1763](https://github.com/terrastruct/d2/pull/1763)
8 changes: 8 additions & 0 deletions d2renderers/d2sketch/sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,14 @@ func ArrowheadJS(r *Runner, arrowhead d2target.Arrowhead, stroke string, strokeW
stroke,
stroke,
)
case d2target.UnfilledTriangleArrowhead:
arrowJS = fmt.Sprintf(
`node = rc.polygon(%s, { strokeWidth: %d, stroke: "%s", fill: "%s", fillStyle: "solid", seed: 2 })`,
`[[-10, -4], [0, 0], [-10, 4]]`,
strokeWidth,
stroke,
BG_COLOR,
)
case d2target.DiamondArrowhead:
arrowJS = fmt.Sprintf(
`node = rc.polygon(%s, { strokeWidth: %d, stroke: "%s", fill: "%s", fillStyle: "solid", seed: 1 })`,
Expand Down
23 changes: 21 additions & 2 deletions d2renderers/d2sketch/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package d2sketch_test
import (
"context"
"encoding/xml"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -1304,6 +1303,26 @@ a -> b: {
}
`,
},
{
name: "unfilled_triangle",
script: `
direction: right
A <-> B: default {
source-arrowhead.style.filled: false
target-arrowhead.style.filled: false
}
C <-> D: triangle {
source-arrowhead: {
shape: triangle
style.filled: false
}
target-arrowhead: {
shape: triangle
style.filled: false
}
}`,
},
}
runa(t, tcs)
}
Expand Down Expand Up @@ -1367,7 +1386,7 @@ func run(t *testing.T, tc testCase) {
assert.Success(t, err)
err = os.MkdirAll(dataPath, 0755)
assert.Success(t, err)
err = ioutil.WriteFile(pathGotSVG, svgBytes, 0600)
err = os.WriteFile(pathGotSVG, svgBytes, 0600)
assert.Success(t, err)
defer os.Remove(pathGotSVG)

Expand Down
Loading

0 comments on commit 8d51666

Please sign in to comment.