Skip to main content

Layout, naming and replication

12. Layout Combinators​

Stacking​

PrimitiveDescription
hstack(r1 r2 ...)Keep r1 where it is and put each next region against the right (east) edge of the one before; each region keeps its own y
vstack(r1 r2 ...)Stack regions along +Y; the first is lowest, and each region keeps its own x
stack(DIR r1 r2 ...)hstack for HORIZONTAL, vstack for VERTICAL
union(r1 r2 ...)Merge regions at their absolute positions
hstack(send compute recv) (* three tiles in a row *)
vstack(bottom middle top) (* three tiles in a column, bottom first *)

Placement​

place(r dx dy) (* translate region by (dx, dy) *)
place(r dx dy R90) (* translate and rotate *)

place is additive — successive calls accumulate offsets.

Flipping and rotation​

PrimitiveDescription
hflip(r)Mirror left to right inside its bounding box
vflip(r)Mirror along y inside its bounding box
rotate(r R0)No rotation
rotate(r R90)90° counter-clockwise: +X turns into +Y
rotate(r R180)180°
rotate(r R270)270° counter-clockwise: +X turns into −Y
mirror(r 0)Mirror horizontally
mirror(r 1)Mirror vertically

Rotation, flips and mirrors turn the route rules painted inside the region with its tiles: [C>R] rotated by R90 becomes [C>U], and under hflip it becomes [C>L]. Kernels and colors do not change.


13. Naming​

region : name('my_name)

Names are critical for:

  • Referencing regions in transports: 'sender.tx
  • Accessing memory via miget/miset: miget symbol=my_name.array ...
  • Identifying tiles in debug output

Important: Apply name() after terminal(). Before or after code() gives the same image.

Name every region whose memory you read. Two code regions without names put the same symbol name in the map twice, such as a at (0, 0) and a at (1, 0). miget symbol=a then reads only the first, and warns symbol [a] has 2 exact map matches; using first entry.


14. Replication​

rep​

rep(r 'dim count dx dy)

Replicates region r count times with step (dx, dy). The dimension is named 'dim for use with miget/link order arguments.

let row = rep(tile() 'x 8 1 0) (* 8 tiles, +1 in x *)
let col = rep(tile() 'y 4 0 1) (* 4 tiles, +1 in y *)

A dimension may step in both axes, such as rep(tile() 'diagonal 3 4 1). Its tiles occupy the generated coordinates, not every point in the enclosing rectangle. Overlap checks use those actual tile coordinates. Paint does not yet place such copies correctly: it puts their kernels at the starting y, (0, 0), (4, 0) and (8, 0) in this example, while the overlap check uses the diagonal, and it gives no message. Use diagplace(r count dx dy) for a diagonal.

hstackrep / vstackrep​

hstackrep(r count) (* replicate horizontally *)
hstackrep(r count space) (* with spacing *)
hstackrep(r count space 'dim) (* with spacing and named dim *)

vstackrep(r count) (* replicate vertically *)
stackrep(r 'dim DIR count) (* along HORIZONTAL or VERTICAL, named dim *)

Passing 0 for count is legal — produces an empty region (useful for conditional inclusion).

arrayplace​

arrayplace(r [y0 y1 y2 ...])

Places copies of r at the given Y offsets, naming each copy x0, x1, etc.

Optional geo-variable binding:

arrayplace(r offsets [varname:values_array])

diagplace / diagarrayplace​

diagplace(r count dx dy) (* diagonal replication *)
diagarrayplace(r dx [y0 y1 ...]) (* diagonal with y-offset array *)