record
Mojo function 🡭
record
fn def record[C: ChartLike](plot: C, output: OutputFormat = OutputFormat.PNG) -> DisplayListRecord plot into a DisplayList that owns the finished drawing and can be replayed into any draw target, as often as needed (#862).
The recording is the whole figure in the order a direct render draws
it: the background, the axes and the mark, the annotations, then
every label, styled run and math rule. It owns every string, run,
path and image it was handed, so it outlives plot, and replaying
it into a Canvas, SvgCanvas or PdfCanvas draws what render(),
render_svg() or render_pdf() would. render() and the other
direct entry points are unchanged and record nothing.
A recording is one finished layout at plot.canvas_width() by
plot.canvas_height() with the plot’s theme. Replaying it under a
scale transform scales that layout; it does not pick new ticks,
rewrap labels or move a legend. For another size, size() the
chart again and record again.
Raster replay is not supersampled for you: to match render(),
replay between the canvas’s begin_supersampled() and
end_supersampled() at the plot’s Theme.raster_supersample.
An erased chart is recorded through its display-list slot, which
erased() leaves unbound; erase it with
erased_with[display_list=True]().
Parameters:
- C (
ChartLike)
Args:
- plot (
C): The chart to record. - output (
OutputFormat): The kind of target the recording will be replayed into. A few marks draw differently for a vector target: a largeimshow()grid is one image there rather than a rect per cell.OutputFormat.SVGorOutputFormat.PDFrecords that form;PNGorBMP(the default) the raster one. Either recording replays into any target.
Returns:
DisplayList: The recorded figure.
Raises:
Error: Whatever rendering the plot raises.