Skip to content

Painters, aliases, configurations and the new PHYSICS types - #3

Merged
burhankhanzada merged 13 commits into
mainfrom
feat/painter-directive
Oct 1, 2026
Merged

burhankhanzada merged 13 commits into
mainfrom
feat/painter-directive

Conversation

@burhankhanzada

Copy link
Copy Markdown
Member

The format work behind PinBench's new parts (PinBench/pinbench#8).

  • PAINTER: a part can draw its body with a Dart painter instead of SVG, and answer to ALIAS names (the LDR as Photoresistor).
  • Configurations: one .pdl can describe a part in several configurations — the transistors are one part picked by its Type.
  • PHYSICS types: npn, pnp, nmos, pmos; Darlington npnDarlington/pnpDarlington; rgbLed; spdt (slide switch); ledArray (7-segment display); diode model parameters.
  • Docs list the new bundled parts: capacitor, RGB LED, coin cell, 1N4148, IR receiver.

dart test: 66 passing. PinBench's pinbench_parts and pinbench_sim resolve this package from main, so their CI needs this merged.

🤖 Generated with Claude Code

burhankhanzada and others added 13 commits September 30, 2026 23:46
PAINTER <name> draws a part's body with a painter the app registers
under that name, in place of an SVG. Only the drawing is code: pins,
properties, behaviour and physics stay in the .pdl, and VISUALS still
draw over it. It is for artwork that arrives as vector paths from a
design tool rather than as an SVG file. A part now needs an SVG, a
PAINTER or VISUALS, and SVG with PAINTER is rejected since both would
draw the body.

ALIAS "<name>", repeatable, is another name a part answers to, so a
renamed part's old .cdl type token still resolves.

PDL.md documents both, and its complete example is the LDR again, now
drawn by a PAINTER and aliased to the Photoresistor it shipped as.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A bipolar transistor maps `c`, `b`, `e` and a MOSFET `d`, `g`, `s`; a
part's numeric PHYSICS parameters are SPICE model parameters over the
engine's defaults, so `bf = 300` makes a higher-gain part. PDL.md
documents them, lists the four transistor parts, and notes that one
PAINTER can serve several parts, as the transistors' does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A Darlington maps `c`, `b`, `e` like one bipolar transistor and is built
as two, the first driving the second's base, with a resistor across each
base-emitter junction as in a TIP120 (`r1`, `r2`). PDL.md documents
them, notes that the power MOSFET parts are plain `nmos`/`pmos` with
their own `vto` and `kp`, and lists the TO-220 parts and their shared
PAINTER.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`rgbLed` maps three anodes, `r`, `g`, `b`, and their shared cathode `k`:
a common-cathode RGB LED built as three measured dies, so a LOGIC reads
each colour's current at its pin. PDL.md documents it, lists the
electrolytic capacitor and the RGB LED among the bundled parts, and
notes that a PAINTER receives the part's state, which is how the RGB
LED's lights up.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A `diode` part's numeric PHYSICS parameters (`is`, `n`) are now its
SPICE model numbers. PDL.md lists the 1N4007 rectifier and 1N5819
Schottky beside the 1N4148, and their shared axial-diode PAINTER.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`spdt` maps a common pole `c` and throws `a` and `b`: two resistors, one
closed and one open, swapped by a single alterable `position` (0 for a,
1 for b), so a `physics.position` rule throws it mid-run. PDL.md lists
it and the slide_switch_spdt part.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`ledArray` is any number of LED dies on one cathode: every mapped role
but `k` is a die from its pin to the cathode, measured like a single
LED, and another `k…` role is a second cathode pin tied inside. `is`
and `n` set the dies' model; red by default. PDL.md documents it and
lists the seven_segment part.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A CONFIGURATION <property> "<option>" block starts one configuration of a
part picked by an enum property: the transistor that is NPN, PNP or a
MOSFET by its Type. Lines before the first block are shared; each block
is read as the shared lines followed by its own, so it adds pins, rules
and parameters, and its single-value directives replace shared ones.
Other blocks' lines are blanked rather than removed, so diagnostics keep
their real line numbers, and a problem on a shared line is reported once.

Each configuration parses to a complete PartDefinition with an ID of its
own and a PartConfiguration naming the part, the property and its
option; the property defaults to that option on it. PdlParseResult gains
definitions, every configuration in option order, with definition the
default one. The parser rejects a block without an ID, an option without
a block, a block for no option, and a non-enum choosing property.

PDL.md documents it, and lists the shipped transistor as one part.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@burhankhanzada
burhankhanzada merged commit 5ae4cef into main Oct 1, 2026
3 checks passed
@burhankhanzada
burhankhanzada deleted the feat/painter-directive branch October 1, 2026 15:20
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant