@@ -37,10 +37,13 @@ def _style_donor(vm: VMobject) -> VMobject:
3737class Polymorph (Animation ):
3838 """Morph a VMobject through one or more target shapes using polymorph.
3939
40- Unlike Transform, subpaths are paired by sorted perimeter, missing
41- subpaths grow from a configurable origin, and closed subpaths rotate
42- their start point toward that origin — producing stable morphs between
43- structurally different shapes.
40+ Unlike Transform, subpaths are paired by sorted perimeter and closed
41+ subpaths rotate their start point toward a configurable origin —
42+ producing stable morphs between structurally different shapes. When
43+ subpath counts differ, the smaller keyframe's subpaths are shared out
44+ across the larger's by default (one shape splits into many, many
45+ merge into one, flubber-style); fill_mode="grow" restores polymorph's
46+ own behavior of growing the missing subpaths from the origin.
4447
4548 Mobjects whose geometry lives in submobjects (Text, Tex, VGroup, SVG
4649 imports) are flattened: every subpath in the family joins one morph.
@@ -53,10 +56,14 @@ class Polymorph(Animation):
5356 targets: one or more target VMobjects; with several, the run time is
5457 divided evenly between consecutive pairs, like polymorph's own
5558 multi-path interpolate. Targets do not need to be on screen.
56- origin: where filler subpaths grow from and where closed subpaths start
57- drawing. Relative origins use SVG semantics — (0, 0) is the top-left
58- of each subpath's bounding box — while Origin(..., absolute=True)
59- is a scene coordinate.
59+ fill_mode: how subpath-count mismatches between keyframes are
60+ resolved. "share" (default) clones the smaller keyframe's
61+ subpaths so every subpath morphs from/to real geometry; "grow"
62+ pads with degenerate subpaths that grow from the origin.
63+ origin: where filler subpaths grow from (fill_mode="grow") and where
64+ closed subpaths start drawing. Relative origins use SVG semantics
65+ — (0, 0) is the top-left of each subpath's bounding box — while
66+ Origin(..., absolute=True) is a scene coordinate.
6067 add_points: extra curves added to every subpath (smooths morphs between
6168 shapes of very different complexity).
6269 optimize: "fill" (default) aligns subpaths automatically; "none"
@@ -71,6 +78,7 @@ def __init__(
7178 self ,
7279 mobject : VMobject ,
7380 * targets : VMobject ,
81+ fill_mode : Literal ["share" , "grow" ] = "share" ,
7482 origin : tuple [float , float ] | Origin = (0.0 , 0.0 ),
7583 add_points : int = 0 ,
7684 optimize : Literal ["fill" , "none" ] = "fill" ,
@@ -95,6 +103,7 @@ def __init__(
95103 origin = Origin (* origin )
96104
97105 self .targets = targets
106+ self .fill_mode = fill_mode
98107 self .origin = origin
99108 self .add_points = add_points
100109 self .optimize = optimize
@@ -130,6 +139,7 @@ def begin(self) -> None:
130139 optimize = self .optimize ,
131140 origin = origin ,
132141 add_points = self .add_points ,
142+ fill_mode = self .fill_mode ,
133143 )
134144 super ().begin ()
135145
0 commit comments