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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
############################################################################
#
# File: isd2ill.icn
#
# Subject: Program to create images from ISDs
#
# Author: Ralph E. Griswold
#
# Date: April 23, 2000
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This program creates Encapsulated PostScript and GIF image files from
# ISDs.
#
# The following options are supported:
#
# -g draw grid lines on drawdown
# -h hold windows open in visible (-v) mode
# -p add showpage for printing
# -s i cell size, default 6
# -v show images during creation; default, don't
#
# Other options to be added include the control of layout and orientation.
#
# Names of ISDs are taken from the command line. For each, six Encap-
# PostScript files are created:
#
# <base name>_tieup.eps (if given)
# <base name>_liftplan.eps (if given)
# <base name>_threading.eps
# <base name>_treadling.eps
# <base name>_drawdown.eps
# <base name>_pattern.eps (colored "drawdown")
#
# Corresponding GIFs also are produced.
#
# Future plans call for handling "shaftplans" specifying what diagrams
# are wanted.
#
############################################################################
#
# Requires: Version 9 graphics
#
############################################################################
#
# Links: basename, interact, options, psrecord, weavutil, xcode
#
############################################################################
link basename
link interact
link options
link psrecord
link weavutil
link xcode
global canvas
global cellsize
global gridlines
global hold
global name
global printing
global draft
$define CellSize 6
procedure main(args)
local opts, input, file
isd
opts := options(args, "ghps+v")
if /opts["p"] then printing := 1
if \opts["v"] then {
canvas := "canvas=normal"
hold := opts["h"] # only if images are visible
}
else canvas := "canvas=hidden"
gridlines := opts["g"]
cellsize := \opts["s"] | CellSize
while file := get(args) do {
input := open(file) | {
Notice("Cannot open " || file)
next
}
name := basename(file, ".isd")
draft := xdecode(input)
draw_panes()
close(input)
}
end
procedure clear_pane(win, n, m, size)
local x, y, width, height, save_fg
width := n * size + 1
height := m * size + 1
save_fg := Fg(win)
Fg(win, "black")
every x := 0 to width by size do
DrawLine(win, x, 0, x, height)
every y := 0 to height by size do
DrawLine(win, 0, y, width, y)
Fg(win, save_fg)
return
end
procedure draw_panes()
local i, j, x, y, treadle, k, treadle_list, c, color
local tieup_win, threading_win, treadling_win, liftplan_win
local drawdown_win, pattern_win
if \draft.tieup then {
tieup_win := WOpen(canvas, "width=" || (cellsize * draft.treadles + 1),
"height=" || (cellsize * draft.shafts + 1))
PSStart(tieup_win, name || "_tieup.eps")
clear_pane(tieup_win, draft.treadles, draft.shafts, cellsize)
every i := 1 to draft.shafts do
every j := 1 to draft.treadles do {
if draft.tieup[j, i] == "1" then
fillcell(tieup_win, j, i, "black")
}
PSDone(printing)
WriteImage(tieup_win, name || "_tieup.gif")
}
if *\draft.liftplan > 0 then {
liftplan_win := WOpen(canvas, "width=" || (cellsize * draft.shafts + 1),
"height=" || (cellsize * *draft.treadling + 1))
PSStart(liftplan_win, name || "_liftplan.eps")
clear_pane(liftplan_win, draft.shafts, *draft.treadling, cellsize)
every i := 1 to *draft.treadling do
every j := 1 to draft.treadles do {
if draft.liftplan[i, j] == "1" then
fillcell(liftplan_win, j, i, "black")
}
PSDone(printing)
WriteImage(liftplan_win, name || "_liftplan.gif")
}
threading_win := WOpen(canvas, "width=" || (cellsize * *draft.threading + 1),
"height=" || (cellsize * draft.shafts) + 1)
PSStart(threading_win, name || "_threading.eps")
clear_pane(threading_win, *draft.threading, draft.shafts + 1, cellsize)
every i := 1 to *draft.threading do
fillcell(threading_win, i, draft.threading[i], "black")
PSDone(printing)
WriteImage(threading_win, name || "_threading.gif")
treadling_win := WOpen(canvas, "height=" || (cellsize * *draft.treadling + 1),
"width=" || (cellsize * draft.treadles + 1))
PSStart(treadling_win, name || "_treadling.eps")
clear_pane(treadling_win, draft.treadles + 1, *draft.treadling, cellsize)
every i := 1 to *draft.treadling do
fillcell(treadling_win, draft.treadling[i], i, "black")
PSDone(printing)
WriteImage(treadling_win, name || "_treadling.gif")
pattern_win := WOpen(canvas, "width=" || (cellsize * *draft.threading + 1),
"height=" || (cellsize * *draft.treadling + 1))
PSStart(pattern_win, name || "_pattern.eps")
clear_pane(pattern_win, draft.shafts, draft.treadles, cellsize)
if *cset(draft.warp_colors) = 1 then { # warp solid black
Fg(pattern_win, draft.color_list[draft.warp_colors[1]])
FillRectangle(pattern_win, 0, 0, *draft.threading * cellsize,
*draft.treadling * cellsize)
}
else {
every i := 0 to *draft.threading - 1 do { # warp striped
Fg(pattern_win, draft.color_list[draft.warp_colors[i]])
FillRectangle(pattern_win, i * cellsize, 0, cellsize - 1,
*draft.treadling * cellsize)
}
}
Fg(pattern_win, "black")
treadle_list := list(draft.treadles)
every !treadle_list := []
every i := 1 to draft.treadles do
every j := 1 to draft.shafts do
if draft.tieup[i, j] == "1" then
every k := 1 to *draft.threading do
if draft.threading[k] == j then
put(treadle_list[i], k, 0)
every y := 1 to *draft.treadling do {
treadle := draft.treadling[y]
color := draft.color_list[draft.weft_colors[y]]
if *treadle_list[treadle] = 0 then next # blank pick
every i := 1 to *treadle_list[treadle] by 2 do
fillcell(pattern_win, treadle_list[treadle][i], y, color)
}
Fg(pattern_win, "black")
if \gridlines then {
every x := 0 to WAttrib(pattern_win, "width") by cellsize do
DrawLine(pattern_win, x, 0, x, WAttrib(pattern_win, "height"))
every y := 0 to WAttrib(pattern_win, "height") by cellsize do
DrawLine(pattern_win, 0, y, WAttrib(pattern_win, "width"), y)
}
PSDone(printing)
WriteImage(pattern_win, name || "_pattern.gif")
drawdown_win := WOpen(canvas, "width=" || (cellsize * *draft.threading + 1),
"height=" || (cellsize * *draft.treadling + 1))
PSStart(drawdown_win, name || "_drawdown.eps")
clear_pane(drawdown_win, draft.shafts, draft.treadles, cellsize)
Fg(drawdown_win, "white")
FillRectangle(drawdown_win, 0, 0, *draft.threading * cellsize,
*draft.treadling * cellsize)
treadle_list := list(draft.treadles)
every !treadle_list := []
every i := 1 to draft.treadles do
every j := 1 to draft.shafts do
if draft.tieup[i, j] == "1" then
every k := 1 to *draft.threading do
if draft.threading[k] == j then
put(treadle_list[i], k, 0)
every y := 1 to *draft.treadling do {
treadle := draft.treadling[y]
if *treadle_list[treadle] = 0 then next # blank pick
every i := 1 to *treadle_list[treadle] by 2 do
fillcell(drawdown_win, treadle_list[treadle][i], y, "black")
}
Fg(drawdown_win, "black")
if \gridlines then {
every x := 0 to WAttrib(drawdown_win, "width") by cellsize do
DrawLine(drawdown_win, x, 0, x, WAttrib(drawdown_win, "height"))
every y := 0 to WAttrib(drawdown_win, "height") by cellsize do
DrawLine(drawdown_win, 0, y, WAttrib(drawdown_win, "width"), y)
}
PSDone(printing)
WriteImage(drawdown_win, name || "_drawdown.gif")
if \hold then {
repeat {
if Event(Active()) === "q" then break
}
}
every WClose(tieup_win | \liftplan_win | threading_win | treadling_win |
pattern_win, drawdown_win)
return
end
procedure fillcell(win, n, m, color)
local save_fg
save_fg := Fg(win)
Fg(win, color)
FillRectangle(win, (n - 1) * cellsize, (m - 1) * cellsize, cellsize,
cellsize)
Fg(win, save_fg)
return
end
|