updated sketch test, fixed improper arrowhead rendering, made markdown background transparent
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -329,23 +330,27 @@ a.9 <-> b.9: cf-one-required {
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "bright_overlay",
|
name: "overlay",
|
||||||
script: `a.style.fill = "#fff"
|
script: `bright: {
|
||||||
`,
|
style.stroke: "#000"
|
||||||
},
|
style.font-color: "#000"
|
||||||
{
|
style.fill: "#fff"
|
||||||
name: "normal_overlay",
|
}
|
||||||
script: `a.style.fill = "#ccc"
|
normal: {
|
||||||
`,
|
style.stroke: "#000"
|
||||||
},
|
style.font-color: "#000"
|
||||||
{
|
style.fill: "#ccc"
|
||||||
name: "dark_overlay",
|
}
|
||||||
script: `a.style.fill = "#555"
|
dark: {
|
||||||
`,
|
style.stroke: "#000"
|
||||||
},
|
style.font-color: "#fff"
|
||||||
{
|
style.fill: "#555"
|
||||||
name: "darker_overlay",
|
}
|
||||||
script: `a.style.fill = "#000"
|
darker: {
|
||||||
|
style.stroke: "#000"
|
||||||
|
style.font-color: "#fff"
|
||||||
|
style.fill: "#000"
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -398,6 +403,7 @@ func run(t *testing.T, tc testCase) {
|
||||||
Pad: d2svg.DEFAULT_PADDING,
|
Pad: d2svg.DEFAULT_PADDING,
|
||||||
Sketch: true,
|
Sketch: true,
|
||||||
ThemeID: 0,
|
ThemeID: 0,
|
||||||
|
DarkThemeID: math.MaxInt64,
|
||||||
})
|
})
|
||||||
assert.Success(t, err)
|
assert.Success(t, err)
|
||||||
err = os.MkdirAll(dataPath, 0755)
|
err = os.MkdirAll(dataPath, 0755)
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 272 KiB After Width: | Height: | Size: 303 KiB |
|
Before Width: | Height: | Size: 253 KiB After Width: | Height: | Size: 285 KiB |
|
Before Width: | Height: | Size: 304 KiB After Width: | Height: | Size: 336 KiB |
|
Before Width: | Height: | Size: 196 KiB After Width: | Height: | Size: 228 KiB |
|
Before Width: | Height: | Size: 248 KiB After Width: | Height: | Size: 280 KiB |
|
Before Width: | Height: | Size: 196 KiB After Width: | Height: | Size: 227 KiB |
136
d2renderers/d2sketch/testdata/connection_label/board.exp.json
generated
vendored
|
|
@ -1,136 +0,0 @@
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"fontFamily": "HandDrawn",
|
|
||||||
"shapes": [
|
|
||||||
{
|
|
||||||
"id": "a",
|
|
||||||
"type": "",
|
|
||||||
"pos": {
|
|
||||||
"x": 1,
|
|
||||||
"y": 0
|
|
||||||
},
|
|
||||||
"width": 114,
|
|
||||||
"height": 126,
|
|
||||||
"opacity": 1,
|
|
||||||
"strokeDash": 0,
|
|
||||||
"strokeWidth": 2,
|
|
||||||
"borderRadius": 0,
|
|
||||||
"fill": "#F7F8FE",
|
|
||||||
"stroke": "#0D32B2",
|
|
||||||
"shadow": false,
|
|
||||||
"3d": false,
|
|
||||||
"multiple": false,
|
|
||||||
"tooltip": "",
|
|
||||||
"link": "",
|
|
||||||
"icon": null,
|
|
||||||
"iconPosition": "",
|
|
||||||
"blend": false,
|
|
||||||
"fields": null,
|
|
||||||
"methods": null,
|
|
||||||
"columns": null,
|
|
||||||
"label": "a",
|
|
||||||
"fontSize": 16,
|
|
||||||
"fontFamily": "DEFAULT",
|
|
||||||
"language": "",
|
|
||||||
"color": "#0A0F25",
|
|
||||||
"italic": false,
|
|
||||||
"bold": true,
|
|
||||||
"underline": false,
|
|
||||||
"labelWidth": 14,
|
|
||||||
"labelHeight": 26,
|
|
||||||
"labelPosition": "INSIDE_MIDDLE_CENTER",
|
|
||||||
"zIndex": 0,
|
|
||||||
"level": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "b",
|
|
||||||
"type": "",
|
|
||||||
"pos": {
|
|
||||||
"x": 0,
|
|
||||||
"y": 226
|
|
||||||
},
|
|
||||||
"width": 115,
|
|
||||||
"height": 126,
|
|
||||||
"opacity": 1,
|
|
||||||
"strokeDash": 0,
|
|
||||||
"strokeWidth": 2,
|
|
||||||
"borderRadius": 0,
|
|
||||||
"fill": "#F7F8FE",
|
|
||||||
"stroke": "#0D32B2",
|
|
||||||
"shadow": false,
|
|
||||||
"3d": false,
|
|
||||||
"multiple": false,
|
|
||||||
"tooltip": "",
|
|
||||||
"link": "",
|
|
||||||
"icon": null,
|
|
||||||
"iconPosition": "",
|
|
||||||
"blend": false,
|
|
||||||
"fields": null,
|
|
||||||
"methods": null,
|
|
||||||
"columns": null,
|
|
||||||
"label": "b",
|
|
||||||
"fontSize": 16,
|
|
||||||
"fontFamily": "DEFAULT",
|
|
||||||
"language": "",
|
|
||||||
"color": "#0A0F25",
|
|
||||||
"italic": false,
|
|
||||||
"bold": true,
|
|
||||||
"underline": false,
|
|
||||||
"labelWidth": 15,
|
|
||||||
"labelHeight": 26,
|
|
||||||
"labelPosition": "INSIDE_MIDDLE_CENTER",
|
|
||||||
"zIndex": 0,
|
|
||||||
"level": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"connections": [
|
|
||||||
{
|
|
||||||
"id": "(a -> b)[0]",
|
|
||||||
"src": "a",
|
|
||||||
"srcArrow": "none",
|
|
||||||
"srcLabel": "",
|
|
||||||
"dst": "b",
|
|
||||||
"dstArrow": "triangle",
|
|
||||||
"dstLabel": "",
|
|
||||||
"opacity": 1,
|
|
||||||
"strokeDash": 0,
|
|
||||||
"strokeWidth": 2,
|
|
||||||
"stroke": "#0D32B2",
|
|
||||||
"label": "hello",
|
|
||||||
"fontSize": 16,
|
|
||||||
"fontFamily": "DEFAULT",
|
|
||||||
"language": "",
|
|
||||||
"color": "#676C7E",
|
|
||||||
"italic": true,
|
|
||||||
"bold": false,
|
|
||||||
"underline": false,
|
|
||||||
"labelWidth": 31,
|
|
||||||
"labelHeight": 23,
|
|
||||||
"labelPosition": "INSIDE_MIDDLE_CENTER",
|
|
||||||
"labelPercentage": 0,
|
|
||||||
"route": [
|
|
||||||
{
|
|
||||||
"x": 57.5,
|
|
||||||
"y": 126
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"x": 57.5,
|
|
||||||
"y": 166
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"x": 57.5,
|
|
||||||
"y": 186
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"x": 57.5,
|
|
||||||
"y": 226
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"isCurve": true,
|
|
||||||
"animated": false,
|
|
||||||
"tooltip": "",
|
|
||||||
"icon": null,
|
|
||||||
"zIndex": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 246 KiB After Width: | Height: | Size: 277 KiB |
68
d2renderers/d2sketch/testdata/overlay/sketch.exp.svg
vendored
Normal file
|
After Width: | Height: | Size: 229 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 115 KiB |
101
d2renderers/d2sketch/testdata/twitter/sketch.exp.svg
vendored
|
Before Width: | Height: | Size: 389 KiB After Width: | Height: | Size: 420 KiB |
|
|
@ -238,7 +238,7 @@ func arrowheadMarker(isTarget bool, id string, bgColor string, connection d2targ
|
||||||
|
|
||||||
var modifierEl *svg_style.ThemableElement
|
var modifierEl *svg_style.ThemableElement
|
||||||
if arrowhead == d2target.CfOneRequired || arrowhead == d2target.CfManyRequired {
|
if arrowhead == d2target.CfOneRequired || arrowhead == d2target.CfManyRequired {
|
||||||
modifierEl := svg_style.NewThemableElement("path")
|
modifierEl = svg_style.NewThemableElement("path")
|
||||||
modifierEl.D = fmt.Sprintf("M%f,%f %f,%f",
|
modifierEl.D = fmt.Sprintf("M%f,%f %f,%f",
|
||||||
offset, 0.,
|
offset, 0.,
|
||||||
offset, height,
|
offset, height,
|
||||||
|
|
@ -246,16 +246,16 @@ func arrowheadMarker(isTarget bool, id string, bgColor string, connection d2targ
|
||||||
modifierEl.Fill = bgColor
|
modifierEl.Fill = bgColor
|
||||||
modifierEl.Stroke = svg_style.ConnectionTheme(connection)
|
modifierEl.Stroke = svg_style.ConnectionTheme(connection)
|
||||||
modifierEl.Class = "connection"
|
modifierEl.Class = "connection"
|
||||||
modifierEl.Style = fmt.Sprintf(`stroke-width="%d"`, connection.StrokeWidth)
|
modifierEl.Attributes = fmt.Sprintf(`stroke-width="%d"`, connection.StrokeWidth)
|
||||||
} else {
|
} else {
|
||||||
modifierEl := svg_style.NewThemableElement("circle")
|
modifierEl = svg_style.NewThemableElement("circle")
|
||||||
modifierEl.Cx = offset/2.0 + 1.0
|
modifierEl.Cx = offset/2.0 + 1.0
|
||||||
modifierEl.Cy = height / 2.0
|
modifierEl.Cy = height / 2.0
|
||||||
modifierEl.R = offset / 2.0
|
modifierEl.R = offset / 2.0
|
||||||
modifierEl.Fill = bgColor
|
modifierEl.Fill = bgColor
|
||||||
modifierEl.Stroke = svg_style.ConnectionTheme(connection)
|
modifierEl.Stroke = svg_style.ConnectionTheme(connection)
|
||||||
modifierEl.Class = "connection"
|
modifierEl.Class = "connection"
|
||||||
modifierEl.Style = fmt.Sprintf(`stroke-width="%d"`, connection.StrokeWidth)
|
modifierEl.Attributes = fmt.Sprintf(`stroke-width="%d"`, connection.StrokeWidth)
|
||||||
}
|
}
|
||||||
|
|
||||||
childPathEl := svg_style.NewThemableElement("path")
|
childPathEl := svg_style.NewThemableElement("path")
|
||||||
|
|
@ -278,13 +278,13 @@ func arrowheadMarker(isTarget bool, id string, bgColor string, connection d2targ
|
||||||
}
|
}
|
||||||
|
|
||||||
gEl := svg_style.NewThemableElement("g")
|
gEl := svg_style.NewThemableElement("g")
|
||||||
gEl.Fill = bgColor
|
|
||||||
gEl.Stroke = svg_style.ConnectionTheme(connection)
|
|
||||||
gEl.Class = "connection"
|
|
||||||
gEl.Style = fmt.Sprintf(`stroke-width="%d"`, connection.StrokeWidth)
|
|
||||||
if !isTarget {
|
if !isTarget {
|
||||||
gEl.Transform = fmt.Sprintf("scale(-1) translate(-%f, -%f)", width, height)
|
gEl.Transform = fmt.Sprintf("scale(-1) translate(-%f, -%f)", width, height)
|
||||||
}
|
}
|
||||||
|
gEl.Fill = bgColor
|
||||||
|
gEl.Stroke = svg_style.ConnectionTheme(connection)
|
||||||
|
gEl.Class = "connection"
|
||||||
|
gEl.Attributes = fmt.Sprintf(`stroke-width="%d"`, connection.StrokeWidth)
|
||||||
gEl.Content = fmt.Sprintf("%s%s",
|
gEl.Content = fmt.Sprintf("%s%s",
|
||||||
modifierEl.Render(), childPathEl.Render(),
|
modifierEl.Render(), childPathEl.Render(),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
2
d2renderers/d2svg/github-markdown.css
vendored
|
|
@ -27,7 +27,7 @@
|
||||||
-webkit-text-size-adjust: 100%;
|
-webkit-text-size-adjust: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: var(--color-fg-default);
|
color: var(--color-fg-default);
|
||||||
background-color: var(--color-canvas-default);
|
background-color: transparent; /* we don't want to define the background color */
|
||||||
font-family: "font-regular";
|
font-family: "font-regular";
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
|
|
|
||||||