Every row and column starts on its own coin flip and then alternates — and the regions that fall out are the pattern.
One coin per line
Hitomezashi — one-stitch sashiko — is a Japanese running-stitch embroidery in which
horizontal and vertical lines of dashes are offset from one another. The rule is as
simple as embroidery gets:
hor[i][0] = rng.NextDouble() < 0.5;
vert[i][0] = rng.NextDouble() < 0.5;
for (var j = 1; j <= GridSize; j++)
{
hor[i][j] = !hor[i][j - 1];
vert[i][j] = !vert[i][j - 1];
}
One coin flip per row and one per column, deciding only the phase — whether that
line starts with a stitch or with a gap. Everything after that alternates
deterministically. Sixteen rows and sixteen columns is thirty-two bits of randomness
in the entire piece.
The horizontal family alone. Each row is a dashed line; the only difference between
rows is where the dashes begin.
Both families. The vertical lines are generated by the same rule with their own coins,
and the two grids know nothing about each other — there is no rule connecting a row’s
phase to a column’s.
Where the pattern comes from
What makes hitomezashi interesting is that those thirty-two independent bits produce
large connected regions with elaborate boundaries. Nothing in the rule mentions
regions, closure or shape.
The mechanism is parity. Walk across a row of cells and flip a marker every time you
cross a vertical stitch:
if (hor[y][0]) mark0 = !mark0;
var mark = mark0;
for (var x = 0; x < GridSize; x++)
{
…
if (vert[x + 1][y]) mark = !mark;
}
Each cell ends up with a two-colour label that depends on the parity of how many
stitches lie between it and the edge. Cells with the same label form connected
regions, and the region boundaries are exactly where the stitching sits.
This is the same structure that makes hitomezashi patterns a recreational-mathematics
subject: the regions have been studied as a percolation model, and the distribution
of their sizes is not obvious from the rule at all.
Hatching applied to the first rows. The two parities get different motifs — one drawn
by DrawHatch1, the other by DrawHatch2 — so the labelling becomes visible.
Fully hatched, with the stitch grid still shown over it.
The stitches are not drawn
DrawStitches is 0 in every rendering. The stitch grid that generated all of this
never appears in the finished piece — only the hatched regions it defined.
That is the whole trick of the composition. The construction is a grid of straight
dashes; the result reads as an irregular mosaic of interlocking shapes, and the
straight lines that produced it are nowhere to be seen.
The hatch motifs
Each motif is a set of NumHatches chevrons, whose arms grow to the cell midpoint and
then shrink again:
var d = i / (float)(NumHatches + 1) * cell;
if (i <= NumHatches / 2) { … arms of length d … }
else { … arms of length cell − d … }
So a hatched cell reads as a diamond of nested Vs rather than as flat tone, and the
two motifs are mirror images. Where a region is several cells wide the chevrons line
up across cell boundaries into longer runs — a second-order Truchet effect on top of
the parity one.
Six renderings
| Rendering | Grid | Hatches | Ink |
|---|
| Zen Ice | 15 | 5 | cyan on black |
| Zen Magenta | 20 | 7 | magenta on near-black |
| Zen Yellow | 12 | 4 | chartreuse on dark |
| Zen Grain | 24 | 8 | mint on black |
| Zen Dusk | 14 | 5, / only | violet on near-black |
| Gallery | 15 | 5 | cyan on black, gallery framed |
GridSize sets the scale: 12 gives large, bold regions; 24 collapses them into a
fine-textured field. NumHatches trades the mosaic reading against the interior
texture — denser hatches bring each cell closer to a solid patch of tone. Zen Dusk
uses only one hatch family (DrawHatches2 = 0), leaving every other region empty.
Those empty cells make negative space a structural element rather than merely a
background.
Determinism
SeededRandom — the project’s stable Xoshiro256StarStar — is seeded from the preset
and consumed twice per line, up front, before anything is drawn. Everything after that
is parity arithmetic.