Skip to content

Morph submobject families and add fill_mode subpath balancing - #6

Merged
pjfo merged 1 commit into
masterfrom
text-morphing-fill-modes
Aug 2, 2026
Merged

Morph submobject families and add fill_mode subpath balancing#6
pjfo merged 1 commit into
masterfrom
text-morphing-fill-modes

Conversation

@pjfo

@pjfo pjfo commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Polymorph previously rejected any mobject whose points live in submobjects, which ruled out Text, Tex, VGroups, and SVG imports. Since polymorph aligns arbitrary numbers of subpaths natively, flatten each keyframe's family into one multi-subpath path instead:

  • collect subpaths per family member in draw order, so boundaries stay exact even when one member's path ends where the next begins
  • collapse the animated mobject to a single flat VMobject during the morph, styled after its first drawn family member; style crossfade interpolates between those representative members rather than the (styleless) parents
  • restore the target's full submobject structure on finish with snap_to_target, so Text/Tex targets end as real glyphs

Flattened text exposes how subpath-count mismatches are filled: with polymorph's origin-point padding, four letters of a five-letter word grow from nothing while only one morphs from the source shape. Add a fill_mode option to control this. The new default, share, clones the smaller keyframe's subpaths (cycling largest-perimeter first) so every subpath morphs from and to real geometry — one shape splits into every glyph of a word, and every glyph merges back into one shape. The previous behavior remains as fill_mode=grow, used explicitly by the demo's origin-growth showcase.

Per-submobject styling collapses to one style mid-morph; documented in the README limitations.

Polymorph previously rejected any mobject whose points live in submobjects, which ruled out Text, Tex, VGroups, and SVG imports. Since polymorph aligns arbitrary numbers of subpaths natively, flatten each keyframe's family into one multi-subpath path instead:

- collect subpaths per family member in draw order, so boundaries stay exact even when one member's path ends where the next begins
- collapse the animated mobject to a single flat VMobject during the morph, styled after its first drawn family member; style crossfade interpolates between those representative members rather than the (styleless) parents
- restore the target's full submobject structure on finish with snap_to_target, so Text/Tex targets end as real glyphs

Flattened text exposes how subpath-count mismatches are filled: with polymorph's origin-point padding, four letters of a five-letter word grow from nothing while only one morphs from the source shape. Add a fill_mode option to control this. The new default, share, clones the smaller keyframe's subpaths (cycling largest-perimeter first) so every subpath morphs from and to real geometry — one shape splits into every glyph of a word, and every glyph merges back into one shape. The previous behavior remains as fill_mode=grow, used explicitly by the demo's origin-growth showcase.

Per-submobject styling collapses to one style mid-morph; documented in the README limitations.
@pjfo
pjfo merged commit 3f96ed5 into master Aug 2, 2026
1 check passed
@pjfo
pjfo deleted the text-morphing-fill-modes branch August 2, 2026 19:29
pjfo added a commit that referenced this pull request Aug 2, 2026
Morph submobject families and add fill_mode subpath balancing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant