I am attempting to draw to a canvas and scale it while keeping the aspect ratio (black bars).
My previous attempt at this have worked, but now I am facing a bit of a problem that I cannot seem to fix.
The pixels of my assets are sometimes "squished" when resizing the window.
Here is my scaling function (I am using fennel, but will supply a lua translation)
Code: Select all
;; fennel
(fn calc-scale [window canvas]
(let [scale-x (/ window.width canvas.width)
scale-y (/ window.height canvas.height]
(if (>= scale-x scale-y)
scale-y
scale-x)))
Code: Select all
-- lua
function calc-scale (window canvas)
local scaleX = window.width / canvas.width
local scaleY = window.height / canvas.height
if scaleX >= scaleY then
return scaleY
else
return scaleX
end
end
In the attachments you can hopefully see that some of the rows and some of the columns are "squished". I have attempted to search for this but I haven't found any help on the matter. Any ideas?
Thank you in advance.