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
|
############################################################################
#
# File: repeater.icn
#
# Subject: Program to repeat image
#
# Author: Ralph E. Griswold
#
# Date: May 2, 2001
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This program repeats images a specified number of times. The image
# names are given on the command line.
#
# The supported options are:
#
# -h i repeat horizontally i times, default 1.
# -v i repeat vertically i times, default 1.
# -a i repeat i times perpendicular to smallest dimension;
# default 10; and 1 time perpendicular to the largest dimension;
# overrides -h and 0v.
# -l i limit size in repeat direction to i; default 256; only applies
# if -a is in force.
# -p s prefix to prepend to image name, default "rep_". Can
# be empty string, in which case the input image is
# overwritten.
#
############################################################################
#
# Requires: Version 9 graphics
#
############################################################################
#
# Links: options, tile, wopen
#
############################################################################
link options
link tile
link wopen
procedure main(args)
local opts, prefix, h_rep, v_rep, win1, win2, name, width, height
local auto, wdim, hdim, limit
opts := options(args, "h+v+a+l+p:")
h_rep := \opts["h"] | 1
v_rep := \opts["v"] | 1
prefix := \opts["p"] | "rep_"
auto := \opts["a"]
limit := \opts["l"] | 256
every name := !args do {
win1 := WOpen("canvas=hidden", "image=" || name) | {
write(&errout, "*** cannot open ", name)
next
}
width := WAttrib(win1, "width")
height := WAttrib(win1, "height")
if \auto then {
if width > height then {
hdim := height * auto
hdim >:= limit
wdim := width
}
else {
hdim := height
wdim := width * auto
wdim >:= limit
}
}
else {
hdim := height * h_rep
wdim := width * v_rep
}
win2 := WOpen("canvas=hidden", "width=" || wdim, "height=" || hdim) | {
write(&errout, "*** cannot open window for repeat")
WClose(win1)
next
}
tile(win1, win2)
WriteImage(win2, prefix || name)
WClose(win1)
WClose(win2)
}
end
|