github.com/jmigpin/editor@v1.6.0/util/fontutil/misc.go (about) 1 package fontutil 2 3 import ( 4 "image" 5 6 "golang.org/x/image/math/fixed" 7 ) 8 9 func Rect266MinFloorMaxCeil(r fixed.Rectangle26_6) image.Rectangle { 10 min := image.Point{r.Min.X.Floor(), r.Min.Y.Floor()} 11 max := image.Point{r.Max.X.Ceil(), r.Max.Y.Ceil()} 12 return image.Rectangle{min, max} 13 } 14 15 func Float32ToFixed266(v float32) fixed.Int26_6 { 16 return fixed.Int26_6(v * 64) 17 } 18 func Float64ToFixed266(v float64) fixed.Int26_6 { 19 return fixed.Int26_6(v * 64) 20 } 21 func Fixed266ToFloat64(v fixed.Int26_6) float64 { 22 return float64(v) / float64(64) 23 }