From fa47688e4f9eb9c0acf4e82916e81b6425a3d98b Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 28 Oct 2014 13:00:58 -0400 Subject: try to maintain a 1:1 pixel aspect ratio --- src/renderer.jl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/renderer.jl b/src/renderer.jl index 3fefe14..34a53c4 100644 --- a/src/renderer.jl +++ b/src/renderer.jl @@ -26,13 +26,23 @@ type FractalCanvas c.mouse.button1press = function(c, x, y) function rubberband_end(c, bb) (size_x, size_y) = tuple(get_size(c)...) + win_aspect_ratio = size_x / size_y + box_aspect_ratio = (bb.xmax - bb.xmin) / (bb.ymax - bb.ymin) line_x = linspace(fc.f.bb.xmin, fc.f.bb.xmax, size_x) line_y = linspace(fc.f.bb.ymin, fc.f.bb.ymax, size_y) plane = [ (x, y) for x=line_x, y=line_y ] - bb = Base.Graphics.BoundingBox( - plane[bb.xmin, bb.ymin][1], plane[bb.xmax, bb.ymax][1], - plane[bb.xmin, bb.ymin][2], plane[bb.xmax, bb.ymax][2], - ) + if box_aspect_ratio > win_aspect_ratio + xmin = plane[bb.xmin, bb.ymin][1] + xmax = plane[bb.xmax, bb.ymax][1] + ymin = plane[bb.xmin, bb.ymin][2] + ymax = ymin + (xmax - xmin) + else + xmin = plane[bb.xmin, bb.ymin][1] + ymin = plane[bb.xmin, bb.ymin][2] + ymax = plane[bb.xmax, bb.ymax][2] + xmax = xmin + (ymax - ymin) + end + bb = Base.Graphics.BoundingBox(xmin, xmax, ymin, ymax) fractal(c, make_c, step, false, bb) end ImageView.rubberband_start(c, x, y, rubberband_end) -- cgit v1.2.3