summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-10-27 11:59:11 -0400
committerJesse Luehrs <doy@tozt.net>2014-10-27 11:59:11 -0400
commit36692c31cf639a54d93758428e27266a278b0941 (patch)
treeda41024d783986fdba4eb15170f2e77e06679a18
parent951032ffbe7a1018b95064b6a4bdac0e8148c0eb (diff)
downloadjulia-fractals-36692c31cf639a54d93758428e27266a278b0941.tar.gz
julia-fractals-36692c31cf639a54d93758428e27266a278b0941.zip
move the "wait for window close" logic into renderfractal
-rw-r--r--examples/mandelbrot.jl16
-rw-r--r--src/renderer.jl7
2 files changed, 7 insertions, 16 deletions
diff --git a/examples/mandelbrot.jl b/examples/mandelbrot.jl
index 2b9d26d..9bcc818 100644
--- a/examples/mandelbrot.jl
+++ b/examples/mandelbrot.jl
@@ -9,19 +9,3 @@ imgsize = (640, 480)
imgc, imgslice = view([ HSV(0, 0, 0) for y=1:imgsize[2], x=1:imgsize[1] ])
mandelbrot(imgc, iterations)
-
-#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
diff --git a/src/renderer.jl b/src/renderer.jl
index 7d7fca7..372353a 100644
--- a/src/renderer.jl
+++ b/src/renderer.jl
@@ -14,6 +14,13 @@ function renderfractal(imgc, iterations, make_c, step)
img[new_pixels] = HSV(i * 360/iterations, 1, 1)
view(imgc, img)
end
+
+ if (!isinteractive())
+ cv = Condition()
+ win = toplevel(imgc)
+ bind(win, "<Destroy>", e->notify(cv))
+ wait(cv)
+ end
end
function mandelbrot(imgc, iterations = 45)