Skip to contents

The engine's compile bundle, converted to R: everything rpic_manifest() returns as JSON text, plus the scene on request, without a JSON parser on the R side. Use it to drive tools (editors, map front ends, checkers) from one compile.

Usage

rpic_compile(
  src,
  circuits = NULL,
  texlabels = NULL,
  scene = FALSE,
  flatten = NULL,
  outline = FALSE
)

Arguments

src

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

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.

scene

also compile the scene (scene element).

flatten, outline

scene options (see rpic_scene()); used only when scene = TRUE.

Value

a named list (see Details).

Details

The list always carries

  • svg — the SVG string (rpic_svg());

  • animations — the animate timelines (a list, empty when unused);

  • diagnostics — print lines and engine notices (a character vector);

  • warnings — structured compiler warnings, each a list with the rpic_error diagnostic fields (with scene = TRUE the scene's own scene_unsupported warnings join them). They are returned, not raised;

  • objects — every drawn object: SVG id ("s0", ...), kind, bbox in viewBox units (NA when it has none) and source position;

  • places — every Label: position statement as a named point (label, x, y in SVG user units, enclosing block, source span);

  • passthrough — troff lines set aside (text and source position);

plus interactions and scroll when the source uses draggable or animate scroll, and scene (the scene document of rpic_scene() as a nested list — text items with text_center/text_rows, blocks with call$raw_args) when scene = TRUE.

JSON objects become named lists, arrays of numbers/strings/logicals atomic vectors, other arrays lists, null is NA; nested names are in sorted order.

Errors

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

See also

rpic_objects(), rpic_places() and rpic_warnings() for objects, places and warnings as data frames.

Examples

b <- rpic_compile('A: (0, 0)
box "hi" at A; arrow')
names(b)
#> [1] "svg"         "animations"  "diagnostics" "warnings"    "objects"    
#> [6] "places"      "passthrough"
b$objects[[1]]$kind   # "box"
#> [1] "box"
b$places[[1]]$label   # "A"
#> [1] "A"
s <- pic("circle") |> rpic_compile(scene = TRUE)
s$scene$items[[1]]$kind     # "circle"
#> [1] "circle"