From ef64b90ed358bc6d0d31bac0e00b1ca3e60b152d Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Mon, 19 Dec 2022 14:42:04 -0800 Subject: [PATCH] Allow for default height/width of SVGMobject specified as class variables --- manimlib/mobject/svg/svg_mobject.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/manimlib/mobject/svg/svg_mobject.py b/manimlib/mobject/svg/svg_mobject.py index 1248456e..6476cd95 100644 --- a/manimlib/mobject/svg/svg_mobject.py +++ b/manimlib/mobject/svg/svg_mobject.py @@ -35,12 +35,14 @@ def _convert_point_to_3d(x: float, y: float) -> np.ndarray: class SVGMobject(VMobject): file_name: str = "" + height: float | None = 2.0 + width: float | None = None def __init__( self, file_name: str = "", should_center: bool = True, - height: float | None = 2.0, + height: float | None = None, width: float | None = None, # Style that overrides the original svg color: ManimColor = None, @@ -66,7 +68,6 @@ class SVGMobject(VMobject): self.file_name = file_name or self.file_name self.svg_default = dict(svg_default) self.path_string_config = dict(path_string_config) - self.height = height super().__init__(**kwargs ) self.init_svg_mobject() @@ -82,6 +83,9 @@ class SVGMobject(VMobject): ) # Initialize position + height = height or self.height + width = width or self.width + if should_center: self.center() if height is not None: