Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fixed :class:`~.DecimalNumber` color when number of displayed digits changes (#2280)

Viicos17ef4a4361f1
diff --git a/manim/mobject/numbers.py b/manim/mobject/numbers.py
index 2dc04df68..9cb459a00 100644
--- a/manim/mobject/numbers.py
+++ b/manim/mobject/numbers.py
@@ -251,6 +251,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
# not needed with opengl renderer
mob.points[:] = 0
+ self.init_colors()
return self
def get_value(self):
diff --git a/tests/test_numbers.py b/tests/test_numbers.py
index 01b9e76c5..dda101638 100644
--- a/tests/test_numbers.py
+++ b/tests/test_numbers.py
@@ -1,6 +1,7 @@
import pytest
+from colour import Color
-from manim.mobject.numbers import DecimalNumber
+from manim import RED, DecimalNumber, Integer
def test_font_size():
@@ -35,3 +36,11 @@ def test_set_value_size():
# round because the height is off by 1e-17
assert round(num.height, 12) == round(test_num.height, 12)
+
+
+def test_color_when_number_of_digits_changes():
+ """Test that all digits of an Integer are colored correctly when
+ the number of digits changes."""
+ mob = Integer(color=RED)
+ mob.set_value(42)
+ assert all([submob.stroke_color == Color(RED) for submob in mob.submobjects])