From 2a174cf7a918637af3f84bf47b2f720dcbc742fe Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 26 Oct 2014 00:20:22 -0400 Subject: refactor this should be able to support both mandelbrot and julia sets --- src/fractal.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/fractal.jl (limited to 'src/fractal.jl') diff --git a/src/fractal.jl b/src/fractal.jl new file mode 100644 index 0000000..41977c1 --- /dev/null +++ b/src/fractal.jl @@ -0,0 +1,15 @@ +type Fractal{T <: FloatingPoint} + z::Array{Complex{T}, 2} + c::Array{Complex{T}, 2} + step::Function + + function Fractal(imgsize, make_c = z -> z, step = (z, c) -> z.^2 + c) + line = linspace(-2.0, 2.0, imgsize) + plane = [ complex(x, y) for x=line, y=line ] + new(plane, make_c(plane), step) + end +end + +function step{T <: FloatingPoint}(f::Fractal{T}) + f.z = f.step(f.z, f.c) +end -- cgit v1.2.3-54-g00ecf