LOOM Studio

LOOM is a tiny language for woven cloth. Set up warp threads, hook each onto a shaft, then throw weft picks one row at a time. Edit the program on the left; the cloth appears on the right.

ready
Runs as you type · Ctrl+Enter run · ← → step when the Weave tab is focused
lifted shafts ▲ raised warp: shows the warp colour lowered warp: the weft passes over it float counters (red = over the limit)

Fabric

The 15 reference programs, run live in this page by the same engine as cli.js, compared character for character with their expected output.

What you are looking at

A loom holds a row of lengthwise warp threads (the columns). Each warp thread is hooked onto one of eight shafts. To weave a row (a pick), some shafts are lifted: every warp thread on a lifted shaft rises, the rest stay down, and the shuttle carries a crosswise weft thread through the gap. Where the warp is raised you see the warp colour; where it is lowered, the weft covers it.

A LOOM program describes this setup and the sequence of picks. Its output is a grid of colour letters, one letter per crossing, drawn here with the palette's colours. Rows not yet woven print as ..

The Weave & debug tab

The top band is the threading: eight rows, one per shaft, with a square in each column showing which shaft that warp thread hangs on. On a pick, the lifted shafts glow yellow and ▲ marks the warp threads that rise. Below is the cloth: woven rows, then bare warp threads waiting. The shuttle crosses the current row. The bars at the bottom count how many rows in a row each column has stayed up or down (its float). Step through one statement at a time; the editor highlights the line being run.

Statements

loom W HFirst line. W warp threads (columns) by H picks (rows), each 1–200.
palette k=#rrggbb …Name colours with single letters a–z.
warp <colours>Colour every warp thread; the sequence repeats across the width.
thread <shafts>Hook each column onto a shaft 1–8, e.g. thread 1-4 or thread mirror(1-4).
treadle N <lift>Save a lift as treadle N (1–10), used as tN.
shuttle <colours>A cycle of weft colours used by picks that name none.
pick [colour] <lift>Weave one row.
cross I JSwap the warp threads in columns I and J (colour and shaft).
drift N / drift -NRotate every warp thread N places right (or left).
maxfloat NFrom now on, stop with an error if any thread floats over more than N crossings.
repeat N { … }Repeat the enclosed lines N times (1–1000). Blocks nest.

Lifts

13 lifts shafts 1 and 3 · - lifts none · * lifts all · !12 lifts all except 1 and 2 · t2 uses treadle 2.

Sequences

a*3 repeats an item · (a b)*2 repeats a group · mirror(a b c) gives a b c b a · in threading, 1-4 is 1 2 3 4 and 4-1 counts down.

Errors

The first problem stops the program with one line such as error line 7: loom full. The editor marks that line; click the red bar to jump to it.

Comments start with //. The full rules are in LOOM_SPEC.md.