Skip to contents

The scene is the engine's device-independent output (format 1, see docs/scene.md in the engine repository): the fully resolved draw list — final geometry in inches (y-up), curves as cubic Béziers, style as descriptors with colors resolved to hex, text as text with baseline anchor points, every variable's final value under vars, and items in draw order carrying the same stable s<N> ids as the SVG. Use it to build your own backend (maps, TikZ, editors) on top of rpic's layout. Items with text carry text_center (the centre the lines are laid out around) and text_rows (the height of the author's label stack, blank rows included); each text line carries its row in that stack, so the visible lines of box "" "below" keep their place. Blocks made by a macro call carry call (name, normalized args, and raw_args: each argument as written, with its source position).

Usage

rpic_scene(
  src,
  flatten = NULL,
  outline = FALSE,
  circuits = NULL,
  texlabels = NULL
)

Arguments

src

pic source code: a pic() object or a single string.

flatten

optional tolerance in inches: deliver every curve as a polyline within this distance of the exact cubics (NULL keeps the Béziers).

outline

embed typeset TeX math as self-contained SVG glyph fragments (outline keys) instead of metrics-only entries.

circuits

load the native circuit-element library (or write copy "circuits" in the source itself). NULL (the default) takes the pic() object's setting, FALSE for a string.

texlabels

typeset fully $...$-delimited labels as TeX math (initializer only — the source can still set texlabels = 0). NULL (the default) takes the pic() object's setting, FALSE for a string.

Value

a JSON string; parse with e.g. jsonlite::fromJSON().

Details

Anything the SVG paints that the scene cannot represent is reported as an R warning() (engine kind scene_unsupported) — never silently dropped.

Errors

Compile errors raise the same classed rpic_error condition as rpic_svg().

Examples

scene <- rpic_scene('geo_lon = -34.88
B: box "hub"
arrow right from B.e')
if (requireNamespace("jsonlite", quietly = TRUE)) {
  s <- jsonlite::fromJSON(scene, simplifyVector = FALSE)
  s$vars$geo_lon      # -34.88
  s$items[[2]]$kind   # "arrow"
}
#> [1] "arrow"