Merge pull request #1763 from gavin-ts/fix-sketched-unfilled-triangle

Fix sketched unfilled triangle
This commit is contained in:
gavin-ts 2023-12-07 11:04:24 -08:00 committed by GitHub
commit 8d516665e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 145 additions and 2 deletions

View file

@ -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)

View file

@ -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 })`,

View file

@ -3,7 +3,6 @@ package d2sketch_test
import (
"context"
"encoding/xml"
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -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)
}
@ -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)

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 70 KiB