summaryrefslogtreecommitdiff
path: root/ipl/gprogs/julia1.icn
blob: 5ff91d8ddcb08b35c64a81460106a3225a4e0b93 (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
69
70
71
72
73
74
75
76
77
78
79
############################################################################
#
#	File:     julia1.icn
#
#	Subject:  Program to display the Julia 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 Julia 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.
#
#  The point in the complex plane for which the Julia set is computed
#  is given on the command line, as in
#
#	julia1 .360284 .100376
#
#  which displays the Julia set for the complex number .360284 + .100376i.
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################
#
#  Links:  wopen
#
############################################################################

link wopen

procedure main(argl)
   local c1, c2, extent, half, quarter, m, n, x0, y0, x, y
   local x1, y1, i, z

   c1 := real(argl[1]) | -1.0		# default is -1.0 + 0.0i
   c2 := real(argl[2]) | 0.0

   extent := 200
   half := 200 / 2
   quarter := real(extent) / 4

   WOpen("label=julia", "height=" || extent, "width=" || extent) |
      stop("*** cannot open window")

   every m := 0 to extent do {
      x0 := -2 + m / quarter
      every n := 0 to half do {
         y0 := 2 - n / quarter
         x := x0
         y := y0
         every i := 1 to 20 do {	# compute orbit
            x1 := x ^ 2 - y ^ 2 + c1
            y1 := 2 * x * y + c2
            x := x1
            y := y1
            z := x ^ 2 + y ^ 2
            if z > 4 then break next	# if escaping, forget it
            }
         DrawPoint(m, n)
         DrawPoint(extent - m, extent - n)
         }
      }

   Event()

end