summaryrefslogtreecommitdiff
path: root/ipl/gprogs/mandel1.icn
blob: fb41d7768f71148782293b798e3477a0c44187a6 (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
############################################################################
#
#	File:     mandel1.icn
#
#	Subject:  Program to display the Mandelbrot set
#
#	Author:   Ralph E. Griswold
#
#	Date:     June 17, 1994
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This is a barebones version of a display of the Mandelbrot set.  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 size, real_size, i, j, c1, c2, x, y, n, x1, y1, limit, extent

   size := 300
   extent := 4.0 / size

   limit := 30

   WOpen("label=mandel", "height=" || size, "width=" || size) |
      stop("*** cannot open window")

   every i := 1 to size do {
      every j := 1 to size / 2 do {
         c1 := -2 + i * extent
         c2 := 2 - j * extent
         x := c1
         y := c2
         every 1 to limit do {		# see what the orbit is
            x1 := x ^ 2 - y ^ 2 + c1
            y1 := 2 * x * y + c2
            if (x1 ^ 2 + y1 ^ 2) > 4 then break next
            x := x1
            y := y1
            }
         DrawPoint(i, j, i, size - j)
         }
      }

   Event()

end