Skip to content
render_tight

render_tight

Mojo function 🡭

render_tight

fn def render_tight[C: ChartLike](plot: C) -> Canvas

render() cropped to the figure’s ink: the whitespace a fixed figure size reserves for a longer title or a legend that is not there is trimmed away (#372).

The figure is laid out at its full size() and then cropped, rather than being laid out smaller – laying out smaller would change where everything goes, and the crop would chase a moving target instead of framing the figure the caller asked for.

The ink is measured with _tight_box, which draws the figure into a BoundsTarget that paints nothing and keeps the union of the extents. Text counts: a title’s box is the box of the glyphs the same layout would draw.

A figure with no ink keeps its full size, since a zero-sized canvas is not usable.

Parameters:

  • C (ChartLike)

Args:

  • plot (C): The chart to render.

Returns:

Canvas: A canvas the size of the figure’s ink.

Raises:

Error: Whatever render() raises.