mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Allow for default height/width of SVGMobject specified as class variables
This commit is contained in:
parent
f158d3e751
commit
ef64b90ed3
1 changed files with 6 additions and 2 deletions
|
@ -35,12 +35,14 @@ def _convert_point_to_3d(x: float, y: float) -> np.ndarray:
|
||||||
|
|
||||||
class SVGMobject(VMobject):
|
class SVGMobject(VMobject):
|
||||||
file_name: str = ""
|
file_name: str = ""
|
||||||
|
height: float | None = 2.0
|
||||||
|
width: float | None = None
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
file_name: str = "",
|
file_name: str = "",
|
||||||
should_center: bool = True,
|
should_center: bool = True,
|
||||||
height: float | None = 2.0,
|
height: float | None = None,
|
||||||
width: float | None = None,
|
width: float | None = None,
|
||||||
# Style that overrides the original svg
|
# Style that overrides the original svg
|
||||||
color: ManimColor = None,
|
color: ManimColor = None,
|
||||||
|
@ -66,7 +68,6 @@ class SVGMobject(VMobject):
|
||||||
self.file_name = file_name or self.file_name
|
self.file_name = file_name or self.file_name
|
||||||
self.svg_default = dict(svg_default)
|
self.svg_default = dict(svg_default)
|
||||||
self.path_string_config = dict(path_string_config)
|
self.path_string_config = dict(path_string_config)
|
||||||
self.height = height
|
|
||||||
|
|
||||||
super().__init__(**kwargs )
|
super().__init__(**kwargs )
|
||||||
self.init_svg_mobject()
|
self.init_svg_mobject()
|
||||||
|
@ -82,6 +83,9 @@ class SVGMobject(VMobject):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Initialize position
|
# Initialize position
|
||||||
|
height = height or self.height
|
||||||
|
width = width or self.width
|
||||||
|
|
||||||
if should_center:
|
if should_center:
|
||||||
self.center()
|
self.center()
|
||||||
if height is not None:
|
if height is not None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue