Skip to main content

Module scale

Module scale 

Source
Expand description

An Nร—N scale-test scene: a sheet wrapping a square grid of identical Add blocks, fully wired, with no pin left dangling.

cargo xtask autogen scale N out.json serializes what this builds, and the editorโ€™s test fixtures lower the same Document in-process, so the file on disk and the scene under test are one scene.

Structsยง

GridPins ๐Ÿ”’
The four pins every grid block carries: two west inputs, two east outputs. Named once so the wiring and the emitter cannot disagree about which is which.
PinSpec ๐Ÿ”’
A pin to create. slot places it on its block-as-child; body places the same pin inside the blockโ€™s own interior view, where the scope draws it as a free-standing port. The two are independent, and the default body is the trap: every boundary port left at it stacks at the origin, and the wires anchored there start from inside whatever block sits over that spot.
Scale ๐Ÿ”’
Every id the grid uses, minted in the order the file numbers them: the sheet, then the grid blocks row-major; the sheetโ€™s boundary ports, then each grid blockโ€™s four.

Constantsยง

BLOCK ๐Ÿ”’
Grid spacing in grid units: each block is BLOCK wide/tall and columns/rows are placed on a PITCH lattice, leaving a gap for wires to route through.
MARGIN ๐Ÿ”’
PITCH ๐Ÿ”’
PORT_H ๐Ÿ”’
PORT_W ๐Ÿ”’
A boundary port body, in cells. Wide enough for its name, two cells tall so the anchor (one cell down from the top) sits inside it.

Functionsยง

build_scale
The Nร—N scene as a folded document.
cells ๐Ÿ”’
east ๐Ÿ”’
port ๐Ÿ”’
port_body ๐Ÿ”’
A boundary portโ€™s body, on the sheetโ€™s west or east margin and level with the grid row it serves, so its wire leaves along that row instead of crossing the sheet to reach it.
title ๐Ÿ”’
west ๐Ÿ”’
wiring ๐Ÿ”’
Every wire, as the pins it joins. The scheme leaves no pin dangling: