From 756113d2d3ef25cfb6a69e4ce2c1591793ba33bd Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 26 Feb 2025 09:48:46 -0600 Subject: [PATCH] Add min_total_width option to DecimalNumber --- manimlib/mobject/numbers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manimlib/mobject/numbers.py b/manimlib/mobject/numbers.py index f5c1fc53..7009dee7 100644 --- a/manimlib/mobject/numbers.py +++ b/manimlib/mobject/numbers.py @@ -40,6 +40,7 @@ class DecimalNumber(VMobject): fill_opacity: float = 1.0, fill_border_width: float = 0.5, num_decimal_places: int = 2, + min_total_width: Optional[int] = 0, include_sign: bool = False, group_with_commas: bool = True, digit_buff_per_font_unit: float = 0.001, @@ -54,6 +55,7 @@ class DecimalNumber(VMobject): self.num_decimal_places = num_decimal_places self.include_sign = include_sign self.group_with_commas = group_with_commas + self.min_total_width = min_total_width self.digit_buff_per_font_unit = digit_buff_per_font_unit self.show_ellipsis = show_ellipsis self.unit = unit @@ -167,6 +169,7 @@ class DecimalNumber(VMobject): "include_sign", "group_with_commas", "num_decimal_places", + "min_total_width", ] ]) config.update(kwargs) @@ -176,6 +179,7 @@ class DecimalNumber(VMobject): config.get("field_name", ""), ":", "+" if config["include_sign"] else "", + "0" + str(config.get("min_total_width", "")) if config.get("min_total_width") else "", "," if config["group_with_commas"] else "", f".{ndp}f" if ndp > 0 else "d", "}",