summaryrefslogtreecommitdiff
path: root/src/anim/Painter.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/anim/Painter.zig')
-rw-r--r--src/anim/Painter.zig12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/anim/Painter.zig b/src/anim/Painter.zig
index b5d492f..f317dc1 100644
--- a/src/anim/Painter.zig
+++ b/src/anim/Painter.zig
@@ -56,11 +56,13 @@ pub fn fit(canvas: sk.Rect) f32 {
}
/// Object `o`'s drawing, centered on its origin, and its bounds.
-fn built(p: *Painter, o: anim.Object, svgs: anytype) !Built {
+fn built(p: *Painter, o: anim.Object, svgs: anytype) anim.BuildError!Built {
const id = o.id();
if (p.drawings.get(id)) |b| return b;
const arena = p.arena.?.allocator();
- const d = try anim.build(arena, o, svgs);
+ // A part, or what is left of an object parts were taken from: shapes
+ // of a whole drawing, which is built (parsed) once.
+ const d = if (o.source == .part or o.cut.len > 0) try anim.sift(arena, (try p.built(o.whole(), svgs)).drawing, o) else try anim.build(arena, o, svgs);
const b: Built = .{ .drawing = d, .bounds = d.bounds().rect() };
try p.drawings.put(arena, id, b);
return b;
@@ -122,7 +124,11 @@ fn paintLayers(p: *Painter, layers: anytype, f: *sk.Frame, shot: anim.Shot, svgs
// Morphing: from where this object began the transform to where
// its target will stand.
const morph = shot.morphs[i];
- const target = (try p.built(shot.objects[pose.into], svgs)).drawing;
+ // Into the whole target, parts and all: parts taken from it
+ // once it is made stand where they were and show as it does.
+ var into = shot.objects[pose.into];
+ into.cut = &.{};
+ const target = (try p.built(into, svgs)).drawing;
const between = try vector.morph.between(f.scratch, d, world.mul(model(morph.from)), target, world.mul(model(morph.to)), pose.morph);
try r.draw(between, .identity, pose.opacity);
shapes += between.shapes.len;