summaryrefslogtreecommitdiffstats
path: root/fractal.jl
blob: f812f305ac4b6dc28806f7c1004b8af7e199d22a (plain) (blame)
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
using Tk
using Images
using ImageView

iterations = 90
imgsize = 1000

mandelbrot(z, c) = z.^2 + c

img = [ Color.HSV(0, 0, 0) for x=1:imgsize, y=1:imgsize ]
c = [
    x + y*im
        for x=linspace(-2.0, 2.0, imgsize), y=linspace(-2.0, 2.0, imgsize)
]
z = c

imgc, imgslice = view(img)

for i = 1:iterations
  z = mandelbrot(z, c)
  img[abs(z) .> 2] = Color.HSV(i * 360/iterations, 1, 1)
  view(imgc, img)
end

#If we are not in a REPL
if (!isinteractive())

    # Create a condition object
    cv = Condition()

    # Get the main window (A Tk toplevel object)
    win = toplevel(imgc)

    # Notify the condition object when the window closes
    bind(win, "<Destroy>", e->notify(cv))

    # Wait for the notification before proceeding ... 
    wait(cv)
end