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:
Arguments
- x
the drawing: a
pic()object or a string of pic source (compiled withrpic_compile()), or a list returned byrpic_compile(). Forrpic_warnings()also anrpic_geojson()orrpic_sf()result.- ...
passed to
rpic_compile()whenxis pic source (circuits,texlabels).
Details
rpic_objects()— every drawn object:id(the SVG group id,"s0","s1", ...),kind("box","circle","path","text", ...), the source spanline,col,end_col,file(NA= your own source; else thecopyinclude or"circuits"), the bounding box in SVG viewBox units (y down) asbbox_x0,bbox_y0(top-left corner) andbbox_x1,bbox_y1(bottom-right corner) —NAfor an object with no extent — andlink(thelink "<url>"extension, elseNA).rpic_places()— everyLabel: positionstatement: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, elseNA) and the source spanline,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 therpic_errordiagnostic). For the result ofrpic_geojson()orrpic_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"