# HG changeset patch # User Tuomo Valkonen # Date 1577730099 -7200 # Node ID fe9ef03a91b2bcdb546d6d25cfbb441b3685777c # Parent b351c5c654505979e5f138651031c04711a28833 "fullscreen" mode modulo GR being capable of it, better transformations diff -r b351c5c65450 -r fe9ef03a91b2 src/Visualise.jl --- a/src/Visualise.jl Sat Dec 28 17:18:52 2019 +0200 +++ b/src/Visualise.jl Mon Dec 30 20:21:39 2019 +0200 @@ -78,33 +78,66 @@ return 0x010101*y + 0xff000000 end -function do_visualise(imgs; refresh=true) +function fill_viewport(vp, c) + GR.savestate() + GR.selntran(0) + GR.setscale(0) + GR.setfillintstyle(GR.INTSTYLE_SOLID) + GR.setfillcolorind(c) + GR.fillrect(vp...) + GR.selntran(1) + GR.restorestate() +end + +function do_visualise(imgs; refresh=true, fullscreen=false) 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 + imgaspect = n > 0 ? float(size(imgs[1], 1))/float(size(imgs[1], 2)) : 1 + # Scaling to maximum size window sc=0.7 # Set up window and transformations GR.clearws() GR.setscale(0); GR.selntran(1) # - First OS window size - if scrw/n>scrh - GR.setwsviewport(0, sc*scrh*n, 0, sc*scrh*aspect) + if fullscreen + w, h = float(scrw), float(scrh) + elseif scrw/n>scrh + w, h = float(sc*scrh*n), float(sc*scrh*imgaspect) else - GR.setwsviewport(0, sc*scrw, 0, sc*scrw/n*aspect) + w, h = float(sc*scrw), float(sc*scrw/n*imgaspect) + end + GR.setwsviewport(0, w, 0, h) + # NDC to device + if w>h + canvas=[0, 1, 0, h/w] + else + canvas=[0, w/h, 0, 1] end - # - Part of normalised window shown - GR.setwswindow(0, 1, 0, 1/n*aspect); - GR.setviewport(0, 1, 0, 1/n*aspect); - # World coordinates - GR.setwindow(0, n, 0, aspect) + GR.setwswindow(canvas...) + fill_viewport(canvas, 1) + # World coordinates to NDC + if imgaspect/n