summaryrefslogtreecommitdiff
path: root/src/Layer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Layer.zig')
-rw-r--r--src/Layer.zig9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Layer.zig b/src/Layer.zig
index e979eab7..a9827304 100644
--- a/src/Layer.zig
+++ b/src/Layer.zig
@@ -106,9 +106,12 @@ const Point = struct { index: u16, col: u16, metrics: Metrics };
fn pointAt(layer: *const Layer, x: f32, y: f32, body_w: f32, body_h: f32, tagline_w: f32, tagline_h: f32) ?Point {
if (layer.rows == 0 or !std.math.isFinite(x) or !std.math.isFinite(y)) return null;
// A band's hit is refused outright on metrics no host could have; a
- // body's has always been floored to a pixel instead.
- if (layer.kind != .body) for ([_]f32{ body_w, body_h, tagline_w, tagline_h }) |metric|
- if (!std.math.isFinite(metric) or metric < 1 or metric > std.math.maxInt(u16)) return null;
+ // body's has always been floored to a pixel instead, and both refuse
+ // what is no number or past a u16 (a host's floats: web's exports).
+ for ([_]f32{ body_w, body_h, tagline_w, tagline_h }) |metric| {
+ if (!std.math.isFinite(metric) or metric > std.math.maxInt(u16)) return null;
+ if (layer.kind != .body and metric < 1) return null;
+ }
const bw = @max(1, body_w);
const bh = @max(1, body_h);
const tw = std.math.clamp(tagline_w, 1, bw);