From 5553b933f7c243b2706eb2a7989d8e33d2f6042b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 02:22:43 -0300 Subject: vector: morph pairs outer contours with outer ones and holes with holes A glyph with a counter blobbed through a morph: subpaths paired by their index alone, so a hole with no partner (a 0 into a 5) collapsed onto the end of the other glyph's outline, travelling out of its own shape and leaving the counter filled, and one listed before its outline (or a shape gaining a hole) was paired with the other side's outline, its winding turned inside out. In manual's second slide the 0 became a black blob for a third of its morph into the 5. Now each pair of shapes sorts its subpaths, outer contours then holes (a hole winds against the shape's largest subpath, as a font's counters do), and pairs within each group. A hole with no partner shrinks to a point (or grows from one) where its middle stands relative to the outer contours' bounds on the other side, so it stays inside its shape as that moves. A shape without a partner, or one with no hole, morphs as before, bit for bit. Test: test/scene_morph, a ring into a disc, a 0 into a 5 and a 0 whose path lists its hole first into a ring, at a quarter, half and three quarters on the GPU and on the CPU: each hole's middle is the background (the 0 into the 5 while its hole is half its size or more), and the disc and the 5 fill it at the end. The old pairing fails it at half way on all three. What changed: the compiled test scene's equation morph (export frames 32-59, compiled-morph.png: no stray dot from a's hole, b and a keep their counters) and manual's three morphs of holed glyphs (exported frames 28.1-29.3 s, C0 into 11 000 000; 55.7-56.9 s, the 0 into the 5; 58.8-60.4 s, ADD into SUB with the row). Everything else is byte-identical: the talk's exports, every scene screenshot (manual's are taken at rest), and zig build diff's corpus, which draws no morph. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/scene_morph.script | 46 ++++++++++++++++++++++++++++++++++++++++++++++ test/scene_morph.zig | 25 +++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 test/scene_morph.script create mode 100644 test/scene_morph.zig (limited to 'test') diff --git a/test/scene_morph.script b/test/scene_morph.script new file mode 100644 index 0000000..0da4670 --- /dev/null +++ b/test/scene_morph.script @@ -0,0 +1,46 @@ +# Holes through morphs (test/scene_morph.zig), a quarter, half and three +# quarters of the way, on the GPU and then on the CPU: the middle of each +# hole is the background, the ring around it drawn (the 0 into the 5 while +# its hole is half its size or more); at the end the disc fills it. +console set deck.playing false +console set deck.t 1 +screenshot .zig-cache/anim/morph-1.png +expect-pixel .zig-cache/anim/morph-1.png 300 360 255 255 255 255 1 +expect-pixel .zig-cache/anim/morph-1.png 240 360 28 28 31 255 1 +expect-pixel .zig-cache/anim/morph-1.png 640 360 28 28 31 255 1 +expect-pixel .zig-cache/anim/morph-1.png 1040 360 28 28 31 255 1 +console set deck.t 2 +screenshot .zig-cache/anim/morph-2.png +expect-pixel .zig-cache/anim/morph-2.png 300 360 255 255 255 255 1 +expect-pixel .zig-cache/anim/morph-2.png 240 360 28 28 31 255 1 +expect-pixel .zig-cache/anim/morph-2.png 640 360 28 28 31 255 1 +expect-pixel .zig-cache/anim/morph-2.png 1040 360 28 28 31 255 1 +console set deck.t 3 +screenshot .zig-cache/anim/morph-3.png +expect-pixel .zig-cache/anim/morph-3.png 300 360 255 255 255 255 1 +expect-pixel .zig-cache/anim/morph-3.png 240 360 28 28 31 255 1 +expect-pixel .zig-cache/anim/morph-3.png 1040 360 28 28 31 255 1 +key b +expect backend cpu +console set deck.t 1 +screenshot .zig-cache/anim/morph-cpu-1.png +expect-pixel .zig-cache/anim/morph-cpu-1.png 300 360 255 255 255 255 1 +expect-pixel .zig-cache/anim/morph-cpu-1.png 240 360 28 28 31 255 1 +expect-pixel .zig-cache/anim/morph-cpu-1.png 640 360 28 28 31 255 1 +expect-pixel .zig-cache/anim/morph-cpu-1.png 1040 360 28 28 31 255 1 +console set deck.t 2 +screenshot .zig-cache/anim/morph-cpu-2.png +expect-pixel .zig-cache/anim/morph-cpu-2.png 300 360 255 255 255 255 1 +expect-pixel .zig-cache/anim/morph-cpu-2.png 240 360 28 28 31 255 1 +expect-pixel .zig-cache/anim/morph-cpu-2.png 640 360 28 28 31 255 1 +expect-pixel .zig-cache/anim/morph-cpu-2.png 1040 360 28 28 31 255 1 +console set deck.t 3 +screenshot .zig-cache/anim/morph-cpu-3.png +expect-pixel .zig-cache/anim/morph-cpu-3.png 300 360 255 255 255 255 1 +expect-pixel .zig-cache/anim/morph-cpu-3.png 240 360 28 28 31 255 1 +expect-pixel .zig-cache/anim/morph-cpu-3.png 1040 360 28 28 31 255 1 +console set deck.t 4 +screenshot .zig-cache/anim/morph-cpu-4.png +expect-pixel .zig-cache/anim/morph-cpu-4.png 240 360 255 255 255 255 1 +expect-pixel .zig-cache/anim/morph-cpu-4.png 640 360 255 255 255 255 1 +expect-pixel .zig-cache/anim/morph-cpu-4.png 1040 360 28 28 31 255 1 diff --git a/test/scene_morph.zig b/test/scene_morph.zig new file mode 100644 index 0000000..fbde51d --- /dev/null +++ b/test/scene_morph.zig @@ -0,0 +1,25 @@ +//! Holes through a morph (vector/morph.zig), for test/scene_morph.script: +//! a ring into a disc, a 0 into a 5, and a 0 whose path has its hole first +//! into a ring, side by side, together over 4 s at a steady pace. +const anim = @import("anim"); + +pub const scene = anim.Scene(construct); + +const disc = "M 40 0 C 40 22 22 40 0 40 C -22 40 -40 22 -40 0 C -40 -22 -22 -40 0 -40 C 22 -40 40 -22 40 0 Z "; +const ring_hole = "M 20 0 C 20 -11 11 -20 0 -20 C -11 -20 -20 -11 -20 0 C -20 11 -11 20 0 20 C 11 20 20 11 20 0 Z "; +const zero = "M 0 -45 C 25 -45 30 -20 30 0 C 30 20 25 45 0 45 C -25 45 -30 20 -30 0 C -30 -20 -25 -45 0 -45 Z "; +const zero_hole = "M 0 -25 C -12 -25 -14 -12 -14 0 C -14 12 -12 25 0 25 C 12 25 14 12 14 0 C 14 -12 12 -25 0 -25 Z "; +const five = "M -25 -45 H 25 V -33 H -13 V -8 H 5 L 20 -3 L 28 10 V 25 L 20 40 L 5 45 H -25 V 33 H 5 L 14 25 V 10 L 5 4 H -25 Z "; + +const head = ""; + +fn construct(s: *anim.Builder) void { + const pairs = .{ .{ disc ++ ring_hole, disc, -400 }, .{ zero ++ zero_hole, five, 0 }, .{ zero_hole ++ zero, disc ++ ring_hole, 400 } }; + var morphs: [pairs.len]anim.Animation = undefined; + inline for (pairs, &morphs) |p, *m| { + const from = s.svg(head ++ p[0] ++ tail, .{ .x = p[2], .scale = 2, .visible = true }); + m.* = from.transformInto(s.svg(head ++ p[1] ++ tail, .{ .x = p[2], .scale = 2 })); + } + s.play(morphs, .{ .seconds = 4, .ease = anim.ease.linear }); +} -- cgit v1.3