From 1d904c2d8a0c862e807afc60d7ab00aa9dd866a1 Mon Sep 17 00:00:00 2001 From: Taksh Date: Tue, 30 Jun 2026 16:16:54 +0530 Subject: [PATCH] fix(text): set color on Text when passed to constructor Fixes #4817 Co-authored-by: Cursor --- manim/mobject/text/text_mobject.py | 3 +++ tests/test_graphical_units/test_text.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/manim/mobject/text/text_mobject.py b/manim/mobject/text/text_mobject.py index d484420301..02f9fb34aa 100644 --- a/manim/mobject/text/text_mobject.py +++ b/manim/mobject/text/text_mobject.py @@ -593,6 +593,9 @@ def add_line_to(end: Point3D) -> None: self.scale(TEXT_MOB_SCALE_FACTOR) self.initial_height = self.height + if color is not None: + self.color = parsed_color + def __repr__(self) -> str: return f"Text({repr(self.original_text)})" diff --git a/tests/test_graphical_units/test_text.py b/tests/test_graphical_units/test_text.py index 7c75f8b995..ac26dfdab6 100644 --- a/tests/test_graphical_units/test_text.py +++ b/tests/test_graphical_units/test_text.py @@ -32,3 +32,10 @@ def test_text_color_inheritance(): # reset the default color so that future tests aren't affected by this change. VMobject.set_default() + + +def test_text_constructor_color(): + from manim import WHITE + + text = Text("test", color=WHITE) + assert text.get_color().to_hex() == WHITE.to_hex()