| Title: | Structural Analysis of Woven Textile Drafts from WIF Files |
|---|---|
| Description: | Imports weaving drafts stored in the Weaving Information File (WIF) interchange format, reconstructs the binary warp and weft drawdown from either a liftplan or a tie-up with treadling, and computes structural descriptors of the cloth: float length distributions, interlacement frequency, weave repeat size, a directional float ratio, and thread colour sequences. A flat-colour simulation of the fabric face helps to separate patterns carried by the interlacement structure from patterns carried by the thread colours. Intended for computational analysis and documentation of handloom and other multi-shaft textiles. |
| Authors: | Mark Joshua R. Secretario [aut, cre] |
| Maintainer: | Mark Joshua R. Secretario <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-11-08 20:51:20 UTC |
| Source: | https://github.com/cran/weaveDraft |
Wraps a binary drawdown matrix (and optional colour information) in an
object of class "weave_draft" that the analysis and plotting
functions of this package accept.
as_weave_draft(drawdown, meta = list(), colors = NULL)as_weave_draft(drawdown, meta = list(), colors = NULL)
drawdown |
A numeric or logical matrix with only 0/1 (or
|
meta |
A named list of metadata, e.g. |
colors |
|
An object of class "weave_draft".
plain <- outer(1:4, 1:4, function(i, j) (i + j) %% 2) draft <- as_weave_draft(plain, meta = list(name = "plain weave")) draftplain <- outer(1:4, 1:4, function(i, j) (i + j) %% 2) draft <- as_weave_draft(plain, meta = list(name = "plain weave")) draft
Many WIF files store both a liftplan and a tie-up/treadling pair. This rebuilds the drawdown from each and compares them, which is a useful data quality check before analysis.
check_wif_consistency(wif)check_wif_consistency(wif)
wif |
An object from |
A list with comparable (FALSE if the file has only
one encoding), consistent (TRUE/FALSE, or NA
if not comparable), and n_mismatch_picks, the number of picks
whose rows differ.
f <- system.file("extdata", "gingham_plain.wif", package = "weaveDraft") check_wif_consistency(read_wif(f))f <- system.file("extdata", "gingham_plain.wif", package = "weaveDraft") check_wif_consistency(read_wif(f))
Many traditional patterns, including colour-and-weave designs on a plain weave structure, live in the thread colours rather than in the interlacement. This function summarises the colour sequence of the warp (or weft) as runs of identical colours.
color_runs(draft, direction = c("warp", "weft"))color_runs(draft, direction = c("warp", "weft"))
draft |
A |
direction |
|
A data frame with one row per run: start and end
(thread numbers), length, hex (the colour), and
index (its palette index when the colour is in the palette, else
NA).
f <- system.file("extdata", "gingham_plain.wif", package = "weaveDraft") color_runs(weave_draft_from_wif(f), "warp")f <- system.file("extdata", "gingham_plain.wif", package = "weaveDraft") color_runs(weave_draft_from_wif(f), "warp")
Reconstructs the binary warp/weft interlacement matrix of a treadle-loom
draft. Warp end is "up" (value 1, warp visible on the face) on
pick when at least one of the shafts it is threaded through is
raised by a treadle pressed on that pick. Internally this is the matrix
product of the treadling, tie-up and threading indicator matrices.
compute_drawdown( threading, treadling, tieup, n_shafts = NULL, rising_shed = TRUE )compute_drawdown( threading, treadling, tieup, n_shafts = NULL, rising_shed = TRUE )
threading |
Integer vector (one shaft per warp end) or a list of integer vectors (several shafts per end allowed). Zero denotes an inactive entry. |
treadling |
Integer vector (one treadle per pick) or a list of integer vectors (several treadles per pick allowed). Treadle numbers below 1 mean "no treadle". |
tieup |
A list in which element |
n_shafts |
Optional number of shafts. Defaults to the largest shaft
number found in |
rising_shed |
Logical; |
For a sinking-shed loom (rising_shed = FALSE) the listed shafts are
the ones that sink, so the result is inverted.
An integer matrix with one row per weft pick and one column per warp end; 1 means warp up (on the face), 0 means weft on the face.
# Plain weave: two shafts, two treadles compute_drawdown( threading = rep(1:2, 4), treadling = rep(1:2, 4), tieup = list(1L, 2L) )# Plain weave: two shafts, two treadles compute_drawdown( threading = rep(1:2, 4), treadling = rep(1:2, 4), tieup = list(1L, 2L) )
Same as compute_drawdown for dobby-style drafts, where each
pick directly lists the shafts raised (no tie-up or treadles).
compute_drawdown_liftplan( threading, liftplan, n_shafts = NULL, rising_shed = TRUE )compute_drawdown_liftplan( threading, liftplan, n_shafts = NULL, rising_shed = TRUE )
threading |
Integer vector (one shaft per warp end) or a list of integer vectors. |
liftplan |
A list with one integer vector per pick, giving the shafts
raised on that pick ( |
n_shafts |
Optional number of shafts. Defaults to the largest shaft
number found in |
rising_shed |
Logical; |
An integer matrix, rows = weft picks, columns = warp ends.
compute_drawdown_liftplan( threading = c(1, 2, 3, 4), liftplan = list(c(1, 2), c(2, 3), c(3, 4), c(4, 1)) )compute_drawdown_liftplan( threading = c(1, 2, 3, 4), liftplan = list(c(1, 2), c(2, 3), c(3, 4), c(4, 1)) )
Mean warp float length divided by mean weft float length: a lightweight indicator of structural directionality. Values near 1 indicate a balanced structure; values far from 1 indicate warp- or weft-dominated floats. It describes the drawing only and is not a measured mechanical property.
directional_float_ratio(draft, side = c("face", "back", "both"))directional_float_ratio(draft, side = c("face", "back", "both"))
draft |
A |
side |
|
A number, or NA if either mean float length is undefined.
f <- system.file("extdata", "diamond_liftplan.wif", package = "weaveDraft") directional_float_ratio(weave_draft_from_wif(f))f <- system.file("extdata", "diamond_liftplan.wif", package = "weaveDraft") directional_float_ratio(weave_draft_from_wif(f))
Counts how many consecutive threads each thread passes over.
float_lengths(draft, side = c("face", "back", "both"))float_lengths(draft, side = c("face", "back", "both"))
draft |
A |
side |
One of |
A warp float is a run of consecutive picks over which one warp end stays up (a run of 1s down a column of the drawdown). A weft float is a run of consecutive warp ends over which one weft pick stays on the face (a run of 0s along a row). A length of 1 is a plain interlacement; longer floats give a looser, more lustrous, more snag-prone structure.
The side argument chooses which fabric side is described. On the
"face" (default), warp floats are runs of 1s and weft floats are
runs of 0s. On the "back" the roles of 0 and 1 swap. With
"both" the runs of both values are pooled for each direction.
Floats are counted within the drawing only; no wrap-around is assumed at the edges.
A list with integer vectors warp and weft, the
float lengths pooled over all warp ends and all picks respectively.
f <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft") d <- weave_draft_from_wif(f) table(float_lengths(d)$warp)f <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft") d <- weave_draft_from_wif(f) table(float_lengths(d)$warp)
Mean and maximum float length
mean_float_length( draft, direction = c("warp", "weft"), side = c("face", "back", "both") ) max_float_length( draft, direction = c("warp", "weft"), side = c("face", "back", "both") )mean_float_length( draft, direction = c("warp", "weft"), side = c("face", "back", "both") ) max_float_length( draft, direction = c("warp", "weft"), side = c("face", "back", "both") )
draft |
A |
direction |
|
side |
|
A single number, or NA if the draft has no floats of that
kind (for example, no warp floats on the face of an all-zero drawdown).
f <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft") d <- weave_draft_from_wif(f) mean_float_length(d, "warp") max_float_length(d, "weft")f <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft") d <- weave_draft_from_wif(f) mean_float_length(d, "warp") max_float_length(d, "weft")
The fraction of adjacent cell pairs in which the drawdown changes between warp-up and weft-up. A plain weave interlaces at every opportunity (1); long-float structures such as satins score low. This is a common proxy for how tightly a fabric is bound.
interlacement_frequency(draft, direction = c("warp", "weft", "both"))interlacement_frequency(draft, direction = c("warp", "weft", "both"))
draft |
A |
direction |
|
A number between 0 and 1, or NA if the draft is too small
for the requested direction (fewer than 2 picks or ends).
f <- system.file("extdata", "gingham_plain.wif", package = "weaveDraft") interlacement_frequency(weave_draft_from_wif(f), "both")f <- system.file("extdata", "gingham_plain.wif", package = "weaveDraft") interlacement_frequency(weave_draft_from_wif(f), "both")
Draws either the binary drawdown (black = warp up) or, for drafts that carry colour information, a simulated fabric face (warp colour where the warp is up, weft colour elsewhere). The simulation is flat colour only; it ignores yarn thickness and thread spacing.
## S3 method for class 'weave_draft' plot( x, type = c("drawdown", "fabric"), pick_origin = c("top", "bottom"), end_origin = c("left", "right"), main = NULL, ... )## S3 method for class 'weave_draft' plot( x, type = c("drawdown", "fabric"), pick_origin = c("top", "bottom"), end_origin = c("left", "right"), main = NULL, ... )
x |
A |
type |
|
pick_origin |
Where pick 1 is drawn: |
end_origin |
Where warp end 1 is drawn: |
main |
Plot title; defaults to the draft name. |
... |
Currently unused. |
By default pick 1 is at the top and warp end 1 at the left. Weaving
software often draws the drawdown with pick 1 at the bottom and/or end 1
at the right; use pick_origin and end_origin to match it.
Axis labels always show the original pick and end numbers.
x, invisibly.
f <- system.file("extdata", "gingham_plain.wif", package = "weaveDraft") d <- weave_draft_from_wif(f) plot(d) plot(d, type = "fabric")f <- system.file("extdata", "gingham_plain.wif", package = "weaveDraft") d <- weave_draft_from_wif(f) plot(d) plot(d, type = "fabric")
Parses a ‘.wif’ file, the open, text-based, INI-style weaving interchange format written by WeavePoint, Fiberworks, ArahWeave and most other weaving software.
read_wif(path)read_wif(path)
path |
Path to a ‘.wif’ file. |
The reader extracts the sections needed to rebuild a drawdown:
[WEAVING], [WARP], [WEFT], [THREADING], and
either [LIFTPLAN] (dobby-style, one entry per pick listing the
shafts raised) or [TIEUP] plus [TREADLING] (treadle-loom
style). Files may contain both encodings; both are kept. If colour
sections ([COLOR PALETTE], [COLOR TABLE],
[WARP COLORS], [WEFT COLORS]) are present they are converted
to hexadecimal colours. Unknown sections are ignored.
Section and key names are matched case-insensitively. Windows (CRLF) line endings and non-UTF-8 text in notes are tolerated. Full-line comments beginning with a semicolon or hash are ignored. Duplicate sections or keys and malformed integer indices are rejected. Missing thread entries are treated as inactive. Unusable colours fall back to neutral grey.
An object of class "wif", a list with elements:
The path that was read.
Declared numbers of shafts and treadles
(NA if not declared).
Logical; TRUE for a rising-shed loom.
Number of warp ends and weft picks.
List with one integer vector per warp end: the shafts that end is threaded through.
List with one integer vector per pick (shafts raised),
or NULL if the file has no liftplan.
List with one integer vector per pick (treadles
pressed), or NULL.
List whose element i holds the shafts raised by
treadle i, or NULL.
Logical flags for the two encodings.
NULL, or a list with palette (data frame),
warp and weft (hex colour per thread).
weave_draft_from_wif to go straight to a drawdown,
check_wif_consistency to compare the two encodings.
f <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft") wif <- read_wif(f) wiff <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft") wif <- read_wif(f) wif
Reads a WIF file (or takes an object from read_wif),
reconstructs the drawdown and returns a weave_draft.
weave_draft_from_wif( x, style = c("auto", "liftplan", "tieup_treadling"), name = NULL )weave_draft_from_wif( x, style = c("auto", "liftplan", "tieup_treadling"), name = NULL )
x |
Path to a ‘.wif’ file, or an object returned by
|
style |
Which encoding to use: |
name |
Optional short name for the draft; defaults to the file name without extension. |
If the file contains both a liftplan and a tie-up/treadling pair,
style = "auto" uses the liftplan, which states the sheds directly.
Use check_wif_consistency to confirm the two encodings
agree.
A weave_draft object.
f <- system.file("extdata", "gingham_plain.wif", package = "weaveDraft") draft <- weave_draft_from_wif(f) draftf <- system.file("extdata", "gingham_plain.wif", package = "weaveDraft") draft <- weave_draft_from_wif(f) draft
Collects the main structural descriptors of a draft in a one-row data
frame, convenient for comparing many drafts with rbind.
weave_metrics(draft, side = c("face", "back", "both"))weave_metrics(draft, side = c("face", "back", "both"))
draft |
A |
side |
|
A one-row data frame with columns name, draft_style,
shafts, picks, ends, repeat_picks,
repeat_ends, mean_warp_float, mean_weft_float,
max_warp_float, max_weft_float, interlace_warp,
interlace_weft, interlace_both and float_ratio.
f <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft") weave_metrics(weave_draft_from_wif(f))f <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft") weave_metrics(weave_draft_from_wif(f))
Finds the smallest number of picks and of ends after which the drawdown
repeats. A partial final repeat is allowed, but the repeat must fit at
least min_repeats times, so a pattern that only matches itself
over a tiny overlap is not reported as repeating.
weave_repeat(draft, min_repeats = 2)weave_repeat(draft, min_repeats = 2)
draft |
A |
min_repeats |
Minimum number of times the repeat must fit into the drawdown (default 2). If no such repeat exists the full dimension is returned. |
A named integer vector with picks (repeat length down the rows,
along warp threads) and ends (repeat length across
the columns, along weft threads).
f <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft") weave_repeat(weave_draft_from_wif(f))f <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft") weave_repeat(weave_draft_from_wif(f))