1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
############################################################################
#
# File: rows2isd.icn
#
# Subject: Program to produce a ISD from bi-level pattern
#
# Author: Ralph E. Griswold
#
# Date: November 16, 2001
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This program takes a row file or BLP from standard input
# and writes an ISD for a draft to standard output.
#
############################################################################
#
# Links: weavutil, xcode, patutils, patxform
#
############################################################################
link patutils
link patxform
link weavutil
link xcode
procedure main(args)
local rows, cols, treadling, threading, count, tieup, y, width, height
local shafts, treadles, i, tie_line, row, treadle, draft, p, line
line := read() | stop("empty file")
if upto("#", line) then rows := pat2rows(line)
else {
rows := [line]
while put(rows, read()) # read in row pattern
}
cols := protate(rows) # rotate to get columns
treadles := examine(rows) # get treadles
shafts := examine(cols) # get shafts
treadling := [] # construct treadling sequence
every put(treadling, treadles[!rows])
threading := [] # construct threading sequence
every put(threading, shafts[!cols])
tieup := []
every row := key(treadles) do { # get unique rows
treadle := treadles[row] # assigned treadle number
tie_line := repl("0", *shafts) # blank tie-up line
every i := 1 to *row do # go through row
if row[i] == "1" then # if warp on top
tie_line[threading[i]] := "1" # mark shaft position
put(tieup, tie_line) # add line to tie-up
}
draft := isd("rows2isd")
draft.threading := threading
draft.treadling := treadling
draft.shafts := *shafts
draft.treadles := *treadles
draft.width := *shafts
draft.height := *treadles
draft.tieup := tieup
draft.color_list := ["black", "white"]
draft.warp_colors := list(*threading, 1)
draft.weft_colors := list(*treadling, 2)
write(xencode(draft))
end
procedure tromp(treadle)
local result
result := ""
treadle ? {
every result ||:= upto("1") || ","
}
return result[1:-1]
end
procedure examine(array)
local count, lines, line
lines := table() # table to be keyed by line patterns
count := 0
every line := !array do # process lines
/lines[line] := (count +:= 1) # if new line, insert with new number
return lines
end
|