summaryrefslogtreecommitdiff
path: root/anim/src/regroup.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/regroup.zig')
-rw-r--r--anim/src/regroup.zig35
1 files changed, 22 insertions, 13 deletions
diff --git a/anim/src/regroup.zig b/anim/src/regroup.zig
index a904ba2..f5c5fd9 100644
--- a/anim/src/regroup.zig
+++ b/anim/src/regroup.zig
@@ -99,10 +99,15 @@ pub const Words = struct {
/// address, each word to where the slot's chain has it.
become: anim.Value,
panel: struct { x: f32 = 0, top: f32 = 0, first: u64 = 0 } = .{},
+ /// Its first row's top (`at.top`): folded on the shelf it can be set
+ /// anew, and unfolds there (the introduction's II8: at the rows III's stack gives the words).
+ top: anim.Value,
+ /// 0 to 1: its header back over its rows after the dump was tied to its place (before a fold).
+ back: anim.Value,
pub fn init(s: *anim.Frame, rec: *const Recording, moment: u64) Words {
const picked = pick(rec, moment);
- return .{ .rec = rec, .at = moment, .in = s.value(-1), .regroup = s.value(-1), .framed = s.value(-1), .fold = s.value(0), .placed = s.value(0), .ink = s.value(-1), .left = s.value(-1), .chains = s.value(-1), .walked = picked.walked, .three = picked.three, .become = s.value(0) };
+ return .{ .rec = rec, .at = moment, .in = s.value(-1), .regroup = s.value(-1), .framed = s.value(-1), .fold = s.value(0), .placed = s.value(0), .ink = s.value(-1), .left = s.value(-1), .chains = s.value(-1), .walked = picked.walked, .three = picked.three, .become = s.value(0), .top = s.value(at.top), .back = s.value(0) };
}
/// The return address the newest frame has, and the first word that
@@ -149,14 +154,14 @@ pub const Words = struct {
}
/// Word `i`'s row's top, its bytes' first x, and how much its address shows, at regroup clock `r`.
- fn where(i: usize, r: f32) struct { y: f32, x: f32, address: f32 } {
+ fn where(i: usize, r: f32, top: f32) struct { y: f32, x: f32, address: f32 } {
const row: f32 = @floatFromInt(i / 2);
const half: f32 = @floatFromInt(i % 2);
const a = glide(r / 18);
const b = glide((r - 18) / 12);
const c = glide((r - 30) / 18);
return .{
- .y = at.top + pitch * (row + row * a + half * b),
+ .y = top + pitch * (row + row * a + half * b),
.x = at.bytes + half * (8 * at.pair + at.middle) * (1 - c),
.address = if (half == 0) 1 else clamp01((r - 36) / 12),
};
@@ -172,8 +177,9 @@ pub const Words = struct {
const fold = placed.value(w.fold);
// Folding: the rows glide up into the header (24 f), which becomes the tag (`tag`).
const gather = glide(fold / 24);
- const header_y = at.top - pitch;
- w.tag(u, fold);
+ const top = placed.value(w.top);
+ const header_y = top - pitch;
+ w.tag(u, fold, top);
if (gather >= 1) return;
const v = u;
const data = read(w.rec, w.at);
@@ -181,14 +187,14 @@ pub const Words = struct {
// The header (mock 29), with the first row; gone as the dump is tied to its place.
// The veil over every row but the walked one, while it is walked (the header too).
const veil = clamp01((r - 48) / 18) - clamp01((r - 270 - later) / 18);
- const header = clamp01(in / 18) * (1 - placed.value(w.placed)) * (1 - veil) * (1 - clamp01((fold - 12) / 8));
- if (header > 0) v.faded(header).text(.sans, theme.size.sans.micro, at.address, at.top - 12, v.print("128 bytes at {x}", .{w.rec.register(w.at, "rsp")}), t.faint);
+ const header = clamp01(in / 18) * (1 - placed.value(w.placed) * (1 - clamp01(placed.value(w.back)))) * (1 - veil) * (1 - clamp01((fold - 12) / 8));
+ if (header > 0) v.faded(header).text(.sans, theme.size.sans.micro, at.address, top - 12, v.print("128 bytes at {x}", .{w.rec.register(w.at, "rsp")}), t.faint);
const address_ink = ui.mix(t.faint, theme.color.region.stack, placed.value(w.placed));
const become = placed.value(w.become);
const g = glide(become);
for (0..words) |i| {
- const p = where(i, r);
+ const p = where(i, r, top);
const arrive = clamp01((in - rows_apart * @as(f32, @floatFromInt(i / 2))) / 18);
if (arrive <= 0) continue;
const row = v.faded(arrive * (if (i == w.walked) 1 else 1 - theme.color.veil_alpha * veil) * (1 - gather));
@@ -207,7 +213,7 @@ pub const Words = struct {
if (framed >= 0) for (w.three, 0..) |i, k| {
const shows = clamp01((framed - 30 * @as(f32, @floatFromInt(k))) / 6);
var rect = w.wordRect(i, data.words[i], placed);
- rect.y = std.math.lerp(rect.y, header_y, gather);
+ rect.y = std.math.lerp(rect.y - at.top + top, header_y, gather);
if (shows > 0) v.faded(1 - gather).read(rect, shows);
};
}
@@ -395,13 +401,16 @@ pub const Words = struct {
/// header out 12 to 20, the tag in 16 to 24, its title where the
/// header's was), which then goes to the shelf (24 f, `glide`); back,
/// the reverse.
- fn tag(_: *const Words, u: ui.Ui, fold: f32) void {
+ fn tag(_: *const Words, u: ui.Ui, fold: f32, top: f32) void {
if (fold <= 16) return;
const title = "the 128 bytes";
- const p = glide((fold - 24) / 24);
+ // To the shelf's height first, then along it (over what stands under it, crossing none); back, the reverse.
+ const p = clamp01((fold - 24) / 24);
const w = u.width(.sans_medium, theme.size.sans.tag, title) + 40;
- const x = std.math.lerp(at.address - 28, theme.canvas.margin_x, p);
- const y = std.math.lerp(at.top - 30, theme.canvas.stage.y, p);
+ const dy = @abs(top - 30 - theme.canvas.stage.y);
+ const share = std.math.clamp(dy / (at.address - 28 - theme.canvas.margin_x + dy), 0.25, 0.6);
+ const y = std.math.lerp(top - 30, theme.canvas.stage.y, glide(p / share));
+ const x = std.math.lerp(at.address - 28, theme.canvas.margin_x, glide((p - 0.6 * share) / (1 - 0.6 * share)));
const v = u.faded(clamp01((fold - 16) / 8)).moved(x, y);
v.fill(.{ .x = 0, .y = 0, .w = w, .h = theme.metric.context.tag }, theme.color.raised);
v.frame(.{ .x = 8, .y = 6, .w = 12, .h = 12 }, t.faint, theme.stroke.rule);