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)orgroup.bring_to_back(mob_in_group)). - The default z_index of all mobjects is 0 besides text mobjects which are 1.
- Set the z_index manually (e.g.
-
Mobjects can be spatially transformed (e.g.
scaleorshift). -
Mobjects can be spatially related (e.g.
mob1.next_to(mob2)). -
Mobjects can be styled with
set_colororset_opacity.- Note that VMobjects, or vectorized mobjects, can be styled with
set_fill(color, opacity)orset_stroke(color, opacity).
- Note that VMobjects, or vectorized mobjects, can be styled with
-
Mobjects have a center and an 8 point bounding box (4 corners, 4 edge midpoints).
mobject.centerto access the centermobject.left,mobject.right,mobject.top,mobject.bottomto access the edge midpointsmobject.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 aGroupshould 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 thefill_color. -
opacity(float | None, default=None) -
stroke_color(ManimColor | None, default=None): the color of the shape outline. Independent offill_color. When set, ignorecolor. -
stroke_opacity(float | None, default=None) -
stroke_width(float | None, default=None) -
fill_color(ManimColor | None, default=None): When set, ignorecolor. -
fill_opacity(float | None, default=None) -
dashed(bool, default=False) -
kwargs(dict): Additional arguments for customization.
Usage Example
Square(stroke_color=RED, dashed=True)