summaryrefslogtreecommitdiff
path: root/src/animation.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/animation.zig')
-rw-r--r--src/animation.zig7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/animation.zig b/src/animation.zig
index ae116e27..51164495 100644
--- a/src/animation.zig
+++ b/src/animation.zig
@@ -96,10 +96,11 @@ pub const Box = extern struct {
return a.x == b.x and a.y == b.y and a.w == b.w and a.h == b.h;
}
- // A cell belongs to a fractional box when its center lies inside.
+ /// A cell belongs to a fractional box when its centre lies inside:
+ /// drawing and hit testing both ask this.
pub fn contains(box: Box, col: u16, row: u16) bool {
- const x: f32 = @floatFromInt(col);
- const y: f32 = @floatFromInt(row);
+ const x = @as(f32, @floatFromInt(col)) + 0.5;
+ const y = @as(f32, @floatFromInt(row)) + 0.5;
return x >= box.x and x < box.x + box.w and y >= box.y and y < box.y + box.h;
}
};