aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2022-04-29 17:46:22 -0230
committerSam Anthony <sam@samanthony.xyz>2022-04-29 17:46:22 -0230
commit6cc1a45f59028cfe97129dfb5dd1b6548e5b0473 (patch)
tree19c8d7408ccb85c12b560f3482782e3372ebb756
parent78cdedbc1101568a19a203511e7539945ef7723d (diff)
downloadvolute-6cc1a45f59028cfe97129dfb5dd1b6548e5b0473.zip
fix compressor map texture getting stretched
-rw-r--r--ui.go19
1 files changed, 18 insertions, 1 deletions
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),
)
}
}