# HG changeset patch # User Tuomo Valkonen # Date 1576790961 -7200 # Node ID f6630036e5888c89b7569c953f569117a790724c # Parent 64a3f09e5fa70d831f33cdb9c84f82cf56dc9b7f Visualisation does aspect ratio correctly. diff -r 64a3f09e5fa7 -r f6630036e588 src/Visualise.jl --- a/src/Visualise.jl Thu Dec 19 21:38:03 2019 +0200 +++ b/src/Visualise.jl Thu Dec 19 23:29:21 2019 +0200 @@ -82,6 +82,7 @@ n = length(imgs) # Get device dimensions in metres and pixels scrw, scrh, pw, ph = GR.inqdspsize() + aspect = n > 0 ? Float64(size(imgs[1], 1))/Float64(size(imgs[1], 2)) : 1 # Scaling to maximums ize window sc=0.7 # Set up window and transformations @@ -90,20 +91,20 @@ GR.selntran(1) # - First OS window size if scrw/n>scrh - GR.setwsviewport(0, sc*scrh*n, 0, sc*scrh) + GR.setwsviewport(0, sc*scrh*n, 0, sc*scrh*aspect) else - GR.setwsviewport(0, sc*scrw, 0, sc*scrw/n) + GR.setwsviewport(0, sc*scrw, 0, sc*scrw/n*aspect) end # - Part of normalised window shown - GR.setwswindow(0, 1, 0, 1/n); - GR.setviewport(0, 1, 0, 1/n); - # Workd coordinates - GR.setwindow(0, n, 0, 1) + GR.setwswindow(0, 1, 0, 1/n*aspect); + GR.setviewport(0, 1, 0, 1/n*aspect); + # World coordinates + GR.setwindow(0, n, 0, aspect) # Plot images for i=1:n im = imgs[i]' sz = size(im) - GR.drawimage(i-1, i, 0, 1, sz[1], sz[2], grayGR.(im)) + GR.drawimage(i-1, i, 0, aspect, sz[1], sz[2], grayGR.(im)) end if refresh GR.updatews()