Each column is a warp thread, each row a pick. Gold marks what the current pick raises: raised threads show their own color, the weft hides the rest.
Gallery
Twelve pieces of cloth written in LOOM. Click one to open it in the editor and watch it being woven.
Conformance
The spec's example programs, run live in this page by the same engine as cli.js, compared character for character with their expected output.
How LOOM works
On a real loom, warp threads are stretched lengthwise and a weft thread is thrown across them one row at a time. Each row is a pick. Before every pick some warp threads are lifted: those raised threads show on top in that row, and the weft covers everything else. Choosing which threads rise on each pick is what makes twills, diamonds and checks.
Shafts and threading
Every warp thread hangs on one of eight shafts. A pick lifts a set of shafts, and every thread on a lifted shaft rises. So the threading (which shaft each thread is on) plus the sequence of lifts decides the pattern.
Reading the loom view
- Top grid: the threading, one mark per warp thread on its shaft's row (shaft 1 is nearest the cloth).
- Top right: the shafts. Gold ones are lifted by the current pick.
- Right column: the lift plan, the shafts lifted for every row.
- Left column: each row's weft color.
- Middle: the cloth. Row 1 is the first pick; bare warp waits below.
The statements
loom 32 24 | Always first: 32 warp threads (columns) and room for 24 picks (rows), each 1-200. |
palette a=#1b3a5c b=#f2e8cf | Names colors with single letters. The cloth is printed with these letters. |
warp a b | Colors of the warp threads, left to right, repeated across the width. |
thread 1-4 | The shaft of each warp thread, repeated across (here 1 2 3 4 1 2 3 4 ...). |
treadle 1 12 | Names a lift: treadle 1 raises shafts 1 and 2. Up to ten treadles. |
pick b t1 | Weaves one row with weft color b, lifting treadle 1. |
pick b 13 | Lifts written directly: 13 = shafts 1 and 3, * = all, - = none, !12 = all but 1 and 2. |
shuttle r o y | A cycle of weft colors used by picks that give no color, as in pick t1. |
repeat 4 { ... } | Runs the lines in between 4 times. Blocks can nest. |
cross 3 7 | Swaps two warp threads (color and shaft) from now on. |
drift 2, drift -1 | Slides every warp thread right (or left), wrapping around the edge. |
maxfloat 3 | From now on, stop with an error if any thread floats over more than 3 others without interlacing. |
// note | A comment, ignored to the end of the line. |
Sequences
Wherever a list of colors or shafts is expected you can use: a*3 (a a a), (a b)*2 (a b a b), mirror(a b c) (a b c b a), and in threading, ranges like 1-4 (1 2 3 4) or 4-1 (4 3 2 1).
Errors
The first mistake stops the program, which then prints a single line such as error line 7: loom full. The Studio highlights that line in the editor.
Keys
Ctrl+Enter weaves. Outside the editor, ← → step through the program, Space plays or pauses, and Home / End jump to the start or the end.
The full definition of the language is LOOM_SPEC.md. This page and node cli.js program.loom share one interpreter, loom.js.