feat(clip-path): a morph can pass through intermediate shapes - #405
Merged
Merged
Conversation
#398 delivered clip-path animation in a different spelling from the one #384 asked for, and I left the issue open with the choice written down: finish the literal `property: "clip-path"` form with shape-valued keyframes, or re-scope. Neither, on reflection. The spelling was never the gap — the limit to two shapes was. A second vocabulary for one capability is worse than one good one, and a shape-valued keyframe would have to re-earn the easing, spring and loop handling that the scalar track already gives for free. So `Morph` gains `via`: shapes the sweep passes through, in order. "clip-path": { "kind": "morph", "from": { "kind": "circle", "radius": 20 }, "via": [ { "kind": "circle", "radius": 140 } ], "to": { "kind": "circle", "radius": 60 } } `progress` spans the whole chain rather than each leg, and the legs are equal in progress whatever the geometric distance between shapes — an uneven pace is the easing's job, not the chain's. Each consecutive pair follows the same interpolation rule as a two-shape morph, and an incompatible pair mid-chain warns and leaves the node unclipped exactly as a lone incompatible pair does. `via` absent is byte-for-byte what a morph has always been, which is what a unit test on `morph_leg` asserts directly rather than through pixels. Four tests. Three fail without the chain. The fourth is the compatibility pin and passes both ways on purpose. One of them replaced an earlier version of itself that was simply wrong: it compared a chain at progress 1.0 against a direct morph at 0.5, which land on different shapes by construction. It asserted something untrue and failed for the right reason. Closes #384
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #384. Refs #388.
The decision, and why it is neither option I offered
#398 landed clip-path animation in a different spelling from the one this issue describes, and I left it open with the choice written into the issue: finish the literal
property: "clip-path"form with shape-valued keyframes, or re-scope.On reflection, neither. The spelling was never the gap — the limit to two shapes was.
A second vocabulary for one capability is worse than one good one, and a shape-valued keyframe would have to re-earn the
easing,spring,loopand per-keyframe easing that the scalarclip_path_progresstrack already provides for free, precisely because it is an ordinary motion property.So the chain gets longer instead:
How it behaves
progressspans the whole chain, not each leg: with onevia,0.5lands exactly on it and0.25is halfway along the first leg. Legs are equal in progress whatever the geometric distance between the shapes — an uneven pace is the easing's job, and putting it inviawould have made two knobs fight over the same thing.Each consecutive pair follows the same rule as a two-shape morph: same kind, same vertex count for a polygon. An incompatible pair mid-chain warns on stderr and leaves the node unclipped, exactly as a lone incompatible pair does — no new failure mode.
Verification
Four tests. Three fail without the chain, confirmed by short-circuiting
morph_leg:an_empty_via_leaves_the_two_shape_morph_exactly_as_it_wasasserts onmorph_legdirectly rather than through pixels: with novia, the endpoints and the progress pass through untouched. That is the clearest possible statement that nothing written before this renders differently.One test replaced an earlier version of itself that was simply wrong. It compared a chain at progress 1.0 against a direct morph at 0.5 — which land on different shapes by construction. It asserted something untrue, and failed for the right reason. Worth saying, because a test that fails for a bad reason is easy to "fix" by loosening it.
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace(1722) all clean.Written comment-free, per the codebase-wide rule from #345.