From f6438aa63834ed6ed577863133d2ca01700f2f1f Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 26 Oct 2014 10:25:56 -0400 Subject: handle non-square windows --- src/fractal.jl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/fractal.jl b/src/fractal.jl index eb0b496..d1fd9f6 100644 --- a/src/fractal.jl +++ b/src/fractal.jl @@ -4,8 +4,17 @@ type Fractal{T <: FloatingPoint} 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 ] + aspect_ratio = imgsize[2] / imgsize[1] + if imgsize[1] < imgsize[2] + range_x = (-2.0, 2.0) + range_y = (-2.0 * aspect_ratio, 2.0 * aspect_ratio) + else + range_x = (-2.0 / aspect_ratio, 2.0 / aspect_ratio) + range_y = (-2.0, 2.0) + end + line_x = linspace(range_x[1], range_x[2], imgsize[1]) + line_y = linspace(range_y[1], range_y[2], imgsize[2]) + plane = [ complex(x, y) for x=line_x, y=line_y ] c = make_c(plane) if !isa(c, Array) c = ones(plane) .* c -- cgit v1.2.3-54-g00ecf