add alternative method for fit to screen
This commit is contained in:
parent
45e58fdca5
commit
5f085c3d82
1 changed files with 8 additions and 1 deletions
|
|
@ -1568,8 +1568,15 @@ func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error) {
|
||||||
backgroundEl.Height = float64(h)
|
backgroundEl.Height = float64(h)
|
||||||
backgroundEl.Fill = BG_COLOR
|
backgroundEl.Fill = BG_COLOR
|
||||||
|
|
||||||
|
fitToScreenWrapper := fmt.Sprintf(`<svg %s preserveAspectRatio="xMinYMin meet" viewBox="0 0 %d %d">`,
|
||||||
|
`xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"`,
|
||||||
|
w, h,
|
||||||
|
)
|
||||||
|
|
||||||
// TODO minify
|
// TODO minify
|
||||||
docRendered := fmt.Sprintf(`<?xml version="1.0" encoding="utf-8"?><svg id="d2-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="%d" height="%d" viewBox="%d %d %d %d">%s%s%s</svg>`,
|
docRendered := fmt.Sprintf(`%s%s<svg id="d2-svg" width="%d" height="%d" viewBox="%d %d %d %d">%s%s%s</svg></svg>`,
|
||||||
|
`<?xml version="1.0" encoding="utf-8"?>`,
|
||||||
|
fitToScreenWrapper,
|
||||||
w, h, left, top, w, h,
|
w, h, left, top, w, h,
|
||||||
backgroundEl.Render(), // must be first
|
backgroundEl.Render(), // must be first
|
||||||
upperBuf.String(),
|
upperBuf.String(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue