Rename a length's abs component to px

`dp` is coming, and then `abs` says which of the two it is not. The
component has always been a pixel count, so the name that admits it is
the one that leaves room for a second unit beside it.

Mechanical: the field on `Len` and `UiScalar`, their constructors,
`to_abs`/`get_abs`, the matching WGSL struct member and the locals
composing it. Field order and types are unchanged, so the `Pod` layout
the shader reads is the same bytes. `f32::abs` is untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
iris-aiandClaude Opus 5 committed 2026-09-14 22:29:20 -04:00
1 parent 3f7cd8251b
commit 7c50a3e51b
22 files changed
+120 -124

No files matched your search

+10 -10
View File
@@ -40,7 +40,7 @@ const CHAIN_LIMIT: u32 = 64u;
fn scalar_within(s: UiScalar, p: UiSpan) -> UiScalar {
return UiScalar(
mix(p.start.rel, p.end.rel, s.rel),
s.abs + mix(p.start.abs, p.end.abs, s.rel),
s.px + mix(p.start.px, p.end.px, s.rel),
);
}
@@ -69,7 +69,7 @@ struct UiSpan {
struct UiScalar {
rel: f32,
abs: f32,
px: f32,
}
struct InstanceInput {
@@ -104,12 +104,12 @@ fn vs_main(
);
let r = resolve_move(in.move_idx, local);
let top_left_rel = vec2(r.x.start.rel, r.y.start.rel);
let top_left_abs = vec2(r.x.start.abs, r.y.start.abs);
let top_left_px = vec2(r.x.start.px, r.y.start.px);
let bot_right_rel = vec2(r.x.end.rel, r.y.end.rel);
let bot_right_abs = vec2(r.x.end.abs, r.y.end.abs);
let bot_right_px = vec2(r.x.end.px, r.y.end.px);
let top_left = floor(top_left_rel * window.dim) + floor(top_left_abs);
let bot_right = floor(bot_right_rel * window.dim) + floor(bot_right_abs);
let top_left = floor(top_left_rel * window.dim) + floor(top_left_px);
let bot_right = floor(bot_right_rel * window.dim) + floor(bot_right_px);
let size = bot_right - top_left;
let uv = vec2<f32>(
@@ -136,12 +136,12 @@ fn masked(in: VertexOutput, color: vec4<f32>) -> vec4<f32> {
// clips content that moves inside it.
let m = resolve_move(mask.move_idx, Region(mask.x, mask.y));
let tl = vec2(m.x.start.rel, m.y.start.rel);
let tl_abs = vec2(m.x.start.abs, m.y.start.abs);
let tl_px = vec2(m.x.start.px, m.y.start.px);
let br = vec2(m.x.end.rel, m.y.end.rel);
let br_abs = vec2(m.x.end.abs, m.y.end.abs);
let br_px = vec2(m.x.end.px, m.y.end.px);
let top_left = floor(tl * window.dim) + floor(tl_abs);
let bot_right = floor(br * window.dim) + floor(br_abs);
let top_left = floor(tl * window.dim) + floor(tl_px);
let bot_right = floor(br * window.dim) + floor(br_px);
let pos = in.clip_position.xy;
if pos.x < top_left.x || pos.x > bot_right.x || pos.y < top_left.y || pos.y > bot_right.y {
return color * 0.0;
+1 -1
View File
@@ -34,6 +34,6 @@ fn distance_from_rect(pixel_pos: vec2<f32>, rect_center: vec2<f32>, rect_corner:
// vec from center to pixel
let p = pixel_pos - rect_center;
// vec from inner rect corner to pixel
let q = abs(p) - (rect_corner - radius);
let q = px(p) - (rect_corner - radius);
return length(max(q, vec2(0.0))) - radius;
}