Public command

toon

Shaded KiCad board illustrations in Python and standalone Rust: the built-in Toon preset drawn by the pcb-svg pipeline.

Usage

kcr toon board.kicad_pcb --assembly
kcr toon project.kicad_pro --all-variants -o output/toon
kcr toon --write-config toon.config
kcr toon board.kicad_pcb --footprint J1 --side top
kcr toon board.kicad_pcb --workers 4 --timings output/toon-timings.json

Arguments

Input is a board or project, or one autodetected project/board in the current directory. --doc selects a project board. Side, footprint, assembly, variant/all-variants, theme/custom soldermask, config/write-config, worker and cache/no-cache controls match the native command. Theme/custom color and cache/no-cache are exclusive; --cache-dir moves the persistent cache and --no-cache keeps reuse within the run only. Config defaults beside the board to toon.config. Explicit view controls override global defaults; requested enabled views alone undergo semantic resolution.

Output

Default destination is ./output/toon/. SVGs and the digest-indexed toon_manifest.a0 manifest replace the destination transactionally after rendering succeeds. Optional toon_timings.a0 records measured phase durations and model work. Known limit: Geometer's degenerate-triangle notes repeat in every side's manifest, once per copy (1,982 per side on the Speedy module tester, in both languages). Python command measurements overlap: geometer_start accumulates worker startup durations while render_and_shutdown includes startup within the complete render interval. Source, config and cache inputs must be outside output; timings must be separate. Default SVG filenames stay <board>__toon_top/bottom.svg. Per-view safe relative output_svg, group_id, mirror and enabled are honored. Named/all variants get separate portable folders. Footprint selection includes only the selected footprint artwork.

Toon frames each view itself; pcb-svg's global.canvas does not apply. The frame is the side's copper and Edge.Cuts, each item measured with its own stroke, arcs to their true extent and zones by their drawn fills, with a 1 mm margin (3 mm for --footprint) and at least 5 mm across, then grown to the drawn model copies plus 0.05 mm. The frame's corner is the SVG origin, as in Altium Cruncher, so only model art past the frame reaches below 0. Ids follow pcb-svg's id rules.

Progress

Python and Rust print the same progress lines to standard output, worded as Altium Cruncher's. The root options come before the command and set the level: info by default, --quiet for warnings and errors only, --verbose or --log-level debug to add phase timings, as in kcr --verbose toon board.kicad_pcb. A cold run on Taillight prints:

Loading project/board context: <dir>\11-10045__taillight__C.kicad_pcb
Rendering 11-10045__taillight__C / base / top
Preparing top STEP models: 10 unique models
Completed top STEP model 1/10: RESC1608X06L.step (R28)
...
Rendering top component illustrations: 92 components
Illustrating top components: 1/92 (D1)
Illustrating top components: 25/92 (R3)
...
Completed top component illustrations: 5/92
Wrote SVG: <output>\11-10045__taillight__C__toon_top.svg
Toon timing base/top: preparation 0.020s, physical_render 0.133s, model_illustration 0.302s, composition 0.010s, total 0.465s
Toon timing command: input 0.001s, geometer_start 0.000s, render_and_shutdown 0.468s, publication 0.286s, total_before_timings_write 0.756s

The unique models are the side's distinct Geometer requests, by model content, pose, footprint rotation and side, that no cache answered, so a warm run prints no preparing or model lines. Models report in finish order, each with its first owning component, and a model that fails reads Failed. Requests clipped at the board surface form a second batch named top clipped or bottom clipped. Component lines count the footprints whose embedded models the view illustrates, from either mount side, at the first and every 25th. The completed count is the footprints that left visible artwork. SVG paths print after transactional publication. The two timing lines are debug level and use the toon_timings.a0 phase names.

Cache

Successful Geometer results persist in one kcr cache, laid out the same in Python and Rust as <cache dir>/<product>/<product version>/<key>.json. The cache dir defaults to .kcr/cache in the project folder: the .kicad_pro's folder, else the board's. --cache-dir replaces it and --no-cache turns persistence off. The user cache directory (for example %LOCALAPPDATA%) is the alternative location, not used for now (owner, 2026-11-24). Whether .kcr/ is gitignored is an open owner decision; until then it is left to the project.

Toon's product is geometer-illustration, version b0: Geometer's model illustration metadata and geometry. A key is the SHA-256 of the canonical JSON of its inputs. These are the Geometer release, C ABI, contract catalog and engine (the SHA-256 of the executable and the dynamic libraries beside it), the model's SHA-256 and the B0 request, whose transform includes the footprint rotation (see Model reuse). Canonical JSON sorts object members, drops null members and writes every number as its shortest round-trip digits in d.ddde<exp> form. Both languages therefore compute the same key, and a warm run in either language reuses the other's entries.

