added width param to render
This commit is contained in:
parent
8bcedbfc53
commit
f061bd964e
@ -433,7 +433,7 @@
|
||||
return (shapes, desc-y)
|
||||
}
|
||||
|
||||
#let render(config, structures) = {
|
||||
#let render(config, structures, width: 100%) = {
|
||||
set text(
|
||||
font: config.default-font-family,
|
||||
size: config.default-font-size
|
||||
@ -458,7 +458,7 @@
|
||||
|
||||
set page(..params)
|
||||
|
||||
canvas(length: 1pt, background: config.background, {
|
||||
let cnvs = canvas(length: 1pt, background: config.background, {
|
||||
let (shapes, _) = draw-structure(
|
||||
config, main, structures,
|
||||
ox: ox,
|
||||
@ -475,6 +475,32 @@
|
||||
fill: none
|
||||
)
|
||||
})
|
||||
|
||||
layout(size => {
|
||||
let m = measure(cnvs)
|
||||
let w = m.width
|
||||
let h = m.height
|
||||
let base-w = if type(width) == ratio {
|
||||
size.width * width
|
||||
} else {
|
||||
width
|
||||
}
|
||||
let r = if w == 0 {
|
||||
0
|
||||
} else {
|
||||
base-w / w
|
||||
}
|
||||
|
||||
let new-w = w * r
|
||||
let new-h = h * r
|
||||
r *= 100%
|
||||
|
||||
box(
|
||||
width: new-w,
|
||||
height: new-h,
|
||||
scale(x: r, y: r, cnvs, reflow: true)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
#let make(config) = {
|
||||
|
@ -56,10 +56,10 @@
|
||||
return structures
|
||||
}
|
||||
|
||||
#let render(structures, config: auto) = {
|
||||
#let render(structures, width: 100%, config: auto) = {
|
||||
if config == auto {
|
||||
config = conf.config()
|
||||
}
|
||||
let renderer_ = renderer.make(config)
|
||||
(renderer_.render)(structures)
|
||||
(renderer_.render)(structures, width: width)
|
||||
}
|
Loading…
Reference in New Issue
Block a user