summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-10-26 12:38:04 -0400
committerJesse Luehrs <doy@tozt.net>2014-10-26 12:38:04 -0400
commit951032ffbe7a1018b95064b6a4bdac0e8148c0eb (patch)
tree25789d32dab84cb33b35d2624e348e49c5c7e8bb
parent54a5bb3d9e56bd8290a677ee50700bec422bb94f (diff)
downloadjulia-fractals-951032ffbe7a1018b95064b6a4bdac0e8148c0eb.tar.gz
julia-fractals-951032ffbe7a1018b95064b6a4bdac0e8148c0eb.zip
add a couple helper functions
-rw-r--r--examples/mandelbrot.jl2
-rw-r--r--src/FractalExplorer.jl1
-rw-r--r--src/renderer.jl10
3 files changed, 11 insertions, 2 deletions
diff --git a/examples/mandelbrot.jl b/examples/mandelbrot.jl
index c73f2c9..2b9d26d 100644
--- a/examples/mandelbrot.jl
+++ b/examples/mandelbrot.jl
@@ -8,7 +8,7 @@ iterations = 45
imgsize = (640, 480)
imgc, imgslice = view([ HSV(0, 0, 0) for y=1:imgsize[2], x=1:imgsize[1] ])
-FractalExplorer.render(imgc, iterations)
+mandelbrot(imgc, iterations)
#If we are not in a REPL
if (!isinteractive())
diff --git a/src/FractalExplorer.jl b/src/FractalExplorer.jl
index 64a52e6..7a8c206 100644
--- a/src/FractalExplorer.jl
+++ b/src/FractalExplorer.jl
@@ -1,4 +1,5 @@
module FractalExplorer
+export renderfractal, mandelbrot, julia
include("fractal.jl")
include("renderer.jl")
end
diff --git a/src/renderer.jl b/src/renderer.jl
index 2d6a213..7d7fca7 100644
--- a/src/renderer.jl
+++ b/src/renderer.jl
@@ -3,7 +3,7 @@ using Images
using ImageView
using Color
-function render(imgc, iterations = 45, make_c = z -> z, step = (z, c) -> z.^2 + c)
+function renderfractal(imgc, iterations, make_c, step)
imgsize = get_size(canvas(imgc))
img = [ HSV(0, 0, 0) for y=1:imgsize[1], x=1:imgsize[2] ]
f = FractalExplorer.Fractal{Float64}(imgsize, make_c, step)
@@ -15,3 +15,11 @@ function render(imgc, iterations = 45, make_c = z -> z, step = (z, c) -> z.^2 +
view(imgc, img)
end
end
+
+function mandelbrot(imgc, iterations = 45)
+ renderfractal(imgc, iterations, z -> z, (z, c) -> z.^2 + c)
+end
+
+function julia(imgc, iterations = 45, c = 0)
+ renderfractal(imgc, iterations, z -> c, (z, c) -> z.^2 + c)
+end