diff options
Diffstat (limited to 'src/fractal.jl')
-rw-r--r-- | src/fractal.jl | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/fractal.jl b/src/fractal.jl index d1fd9f6..8b7fa0d 100644 --- a/src/fractal.jl +++ b/src/fractal.jl @@ -4,17 +4,18 @@ type Fractal{T <: FloatingPoint} step::Function function Fractal(imgsize, make_c = z -> z, step = (z, c) -> z.^2 + c) - 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) + (size_y, size_x) = imgsize + aspect_ratio = size_y / size_x + if size_x < size_y + range_x = (-2.0 * aspect_ratio, 2.0 * aspect_ratio) range_y = (-2.0, 2.0) + else + range_x = (-2.0, 2.0) + range_y = (-2.0 / aspect_ratio, 2.0 / aspect_ratio) 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 ] + line_x = linspace(range_x[1], range_x[2], size_x) + line_y = linspace(range_y[1], range_y[2], size_y) + plane = [ complex(x, y) for y=line_y, x=line_x ] c = make_c(plane) if !isa(c, Array) c = ones(plane) .* c |