mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
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:
@@ -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()}
|
||||
|
||||
Reference in New Issue
Block a user