Skip to main content

Overview

Mobjects

Mobjects in smanim are Python objects that represent different components in the diagram. Examples of common mobject classes include Square, Text, Group, and Graph mobjects. While similar to mobjects in Manim, smanim mobjects have minor variations in their function names and parameters.

  • Mobjects by default are positioned at the ORIGIN (0, 0, 0).

  • Mobjects can be copied (e.g. mob2 = mob1.copy()).

  • Mobjects can be layered via z_index.

    • Set the z_index manually (e.g. s = Square(z_index=2)).
    • Or use higher-level functions (e.g.group.bring_to_front(mob_in_group) or group.bring_to_back(mob_in_group)).
    • The default z_index of all mobjects is 0 besides text mobjects which are 1.
  • Mobjects can be spatially transformed (e.g. scale or shift).

  • Mobjects can be spatially related (e.g. mob1.next_to(mob2)).

  • Mobjects can be styled with set_color or set_opacity.

    • Note that VMobjects, or vectorized mobjects, can be styled with set_fill(color, opacity) or set_stroke(color, opacity).
  • Mobjects have a center and an 8 point bounding box (4 corners, 4 edge midpoints).

    • mobject.center to access the center
    • mobject.left, mobject.right, mobject.top, mobject.bottom to access the edge midpoints
    • mobject.get_corner(UL), mobject.get_corner(UR), mobject.get_corner(DL), mobject.get_corner(DR) to access corners
  • Mobjects can have submobjects (e.g. square.add(Text("Square"))), though creating a Group should be preferred.

VMobjects

VMobjects in smanim are vectorized mobjects represented spatially by a list of points. Circle, Square, Arrow, and any other mobject that doesn't include Text is a VMobject. The relevant params for the VMobject constructor:

  • color (ManimColor | None, default=None): by default, sets the fill_color.

  • opacity (float | None, default=None)

  • stroke_color (ManimColor | None, default=None): the color of the shape outline. Independent of fill_color. When set, ignore color.

  • stroke_opacity (float | None, default=None)

  • stroke_width (float | None, default=None)

  • fill_color (ManimColor | None, default=None): When set, ignore color.

  • fill_opacity (float | None, default=None)

  • dashed (bool, default=False)

  • kwargs (dict): Additional arguments for customization.

Usage Example

Square(stroke_color=RED, dashed=True)