Getting started with weaveDraft

What a WIF file holds

Weaving software saves a draft as a WIF text file. It lists which shaft each warp end passes through (the threading) and which shafts rise on each weft pick, either directly (a liftplan) or through treadles (a tie-up plus a treadling). From these, weaveDraft rebuilds the drawdown: a binary matrix with one row per pick and one column per warp end, where 1 means the warp end is up on the fabric face.

Load a draft

f <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft")
twill <- weave_draft_from_wif(f)
twill
#> <weave_draft> twill_2_2
#>   24 weft picks x 24 warp ends
#>   source: WIF (tieup_treadling) | colours: yes
plot(twill)

Structural descriptors

weave_metrics(twill)
#>        name     draft_style shafts picks ends repeat_picks repeat_ends
#> 1 twill_2_2 tieup_treadling      4    24   24            4           4
#>   mean_warp_float mean_weft_float max_warp_float max_weft_float interlace_warp
#> 1            1.92            1.92              2              2            0.5
#>   interlace_weft interlace_both float_ratio
#> 1            0.5            0.5           1

Structure versus colour

Some patterns live entirely in the thread colours. The bundled gingham draft is a plain weave, structurally the simplest cloth possible, yet it shows a clear check pattern.

g <- weave_draft_from_wif(system.file("extdata", "gingham_plain.wif",
                                      package = "weaveDraft"))
weave_metrics(g)[, c("interlace_both", "mean_warp_float", "repeat_picks")]
#>   interlace_both mean_warp_float repeat_picks
#> 1              1               1            2
plot(g)                    # the structure: a plain weave

plot(g, type = "fabric")   # the structure seen through its colours

color_runs(g, "warp")
#>   start end length     hex index
#> 1     1   8      8 #C81E28     2
#> 2     9  16      8 #FFFFFF     1
#> 3    17  24      8 #C81E28     2
#> 4    25  32      8 #FFFFFF     1
#> 5    33  40      8 #C81E28     2

Structural metrics alone describe the first picture; colour sequences describe the second. For colour-and-weave textiles, report both.

Two encodings, one check

Many files store both a liftplan and a tie-up with treadling. check_wif_consistency() rebuilds the drawdown from each and compares them:

check_wif_consistency(read_wif(system.file("extdata", "gingham_plain.wif",
                                           package = "weaveDraft")))
#> $comparable
#> [1] TRUE
#> 
#> $consistent
#> [1] TRUE
#> 
#> $n_mismatch_picks
#> [1] 0

Your own drawdown

Any 0/1 matrix can be analysed:

satin <- outer(0:9, 0:9, function(i, j) as.integer((j - 2 * i) %% 5 == 0))
s <- as_weave_draft(satin, meta = list(name = "5-end satin"))
weave_metrics(s)[, c("mean_warp_float", "mean_weft_float", "interlace_both")]
#>   mean_warp_float mean_weft_float interlace_both
#> 1               1        3.076923            0.4