diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:28:24 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:20:23 -0300 |
| commit | 034ac8e5128e3dc917b3a98bead6db71a5249739 (patch) | |
| tree | dacb14c512f6c9b98bdcce2b16dac3db9bb616b8 /src/animation.zig | |
| parent | 3ac1a89c2587fd97e58900f1162fad21048b0577 (diff) | |
| download | pardes-034ac8e5128e3dc917b3a98bead6db71a5249739.tar.gz pardes-034ac8e5128e3dc917b3a98bead6db71a5249739.zip | |
Presentation: a cell is in a box by one test, animation.Box.contains, now the centre test its comment always said (its one other caller passes whole-cell pane boxes, where centre and corner agree), so boxContainsCell goes; the aliases used once are spelled where they are used
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/animation.zig')
| -rw-r--r-- | src/animation.zig | 7 |
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; } }; |
