Skip to content

Commit 40987d5

Browse files
committed
My clean commit message
1 parent d3d4204 commit 40987d5

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

manim/animation/creation.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def construct(self):
9494
from ..animation.animation import Animation
9595
from ..animation.composition import Succession
9696
from ..mobject.mobject import Group, Mobject
97-
from ..mobject.svg.svg_mobject import SVGMobject
9897
from ..mobject.types.vectorized_mobject import VMobject
9998
from ..utils.bezier import integer_interpolate
10099
from ..utils.rate_functions import double_smooth, linear
@@ -294,17 +293,17 @@ def interpolate_submobject(
294293

295294

296295
class Write(DrawBorderThenFill):
297-
"""Simulate hand-writing a text-based mobject, such as :class:`~.Text`,
298-
:class:`~.MarkupText`, :class:`~.Tex`, :class:`~.MathTex`,
299-
or :class:`~.VMobject` in general.
296+
"""Simulate hand-writing a text-based mobject, such as :class:`~.Text`
297+
and :class:`~.Tex`, or simulate hand-drawing a :class:`~.VMobject`.
300298
301299
Parameters
302300
----------
303301
vmobject
304302
The VMobject to animate.
305303
stroke_width
306-
Stroke width for drawing. If not given, for SVG-based mobjects (such as :class:`Text`, :class:`MarkupText`, or :class:`MathTex`)
307-
the stroke width is scaled relative to the font size. Others use 2.0.
304+
Stroke width for drawing. If not provided, it is scaled based on font size
305+
for text-based mobjects when the font is very small or very large;
306+
otherwise defaults to 2.0.
308307
rate_func
309308
The function defining the animation progress.
310309
reverse
@@ -386,10 +385,14 @@ def _adjust_stroke_width_for_text(
386385
) -> float:
387386
if stroke_width is not None:
388387
return stroke_width
389-
if not isinstance(vmobject, SVGMobject):
390-
return 2.0 # default in DrawBorderThenFill
391-
font_size = getattr(vmobject, "font_size", DEFAULT_FONT_SIZE)
392-
return (font_size / DEFAULT_FONT_SIZE) * DEFAULT_STROKE_WIDTH * scale_factor
388+
if not hasattr(vmobject, "font_size") or vmobject.height == 0:
389+
return 2
390+
font_size = vmobject.font_size
391+
if font_size < 20 or font_size > 6 * DEFAULT_FONT_SIZE:
392+
# adjust stroke_width if font_size is too small or too big
393+
return (font_size / DEFAULT_FONT_SIZE) * DEFAULT_STROKE_WIDTH * scale_factor
394+
else:
395+
return 2
393396

394397
def reverse_submobjects(self) -> None:
395398
self.mobject.invert(recursive=True)

0 commit comments

Comments
 (0)