Skip to contents

The parts of the compile bundle (rpic_compile()) that are tables, as plain data.frames with one row per record — ready for subset(), merge(), dplyr or ggplot2:

Usage

rpic_objects(x, ...)

rpic_places(x, ...)

rpic_warnings(x, ...)

Arguments

x

the drawing: a pic() object or a string of pic source (compiled with rpic_compile()), or a list returned by rpic_compile(). For rpic_warnings() also an rpic_geojson() or rpic_sf() result.

...

passed to rpic_compile() when x is pic source (circuits, texlabels).

Value

a data.frame (see Details).

Details

  • rpic_objects() — every drawn object: id (the SVG group id, "s0", "s1", ...), kind ("box", "circle", "path", "text", ...), the source span line, col, end_col, file (NA = your own source; else the copy include or "circuits"), the bounding box in SVG viewBox units (y down) as bbox_x0, bbox_y0 (top-left corner) and bbox_x1, bbox_y1 (bottom-right corner) — NA for an object with no extent — and link (the link "<url>" extension, else NA).

  • rpic_places() — every Label: position statement: label (the resolved key, subscripts included: "P[2]"), x, y (SVG user units, the frame of the objects' bounding boxes), block (the enclosing block path when the engine reports one, else NA) and the source span line, col, end_col, file.

  • rpic_warnings() — compiler warnings for accepted-but-ignored input: kind, message, line, col, end_col, file, found, expected, hint (the fields of the rpic_error diagnostic). For the result of rpic_geojson() or rpic_sf() it tabulates that result's "warnings" attribute instead: kind, message, hint, id, line, col, end_col, file.

A drawing with nothing to report gives a data frame with the same columns and zero rows. Line and column numbers are integers.

Compile errors

Source that does not compile raises the classed rpic_error of rpic_svg() — an error is not a warning row.

See also

rpic_compile() for the whole bundle.

Examples

p <- pic('A: (0, 0)
box "hi" at A link "https://rpic.dev"
arrow
circle "x"
box foo')
rpic_objects(p)
#>   id   kind line col end_col file  bbox_x0 bbox_y0  bbox_x1 bbox_y1
#> 1 s0    box    2   1       4 <NA>   1.0667  0.5333  73.0667 48.5333
#> 2 s1   path    3   1       6 <NA>  73.0667 22.1333 121.0667 26.9333
#> 3 s2 circle    4   1       7 <NA> 121.0667  0.5333 169.0667 48.5333
#> 4 s3    box    5   1       4 <NA> 169.0667  0.5333 241.0667 48.5333
#>               link
#> 1 https://rpic.dev
#> 2             <NA>
#> 3             <NA>
#> 4             <NA>
rpic_places(p)
#>   label       x       y block line col end_col file
#> 1     A 37.0667 24.5333  <NA>    1   1       2 <NA>
rpic_warnings(p)[, c("kind", "line", "found", "hint")]
#>                kind line found                hint
#> 1 ignored_attribute    5   foo did you mean `fit`?

# one compile, several tables
b <- rpic_compile(p)
rpic_objects(b)$kind
#> [1] "box"    "path"   "circle" "box"