Support Fluxion Engine
If you find this project useful, please consider supporting its development.
Support ProjectComplete reference for mathematical objects (Mobjects) in Fluxion.
Mobjects (Mathematical Objects) are the fundamental building blocks of Fluxion animations. Everything you see on screen is a mobject.
The base class for all mobjects.
class Mobject:
def __init__(self, **kwargs):
passVector-based mobjects (most common).
class VMobject(Mobject):
passCircle(radius=1.0, color=WHITE, **kwargs)Example:
circle = Circle(radius=2, color=BLUE)
circle.set_fill(BLUE, opacity=0.5)Square(side_length=2.0, color=WHITE, **kwargs)Rectangle(width=4.0, height=2.0, **kwargs)Triangle(**kwargs)Polygon(*vertices, **kwargs)Example:
pentagon = Polygon(
UP, UR, DR, DL, UL,
color=GREEN
)Line(start=LEFT, end=RIGHT, **kwargs)Arrow(start=ORIGIN, end=RIGHT, **kwargs)Vector(direction=RIGHT, **kwargs)DashedLine(start=LEFT, end=RIGHT, **kwargs)Ellipse(width=2.0, height=1.0, **kwargs)Annulus(inner_radius=1, outer_radius=2, **kwargs)Arc(radius=1.0, start_angle=0, angle=TAU/4, **kwargs)Sector(outer_radius=1, inner_radius=0, **kwargs)Text(text, font="Arial", font_size=48, **kwargs)Example:
title = Text("Hello Fluxion!", font="Arial", font_size=60)
title.set_color(BLUE)LaTeX mathematical expressions:
MathTex(tex_string, **kwargs)Example:
formula = MathTex(r"E = mc^2")
equation = MathTex(
r"\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}"
)General LaTeX text:
Tex(tex_string, **kwargs)Sphere(radius=1, **kwargs)Cube(side_length=2, **kwargs)Cylinder(radius=1, height=2, **kwargs)Cone(base_radius=1, height=2, **kwargs)# Move to position
mobject.move_to(ORIGIN)
mobject.move_to(UP * 2 + RIGHT * 3)
# Shift by vector
mobject.shift(LEFT * 2)
# Align to edge
mobject.to_edge(UP)
mobject.to_corner(UR)
# Position relative to another
mobject.next_to(other, RIGHT, buff=0.5)# Scale uniformly
mobject.scale(2)
# Scale on specific axis
mobject.scale(2, axis=0) # X-axis
# Stretch
mobject.stretch(2, 0) # Stretch horizontally# Rotate around origin
mobject.rotate(PI / 4)
# Rotate around point
mobject.rotate(PI / 4, about_point=ORIGIN)
# Rotate around axis
mobject.rotate(PI / 4, axis=OUT)# Set color
mobject.set_color(BLUE)
mobject.set_color_by_gradient(BLUE, GREEN)
# Set fill
mobject.set_fill(RED, opacity=0.5)
# Set stroke
mobject.set_stroke(WHITE, width=4)
# Set opacity
mobject.set_opacity(0.5)# Align to another mobject
mobject.align_to(other, UP)
mobject.align_to(other, LEFT)
# Center
mobject.center()Group multiple mobjects:
group = VGroup(circle, square, triangle)
group.arrange(RIGHT, buff=1)Methods:
# Add to group
group.add(mobject)
# Remove from group
group.remove(mobject)
# Arrange
group.arrange(direction=RIGHT, buff=0.5)
group.arrange_in_grid(rows=2, cols=3)Create your own:
class CustomShape(VMobject):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.set_points_as_corners([
UP, RIGHT, DOWN, LEFT, UP
])
self.set_fill(BLUE, opacity=0.5)If you find this project useful, please consider supporting its development.
Support Project