summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/colors.zig36
1 files changed, 29 insertions, 7 deletions
diff --git a/core/colors.zig b/core/colors.zig
index 3325671c..4f58aed5 100644
--- a/core/colors.zig
+++ b/core/colors.zig
@@ -644,8 +644,8 @@ pub const Roles = struct {
pub const rule_floor: f32 = 1.8;
pub const rule_ceiling: f32 = 2.5;
pub const ink_floor: f32 = 4.5;
- pub const hit_floor: f32 = 1.25;
- pub const hit_current_floor: f32 = 1.6;
+ pub const hit_floor: f32 = 1.5;
+ pub const hit_current_floor: f32 = 1.9;
pub const reading_distance: f32 = 0.04;
pub fn on(r: *const Roles, ground: TagGround) *const Inks {
@@ -795,8 +795,10 @@ fn selectionOf(own: [3]u8, ground: [3]u8, text: [3]u8) [3]u8 {
/// A ground off `page` toward `hue` at `t` (past 1, beyond the hue, as far
/// as the gamut goes), held where the body's `ink` reads on it at 4.5:1
-/// (or its own on the page, where that is less); moved on toward the ink
-/// until it stands off the page at `floor`, as far as the ink allows.
+/// (or its own on the page, where that is less); on toward the hue, the
+/// least way that stands off the page at `floor`, where the ink still
+/// reads on it; else moved on toward the ink until it stands off the page
+/// at `floor`, as far as the ink allows.
fn hitOf(page: [3]u8, hue: [3]u8, ink: [3]u8, t: f32, floor: f32) [3]u8 {
const a = toOklab(page);
const b = toOklab(hue);
@@ -807,6 +809,22 @@ fn hitOf(page: [3]u8, hue: [3]u8, ink: [3]u8, t: f32, floor: f32) [3]u8 {
k -= t / 50;
c = fromOklab(.{ a[0] + (b[0] - a[0]) * k, a[1] + (b[1] - a[1]) * k, a[2] + (b[2] - a[2]) * k });
}
+ // Found by halves, seven mixes: the nearer the hue, the further off
+ // the page (UX E7 7b: a landing line 1.5:1, its span 1.9:1).
+ if (contrast(c, page) < floor and k < 1 and contrast(hue, page) >= floor) {
+ var lo = k;
+ var hi: f32 = 1;
+ var far = hue;
+ for (0..7) |_| {
+ const mid = (lo + hi) / 2;
+ const m = fromOklab(.{ a[0] + (b[0] - a[0]) * mid, a[1] + (b[1] - a[1]) * mid, a[2] + (b[2] - a[2]) * mid });
+ if (contrast(m, page) < floor) lo = mid else {
+ hi = mid;
+ far = m;
+ }
+ }
+ if (contrast(ink, far) >= ink_floor) c = far;
+ }
const start = c;
var step: f32 = 1;
while (contrast(c, page) < floor and step <= 50) : (step += 1) {
@@ -1587,7 +1605,9 @@ test "every theme's walk UI roles meet their floors on every ground they are dra
for ([_][3]u8{ th.tag_fg, th.tag_active_fg orelse th.tag_fg }) |ink|
try checks.append(a, .{ .what = "text on reading", .got = contrast(ink, chrome.tag_reading_bg), .floor = @min(7, contrast(ink, th.tag_bg)) - 0.02 });
const ink_floor = @min(Roles.ink_floor, contrast(body_ink, page));
- for ([_][3]u8{ r.hit, r.hit_current }, [_]f32{ Roles.hit_floor, Roles.hit_current_floor }) |ground, floor| {
+ // A preview's landing line 1.5:1 off the page, its matched span (the
+ // current hit) a step stronger, 1.9:1 (UX E7 7b: 1.29 read as faint).
+ for ([_][3]u8{ r.hit, r.hit_current }, [_]f32{ 1.5, 1.9 }) |ground, floor| {
const on = contrast(body_ink, ground);
try checks.append(a, .{ .what = "hit", .got = contrast(ground, page), .floor = if (on < ink_floor + 0.3) 0 else floor });
try checks.append(a, .{ .what = "ink on hit", .got = on, .floor = ink_floor - 0.01 });
@@ -1603,13 +1623,15 @@ test "every theme's walk UI roles meet their floors on every ground they are dra
test "neonotte84's and acme's roles are the ones UX derived (DESIGN.md D4, tools/roles.py)" {
const Want = struct { name: []const u8, text: ?[3]u8, dim: [3]u8, rule: [3]u8, key: [3]u8, match: [3]u8, reading: [3]u8, hit: [3]u8, hit_current: [3]u8 };
+ // The hit grounds past UX's 18 % / 32 % mix, to 1.5:1 and 1.9:1 off the
+ // page (UX E7 7b).
const wants = [_]Want{
- .{ .name = "neonotte84", .text = .{ 0xb5, 0xbf, 0xe3 }, .dim = .{ 0x70, 0x76, 0x8f }, .rule = .{ 0x4c, 0x50, 0x63 }, .key = .{ 0xf8, 0xde, 0xd9 }, .match = .{ 0xf1, 0xa2, 0x71 }, .reading = .{ 0x29, 0x27, 0x1e }, .hit = .{ 0x36, 0x28, 0x2a }, .hit_current = .{ 0x52, 0x38, 0x31 } },
+ .{ .name = "neonotte84", .text = .{ 0xb5, 0xbf, 0xe3 }, .dim = .{ 0x70, 0x76, 0x8f }, .rule = .{ 0x4c, 0x50, 0x63 }, .key = .{ 0xf8, 0xde, 0xd9 }, .match = .{ 0xf1, 0xa2, 0x71 }, .reading = .{ 0x29, 0x27, 0x1e }, .hit = .{ 0x47, 0x32, 0x2e }, .hit_current = .{ 0x5f, 0x3f, 0x33 } },
// acme's key and match a little darker than UX's #5c5c8d and
// #974d00 (which hold on its tag and its #9eeeee): a reading pane's
// band's selection is pushed off the reading ground (#9eeeee is
// 1.12:1 off #f3f0cc), and they read on that one too.
- .{ .name = "acme", .text = null, .dim = .{ 0x7a, 0x86, 0x86 }, .rule = .{ 0xa8, 0xb7, 0xb7 }, .key = .{ 0x55, 0x55, 0x83 }, .match = .{ 0x8f, 0x48, 0x00 }, .reading = .{ 0xf3, 0xf0, 0xcc }, .hit = .{ 0xec, 0xd8, 0xbb }, .hit_current = .{ 0xdd, 0xbc, 0x99 } },
+ .{ .name = "acme", .text = null, .dim = .{ 0x7a, 0x86, 0x86 }, .rule = .{ 0xa8, 0xb7, 0xb7 }, .key = .{ 0x55, 0x55, 0x83 }, .match = .{ 0x8f, 0x48, 0x00 }, .reading = .{ 0xf3, 0xf0, 0xcc }, .hit = .{ 0xe6, 0xcd, 0xae }, .hit_current = .{ 0xd9, 0xb4, 0x90 } },
};
for (wants) |want| {
const chrome = ChromeTheme.fromTheme(&themes[themeIndex(want.name).?]);