updated export and render options

This commit is contained in:
Vojtěch Fošnár 2023-01-27 22:41:59 +01:00
parent a8e3ebb9a5
commit d24a5c1ec3
No known key found for this signature in database
GPG key ID: 657727E71C40859A
27 changed files with 125 additions and 118 deletions

View file

@ -128,7 +128,7 @@ func test(t *testing.T, textPath, text string) {
t.Fatal(err)
}
_, err = d2exporter.Export(ctx, g, 0, nil)
_, err = d2exporter.Export(ctx, g, nil)
if err != nil {
t.Fatal(err)
}

View file

@ -244,7 +244,7 @@ func run(t *testing.T, tc testCase) {
t.Fatal(err)
}
got, err := d2exporter.Export(ctx, g, tc.themeID, nil)
got, err := d2exporter.Export(ctx, g, nil)
if err != nil {
t.Fatal(err)
}

View file

@ -8,7 +8,6 @@ import (
"oss.terrastruct.com/d2/d2layouts/d2dagrelayout"
"oss.terrastruct.com/d2/d2lib"
"oss.terrastruct.com/d2/d2oracle"
"oss.terrastruct.com/d2/d2themes/d2themescatalog"
"oss.terrastruct.com/d2/lib/textmeasure"
)
@ -19,7 +18,6 @@ func main() {
_, graph, _ := d2lib.Compile(context.Background(), "x -> y", &d2lib.CompileOptions{
Layout: d2dagrelayout.DefaultLayout,
Ruler: ruler,
ThemeID: d2themescatalog.GrapeSoda.ID,
})
// Create a shape with the ID, "meow"

View file

@ -3,6 +3,7 @@ package main
import (
"context"
"io/ioutil"
"math"
"path/filepath"
"strings"
@ -20,9 +21,11 @@ func main() {
ruler, _ := textmeasure.NewRuler()
_ = graph.SetDimensions(nil, ruler, nil)
_ = d2dagrelayout.Layout(context.Background(), graph, nil)
diagram, _ := d2exporter.Export(context.Background(), graph, d2themescatalog.NeutralDefault.ID, nil)
diagram, _ := d2exporter.Export(context.Background(), graph, nil)
out, _ := d2svg.Render(diagram, &d2svg.RenderOpts{
Pad: d2svg.DEFAULT_PADDING,
ThemeID: d2themescatalog.NeutralDefault.ID,
DarkThemeID: math.MaxInt64, // Without dark theme
})
_ = ioutil.WriteFile(filepath.Join("out.svg"), out, 0600)
}

View file

@ -137,6 +137,7 @@
"Host": "icons.terrastruct.com",
"Path": "/essentials/004-picture.svg",
"RawPath": "",
"OmitHost": false,
"ForceQuery": false,
"RawQuery": "",
"Fragment": "",

View file

@ -218,6 +218,7 @@
"Host": "icons.terrastruct.com",
"Path": "/essentials/004-picture.svg",
"RawPath": "",
"OmitHost": false,
"ForceQuery": false,
"RawQuery": "",
"Fragment": "",

View file

@ -368,6 +368,7 @@
"Host": "",
"Path": "orange",
"RawPath": "",
"OmitHost": false,
"ForceQuery": false,
"RawQuery": "",
"Fragment": "",

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -55,8 +55,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -73,7 +73,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -95,12 +95,12 @@
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#0D32B2",
"stroke": "B1",
"label": "",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"color": "N2",
"italic": true,
"bold": false,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -55,8 +55,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -73,7 +73,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -95,12 +95,12 @@
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#0D32B2",
"stroke": "B1",
"label": "",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"color": "N2",
"italic": true,
"bold": false,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -55,8 +55,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -73,7 +73,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -95,12 +95,12 @@
"opacity": 1,
"strokeDash": 4,
"strokeWidth": 2,
"stroke": "#0D32B2",
"stroke": "B2",
"label": "",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"color": "N2",
"italic": true,
"bold": false,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#E7EAFF",
"stroke": "#000E3D",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -55,8 +55,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#E7EAFF",
"stroke": "#000E3D",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -73,7 +73,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -95,12 +95,12 @@
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#000E3D",
"stroke": "B1",
"label": "",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"color": "N2",
"italic": true,
"bold": false,
"underline": false,
@ -126,12 +126,12 @@
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#000E3D",
"stroke": "B1",
"label": "",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"color": "N2",
"italic": true,
"bold": false,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -55,8 +55,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -73,7 +73,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -95,7 +95,7 @@
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#0D32B2",
"stroke": "B1",
"label": "yo",
"fontSize": 16,
"fontFamily": "DEFAULT",

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 5,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#FFFFFF",
"stroke": "#0D32B2",
"fill": "N7",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -30,6 +30,7 @@
"Host": "icons.terrastruct.com",
"Path": "/essentials/004-picture.svg",
"RawPath": "",
"OmitHost": false,
"ForceQuery": false,
"RawQuery": "",
"Fragment": "",
@ -44,7 +45,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 0,
"borderRadius": 0,
"fill": "#FFFFFF",
"stroke": "#0D32B2",
"fill": "N7",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 28,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": false,
"underline": false,
@ -55,8 +55,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#EDF0FD",
"stroke": "#0D32B2",
"fill": "B5",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -73,7 +73,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": false,
"underline": false,
@ -95,8 +95,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#EDF0FD",
"stroke": "#0D32B2",
"fill": "B5",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -113,7 +113,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": false,
"underline": false,
@ -135,8 +135,8 @@
"strokeDash": 0,
"strokeWidth": 0,
"borderRadius": 0,
"fill": "#DEE1EB",
"stroke": "#0D32B2",
"fill": "N5",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -153,7 +153,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": false,
"underline": false,
@ -175,12 +175,12 @@
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#0D32B2",
"stroke": "B1",
"label": "",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"color": "N2",
"italic": true,
"bold": false,
"underline": false,
@ -205,12 +205,12 @@
"opacity": 1,
"strokeDash": 6,
"strokeWidth": 2,
"stroke": "#0D32B2",
"stroke": "B2",
"label": "",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"color": "N2",
"italic": true,
"bold": false,
"underline": false,
@ -235,12 +235,12 @@
"opacity": 1,
"strokeDash": 6,
"strokeWidth": 2,
"stroke": "#0D32B2",
"stroke": "B2",
"label": "",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"color": "N2",
"italic": true,
"bold": false,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -55,8 +55,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#F7F8FE",
"stroke": "#0D32B2",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -73,7 +73,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,

View file

@ -16,7 +16,7 @@
"strokeWidth": 2,
"borderRadius": 0,
"fill": "transparent",
"stroke": "#0A0F25",
"stroke": "N1",
"shadow": false,
"3d": false,
"multiple": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#E7EAFF",
"stroke": "#000E3D",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -55,8 +55,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#E7EAFF",
"stroke": "#000E3D",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -73,7 +73,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -95,12 +95,12 @@
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#000E3D",
"stroke": "B1",
"label": "asdf",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"color": "N2",
"italic": true,
"bold": true,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#E7EAFF",
"stroke": "#000E3D",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -55,8 +55,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#E7EAFF",
"stroke": "#000E3D",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -73,7 +73,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -95,12 +95,12 @@
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#000E3D",
"stroke": "B1",
"label": "asdf",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"color": "N2",
"italic": true,
"bold": false,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#E7EAFF",
"stroke": "#000E3D",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -55,8 +55,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#E7EAFF",
"stroke": "#000E3D",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -73,7 +73,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": true,
"underline": false,
@ -95,12 +95,12 @@
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#000E3D",
"stroke": "B1",
"label": "asdf",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": false,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#E7EAFF",
"stroke": "#000E3D",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"color": "N2",
"italic": true,
"bold": true,
"underline": false,

View file

@ -15,8 +15,8 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#E7EAFF",
"stroke": "#000E3D",
"fill": "B6",
"stroke": "B1",
"shadow": false,
"3d": false,
"multiple": false,
@ -33,7 +33,7 @@
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"color": "N1",
"italic": false,
"bold": false,
"underline": false,

View file

@ -235,6 +235,7 @@
"Host": "icons.terrastruct.com",
"Path": "/essentials/142-target.svg",
"RawPath": "",
"OmitHost": false,
"ForceQuery": false,
"RawQuery": "",
"Fragment": "",

View file

@ -132,6 +132,7 @@
"Host": "icons.terrastruct.com",
"Path": "/essentials/087-menu.svg",
"RawPath": "",
"OmitHost": false,
"ForceQuery": false,
"RawQuery": "",
"Fragment": "",