An entry is one kicad_cruncher.cache_entry.a0 JSON object (schema, product, version, key and payload), written to a temporary file and renamed into place. A bad entry warns, is deleted and is computed again; failures are never stored. A run that stored entries then removes the other versions of the known products and abandoned temporary files. It never removes other files, follows links or touches unknown products. A run that reused or stored entries prints Cache: N reused, M stored (<dir>). A product's version names its payload format; a new format takes a new version. A retired product (geometer-hlr-cli, Python pcb-svg's former command-line projections) is removed whole. Physical layers (copper, mask and silkscreen) are not cached. Caching them for colour-only reruns is an open owner decision: they are 6–7% of a warm Speedy module tester Toon run, and colours are baked into the drawing, so a colour-only rerun would miss.

Model reuse

Each model is drawn once per rotation and side, as Altium Cruncher draws its illustrations. The Geometer request's transform is Rz(footprint angle) ยท local pose (model offset, rotation and scale, mount side and board thickness), built with the same matrix helpers in Python and Rust, so the key names the model, its pose, the footprint rotation and the side, and copies of one key differ only by a translation. The light therefore stays fixed to the board on turned parts. Copies at one rotation share one Geometer request and one drawing. Each distinct embedded model file is decoded and its checksum checked once per board, for both sides and every view and variant.

Each key's art is built once per command in local coordinates (x', -y), where x' is -x in the bottom view: its SVG primitives, written straight from Geometer's rings as one even-odd path per surface layer (as Altium Cruncher's illustration geometry writer does), its bounds, the hidden-by-board envelope and the label region enclosed by its outline lines. A copy adds its footprint's canvas offset (at_x - ox, at_y - oy). No ink or Boolean is computed per copy.

Each view writes a key's drawing once into its illustration layer's <defs> as toon-art-N, numbered in the order the view first draws keys. A copy keeps its toon-model-K group and is classed by its key's Geometer bounds against the visible surface (+T/2 for top, -T/2 for bottom, tolerance 1e-6 mm), as in Altium Cruncher:

The masks stay on the board-frame groups, in board coordinates, never on the translated <use>. Label masks use the toon-model-K groups.

Geometer work runs on one worker pool per command, shared by every view and variant: lazy, bounded by --workers, one Geometer client per worker, every miss of a batch submitted before any result is awaited, and results taken in source order.

Board masks

Each view's illustration layer writes two luminance masks into its <defs>, only when some copy has an aperture: illustration-{side}-board-occlusion, white on board material, and illustration-{side}-open-space, its complement. Both are built once per board from the same facts as the board domain below: every closed profile loop is one even-odd path painted in depth order, white at even depth and black at odd depth, then every open bore is painted black (a circle for a round bore, a path for a capsule or for a bore cut to its pad's mask aperture). The complement starts with a white rectangle and swaps black and white. They cover the canvas and every drawn copy's art, padded 0.1 mm, in the canvas frame before a bottom view's reflection. Each copy is drawn whole, so no clip path cuts a seam along board edges. The masks render in browsers, resvg and Inkscape; tests/cases/toon/masks holds the board, two fake Geometer results and pixels.json, the colour each language's pixel test expects at seven points in both views.

Implementation

Monkey owns source parsing, placement facts and base plotting. Cruncher owns private render planning and composition. Python remains Python on all platforms and calls the public Geometer geometry service; it never delegates to Rust KiCad/Cruncher/PCBE. Rust runs independently. Toon is a preset, not a renderer: the packaged config resources/toon.config.json supplies both languages, and each draws it through its pcb-svg pipeline (Python: one PcbSvgSession per board per command, holding the render cache, Geometer workers, model art and the occlusion domain). The preset's global sets clip_to_outline and clip_holes_from_copper to false, as Toon drew before. toon keeps input resolution, themes, the side, footprint, assembly and variant options, the transaction, the manifest, the timings and its frame. Holes come only from the DRILLS and SLOTS tokens, which leave tented vias out, as in any pcb-svg view.

Mount and camera sides are independent. Preserve the complete STEP root placement and authored KiCad pose with its existing outward 0.05 mm offset. The finished general board thickness T defines centered surfaces at +T/2 and -T/2. Actual B0 clipping keeps z>=+T/2 for top and z<=-T/2 for bottom, tolerance 1e-6 mm, no cap. Clipped artwork shows on material and uncut artwork in open space, through the board masks. Masks stay in board coordinates, occurrence opacity is applied once, and existing per-attachment far-to-near ordering is preserved. This is not a global inter-model 3D occlusion solver.

Nested outlines and separate islands survive. Slots are capsules. Through-view holes require both ends open and no effective tent, fill, plug or cap. Unknown facts keep an unsafe bore closed with a scoped warning. ACR currently differs by checking only the viewed-end tent; this slice intentionally leaves ACR unchanged. Missing or invalid topology/thickness retains authored-side uncut artwork and omits unqualified opposite-side fragments with diagnostics. Successful empty fragments have no ink, label or bounds. Fit presentation to accepted visible overhangs without changing physical board extents.

