summaryrefslogtreecommitdiff
path: root/src/draw.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/draw.zig')
-rw-r--r--src/draw.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/draw.zig b/src/draw.zig
index 93d5b2d9..b0b16e12 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -723,6 +723,7 @@ fn composedCell(
return switch (animation.charSource(track, col - area.x0, row - area.y0, area)) {
.old => canonical.previous_cells[index],
.byte => |byte| withByte(canonical.cells[index], byte),
+ .edge => |weight| towardGround(canonical.cells[index], canonical.previous_cells[index].style.bg, weight),
// Churn belongs on the glyph, not on the pane's empty space, and it
// borrows whichever side of the diff actually has one.
.churn => |byte| blk: {
@@ -749,6 +750,25 @@ fn composedCell(
};
}
+/// A cell with its ink and ground drawn `weight` of the way toward another
+/// ground, in OKLab. A palette or default colour cannot be mixed, so the
+/// ground steps over at the halfway point instead.
+fn towardGround(cell: Cell, ground: Color, weight: f32) Cell {
+ var out = cell;
+ const to = switch (ground) {
+ .rgb => |rgb| rgb,
+ .default, .index => return if (weight >= 0.5) blk: {
+ out.style.bg = ground;
+ break :blk out;
+ } else out,
+ };
+ inline for (.{ &out.style.fg, &out.style.bg }) |color| switch (color.*) {
+ .rgb => |rgb| color.* = .{ .rgb = colors.mixOklab(rgb, to, weight) },
+ .default, .index => {},
+ };
+ return out;
+}
+
fn withByte(cell: Cell, byte: u8) Cell {
var out = cell;
out.text[0] = byte;