Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fixed numerals merge issue

Grant Sandersond52776a0a7ed
diff --cc topics/numerals.py
index e53e20e90,0a1337a04..1bcc61fe3
--- a/topics/numerals.py
+++ b/topics/numerals.py
@@@ -41,31 -41,34 +41,43 @@@ class DecimalNumber(VMobject)
if self.show_ellipsis:
self.add(TexMobject("\\dots"))
- if self.unit is not None:
- self.add(TexMobject(self.unit))
+
+ if num_string.startswith("-"):
+ minus = self.submobjects[0]
+ minus.next_to(
+ self.submobjects[1], LEFT,
+ buff = self.digit_to_digit_buff
+ )
+
+ if self.unit != None:
- unit_sign = TexMobject(self.unit)
- unit_sign.next_to(self.submobjects[-1],RIGHT,
- buff = self.digit_to_digit_buff)
-
- if self.unit.startswith("^"):
- unit_sign.align_to(self,UP)
- else:
- unit_sign.align_to(self,DOWN)
- self.add(unit_sign)
++ self.unit_sign = TexMobject(self.unit)
++ self.add(self.unit_sign)
self.arrange_submobjects(
buff = self.digit_to_digit_buff,
aligned_edge = DOWN
)
+ #Handle alignment of parts that should be aligned
+ #to the bottom
+ for i, c in enumerate(num_string):
+ if c == "-" and len(num_string) > i+1:
+ self[i].align_to(self[i+1], alignment_vect = UP)
- if self.unit.startswith("^"):
- self[-1].align_to(self, UP)
++ if self.unit and self.unit.startswith("^"):
++ self.unit_sign.align_to(self, UP)
+ #
+ if self.include_background_rectangle:
+ self.add_background_rectangle()
+ def add_background_rectangle(self):
+ #TODO, is this the best way to handle
+ #background rectangles?
+ self.background_rectangle = BackgroundRectangle(self)
+ self.submobjects = [
+ self.background_rectangle,
+ VGroup(*self.submobjects)
+ ]
+ return self
class Integer(DecimalNumber):
CONFIG = {