Embedded STEP/STP only. Assembly labels stay on their mount side, fit the area enclosed by the outline lines of each copy's board-surface art (holes filled; the lines' box when they enclose nothing), and remain readable after final mirroring. Copies of one drawing fit once. Toon and pcb-svg share this designator path (see pcb-svg's ASSEMBLY_DESIGNATORS): a footprint without a model is fitted to its pad shapes on its side, wrapped in one outline, so a round test point keeps a round label area; one whose models give no drawing falls back to its pads with a warning, and a drawing with no outline lines is omitted with a warning. There is no minimum label size. Cache identity includes B0 request, pose, footprint rotation, view, clipping and model content; successful empty fragments reuse normally and failures retry. Python and Rust share cache entries; see Cache. Native Toon no longer rejects mixed copper or silkscreen settings: each primitive takes its own style.

Shield transparency and label visibility

Set "components": {"SH1": {"illustration": {"opacity": 0.4}}, "SH2": {"illustration": {"opacity": 0.4}}} in the Toon config to make only those model occurrences translucent. The finite numeric multiplier is from 0 to 1 and multiplies authored model opacity and the global illustration opacity once per occurrence. It does not change geometry requests or cache identity. Zero hides model artwork; its own assembly label remains controlled separately by show_designator. components keys may be selectors (SH, SH*, SH1-SH2), applied as in pcb-svg. Toon writes no components of its own: the assembly part rules' entries apply in memory beneath the config's components, under any --config.

When the label layer follows illustration, labels transmit through the actual later-painted model artwork: opaque coverage hides them; 40% coverage leaves 60% label transmission. Holes, source surface opacity, clipped branches and bottom mirroring survive. The last visible attachment of the labeled component establishes its rank; its own attachments do not cover its label. Pad-only labels start at the board surface. These are visibility-attenuated annotation overlays using existing painter order, not exact optical color compositing or a per-pixel 3D depth solver. Label-only views remain readable. If labels precede illustration, normal SVG painting supplies coverage without a second mask.

Physical Toon excludes synthetic documentation drill outlines. Native recoloring preserves authored fill/no-fill, and pad/drill board-absolute angles are normalized before footprint transforms. The imported connector fixture records its restored hole-edge mask apertures and original saved display color; its comparison config uses that color without inventing a material stack.

Per-instance label paint

Toon accepts every label key, the paint (color, opacity, stroke_color, stroke_width_mm and stroke_width_pct) and the font and fit (font_family, font_weight, box_fill_ratio, max_font_size_mm), under global/view styles.assembly_designators, its selector_overrides and components.<reference>.assembly_designators, in that order. Instance values replace inherited global/view values; label opacity is independent of illustration opacity and then receives the normal coverage attenuation. Colors use #RRGGBB or #RRGGBBAA; opacity is finite 0 to 1. Widths are finite and non-negative.

{
  "components": {
    "U3": {
      "assembly_designators": {
        "opacity": 0.8,
        "color": "#FFCC00",
        "stroke_color": "#FFFFFF",
        "stroke_width_pct": 8
      }
    }
  }
}

Here the white outline is 8% of the final fitted SVG font-size, expressed as a numeric width in millimeters. The same percentage scales with differently sized labels and stays unchanged by mirroring. Stroke is centered on the glyph and painted before its fill. The nearest scope explicitly setting either width mode wins (instance, then view, then global); percentage wins when both modes are authored at the same scope. An explicit percentage of 0 disables stroke. Percentage is absent by default so existing millimeter settings keep their behavior. The fitting region stays the component artwork; an outline can extend beyond it, and visibility-mask/filter padding expands to include the stroke.

Tests

L3_014 covers shared mount/view and tenting vectors, inherited closures, capsule slots, multiple/footprint/incomplete profiles, config, footprint scope, manifest/timing schemas, engine failures and source/output safety. Focused native tests cover equivalent physical rules. Explicit integration qualification uses the imported five-connector Altium projection fixture, supplemental reverse-mount controls, and one top/bottom smoke each on Taillight and Speedy with the exact candidate. L3_014 also checks that the footprint rotation is in the request and that copies at 0, 0 and 90 degrees make two requests per side, the two 0-degree copies using one toon-art drawing. L3_014's pixel test renders tests/cases/toon/masks with a fake illustrator and checks its pixels.json at 254 dpi with resvg, in the top and mirrored bottom views. L3_016 and the Rust cache unit tests cover the cache layout, the shared canonical key, bad entries, cleaning and warm reuse without starting Geometer. Tests do not require Altium at runtime. Browser inspection checks actual masks, model placement and visible bounds. Broad corpus and performance matrices are outside this slice.