# Splinterfields: Mathematickal Arts #2

For my contribution to the Mathematickal Arts workshop, I wanted to explore weaving, specifically plain weave. This is the simplest form of weaving, but when combined with sequences of colour it can produce many different types of pattern. Some of these patterns when combined with muted colours, have in the past been used as a type of camouflage – and are classified into District Checks for use in hunting in Lowland Scotland. This is, I guess, a kind of less prestigious form of Tartan.

I started off by trying to understand how the patterns emerge, beginning with the basic structure: The threads running top to bottom are the warp, those running across are the weft. If we consider the top most thread as visible, we can figure out the colours of this small section of weave. A few lines of scheme calculate and print the colours of an arbitrarily sized weave, by using lists of warp and weft as input.

```; return warp or weft, dependant on the position
(define (stitch x y warp weft)
(if (eq? (modulo x 2)
(modulo y 2))
warp weft))

; prints out a weaving
(define (weave warp weft)
(for ((x (in-range 0 (length weft))))
(for ((y (in-range 0 (length warp))))
(display (stitch x y
(list-ref warp y)
(list-ref weft x))))
(newline)))
```

I’ve been visualising the weaves with single characters representing colours for ascii previewing, here are some examples:

```(weave '(O O O O O O O) '(: : : : : : : : :))
=>
O : O : O : O
: O : O : O :
O : O : O : O
: O : O : O :
O : O : O : O
: O : O : O :
O : O : O : O
: O : O : O :
O : O : O : O

(weave '(O O : : O O : : O O) '(O : : O O : : O O :))
=>
: O : : : O : : : O
O : : : O : : : O :
O O O : O O O : O O
O O : O O O : O O O
: O : : : O : : : O
O : : : O : : : O :
O O O : O O O : O O
O O : O O O : O O O
: O : : : O : : : O
```

This looked quite promising as ascii art, but I didn’t really know how it would translate into a textile. I also wanted to look into ways of generating new patterns algorithmically, using formal grammars – this was actually one of the simpler parts of the project. The idea is that you begin with an axiom, or starting state, and do a search replace on it repeatedly following one or more simple rules:

```Axiom: O
Rule: O -> :O:O

Generation 1: O
Generation 2: :O:O
Generation 3: ::O:O::O:O
Generation 4: :::O:O::O:O:::O:O::O:O
```

We can then generate quite complex patterns for the warp and the weft from very small instructions, next I’ll show what happens when some of these are translated into real woven fabric…