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
|
############################################################################
#
# File: blp2grid.icn
#
# Subject: Program to convert BLP drawdown to grid image
#
# Author: Ralph E. Griswold
#
# Date: June 26, 2002
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# The following options are supported:
#
# -s i size of cells; default 5
# -c s color for filling cells; default black
#
# Also handles row files.
#
############################################################################
#
# Requires: Version 9 graphics
#
############################################################################
#
# Links: basename, cells, convert, options, patutils, wopen
#
############################################################################
link basename
link cells
link convert
link options
link patutils
link wopen
procedure main(args)
local rows, panel, input, line, name, opts, size, file, color
opts := options(args, "s+c:")
size := \opts["s"] | 5
color := \opts["c"] | "black"
while file := get(args) do {
input := open(file) | stop("*** cannot open pattern file")
rows := []
line := read(input) | stop("empty file")
if upto("#", line) then rows := pat2rows(line)
else {
rows := [line]
while put(rows, read(input)) # read in row pattern
}
panel := matrixpanel(rows, size)
fill_cells(panel, rows, color)
name := basename(file, ".blp")
name := basename(name, ".rows")
WriteImage(panel.window, name || "_grid.gif")
WClose(panel.window)
close(input)
}
end
procedure fill_cells(panel, rows, cellcolor)
local i, j, color
every i := 1 to *rows do {
every j := 1 to *rows[1] do {
color := if rows[i, j] == "1" then cellcolor else "white"
colorcell(panel, j, i, color)
}
}
return
end
|