gesture,widget,f32: [API] use integer coordinates for gesture coordinates

Most widget code operate in integer coordinates. This change makes
gesture pointer coordinates integer, to lessen the number of float32
to int conversions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-04-26 10:36:41 +02:00
parent 87be31cbec
commit 14805af367
4 changed files with 13 additions and 6 deletions
+8
View File
@@ -81,6 +81,14 @@ func (p Point) In(r Rectangle) bool {
r.Min.Y <= p.Y && p.Y < r.Max.Y
}
// Round returns the integer point closest to p.
func (p Point) Round() image.Point {
return image.Point{
X: int(math.Round(float64(p.X))),
Y: int(math.Round(float64(p.Y))),
}
}
// Size returns r's width and height.
func (r Rectangle) Size() Point {
return Point{X: r.Dx(), Y: r.Dy()}