Field notes
The cloth is a program the hand runs once.
१ Tapestry, not brocade
Paithani figures are woven in tapestry: the colour of a figure is the weft itself, laid in by hand, a separate small bobbin for each patch of colour in a row. Where two colours meet, the weavers can interlock the wefts (kadiyal), so the back is almost as clean as the front. That makes every design a counting problem. A peacock in four colours on a zari ground is not one pass of the shuttle but dozens of short passes, every row.
२ What the compiler counts
For each pick (row) it run-length encodes the weft: runs = bobbins. It also counts joins between runs, single-end runs that are fragile under the beater, and boundaries that stay at the same end for six or more picks (the places a simple split tapestry would open a slit). The effort index is an illustrative model: a plain pick costs 1, and each extra bobbin adds 0.5. It is an assumption for comparing designs, not a measurement of anyone's labour.
३ The optimiser
For one pick with design colours c₁…cₙ we choose thread labels ℓ₁…ℓₙ minimising Σ ΔE(cᵢ,ℓᵢ) + λ·#changes + μ·Σ[upright break]. ΔE is CIELAB distance with a penalty for swapping silk and metal. This is a 1-D Potts model; a dynamic program over position × label solves it exactly in O(n·K). Picks are solved top to bottom, each conditioned on the one above. The brute-force check in the test suite agrees with it on random rows.
४ Why the silk turns
The renderer resolves every cell into plain-weave interlacement. Warp threads run lengthwise, weft threads across, and each gets a cylindrical profile and Kajiya–Kay anisotropic highlights along its own direction. When warp and weft are different colours, the highlight passes from one set of threads to the other as the lamp or your view moves. That is how shot silk shifts colour in real cloth, and here it is computed rather than painted. Zari takes a sharper, metal-tinted highlight.
One cell here stands for a bundle of threads; a real sari has thousands of ends and takes weeks to months to weave. The colour names follow the traditional Paithani vocabulary (aboli, firozi, kalichandrakala, morpankhi, motia, neeligunji, pophali, sankirodak, uddani, vangi); the shades are this project's interpretation. All motifs are original geometric drawings. Nothing here is a reproduction of any particular sari, weaver or workshop.