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
|
############################################################################
#
# File: moire.icn
#
# Subject: Program to display Moire patterns
#
# Author: Ralph E. Griswold
#
# Date: May 2, 2001
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This program displays moire patterns.
#
# The following options are supported:
#
# -g run continuously; ignore user events; default: process user
# events
# -i i initial size, default 50
# -k i increment, default 1
# -l i limit on number of iterations, default 2 ^ 10
# -p s palette, default "c2"
# -s i size of window (width/height); default 256
#
# This program is based on material given in "FractalVision",
# Dick Oliver, Sams Publishing, 1992, pp. 185-190.
#
############################################################################
#
# Requires: Version 9 graphics
#
############################################################################
#
# Links: colrlist, interact, options, wopen
#
############################################################################
link colrlist
link interact
link options
link wopen
procedure main(args)
local extent, size, colors, ncolors, k, x, i, y, j, c, palette
local opts, init, incr, limit, run
opts := options(args, "gs+p:i+k+l+")
palette := \opts["p"] | "c2"
extent := \opts["s"] | 256
init := \opts["i"] | 50
incr := \opts["k"] | 1
limit := \opts["l"] | (2 ^ 10)
run := opts["g"]
size := extent / 2
WOpen("label=moire", "height=" || extent, "width=" || extent,
"dx=" || size, "dy=" || size, "bg=light gray") |
ExitNotice("Cannot open window.")
colors := colrplte(palette) | ExitNotice("Invalid palette.")
ncolors := *colors
every k := seq(init, incr) \ limit do {
x := k
every i := 0 to size do {
y := x
every j := i to size do {
c := colors[?ncolors]
Fg(c)
DrawPoint(
i, j,
j, i,
j, -i,
i, -j,
-i, -j,
-j, -i,
-j, i,
-i, j
)
y +:= k
}
x +:= k
}
Fg("black")
if /run then repeat case Event() of {
"q": exit()
"s": snapshot()
"n": break
}
}
end
|