image popup aspect ratio matches that of image

This commit is contained in:
Drew Weymouth
2023-02-06 20:19:37 -08:00
parent 3584888924
commit 87ae3e940f
2 changed files with 20 additions and 2 deletions
+6
View File
@@ -2,6 +2,7 @@ package util
import (
"fmt"
"image"
"math"
"strings"
@@ -20,6 +21,11 @@ func SecondsToTimeString(s float64) string {
return fmt.Sprintf("%d:%02d", min, sec)
}
func ImageAspect(im image.Image) float32 {
b := im.Bounds()
return float32(b.Max.X-b.Min.X) / float32(b.Max.Y-b.Min.Y)
}
func RichTextSegsFromHTMLString(s string) []widget.RichTextSegment {
tokr := html.NewTokenizer(strings.NewReader(s))
var segs []widget.RichTextSegment