Skip to contents

Convenience wrapper around text_layer for the case where no meshes are involved: the labels are drawn onto the background described by the render options. Screen-space labels (space = "screen") do not use a camera at all, so this is the quick way to turn a label into an image or to decorate an empty canvas; world-space labels need a camera.

Usage

render_text(positions, text, camera = NULL, options = NULL, ...)

Arguments

positions

Anchor positions, see text_layer.

text

Character vector of labels, see text_layer.

camera

A camera list from camera() or camera_auto(). Ignored for screen-space labels; when NULL, a default camera is used.

options

Render options from render_options().

...

Further arguments passed to text_layer (for example size, space, color, halo_color).

Value

A list with components width, height, and pixels (raw vector of RGBA values).

Examples

img <- render_text(c(20, 20), "figure A", space = "screen",
                   adj = c(0, 1), size = 24,
                   options = render_options(width = 300, height = 80))
tmp <- tempfile(fileext = ".png")
write_png(img, tmp)