From 2bd4066a932ec8fc401e4b85e9f8441b17df3cfb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 11:34:44 -0300 Subject: effects out, Lift and InactiveDim: the core's per-pane lift springs (Pardes.lifts, lift_serials, Region.lift, Chrome.lift_style) and the unfocused panes' recede (draw.zig's dim, its contrast memo and linear blend) go with the words, their settings and tests; the window loses its soft shadows (addSoft, the lift and rim casting, the shadow a sliding pane cast, the contrast ceilings, decor.frag's Gaussian path) and Chrome.sel_fg and sel_bg, which only the ceilings read; a pane closed mid-lift left its spring unsettled and continuous() true for ever, so a window could never go idle (monkey-gui failed `never settled` in the Lift combinations, and passes now); GUI golden 18-mid-transition changes, its sliding pane casting no shadow (the scene leaves with the transitions); root_ctl's out-of-range case is SearchRows', settings' GUI-only case GripWidth's, the window monkey loses its Lift axis Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/gui/gui.zig | 381 -------------------------------------------------------- 1 file changed, 381 deletions(-) (limited to 'src/gui') diff --git a/src/gui/gui.zig b/src/gui/gui.zig index ca3c7724..e97e6e38 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -480,8 +480,6 @@ const ImageInstance = extern struct { const old_layer_bit: u32 = 0x8000_0000; const clear_bg_bit: u32 = 0x4000_0000; const opaque_bg_bit: u32 = 0x2000_0000; -/// Decor that is a soft shadow, not a flat fill (decor.frag.glsl). -const soft_shadow_bit: u32 = 0x1000_0000; /// Decor that is a checker (decor.frag.glsl). const checker_bit: u32 = 0x0800_0000; /// A cell on the page's ground under the theme's dots, and a file name's @@ -8280,111 +8278,6 @@ fn addPattern(g: *Gui, gpa: std.mem.Allocator, x0: f32, y0: f32, x1: f32, y1: f3 instance.effect |= checker_bit; } -/// How a lift of 0 to 1 stands off the page: the shadow's blur and offset -/// in cell heights, and its darkest, where it leaves the caster's edge. -/// Within §8.2's budget: sigma 0.4-0.8 cell, at most 30% darker at the edge. -const Shadow = struct { - // A key light above: the drop is most of the blur, so the shadow hangs - // below and to the right and barely reaches over the caster's top. - const sigma: f32 = 0.42; - const drop: f32 = 0.34; - const side: f32 = 0.1; - const strength: f32 = 0.42; -}; - -/// A soft rectangle around `caster` (window pixels), blurred by `sigma` -/// and moved by (dx, dy): black is a shadow, a light colour a rim or a -/// glow. The caster's own rectangle is left alone, and `track` moves it all -/// as its caster moves. -fn addSoft(g: *Gui, gpa: std.mem.Allocator, caster: [4]f32, sigma_in: f32, dx: f32, dy: f32, strength: f32, rgb: [3]u8, track: ?pardes.animation.Track, win_w: f32, win_h: f32) !void { - if (strength <= 0.002) return; - const sigma = @max(0.5, sigma_in); - const x0 = caster[0] + dx - 3 * sigma; - const y0 = caster[1] + dy - 3 * sigma; - const x1 = caster[2] + dx + 3 * sigma; - const y1 = caster[3] + dy + 3 * sigma; - const w = x1 - x0; - const ht = y1 - y0; - if (w <= 0 or ht <= 0) return; - // In the quad's own 0..1 space (decor.frag.glsl): sigma per axis, the - // caster's offset from its shadow, the strength. - var instance: CellInstance = .{ - .x0 = (x0 / win_w) * 2.0 - 1.0, - .y0 = 1.0 - (y0 / win_h) * 2.0, - .x1 = (x1 / win_w) * 2.0 - 1.0, - .y1 = 1.0 - (y1 / win_h) * 2.0, - .u0 = sigma / w, - .v0 = sigma / ht, - .u1 = sigma / w, - .v1 = sigma / ht, - .fr = strength, - .fg = dx / w, - .fb = dy / ht, - .br = @as(f32, @floatFromInt(rgb[0])) / 255, - .bg = @as(f32, @floatFromInt(rgb[1])) / 255, - .bb = @as(f32, @floatFromInt(rgb[2])) / 255, - }; - setTransitionFields(&instance, track, fixedCellLayout(g), win_w, win_h, 0); - instance.effect |= soft_shadow_bit; - try g.decor.append(gpa, instance); -} - -/// How far each lift style may go on this theme without its text falling -/// below min(its contrast, 4.5): a shadow darkens, the others lighten. -const LiftCeilings = struct { - shadow: f32, - white: f32, - /// A rim is light on a dark page and shade on a light one, where light - /// would not show. - rim: [3]u8, - - /// Over the text on the page, and over a selection's text on its own - /// ground: the lower of the two. - fn of(chrome: *const pardes.Chrome) LiftCeilings { - const fg = chrome.fg orelse fg_default; - const bg = chrome.page orelse bg_default; - return .{ - .shadow = @min(shadowCeiling(fg, bg), shadowCeiling(chrome.sel_fg, chrome.sel_bg)), - .white = @min(lightenCeiling(fg, bg, .{ 255, 255, 255 }), lightenCeiling(chrome.sel_fg, chrome.sel_bg, .{ 255, 255, 255 })), - .rim = if (luminance(bg) < 0.18) .{ 255, 255, 255 } else .{ 0, 0, 0 }, - }; - } -}; - -/// What stands a lifted part off the page, `lift` 0 to 1 (a pane's spring, -/// a notice's 1), in the style chosen: a soft shadow, or a rim along the -/// top of the focused pane's tag rows (`rim_edge`, a pane's only: -/// never a notice's). -fn addLift(g: *Gui, gpa: std.mem.Allocator, style: pardes.config.Runtime.LiftStyle, ceilings: LiftCeilings, caster: [4]f32, rim_edge: ?[3]f32, bodies: []const [4]f32, lift: f32, track: ?pardes.animation.Track, win_w: f32, win_h: f32) !void { - if (lift <= 0.001) return; - const h: f32 = @floatFromInt(g.cell_h); - // The core sends `auto` already resolved (draw.liftStyle). - const shadow = switch (style) { - .off => return, - .shadow, .auto => true, - .rim => false, - }; - if (shadow) { - // Nothing of a shadow may touch a focus indicator (docs/effects.md): - // it falls on pane bodies and rails, never a tag, a grip or a header. - const first = g.decor.items.len; - try addSoft(g, gpa, caster, Shadow.sigma * h * lift, Shadow.side * h * lift, Shadow.drop * h * lift, @min(Shadow.strength * lift, ceilings.shadow), .{ 0, 0, 0 }, track, win_w, win_h); - try clipToBodies(g, gpa, first, bodies); - } - // A hairline just above the focused tag rows, never on them: it adds to - // the indicator without changing its colour. - if (style == .rim) if (rim_edge) |edge| { - const light = ceilings.rim[0] == 255; - const alpha = @min(Lift.rim * lift, if (light) ceilings.white else ceilings.shadow); - try addDecor(g, gpa, edge[0], edge[2] - dp(1), edge[1], edge[2], ceilings.rim, alpha, track, win_w, win_h); - }; -} - -/// A rim's strength, in the §8.2 budget for coloured light. -const Lift = struct { - const rim: f32 = 0.35; -}; - /// A body region in window pixels. fn bodyPixels(region: pardes.Region, layout: CellLayout) [4]f32 { return .{ @@ -8395,166 +8288,6 @@ fn bodyPixels(region: pardes.Region, layout: CellLayout) [4]f32 { }; } -/// Replaces the decor from `first` on with a copy per pane body it reaches, -/// each clipped to that body (and to what a vertical transition already -/// clipped it to): the lift then never reaches a tag, a grip or a header. -fn clipToBodies(g: *Gui, gpa: std.mem.Allocator, first: usize, bodies: []const [4]f32) !void { - const added = g.decor.items.len - first; - if (added == 0) return; - var own: [8]CellInstance = undefined; - const n = @min(added, own.len); - @memcpy(own[0..n], g.decor.items[first..][0..n]); - g.decor.shrinkRetainingCapacity(first); - for (own[0..n]) |instance| for (bodies) |body| { - var copy = instance; - const vertical = copy.clip_x1 >= copy.clip_x0; - copy.clip_x0 = if (vertical) @max(copy.clip_x0, body[0]) else body[0]; - copy.clip_y0 = if (vertical) @max(copy.clip_y0, body[1]) else body[1]; - copy.clip_x1 = if (vertical) @min(copy.clip_x1, body[2]) else body[2]; - copy.clip_y1 = if (vertical) @min(copy.clip_y1, body[3]) else body[3]; - if (copy.clip_x1 <= copy.clip_x0 or copy.clip_y1 <= copy.clip_y0) continue; - try g.decor.append(gpa, copy); - }; -} - -/// Like shadowCeiling for a light colour laid over at `a` (sRGB blend, as -/// the decor pipeline blends a colour that is not black): the largest `a` -/// that keeps text and page apart by min(their contrast, 4.5). -fn lightenCeiling(fg: [3]u8, bg: [3]u8, rgb: [3]u8) f32 { - const contrast = pardes.colors.contrast; - const blend = struct { - fn of(under: [3]u8, over: [3]u8, a: f32) [3]u8 { - var out: [3]u8 = undefined; - for (&out, under, over) |*o, x, y| o.* = @intFromFloat(@round(@as(f32, @floatFromInt(x)) * (1 - a) + @as(f32, @floatFromInt(y)) * a)); - return out; - } - }.of; - const target = @min(contrast(fg, bg), 4.5); - var lo: f32 = 0; - var hi: f32 = 1; - for (0..24) |_| { - const mid = (lo + hi) / 2; - if (contrast(blend(fg, rgb, mid), blend(bg, rgb, mid)) >= target - 1e-3) lo = mid else hi = mid; - } - return lo; -} - -const luminance = pardes.colors.relativeLuminance; - -/// How dark a shadow may make the page and its text, both together, before -/// the pair drops below its own contrast or 4.5, whichever is lower (§8.2): -/// darkening in linear light by k leaves (k L1 + .05) / (k L2 + .05). -pub fn shadowCeiling(fg: [3]u8, bg: [3]u8) f32 { - const a = luminance(fg); - const b = luminance(bg); - const light = @max(a, b); - const dark = @min(a, b); - const target = @min((light + 0.05) / (dark + 0.05), 4.5); - const room = light - target * dark; - if (room <= 0) return 0; - return std.math.clamp(1 - 0.05 * (target - 1) / room, 0, 1); -} - -test "a rim never lightens a native theme's text below its contrast or 4.5" { - for (pardes.themes) |theme| { - const fg = theme.fg orelse fg_default; - const bg = theme.bg orelse bg_default; - for ([_][3]u8{.{ 255, 255, 255 }}) |light| { - const a = @min(Lift.rim, lightenCeiling(fg, bg, light)); - const blend = struct { - fn of(under: [3]u8, over: [3]u8, t: f32) [3]u8 { - var out: [3]u8 = undefined; - for (&out, under, over) |*o, x, y| o.* = @intFromFloat(@round(@as(f32, @floatFromInt(x)) * (1 - t) + @as(f32, @floatFromInt(y)) * t)); - return out; - } - }.of; - const ratio = pardes.colors.contrast; - try std.testing.expect(ratio(blend(fg, light, a), blend(bg, light, a)) >= @min(ratio(fg, bg), 4.5) - 2e-3); - } - } -} - -test "a lift never touches a tag, a grip or a header, on a light theme or a dark one" { - const gpa = std.testing.allocator; - for ([_][]const u8{ "forge", "daybreak" }) |name| { - const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); - defer core.deinit(); - core.update(.{ .resize = .{ .cols = 80, .rows = 24, .row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 6, .tagline_h = 12 } } }); - _ = try core.newShell(1, ""); - try std.testing.expect(pardes.layout.splitColumn(core, 0, 1, false)); - var line: [64]u8 = undefined; - try std.testing.expect(core.executeBuiltinLine(0, try std.fmt.bufPrint(&line, "Theme {s}", .{name}))); - for (0..40) |_| core.update(.tick); - for (std.enums.values(pardes.config.Runtime.LiftStyle)) |style| { - core.settings.lift = style; - try std.testing.expect(core.executeBuiltinLine(0, "Msg a floating notice")); - core.advance(core.now_ns + 2 * std.time.ns_per_s); - core.sync(); - const s = try core.render(core.scratch.allocator()); - core.advance(core.now_ns + 2 * std.time.ns_per_s); - const settled = try core.render(core.scratch.allocator()); - _ = s; - // The focus indicator itself: the focused pane's tag is not the - // others' colour, whatever the lift. - var active: ?[3]u8 = null; - var other: ?[3]u8 = null; - for (settled.tagLayers()) |layer| if (layer.rows != 0 and layer.kind == .pane) { - if (layer.id == core.active) active = layer.bg else other = layer.bg; - }; - try std.testing.expect(!std.mem.eql(u8, &active.?, &other.?)); - var g = testGui(10, 20, 6, 12); - defer g.decor.deinit(gpa); - var groups = makeGroups(&.{}, false); - try buildDecor(&g, gpa, settled, &groups, fixedCellLayout(&g), 800, 480, true); - var lifted: usize = 0; - for (g.decor.items) |item| { - if (item.clip_x1 < item.clip_x0) continue; - lifted += 1; - // Inside a body or a rail, all of it. - const inside = for (settled.regionList()) |region| { - if (region.kind != .body and region.kind != .rail) continue; - const r = bodyPixels(region, fixedCellLayout(&g)); - if (item.clip_x0 >= r[0] and item.clip_y0 >= r[1] and item.clip_x1 <= r[2] and item.clip_y1 <= r[3]) break true; - } else false; - try std.testing.expect(inside); - } - const light_page = std.mem.eql(u8, name, "daybreak"); - try std.testing.expectEqual(style == .shadow or (style == .auto and light_page), lifted != 0); - // A rim is one hairline, just above the focused pane's tag row. - var rims: usize = 0; - for (g.decor.items) |item| { - if (item.clip_x1 >= item.clip_x0) continue; - const top = (1 - item.y0) / 2 * 480; - const height = (item.y0 - item.y1) / 2 * 480; - const on_active_tag = for (settled.regionList()) |region| { - if (region.kind == .tag and region.owner == core.active and @abs(top + 1 - @as(f32, @floatFromInt(region.rect.y)) * 20) < 0.01 and @abs(height - 1) < 0.01) break true; - } else false; - // Not the rule under a column bar, which may run there too. - rims += @intFromBool(on_active_tag and item.fr < 1); - } - try std.testing.expectEqual(@as(usize, @intFromBool(style == .rim)), rims); - } - } -} - -test "a shadow never darkens a native theme's text below its contrast or 4.5" { - var shaded: usize = 0; - for (pardes.themes) |theme| { - const fg = theme.fg orelse fg_default; - const bg = theme.bg orelse bg_default; - const ceiling = shadowCeiling(fg, bg); - const k = 1 - @min(Shadow.strength, ceiling); - const light = @max(luminance(fg), luminance(bg)); - const dark = @min(luminance(fg), luminance(bg)); - const before = (light + 0.05) / (dark + 0.05); - const after = (k * light + 0.05) / (k * dark + 0.05); - try std.testing.expect(after >= @min(before, 4.5) - 1e-3); - shaded += @intFromBool(ceiling > 0.05); - } - // And most themes have room for one. - try std.testing.expect(shaded * 2 > pardes.themes.len); -} - /// The frame's decor, group by group (docs/render-pipeline.md §3.4), all of it /// read from the regions and the palette: the page's rules and the still /// panes' rails, rules and grip marks in tier 0, a moving or closing pane's @@ -8563,18 +8296,6 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g g.decor.clearRetainingCapacity(); const chrome = &surface.chrome; const regions = surface.regionList(); - const ceilings = LiftCeilings.of(chrome); - var current_buf: [pardes.MAX_PANES][4]f32 = undefined; - var ncurrent: usize = 0; - for (regions) |part| if ((part.kind == .body or part.kind == .rail) and ncurrent < current_buf.len) { - current_buf[ncurrent] = bodyPixels(part, layout); - ncurrent += 1; - }; - const current_bodies = current_buf[0..ncurrent]; - const lift_style = std.enums.fromInt(pardes.config.Runtime.LiftStyle, chrome.lift_style) orelse .off; - const notice_lift = for (regions) |region| { - if (region.kind == .notice) break region.lift; - } else 0; for (groups.items[0..groups.len], 0..) |*group, index| { group.decor_start = @intCast(g.decor.items.len); defer group.decor_count = @as(u32, @intCast(g.decor.items.len)) - group.decor_start; @@ -8626,14 +8347,6 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g // A closing pane is gone: its chrome is the last frame's. const closing = if (track) |active| active.phase == .closing else false; const placed = if (closing) surface.previous_regions else regions; - // Where a lift may fall: pane bodies, never tags (addLift). - var body_buf: [pardes.MAX_PANES][4]f32 = undefined; - var nbodies: usize = 0; - for (placed) |part| if ((part.kind == .body or part.kind == .rail) and nbodies < body_buf.len) { - body_buf[nbodies] = bodyPixels(part, layout); - nbodies += 1; - }; - const bodies = body_buf[0..nbodies]; const ticks: []const pardes.RailTick = if (closing) &.{} else surface.rail_ticks[0..surface.nrail_ticks]; try paneDecor(g, gpa, placed, ticks, groups, index, chrome, layout, surface.cols, surface.rows, win_w, win_h, track); // A single spine runs down each column, through every tag and body. @@ -8647,66 +8360,11 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g if (column.rect.x == 0) continue; if (y1 > y0) try addDecor(g, gpa, x, y0, x + rulePx(chrome), y1, chrome.border, 1, null, win_w, win_h); }; - // Cast last in the group, over its cells, images and chrome: a - // lifted pane's shadow darkens its neighbours' rails and rules - // as it darkens their text, and never the pane itself. - for (placed) |grip| { - if (grip.kind != .grip or grip.lift <= 0.001 or groupOf(groups, grip.serial) != index) continue; - var box: [4]f32 = .{ @as(f32, @floatFromInt(grip.rect.x)) * layout.w, @as(f32, @floatFromInt(grip.rect.y)) * layout.h, 0, @as(f32, @floatFromInt(grip.rect.y + grip.rect.h)) * layout.h }; - box[2] = box[0]; - for (placed) |part| { - if (part.owner != grip.owner or (part.kind != .tag and part.kind != .rail and part.kind != .body)) continue; - box[1] = @min(box[1], @as(f32, @floatFromInt(part.rect.y)) * layout.h); - box[2] = @max(box[2], @as(f32, @floatFromInt(part.rect.x + part.rect.w)) * layout.w); - box[3] = @max(box[3], @as(f32, @floatFromInt(part.rect.y + part.rect.h)) * layout.h); - } - // The top edge of its tag rows, for a rim: x0, x1, y. - const rim_edge: ?[3]f32 = for (placed) |part| { - if (part.owner == grip.owner and part.kind == .tag) break .{ @as(f32, @floatFromInt(grip.rect.x)) * layout.w, @as(f32, @floatFromInt(part.rect.x + part.rect.w)) * layout.w, @as(f32, @floatFromInt(part.rect.y)) * layout.h }; - } else null; - try addLift(g, gpa, lift_style, ceilings, box, rim_edge, bodies, grip.lift, track, win_w, win_h); - } - // G7: a pane on the move stands off the page, rising as it sets - // out and settling as it lands, its shadow on the other panes' - // bodies only (never a tag, a grip or its own text), moving - // with it. - if (track) |active| if (active.phase != .closing and (active.effect == .slide or active.effect == .zoom or active.effect == .vertical)) { - const steps: f32 = @floatFromInt(@max(1, active.frames() -| 1)); - const u = std.math.clamp(@as(f32, @floatFromInt(active.frame)) / steps, 0, 1); - const lift = @sin(std.math.pi * u); - var box: [4]f32 = .{ std.math.inf(f32), std.math.inf(f32), -std.math.inf(f32), -std.math.inf(f32) }; - var others: [pardes.MAX_PANES][4]f32 = undefined; - var nothers: usize = 0; - for (placed) |part| { - if (part.kind != .tag and part.kind != .rail and part.kind != .body and part.kind != .grip) continue; - const r = bodyPixels(part, layout); - if (part.owner == active.pane) { - box = .{ @min(box[0], r[0]), @min(box[1], r[1]), @max(box[2], r[2]), @max(box[3], r[3]) }; - } else if ((part.kind == .body or part.kind == .rail) and nothers < others.len) { - others[nothers] = r; - nothers += 1; - } - } - if (box[2] > box[0] and lift > 0.01) { - const h: f32 = @floatFromInt(g.cell_h); - const first = g.decor.items.len; - try addSoft(g, gpa, box, Shadow.sigma * h * lift, Shadow.side * h * lift, Shadow.drop * h * lift, @min(Shadow.strength * lift, ceilings.shadow), .{ 0, 0, 0 }, track, win_w, win_h); - try clipToBodies(g, gpa, first, others[0..nothers]); - } - }; } // A notice chip is tagline hung over the body's top rows, so it is // ruled off from the text beneath it the way a tag is: the same // colour and thickness along its bottom, running to the window's // edge when it does, fading up and dissolving with its band. - // A notice floats: its shadow first, then every rule. - for (surface.tagLayers()) |*layer| { - if (layer.rows == 0 or layer.kind != .notice or noticeGroup(groups, layer) != index) continue; - const x = @as(f32, @floatFromInt(layer.viewport.x)) * layout.w; - const top = (@as(f32, @floatFromInt(layer.viewport.y)) + layer.slide) * layout.h; - const track = groups.items[groupAt(groups, layer.viewport.x, layer.viewport.y)].track; - try addLift(g, gpa, lift_style, ceilings, .{ x, top, x + @as(f32, @floatFromInt(layer.viewport.w)) * layout.w, top + layout.h }, null, current_bodies, notice_lift * layer.fade, track, win_w, win_h); - } for (surface.tagLayers()) |*layer| { if (layer.rows == 0 or layer.kind != .notice or noticeGroup(groups, layer) != index) continue; const x0 = @as(f32, @floatFromInt(layer.viewport.x)) * layout.w; @@ -9415,45 +9073,6 @@ test "decor is read from the regions, each pane's in its own group" { try std.testing.expectEqual(@as(u32, 0), groups.items[groups.ink].decor_count); } -test "a pane on the move casts a shadow on the other panes' bodies alone, most at mid-way" { - const gpa = std.testing.allocator; - const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); - defer core.deinit(); - _ = try core.newShell(1, ""); - try std.testing.expect(pardes.layout.splitColumn(core, 0, 1, false)); - try std.testing.expect(core.executeBuiltinLine(0, "Theme acme")); - for (0..40) |_| core.update(.tick); - core.sync(); - const s = try core.render(core.scratch.allocator()); - var g = testGui(10, 20, 6, 12); - defer g.decor.deinit(gpa); - const layout = fixedCellLayout(&g); - const serial = core.panes[1].?.serial; - var strengths: [3]f32 = @splat(0); - for ([_]u16{ 0, 6, 12 }, 0..) |frame, i| { - g.decor.clearRetainingCapacity(); - const moving: pardes.animation.Track = .{ .pane = 1, .serial = serial, .phase = .moving, .effect = .slide, .frame = frame, .frame_count = 13, .from = .{ .x = 0, .y = 1, .w = 40, .h = 23 }, .to = .{ .x = 40, .y = 1, .w = 40, .h = 23 } }; - var groups = makeGroups(&.{moving}, true); - if (!moving.active()) groups = makeGroups(&.{}, true); - try buildDecor(&g, gpa, s, &groups, layout, 800, 480, false); - for (g.decor.items) |item| { - if (item.effect & soft_shadow_bit == 0) continue; - strengths[i] = @max(strengths[i], item.fr); - // Clipped to pane 0's body or rail, never pane 1's, never a tag. - try std.testing.expect(item.clip_x1 >= item.clip_x0); - for (s.regionList()) |region| { - if (region.kind != .tag and region.kind != .grip and !(region.owner == 1 and (region.kind == .body or region.kind == .rail))) continue; - const r = bodyPixels(region, layout); - try std.testing.expect(item.clip_x1 <= r[0] or item.clip_x0 >= r[2] or item.clip_y1 <= r[1] or item.clip_y0 >= r[3]); - } - } - } - // Rising as it sets out, gone as it lands. - try std.testing.expectEqual(@as(f32, 0), strengths[0]); - try std.testing.expect(strengths[1] > 0.05); - try std.testing.expectEqual(@as(f32, 0), strengths[2]); -} - test "a body tells its first line, and lapis's dots under it move a quarter as far" { const gpa = std.testing.allocator; const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); -- cgit v1.3