Skip to contents

Convenience helper for vignettes and reports: renders a surface with `view_surface()` onto an off-screen rgl device and saves a PNG. When `rgl.useNULL()` is `TRUE` (headless builds), a proper snapshot requires the `webshot2` package; otherwise a blank image is likely and an empty path is returned.

Usage

snapshot_surface(surfgeom, file = NULL, width = 1200, height = 900, ...)

Arguments

surfgeom

A SurfaceGeometry object.

file

Output path for the PNG. Defaults to the current knitr figure path when knitting, otherwise a temporary file.

width, height

Device size in pixels (controls render resolution).

...

Additional arguments passed to view_surface.

Value

The file path (invisibly). Callers can use knitr::include_graphics() or read the image via png::readPNG(). In headless mode without `webshot2`, an empty character vector is returned.

Examples

if (FALSE) { # \dontrun{
fs <- load_fsaverage_std8("inflated")
img <- snapshot_surface(fs$lh, viewpoint = "lateral", specular = "black")
# knitr::include_graphics(img)
} # }