Skip to content

Commit 429f253

Browse files
authored
Fixed inconsistent stroke width scaling for text in compound objects (#4694)
* fixed zero-stroke mobject scaling * updated vectorized_mobject scale docstring text
1 parent c457249 commit 429f253

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

manim/mobject/types/vectorized_mobject.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,10 @@ def scale(
500500
will shrink, and for :math:`|\alpha| > 1` it will grow. Furthermore,
501501
if :math:`\alpha < 0`, the mobject is also flipped.
502502
scale_stroke
503-
Boolean determining if the object's outline is scaled when the object is scaled.
504-
If enabled, and object with 2px outline is scaled by a factor of .5, it will have an outline of 1px.
503+
Boolean determining if each submobject's outline is scaled when the object
504+
is scaled. If enabled, each submobject keeps its relative stroke width (for
505+
example, a submobject with a 2px outline scaled by a factor of .5 will have
506+
a 1px outline, while a submobject with 0px stroke remains at 0px).
505507
kwargs
506508
Additional keyword arguments passed to
507509
:meth:`~.Mobject.scale`.
@@ -538,11 +540,17 @@ def construct(self):
538540
539541
"""
540542
if scale_stroke:
541-
self.set_stroke(width=abs(scale_factor) * self.get_stroke_width())
542-
self.set_stroke(
543-
width=abs(scale_factor) * self.get_stroke_width(background=True),
544-
background=True,
545-
)
543+
for mob in self.get_family():
544+
if isinstance(mob, VMobject):
545+
mob.set_stroke(
546+
width=abs(scale_factor) * mob.get_stroke_width(),
547+
family=False,
548+
)
549+
mob.set_stroke(
550+
width=abs(scale_factor) * mob.get_stroke_width(background=True),
551+
background=True,
552+
family=False,
553+
)
546554
super().scale(scale_factor, about_point=about_point, about_edge=about_edge)
547555
return self
548556

0 commit comments

Comments
 (0)