rpic (development version)
API
The API moves towards tidyverse style before the next CRAN release: one object for the source, pipe-first verbs, snake_case columns, data frames.
-
pic(src, circuits = NULL, texlabels = NULL)wraps pic source in anrpic_sourceobject (the source string with itscircuitsandtexlabelsoptions as attributes). LeftNULL, the options are detected from the source as the rpic Studio does:circuitswhen it uses a circuit element (resistor(A,B), a bareground, …) or sayscopy "circuits",texlabelswhen a string label is entirely$...$.print()shows a summary and, interactively, opens the drawing in the viewer;format()returns the summary; in knitr a visiblepic()is drawn as the chunk’s figure (knit_print(), registered for knitr when it is installed; figures are named by content, so several per chunk never collide). - Every
rpic_*()function takes apic()or a string first, so drawings read as pipes:pic(src) |> rpic_png("a.png"),pic(src) |> rpic_compile(scene = TRUE),pic(src) |> rpic_sf(). Given apic(), itscircuits/texlabelsare the defaults;circuitsandtexlabelsnow default toNULL(= thepic()’s setting,FALSEfor a string — unchanged for existing code). -
rpic_objects(),rpic_places()andrpic_warnings()return the compile bundle’s tables as plain data frames, one row per object, place or warning:id,kind, source span,bbox_x0/bbox_y0/bbox_x1/bbox_y1(NAwithout extent) andlinkfor objects;label,x,y,blockand span for places; the diagnostic fields for warnings (also the"warnings"attribute of anrpic_geojson()/rpic_sf()result). They take apic(), a string or anrpic_compile()result. -
Breaking (development version only — never on CRAN):
rpic_sf()columns are snake_case: every:and-of a GeoJSON property name becomes_—geopic.kind→geopic_kind,geopic.font_size→geopic_font_size,stroke-width→stroke_width,fill-opacity→fill_opacity, …rpic_sf_names()is the documented mapping, with the full vocabulary table. The GeoJSON text (and so the MapLibre layers) keeps the engine’s names. -
add_rpic(map, x, ..., before = NULL, text_scale = 1, font = "style", fit = TRUE)is the mapgl adder, map first like mapgl’s ownadd_*()verbs:maplibre() |> add_rpic(pic(src)).rpic_mapgl()stays as an alias (the same function). -
rpic_layers(x)returns theggplot2layers that draw a georeferenced drawing as pic drew it —ggplot() + rpic_layers(x), alone or over a basemap: shapes throughgeom_sf()with their fills and strokes (linewidth = NULLuses pic’s own widths), texts as labels justified and turned as pic placed them (geopic_anchor→hjust/vjust,geopic_rotation→angle, so"2 km" abovesits above its line), andcoord_sf(clip = "off").xis anrpic_sf()data frame or pic source. -
autoplot()(ggplot2) of a georeferencedpic()isrpic_layers()on a blank theme. -
vignette("maps")opens with a three-line quick start, shows whatrpic_sf()returns column by column, tells pic’sscale,geo_scaleand text sizes apart, adds ageo_bearingexample (a pitch laid at 55°) and draws every figure on the longitude/latitude grid with its labels placed as pic placed them. - Vignettes, the mapgl article, README and examples are written with
pic()and|>; the reference index is grouped as Compile and export · Drawing data · Maps · knitr.
New features
-
rpic_geojson()places a pic drawing on the Earth and returns it as a GeoJSONFeatureCollection(WGS84), through the engine’s newgeopic-corecrate: registration bygeo_lon/geo_lat/geo_scale/geo_bearingin the source (or theanchor,scale,bearing,framearguments, which win) or by control points<Label>_lon/<Label>_lat; geometry densified so lines and circles are true on the ellipsoid. The registration and the warnings ride as attributes.featuresinjects named places from R — a named list, a data frame or ansfobject (centroid + bounding box) — that the source can use by name. -
rpic_sf()reads the same result into ansfdata frame (EPSG:4326), one snake_case column per property (stroke,stroke_width,fill,geopic_kind, …; see API above).sfis a suggested package only. - Losses are never silent: one
rpic_geo_warning(anrpic_warning) per kind; registration failures raiserpic_geo_error(anrpic_error) withe$info$kindande$info$hint. -
rpic_compile()returns the engine’s whole compile bundle as an R list —svg,animations,diagnostics,warnings,objects,places,passthroughand, withscene = TRUE, the scene — without JSON parsing in R. - The knitr engine georeferences chunks with
geo = TRUE: the chunk assigns itsrpic_sf()result (orrpic_geojson()withoutsf) to a variable named bygeo.var(default: the chunk label) for later R chunks, e.g.ggplot2::geom_sf(). - New vignette
vignette("maps"): the engine’s four geo examples withggplot2, features fromsf’sncdataset, andmapgl. -
rpic_maplibre_layers()returns the engine’s MapLibre style-spec layers for a georeferenced drawing (engine 0.15.0,geopic-core’smaplibremodule): the six layers rpic.dev’s Maps page draws with — fills, solid and dashed strokes, dots, text, shape titles — with every size true to the ground, as R lists that serialise back to the engine’s JSON. It takes anrpic_geojson()result, anrpic_sf()data frame or pic source. -
add_rpic()(namedrpic_mapgl()earlier in this development cycle; that name stays as an alias) adds a drawing to amapgl::maplibre()ormapgl::mapboxgl()map: the engine’s GeoJSON as source"pic", the six layers and a fit to the drawing.rpic_sf()results keep the engine’s GeoJSON text in a"geojson"attribute for both.vignette("maps")uses the helper; live maps are in the website article “Interactive maps with mapgl” (https://milkway.github.io/rpic-r/articles/mapgl.html), which is not shipped in the package. -
rpic_maplibre_layers()andadd_rpic()gaintext_scale(engine 0.16.0’s layer option): it multiplies every label’s font size, a number in (0, 16], default 1 (unchanged output). Strokes and dots keep their ground sizes. Out of range or not a number: anrpic_geo_errorwithe$info$kind == "invalid_options". -
add_rpic()gainsfont: the drawing’s labels (pic-text,pic-title) use the style’s own font by default ("style": the most common upright Regular/Mediumtext-fontstack among its symbol layers — CARTO’s positron: Montserrat Medium, Open Sans Regular, …). The engine’s “Noto Sans Regular”, as a glyph server like CARTO’s serves it, has other vertical metrics, and a label placedabovea line sat on it."spec"keeps the engine’s font; a character vector is an explicit stack. An unreadable style keeps the engine’s font, without a warning of its own. -
add_rpic()gainsbefore:"labels"puts the drawing’s shapes (pic-fill,pic-stroke,pic-stroke-dashed,pic-dot) under the basemap’s labels — before the style’s layerlabels, else at the start of its trailing label block (the first layer after the last non-symbollayer; not the firstsymbollayer, which in CARTO’s positron iswaterway_label, below roads and buildings) — while the drawing’s own labels (pic-text,pic-title) stay on top, the rule of the engine’s JavaScriptattach(); a layer id inserts before that layer;NULL(the default) appends as before. A style given as a URL is fetched once to find the layer; when it cannot be read, a warning, and the layers go on top.
Bug fixes
- The knitr engine includes the rendered PNG as a figure again; with current knitr it printed the figure’s path as text output.
Engine 0.19.1
Tracks the rpic engine 0.19.1 (vendored crates 0.19.1). Nothing changes for R users: the engine release only ships LICENSE and ACKNOWLEDGMENTS.md inside each crate and names dpic in the crate descriptions; rendering is the same as 0.19.0.
Engine 0.19.0
Tracks the rpic engine 0.19.0 (vendored crates 0.19.0). What reaches R users:
- A label’s face reaches the map.
"Marco Zero" bold,"Porto" italic,"8080" monoandfont "Georgia"travel asgeopic:font_weight,geopic:font_styleandgeopic:font_family(rpic_sf()columnsgeopic_font_weight,geopic_font_style,geopic_font_family, present only when a label sets them), and thetext-fontofrpic_maplibre_layers()picks a Bold / Italic stack from them. -
add_rpic(font = "style")takes the bold, italic and bold italic stacks from the style’s own symbol layers (the body font when the style has none), andfontalso acceptslist(regular =, bold =, italic =, bold_italic =).monoandfont "..."labels are drawn in the body family on the map. -
rpic_layers()/autoplot()draw bold and italic labels with the matchingfontface, andmonolabels in the"mono"family.
Engine 0.18.0
Tracks the rpic engine 0.18.0 (vendored crates 0.18.0). What reaches R users:
- A text object takes colour the dpic way:
"note" shaded "gray"fills the glyphs (outlinedstrokes them,coloredboth).rpic_scene()text lines carrycolor/strokewhen set;rpic_sf()/rpic_geojson()are unchanged. - A free text of several lines keeps every line at 11 pt one em apart (they were squeezed before), and a
"Name" "sub" smallstack keeps the name at 11 pt. A repeated size word keeps its last value (box wid 1 wid 2is 2 in). - The engine repo now ships an Agent Skill (
skills/rpic) that draws diagrams, circuits and maps with rpic; its map recipes use this package.
Engine 0.17.1
Tracks the rpic engine 0.17.1 (vendored crates 0.17.1): a fix in macro substitution so a "$n" label inside a library macro keeps the library’s source position (it surfaced as a user position before); no R-visible change beyond rpic_objects() reporting the right file/end_col for such labels.
Engine 0.17.0
Tracks the rpic engine 0.17.0 (vendored crates rpic-core/rpic-render/ geopic-core 0.17.0). Nothing changes in what reaches R users: the release carries the engine’s embedder additions (CompileOptions.preludes, places[].block in the --json bundle) and the JS MapLibre module’s before = "labels"/font = "style" rules, which add_rpic() already implemented on the R side in the previous entry.
Engine 0.16.0
Tracks the rpic engine 0.16.0 (vendored crates rpic-core/rpic-render/ geopic-core 0.16.0). What reaches R users:
- Blank rows of a label stack are kept in
geopic:text(box "" "below"gives"\nbelow"), so a map draws “below” one row under the centre, as the SVG does; thepic-text/pic-titlelayers settext-line-heightto 1 and pad a trailing empty row so MapLibre keeps it. - Scene (
rpic_scene(),rpic_compile(scene = TRUE)): each text line carriesrow, its row in the label stack, and the itemtext_rows, the stack’s height; blocks made by a macro call carrycall$raw_args, each argument as written (1e-9stays1e-9) with its source position. - Labels on flat macro calls:
R1: resistor(A, B)names the group of objects the call draws, like a block (R1.n,R1.start), when the macro body could not take a label before (it starts with assignments, a label or a control statement). Sources that compiled before render the same. - troff passthrough: a
+line right after a passthrough line continues it (the bundle’spassthroughentry gainsend_line).
Engine 0.15.1
Tracks the rpic engine 0.15.1 (vendored crates rpic-core/rpic-render/ geopic-core 0.15.1; 0.15.0 added the MapLibre layers above). The existing R functions and their arguments are unchanged; rendering is byte-identical to 0.12.1 over the engine’s whole corpus. What reaches R users through the pic source and the JSON outputs:
-
rpic_scene()gains a top-levelplacesarray — everyLabel: positionstatement as a named point in scene units, with its enclosing block and source span — and block items carryspan(the outermost macro call that produced the block, or its[) andcall(name,args). The scene format version stays 1 (additive). - A shape with text (
box "Marco Zero") gains atitlepoint feature at the centre of its text: inrpic_sf()a row withgeopic_kind == "title",geopic_id"<id>:title"andgeopic_fornaming the shape; arrowheads no longer repeat the shape’stitle/geopic_text. Thepic-titleMapLibre layer draws these points (a box’s title was drawn twice when the box straddled a map tile boundary). The scene’s text items gaintext_center(additive). - troff requests (a line with
.in column 1 other than.PS/.PE, e.g..ft B) are set aside as classic pic and dpic do instead of failing to parse.
Credits
- The
Description, the package help page and the README name ‘dpic’ by J. D. Aplevich as the reference implementation of ‘pic’ whose grammar and behaviour ‘rpic’ follows, and ‘circuit_macros’ as the model of the circuit library. ‘rpic’ is not affiliated with or endorsed by the authors of ‘pic’, ‘dpic’, ‘circuit_macros’ or ‘pikchr’.
rpic 0.12.1
CRAN release: 2026-11-02
Tracks the rpic engine from 0.11.3 to 0.12.1 and adds one function.
- New
rpic_scene(): the engine’s scene output — the resolved draw list as versioned, device-independent JSON (final geometry in inches, curves as cubic Béziers orflattened polylines, style descriptors with hex colors, text with baseline anchors, every variable’s final value undervars, and items in draw order carrying the SVG’s stables<N>ids). Parse it withjsonlite::fromJSON()and build map layers, TikZ output or editors on top of rpic’s layout. Anything the SVG paints that the scene cannot represent raises a classedrpic_warning(engine kindscene_unsupported). - Engine updates reaching R users: the whole corpus renders byte-identically to 0.11.3 (the 0.12.x line’s changes are the opt-in scene export plus packaging); dependency refreshes (resvg 0.49, RaTeX 0.1.15) are likewise output-identical.
rpic 0.11.3
CRAN release: 2026-10-01
Tracks the rpic engine from 0.6.2 to 0.11.3. The R functions and their arguments are unchanged; everything below is reached through the pic source.
- New pic extensions, all opt-in:
canvas(fixed page), per-string font attributes (bold,italic,mono,font,fontsize,big,small),rotatedandalignedlabels, colour literalsrgb(r, g, b)and0xRRGGBB, variables and expressions in colour position,thin, andlink "<url>"for clickable objects in SVG output. -
animategrew from three effects to a full set:move,highlight,slide,morph,type,scrambleandwiggle, plusout,repeat,yoyo,ease,stagger, a partialdraw from ... to ..., anddraggableobjects. -
rpic_manifest()bundles gain anobjectsarray (id, kind, bounding box and source position of every drawn object) and, whendraggableis used, aninteractionsarray. - Better compatibility with ‘dpic’: extension words such as
after,repeatandpreviousno longer shadow identifiers, so sources that use them as variable or macro names compile. - Recursive macro expansion is no longer exponential in its depth.
- Robustness: deeply nested input is rejected with a diagnostic instead of overflowing the stack, and
invalid_colorwarnings carry a source position. - Rust 1.88 or later is now required to build from source (
SystemRequirements).
rpic 0.6.2
CRAN release: 2026-07-15
- Track rpic 0.6.2 (the 2026-07 audit series): always-valid SVG for negative dimensions, canvas bounds that contain arrowheads and math fragments, dpic-parity fixes for
chop/continue/deadforbodies, and structured eval-phase diagnostics with include attribution. - Internal: the option builder is resilient to additive engine option fields.
rpic 0.6.1
- Track rpic 0.6.1 (
rpic-core/rpic-renderfrom crates.io; previously 0.1.0). - New
texlabelsargument onrpic_svg(),rpic_png(),rpic_pdf()andrpic_manifest(), and as a knitr chunk option: fully$...$-delimited labels are typeset as TeX math, natively (the math renderer is now registered — it previously was not, so math labels fell back to literal text). -
circuits = TRUEis now a compile option instead of prepending the library to the source: compile-error positions stay relative to your own input. The library can also be loaded in-source withcopy "circuits". - Structured errors: compile failures are raised as a classed
rpic_errorcondition;e$infoholds the diagnostic (message,line,col,end_col,file,kind,found,expected,hint). -
rpic_manifest()bundles now include awarningsarray with structured compiler warnings for accepted-but-ignored input.
rpic 0.1.0
- First public release:
rpic_svg(),rpic_png(),rpic_pdf(),rpic_manifest(), the knitr engine (rpic_register_knitr()), and the native circuit-element library (circuits = TRUE).