## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 5, fig.height = 5) library(weaveDraft) ## ----load--------------------------------------------------------------------- f <- system.file("extdata", "twill_2_2.wif", package = "weaveDraft") twill <- weave_draft_from_wif(f) twill plot(twill) ## ----metrics------------------------------------------------------------------ weave_metrics(twill) ## ----gingham------------------------------------------------------------------ g <- weave_draft_from_wif(system.file("extdata", "gingham_plain.wif", package = "weaveDraft")) weave_metrics(g)[, c("interlace_both", "mean_warp_float", "repeat_picks")] plot(g) # the structure: a plain weave plot(g, type = "fabric") # the structure seen through its colours color_runs(g, "warp") ## ----consistency-------------------------------------------------------------- check_wif_consistency(read_wif(system.file("extdata", "gingham_plain.wif", package = "weaveDraft"))) ## ----own---------------------------------------------------------------------- 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")]