From 6cc1a45f59028cfe97129dfb5dd1b6548e5b0473 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Fri, 29 Apr 2022 17:46:22 -0230 Subject: fix compressor map texture getting stretched --- ui.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'ui.go') diff --git a/ui.go b/ui.go index 88b35b3..1ee281d 100644 --- a/ui.go +++ b/ui.go @@ -357,10 +357,27 @@ func compressorWidget() { canvas := g.GetCanvas() if compressorTexture != nil { winWidth, winHeight := g.GetAvailableRegion() + + bounds := compressorImage.Bounds() + imWidth := float32(bounds.Dx()) + imHeight := float32(bounds.Dy()) + + var ratio, xratio, yratio float32 + xratio = winWidth / imWidth + yratio = winHeight / imHeight + if xratio < yratio { + ratio = xratio + } else { + ratio = yratio + } + + x := int(imWidth * ratio) + y := int(imHeight * ratio) + canvas.AddImage( compressorTexture, image.Pt(0, 250), - image.Pt(int(winWidth), int(winHeight)), + image.Pt(x, y), ) } } -- cgit v1.2.3