Reading the loom
- Top grid - the threading: one row per shaft (1 at the bottom). Each dot is a warp thread tied to that shaft. Gold rows are the shafts lifted by the current pick.
- warp - the colour of every thread.
- shed - threads lifted for this pick sit up, the rest sink down; the shuttle pulls the weft through, over the sunk threads and under the raised ones.
- float - with
maxfloat: how long each thread has stayed up or down. - Cloth - woven rows so far, top to bottom. Click a row to jump to when it was woven.
- lifts - each row's lifted shafts (gold) beside its weft colour.
Gallery
Original cloths, each written in LOOM. Click one to open it in the Studio and watch it being woven. The files live in gallery/.
Conformance
The 15 reference programs from conformance/ are run right here, in this page, by the same engine as cli.js, and compared character for character with their expected output.
How LOOM works
You do not need to know anything about weaving. Here is the whole idea in a minute.
1. A loom holds threads
Long warp threads hang side by side, each with a colour. Every warp thread is also tied to one of up to eight shafts (numbered 1–8): frames that can lift many threads at once. Which thread goes to which shaft is called the threading.
The loom is W columns wide and will weave H rows.
2. A pick weaves one row
To weave a row you lift some shafts, then send a weft thread across. Lifted warp threads stay on top and show their own colour; the rest sink below the weft, so the weft colour shows there.
Row by row, the pattern of lifts draws the cloth. The finished cloth is a grid of colours: that grid is what a program prints.
Reading the Loom view
warp): the colour of each thread, left to right.shed): threads lifted for this pick rise, the others sink, and the shuttle slides the weft through the gap — over the sunk threads, under the raised ones.float, only when maxfloat is on): how many picks in a row each thread has stayed up or down. Amber means at the limit, red means over it.lifts, right): for every row, which shafts were lifted, next to a swatch of the weft colour.The language
One statement per line. // starts a comment. Colours are single lowercase letters. The first statement must be loom.
| Statement | What it does |
|---|---|
loom 12 8 | 12 columns (warp threads), 8 rows (picks). Each 1–200. Must be first. |
palette a=#1b3a5c b=#f2e8cf | Names colours. Only the letters appear in the output; the hex values are for looking at. |
warp a b | Colours of the warp threads, repeated across the width. |
thread 1-4 | Shaft of each warp thread, repeated across the width. Ranges: 1-4 is 1 2 3 4, 4-2 is 4 3 2. |
treadle 1 12 | Saves a lift under a number (1–10) so picks can say t1. |
shuttle r o y | Loads weft colours that picks use in turn when they name no colour. |
pick b 13 pick t2 | Weave a row: weft colour (optional) and lift. With no colour the next shuttle colour is used. |
cross 1 6 | Swap two warp threads (colour and shaft) from now on. |
drift 2 drift -1 | Slide every warp thread that many places right (or left), wrapping round. |
maxfloat 3 | From now on, a thread may not stay up or down for more than 3 rows in a row (nor more than 3 neighbours in one row). |
repeat 4 { … } | Run the lines in between several times. May nest. |
Sequences
Used by warp, thread and shuttle.
a b c | a b c |
a*3 | a a a |
(a b)*2 | a b a b |
mirror(a b c) | a b c b a |
1-4 (shafts) | 1 2 3 4 |
Lifts
Used by pick and treadle.
13 | shafts 1 and 3 |
- | none (all sunk) |
* | all eight shafts |
!12 | everything except 1 and 2 |
t2 | whatever treadle 2 holds (picks only) |
Try it
When something is wrong
A program either weaves a cloth or stops at its first mistake with one line, error line 7: unknown color 'q'. Studio shows that line, marks it in the editor, and says what usually causes it.
| Message | Usually means |
|---|
Keyboard
Ctrl+Enter weave · Space play / pause · ← → step back / forward · Home End first / last step · Tab indent (in the editor; Esc then Tab leaves it)
The command line: node cli.js cloth.loom prints the same grid this page renders.