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 thepic()object's setting,FALSEfor a string.- texlabels
typeset fully
$...$-delimited labels as TeX math (initializer only — the source can still settexlabels = 0).NULL(the default) takes thepic()object's setting,FALSEfor a string.- scene
also compile the scene (
sceneelement).- flatten, outline
scene options (see
rpic_scene()); used only whenscene = TRUE.
Details
The list always carries
svg— the SVG string (rpic_svg());animations— theanimatetimelines (a list, empty when unused);diagnostics—printlines and engine notices (a character vector);warnings— structured compiler warnings, each a list with therpic_errordiagnostic fields (withscene = TRUEthe scene's ownscene_unsupportedwarnings join them). They are returned, not raised;objects— every drawn object: SVGid("s0", ...),kind,bboxin viewBox units (NAwhen it has none) and source position;places— everyLabel: positionstatement as a named point (label,x,yin SVG user units, enclosingblock, source span);passthrough— troff lines set aside (textand 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"