Treat font_size as a float

This commit is contained in:
Grant Sanderson
2023-01-16 13:43:48 -08:00
parent a46e580fa4
commit 8ef93b0f9d

View File

@ -32,7 +32,7 @@ class DecimalNumber(VMobject):
unit: str | None = None, # Aligned to bottom unless it starts with "^" unit: str | None = None, # Aligned to bottom unless it starts with "^"
include_background_rectangle: bool = False, include_background_rectangle: bool = False,
edge_to_fix: Vect3 = LEFT, edge_to_fix: Vect3 = LEFT,
font_size: int = 48, font_size: float = 48,
text_config: dict = dict(), # Do not pass in font_size here text_config: dict = dict(), # Do not pass in font_size here
**kwargs **kwargs
): ):
@ -115,8 +115,8 @@ class DecimalNumber(VMobject):
super().init_uniforms() super().init_uniforms()
self.uniforms["font_size"] = self.font_size self.uniforms["font_size"] = self.font_size
def get_font_size(self) -> int: def get_font_size(self) -> float:
return int(self.uniforms["font_size"]) return float(self.uniforms["font_size"])
def get_formatter(self, **kwargs) -> str: def get_formatter(self, **kwargs) -> str:
""" """
@ -167,7 +167,7 @@ class DecimalNumber(VMobject):
return self return self
def _handle_scale_side_effects(self, scale_factor: float) -> None: def _handle_scale_side_effects(self, scale_factor: float) -> None:
self.uniforms["font_size"] *= scale_factor self.uniforms["font_size"] = scale_factor * self.uniforms["font_size"]
def get_value(self) -> float | complex: def get_value(self) -> float | complex:
return self.number return self.number