diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 07:24:52 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 07:24:52 -0300 |
| commit | 415b4e2683d03624f5600c23bfabde749a1a207c (patch) | |
| tree | 4b03bdf26e2d7d9071094020aca491e85e582e6f /core | |
| parent | ce8c6823c61cc94d04323f0c4226e4c99f2243f8 (diff) | |
| download | pardes-415b4e2683d03624f5600c23bfabde749a1a207c.tar.gz pardes-415b4e2683d03624f5600c23bfabde749a1a207c.zip | |
colors: the walk UI roles worked out in a fraction of the instructions (the frame gate's perfops against tree7: `open on small (per-op)` +23.3%, over the round's 10%: a pardes-perf open boots a core and draws its first frame, whose bodyChrome derives the chrome of the theme, roles and all, about 1.2M instructions of OKLab mixes, each three pow calls): `toward` (the dim and rule inks, two a ground, nine grounds) finds its hundredth by halves, seven mixes where its walk took up to a hundred (a mix's contrast falls as it nears the ground, so the step found is the walk's: the floors and UX's values hold to the unit); `pushAway` returns an ink that already reads without a mix; `selectionOf` keeps a selection that already stands off its ground with its text reading, and mixes from OKLab ends worked out once; RUN (perfops.sh tree7 against this tree's ReleaseFast prefix): `open on small` +6.53% against tree7 (+23.33% before), +5.77% against P3's tree on the same base; core-test 1069/1239 (170 skipped), process-test 0 of 146 failed (its goldens, which hold the inks, unchanged: the same inks to the byte); TEST: colors.zig's floors and UX-values tests unchanged and passing
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core')
| -rw-r--r-- | core/colors.zig | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/core/colors.zig b/core/colors.zig index 6b578f09..b2069465 100644 --- a/core/colors.zig +++ b/core/colors.zig @@ -708,17 +708,23 @@ fn inksOn(ground: [3]u8, ink: [3]u8) Inks { } /// `ink` mixed toward `ground` (OKLab) by hundredths as far as it still -/// reads at `floor` on it. +/// reads at `floor` on it: found by halves (its contrast falls as it nears +/// the ground), seven mixes where a walk took up to a hundred (the first +/// frame's bodyChrome derives them too). fn toward(ink: [3]u8, ground: [3]u8, floor: f32) [3]u8 { const a = toOklab(ink); const b = toOklab(ground); var best = ink; - var step: f32 = 1; - while (step <= 100) : (step += 1) { - const t = step / 100; + var lo: u32 = 0; + var hi: u32 = 101; + while (hi - lo > 1) { + const mid = (lo + hi) / 2; + const t = @as(f32, @floatFromInt(mid)) / 100; const c = fromOklab(.{ a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t }); - if (contrast(c, ground) < floor) break; - best = c; + if (contrast(c, ground) >= floor) { + lo = mid; + best = c; + } else hi = mid; } return best; } @@ -729,6 +735,7 @@ fn toward(ink: [3]u8, ground: [3]u8, floor: f32) [3]u8 { fn pushAway(ink: [3]u8, grounds: []const [3]u8, floor: f32) [3]u8 { const white: [3]u8 = @splat(255); const black: [3]u8 = @splat(0); + if (leastContrast(ink, grounds) >= floor) return ink; const end = if (leastContrast(white, grounds) >= leastContrast(black, grounds)) white else black; const a = toOklab(ink); const b = toOklab(end); @@ -765,10 +772,14 @@ fn selectionOf(own: [3]u8, ground: [3]u8, text: [3]u8) [3]u8 { var best = own; var best_off: f32 = 0; const away: [3]u8 = if (relativeLuminance(text) > relativeLuminance(own)) @splat(0) else @splat(255); + if (contrast(own, ground) >= Roles.selectionFloor(ground) and contrast(text, own) >= Roles.text_floor) return own; + const o = toOklab(own); for ([2][3]u8{ text, away }) |end| { + const e = toOklab(end); var step: f32 = 0; while (step <= 100) : (step += 1) { - const c = mixOklab(own, end, step / 100); + const t = step / 100; + const c = fromOklab(.{ o[0] + (e[0] - o[0]) * t, o[1] + (e[1] - o[1]) * t, o[2] + (e[2] - o[2]) * t }); if (contrast(text, c) < Roles.text_floor) break; const off = contrast(c, ground) / Roles.selectionFloor(ground); if (off >= 1) return c; |
