LOOM Studio

a tiny programming language that weaves cloth

Ctrl+Enter
Text output (exactly what node cli.js prints)

    
How to read the loom. Each vertical warp thread hangs on one of 8 shafts (grid on top). Each row, a pick, lifts some shafts (grid on the right): lifted threads show their colour, and the shuttle lays the weft colour everywhere else.

LOOM in two minutes

A LOOM program sets up a loom and then weaves it one row at a time. The result is a grid of colour letters, the fabric.

  1. Warp. W vertical threads, one per column. Each has a colour and hangs on one of 8 shafts.
  2. Pick. Each row lifts a set of shafts. Columns whose shaft is lifted are raised and show the warp colour; the others show the weft colour thrown across.
  3. Floats. A run of the same raised/lowered state is a float. Long floats make weak cloth, so maxfloat can forbid them.

Statements

loom W HFirst line. W columns, H rows (1–200).
palette k=#rrggbb …Name colours with single letters.
warp <colours>Colour of every column; the sequence repeats across.
thread <shafts>Shaft of every column (1–8); ranges like 1-4 allowed.
treadle N <lift>Remember a lift as treadle N (1–10).
shuttle <colours>Weft colours that cycle for picks with no colour.
pick [colour] <lift>Weave one row.
cross I JSwap the warp threads in columns I and J.
drift N / drift -NRotate all warp threads right / left.
maxfloat NFrom now on, no float may be longer than N.
repeat N { … }Repeat the enclosed lines N times (1–1000).

Sequences

a b cone after another
a*3a a a
(a b)*2a b a b
mirror(a b c)a b c b a
1-4, 4-21 2 3 4, 4 3 2 (shafts only)

Lifts

13shafts 1 and 3
- / *no shafts / all shafts
!12every shaft except 1 and 2
t2whatever treadle 2 lifts (in pick)

Reading the draft

The Loom tab draws a classic weaving draft: the threading on top (one mark per column, on its shaft; shaft 1 is the bottom row), the lift plan on the right (one row per pick, a mark for each lifted shaft, then the weft colour), and the drawdown — the cloth — in the middle.

Errors

The first problem stops the program with a single line such as error line 5: unknown color 'q'. Structural problems (a missing loom header, unbalanced { }) are found before anything runs; everything else is found when its line runs.

Full details: LOOM_SPEC.md next to this file.