The raster counterpart to draw_to_svg(), for the same job: letting a module
whose output is not a plotly graph supply its own artwork to an export. Where
draw_to_svg() yields markup to splice, this yields the bytes of a finished
file.
Arguments
- draw_fn
A function of no arguments that draws onto the active device.
- width, height
Size in pixels.
- res
Pixels per inch used to size the drawing. The default matches
shiny::renderPlot()'s ownres, so the result is laid out on a canvas the same physical size as the one the plot was rendered at on screen – which matters for anything sized in absolute points; see the note onresindraw_to_svg().- scale
Pixel density multiplier. The drawing is laid out at the same physical size (
resscales with the pixel count) but rasterised atscaletimes the resolution, so the result is a crisp image rather than a screenshot. Matches thescaleplotly's own image export defaults to.- bg
Background color.
Value
A raw vector holding a PNG file, or NULL if the requested size is
not usable or the R build has no PNG support. An error raised by draw_fn
itself propagates to the caller; the device is closed either way.
See also
draw_to_svg() for the vector counterpart.