summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-10-28 13:00:58 -0400
committerJesse Luehrs <doy@tozt.net>2014-10-28 13:00:58 -0400
commitfa47688e4f9eb9c0acf4e82916e81b6425a3d98b (patch)
tree8c3e65da9dc987e88874e3616f1cf408d8d9a426
parent88c13f0fe69cc62bbe461e205d8a510e6bc263d3 (diff)
downloadjulia-fractals-fa47688e4f9eb9c0acf4e82916e81b6425a3d98b.tar.gz
julia-fractals-fa47688e4f9eb9c0acf4e82916e81b6425a3d98b.zip
try to maintain a 1:1 pixel aspect ratio
-rw-r--r--src/renderer.jl18
1 files 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)