SVGMobject#

Qualified name: manim.mobject.svg.svg\_mobject.SVGMobject

class SVGMobject(file_name=None, should_center=True, height=2, width=None, unpack_groups=True, stroke_width=4, fill_opacity=1.0, should_subdivide_sharp_curves=False, should_remove_null_curves=False, color=None, *, fill_color=None, stroke_color=None, stroke_opacity=1.0, **kwargs)[source]#

Bases: VMobject

A SVGMobject is a Vector Mobject constructed from an SVG (or XDV) file.

SVGMobjects are constructed from the XML data within the SVG file structure. As such, subcomponents from the XML data can be accessed via the submobjects attribute. There is varying amounts of support for SVG elements, experiment with SVG files at your own peril.

Examples

class Sample(Scene):
    def construct(self):
        self.play(FadeIn(SVGMobject("manim-logo-sidebar.svg")))
Parameters
  • file_name (str or pathlib.Path) – The file’s path name. When possible, the full path is preferred but a relative path may be used as well. Relative paths are relative to the directory specified by the –assets_dir command line argument.

  • should_center (bool) – Whether the SVGMobject should be centered to the origin. Defaults to True.

  • height (float) – Specify the final height of the SVG file. Defaults to 2 units.

  • width (float) – Specify the width the SVG file should occupy. Defaults to None.

  • unpack_groups (bool) – Whether the hierarchies of VGroups generated should be flattened. Defaults to True.

  • stroke_width (float) – The stroke width of the outer edge of an SVG path element. Defaults to 4.

  • fill_opacity (float) – Specifies the opacity of the image. 1 is opaque, 0 is transparent. Defaults to 1.

Methods

generate_points

Called by the Mobject abstract base class.

generate_style

init_colors

Initializes the colors.

init_points

Called by the Mobject abstract base class.

Attributes

animate

Used to animate the application of any method of self.

animation_overrides

color

depth

The depth of the mobject.

fill_color

If there are multiple colors (for gradient) this returns the first one

height

The height of the mobject.

sheen_factor

stroke_color

width

The width of the mobject.

generate_points()[source]#

Called by the Mobject abstract base class. Responsible for generating the SVGMobject’s points from XML tags, populating self.mobjects, and any submobjects within self.mobjects.

init_colors(propagate_colors=False)[source]#

Initializes the colors.

Gets called upon creation. This is an empty method that can be implemented by subclasses.

init_points()#

Called by the Mobject abstract base class. Responsible for generating the SVGMobject’s points from XML tags, populating self.mobjects, and any submobjects within self.mobjects.