Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

added regression test for inconsistent stroke width scaling for text in compound objects (#4703)

Vihaan Dutta3b9b92d97bc8
diff --git a/tests/module/mobject/types/vectorized_mobject/test_stroke.py b/tests/module/mobject/types/vectorized_mobject/test_stroke.py
index 62076e3d0..f5ca2eb3c 100644
--- a/tests/module/mobject/types/vectorized_mobject/test_stroke.py
+++ b/tests/module/mobject/types/vectorized_mobject/test_stroke.py
@@ -1,7 +1,7 @@
from __future__ import annotations
import manim.utils.color as C
-from manim import VMobject
+from manim import ORIGIN, NumberPlane, VMobject
from manim.mobject.vector_field import StreamLines
@@ -63,6 +63,30 @@ def test_background_stroke_scale():
assert b.get_stroke_width(background=True) == 25
+def test_scale_stroke_preserves_zero_width_on_number_plane_coordinates():
+ """Regression for #4648: compound scale with scale_stroke must not add stroke to text labels."""
+ npl = NumberPlane().add_coordinates()
+ zero_stroke_mobs = [
+ mob
+ for mob in npl.get_family()
+ if isinstance(mob, VMobject) and mob.get_stroke_width() == 0
+ ]
+
+ nonzero_stroke_mobs = [
+ mob
+ for mob in npl.get_family()
+ if isinstance(mob, VMobject) and mob.get_stroke_width() != 0
+ ]
+
+ assert zero_stroke_mobs
+ assert nonzero_stroke_mobs
+
+ npl.scale(0.01, scale_stroke=True, about_point=ORIGIN)
+
+ for mob in zero_stroke_mobs:
+ assert mob.get_stroke_width() == 0
+
+
def test_stroke_scale_preserves_relative_widths_in_compound_mobjects():
"""Regression test for fix 429f25328 (PR #4694).