diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2022-04-29 17:46:22 -0230 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2022-04-29 17:46:22 -0230 |
| commit | 6cc1a45f59028cfe97129dfb5dd1b6548e5b0473 (patch) | |
| tree | 19c8d7408ccb85c12b560f3482782e3372ebb756 | |
| parent | 78cdedbc1101568a19a203511e7539945ef7723d (diff) | |
| download | volute-6cc1a45f59028cfe97129dfb5dd1b6548e5b0473.zip | |
fix compressor map texture getting stretched
| -rw-r--r-- | ui.go | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -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), ) } } |