Persist a scene so it can be rebuilt later, in another session, or in another
process. .rds is the default and needs nothing extra; .json produces a
portable text format and needs the jsonlite package.
Arguments
- scene
A
vl_scene(), or anything with anas_vellum_scene()method.- path
File path. The extension picks the format (
.rdsor.json).
Details
What this buys you: caching a built scene without re-running the code that built it, sending one over a wire for a worker to render, and keeping a reproducible intermediate between "the code" and "the pixels".
Examples
s <- vl_scene(2, 2) |> draw(circle_grob(gp = vl_gpar(fill = "steelblue")))
f <- tempfile(fileext = ".rds")
scene_write(s, f)
identical(as_scene_spec(scene_read(f)), as_scene_spec(s))
#> [1] TRUE
