mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Added include_sign flag to DecimalNumber
This commit is contained in:
parent
edaaa26b7a
commit
45c0e0ccb7
1 changed files with 3 additions and 0 deletions
|
@ -13,6 +13,7 @@ class DecimalNumber(VMobject):
|
||||||
"show_ellipsis": False,
|
"show_ellipsis": False,
|
||||||
"unit": None, # Aligned to bottom unless it starts with "^"
|
"unit": None, # Aligned to bottom unless it starts with "^"
|
||||||
"include_background_rectangle": False,
|
"include_background_rectangle": False,
|
||||||
|
"include_sign": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, number, **kwargs):
|
def __init__(self, number, **kwargs):
|
||||||
|
@ -30,6 +31,8 @@ class DecimalNumber(VMobject):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
num_string = '%.*f' % (ndp, number)
|
num_string = '%.*f' % (ndp, number)
|
||||||
|
if self.include_sign and number >= 0:
|
||||||
|
num_string = "+" + num_string
|
||||||
negative_zero_string = "-%.*f" % (ndp, 0.)
|
negative_zero_string = "-%.*f" % (ndp, 0.)
|
||||||
if num_string == negative_zero_string:
|
if num_string == negative_zero_string:
|
||||||
num_string = num_string[1:]
|
num_string = num_string[1:]
|
||||||
|
|
Loading…
Add table
Reference in a new issue