blob: 2ae6ba2a3f2fc9c7cf023879ad90ff452764bde7 (
plain)
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
|
############################################################################
#
# File: sier2.icn
#
# Subject: Program to display the Sierpinski fractal
#
# Author: Ralph E. Griswold
#
# Date: June 24, 1994
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This is a barebones version of a display of the Sierpinski fractal.
# It has deliberately been left simple and free of options so that the
# basic idea is clear and so that it can be used as the basis of
# more capable versions.
#
# This program is based on material given in "Chaos, Fractals,
# and Dynamics", Robert L. Devaney, Addison-Wesley, 1990.
#
############################################################################
#
# Requires: Version 9 graphics
#
############################################################################
#
# Links: wopen
#
############################################################################
link wopen
procedure main()
local extent, x, y, i
extent := 300
WOpen("label=sier", "height=" || extent, "width=" || extent) |
stop("*** cannot open window")
x := 20 # The results do not depend on these values
y := 150
every i := 1 to 100000 do {
case ?3 of { # Decide what to do at random
1: {
x /:= 2
y /:= 2
}
2: {
x /:= 2
y := (extent + y) / 2
}
3: {
x := (extent + x) / 2
y := (extent + y) / 2
}
}
if i > 1000 then DrawPoint(x, y) # Wait until attraction
}
Event()
end
|