reduce roughness of sketch connections
|
|
@ -4,6 +4,7 @@
|
|||
#### Improvements 🧹
|
||||
|
||||
- `dagre` layouts that have a connection where one endpoint is a container is much improved. [#1011](https://github.com/terrastruct/d2/pull/1011)
|
||||
- `sketch` draws connections with less roughness, which especially improves look of corner bends in ELK. [#1014](https://github.com/terrastruct/d2/pull/1014)
|
||||
|
||||
#### Bugfixes ⛑️
|
||||
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ func Paths(r *Runner, shape d2target.Shape, paths []string) (string, error) {
|
|||
}
|
||||
|
||||
func Connection(r *Runner, connection d2target.Connection, path, attrs string) (string, error) {
|
||||
roughness := 1.0
|
||||
roughness := 0.5
|
||||
js := fmt.Sprintf(`node = rc.path("%s", {roughness: %f, seed: 1});`, path, roughness)
|
||||
paths, err := computeRoughPathData(r, js)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2layouts/d2dagrelayout"
|
||||
"oss.terrastruct.com/d2/d2layouts/d2elklayout"
|
||||
"oss.terrastruct.com/d2/d2lib"
|
||||
"oss.terrastruct.com/d2/d2renderers/d2fonts"
|
||||
"oss.terrastruct.com/d2/d2renderers/d2svg"
|
||||
|
|
@ -39,6 +40,15 @@ func TestSketch(t *testing.T) {
|
|||
script: `winter.snow -> summer.sun
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "elk corners",
|
||||
engine: "elk",
|
||||
script: `a -> b
|
||||
b -> c
|
||||
a -> c
|
||||
c -> a
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "animated",
|
||||
script: `winter.snow -> summer.sun -> trees -> winter.snow: { style.animated: true }
|
||||
|
|
@ -1015,7 +1025,7 @@ something
|
|||
|
||||
json: jsonb {constraint: unique}
|
||||
last_updated: timestamp with time zone
|
||||
|
||||
|
||||
style: {
|
||||
fill: red
|
||||
border-radius: 0
|
||||
|
|
@ -1027,7 +1037,7 @@ something
|
|||
|
||||
field: "[]string"
|
||||
method(a uint64): (x, y int)
|
||||
|
||||
|
||||
style: {
|
||||
border-radius: 0
|
||||
}
|
||||
|
|
@ -1057,6 +1067,7 @@ type testCase struct {
|
|||
themeID int64
|
||||
script string
|
||||
skip bool
|
||||
engine string
|
||||
}
|
||||
|
||||
func runa(t *testing.T, tcs []testCase) {
|
||||
|
|
@ -1083,9 +1094,13 @@ func run(t *testing.T, tc testCase) {
|
|||
return
|
||||
}
|
||||
|
||||
layout := d2dagrelayout.DefaultLayout
|
||||
if strings.EqualFold(tc.engine, "elk") {
|
||||
layout = d2elklayout.DefaultLayout
|
||||
}
|
||||
diagram, _, err := d2lib.Compile(ctx, tc.script, &d2lib.CompileOptions{
|
||||
Ruler: ruler,
|
||||
Layout: d2dagrelayout.DefaultLayout,
|
||||
Layout: layout,
|
||||
FontFamily: go2.Pointer(d2fonts.HandDrawn),
|
||||
})
|
||||
if !tassert.Nil(t, err) {
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 298 KiB After Width: | Height: | Size: 298 KiB |
|
Before Width: | Height: | Size: 288 KiB After Width: | Height: | Size: 288 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 284 KiB |
|
Before Width: | Height: | Size: 275 KiB After Width: | Height: | Size: 275 KiB |
|
Before Width: | Height: | Size: 334 KiB After Width: | Height: | Size: 334 KiB |
|
Before Width: | Height: | Size: 325 KiB After Width: | Height: | Size: 325 KiB |
|
Before Width: | Height: | Size: 227 KiB After Width: | Height: | Size: 227 KiB |
|
Before Width: | Height: | Size: 218 KiB After Width: | Height: | Size: 218 KiB |
|
Before Width: | Height: | Size: 279 KiB After Width: | Height: | Size: 279 KiB |
|
Before Width: | Height: | Size: 270 KiB After Width: | Height: | Size: 270 KiB |
|
Before Width: | Height: | Size: 276 KiB After Width: | Height: | Size: 276 KiB |
|
Before Width: | Height: | Size: 267 KiB After Width: | Height: | Size: 267 KiB |
|
Before Width: | Height: | Size: 332 KiB After Width: | Height: | Size: 332 KiB |
|
Before Width: | Height: | Size: 323 KiB After Width: | Height: | Size: 323 KiB |
31
d2renderers/d2sketch/testdata/elk_corners/sketch.exp.svg
vendored
Normal file
|
After Width: | Height: | Size: 233 KiB |
|
Before Width: | Height: | Size: 340 KiB After Width: | Height: | Size: 340 KiB |
|
Before Width: | Height: | Size: 331 KiB After Width: | Height: | Size: 331 KiB |
|
Before Width: | Height: | Size: 306 KiB After Width: | Height: | Size: 306 KiB |
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 418 KiB After Width: | Height: | Size: 418 KiB |
|
Before Width: | Height: | Size: 418 KiB After Width: | Height: | Size: 418 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |