d2cli: fix theme passing to gif, fix scale on animated svg
This commit is contained in:
parent
105e52535e
commit
569da7bde8
4 changed files with 30 additions and 13 deletions
|
|
@ -20,3 +20,5 @@
|
||||||
- Vars: Spread variables are inserted in place instead of appending to end of scope [#2062](https://github.com/terrastruct/d2/pull/2062)
|
- Vars: Spread variables are inserted in place instead of appending to end of scope [#2062](https://github.com/terrastruct/d2/pull/2062)
|
||||||
- Imports: fix local icon imports from files that are imported [#2066](https://github.com/terrastruct/d2/pull/2066)
|
- Imports: fix local icon imports from files that are imported [#2066](https://github.com/terrastruct/d2/pull/2066)
|
||||||
- CLI: fixes edge case of watch mode links to nested board that had more nested boards not working [#2070](https://github.com/terrastruct/d2/pull/2070)
|
- CLI: fixes edge case of watch mode links to nested board that had more nested boards not working [#2070](https://github.com/terrastruct/d2/pull/2070)
|
||||||
|
- CLI: fixes theme flag not being passed to GIF outputs [#2071](https://github.com/terrastruct/d2/pull/2071)
|
||||||
|
- CLI: fixes scale flag not being passed to animated SVG outputs [#2071](https://github.com/terrastruct/d2/pull/2071)
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ Path to .ttf file to use for the bold font. If none provided, Source Sans Pro Bo
|
||||||
Pixels padded around the rendered diagram
|
Pixels padded around the rendered diagram
|
||||||
.Ns .
|
.Ns .
|
||||||
.It Fl -animate-interval Ar 0
|
.It Fl -animate-interval Ar 0
|
||||||
If given, multiple boards are packaged as 1 SVG which transitions through each board at the interval (in milliseconds). Can only be used with SVG exports
|
If given, multiple boards are packaged as 1 SVG which transitions through each board at the interval (in milliseconds). Can only be used with SVG and GIF exports
|
||||||
.Ns .
|
.Ns .
|
||||||
.It Fl -browser Ar true
|
.It Fl -browser Ar true
|
||||||
Browser executable that watch opens. Setting to 0 opens no browser
|
Browser executable that watch opens. Setting to 0 opens no browser
|
||||||
|
|
|
||||||
|
|
@ -847,9 +847,9 @@ func _render(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opts
|
||||||
Pad: opts.Pad,
|
Pad: opts.Pad,
|
||||||
Sketch: opts.Sketch,
|
Sketch: opts.Sketch,
|
||||||
Center: opts.Center,
|
Center: opts.Center,
|
||||||
|
MasterID: opts.MasterID,
|
||||||
ThemeID: opts.ThemeID,
|
ThemeID: opts.ThemeID,
|
||||||
DarkThemeID: opts.DarkThemeID,
|
DarkThemeID: opts.DarkThemeID,
|
||||||
MasterID: opts.MasterID,
|
|
||||||
ThemeOverrides: opts.ThemeOverrides,
|
ThemeOverrides: opts.ThemeOverrides,
|
||||||
DarkThemeOverrides: opts.DarkThemeOverrides,
|
DarkThemeOverrides: opts.DarkThemeOverrides,
|
||||||
Scale: scale,
|
Scale: scale,
|
||||||
|
|
@ -936,11 +936,14 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opt
|
||||||
}
|
}
|
||||||
|
|
||||||
svg, err = d2svg.Render(diagram, &d2svg.RenderOpts{
|
svg, err = d2svg.Render(diagram, &d2svg.RenderOpts{
|
||||||
Pad: opts.Pad,
|
Pad: opts.Pad,
|
||||||
Sketch: opts.Sketch,
|
Sketch: opts.Sketch,
|
||||||
Center: opts.Center,
|
Center: opts.Center,
|
||||||
Scale: scale,
|
Scale: scale,
|
||||||
ThemeID: opts.ThemeID,
|
ThemeID: opts.ThemeID,
|
||||||
|
DarkThemeID: opts.DarkThemeID,
|
||||||
|
ThemeOverrides: opts.ThemeOverrides,
|
||||||
|
DarkThemeOverrides: opts.DarkThemeOverrides,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -1286,10 +1289,14 @@ func renderPNGsForGIF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plug
|
||||||
scale = go2.Pointer(1.)
|
scale = go2.Pointer(1.)
|
||||||
}
|
}
|
||||||
svg, err = d2svg.Render(diagram, &d2svg.RenderOpts{
|
svg, err = d2svg.Render(diagram, &d2svg.RenderOpts{
|
||||||
Pad: opts.Pad,
|
Pad: opts.Pad,
|
||||||
Sketch: opts.Sketch,
|
Sketch: opts.Sketch,
|
||||||
Center: opts.Center,
|
Center: opts.Center,
|
||||||
Scale: scale,
|
Scale: scale,
|
||||||
|
ThemeID: opts.ThemeID,
|
||||||
|
DarkThemeID: opts.DarkThemeID,
|
||||||
|
ThemeOverrides: opts.ThemeOverrides,
|
||||||
|
DarkThemeOverrides: opts.DarkThemeOverrides,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,17 @@ func Wrap(rootDiagram *d2target.Diagram, svgs [][]byte, renderOpts d2svg.RenderO
|
||||||
width := br.X - tl.X + int(*renderOpts.Pad)*2
|
width := br.X - tl.X + int(*renderOpts.Pad)*2
|
||||||
height := br.Y - tl.Y + int(*renderOpts.Pad)*2
|
height := br.Y - tl.Y + int(*renderOpts.Pad)*2
|
||||||
|
|
||||||
fitToScreenWrapperOpening := fmt.Sprintf(`<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" d2Version="%s" preserveAspectRatio="xMinYMin meet" viewBox="0 0 %d %d">`,
|
var dimensions string
|
||||||
|
if renderOpts.Scale != nil {
|
||||||
|
dimensions = fmt.Sprintf(` width="%d" height="%d"`,
|
||||||
|
int(math.Ceil((*renderOpts.Scale)*float64(width))),
|
||||||
|
int(math.Ceil((*renderOpts.Scale)*float64(height))),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fitToScreenWrapperOpening := fmt.Sprintf(`<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" d2Version="%s" preserveAspectRatio="xMinYMin meet" viewBox="0 0 %d %d"%s>`,
|
||||||
version.Version,
|
version.Version,
|
||||||
width, height,
|
width, height, dimensions,
|
||||||
)
|
)
|
||||||
fmt.Fprint(buf, fitToScreenWrapperOpening)
|
fmt.Fprint(buf, fitToScreenWrapperOpening)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue