Support Fluxion Engine
If you find this project useful, please consider supporting its development.
Support ProjectAdvanced concepts and internals of Fluxion.
Understanding how Fluxion renders animations:
construct() method is calledplay()Mobject (base class)
├── VMobject (vector graphics)
│ ├── Circle
│ ├── Square
│ ├── Line
│ └── Polygon
├── ImageMobject (raster graphics)
└── Group (container)Create your own mobjects:
class CustomShape(VMobject):
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Define points
self.set_points_as_corners([
UP, RIGHT, DOWN, LEFT, UP
])Animations interpolate between states:
class CustomAnimation(Animation):
def interpolate_mobject(self, alpha):
# alpha goes from 0 to 1
# Modify self.mobject based on alpha
self.mobject.set_opacity(alpha)Control animation timing:
from fluxion import *
# Linear (default)
self.play(animation, rate_func=linear)
# Smooth (ease in/out)
self.play(animation, rate_func=smooth)
# Custom rate function
def custom_rate(t):
return t ** 2 # Quadratic
self.play(animation, rate_func=custom_rate)Dynamic animations that update every frame:
def update_func(mob, dt):
mob.rotate(dt * PI / 2)
circle.add_updater(update_func)
self.add(circle)
self.wait(2) # Circle rotates for 2 seconds
circle.remove_updater(update_func)Advanced camera manipulation:
# Move camera
self.camera.frame.move_to(RIGHT * 3)
# Zoom
self.camera.frame.scale(0.5) # Zoom in
# Rotate camera
self.camera.frame.rotate(PI / 4)class My3DScene(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(axes)# Cache complex mobjects
@cache
def create_complex_shape():
return ComplexMobject()# Render specific time range
fluxion scene.py MyScene -n 0,60 # First 60 framesCreate Fluxion plugins:
# my_plugin.py
from fluxion import *
class MyCustomMobject(VMobject):
pass
# Use in scenes
from my_plugin import MyCustomMobject# Print mobject info
print(mobject.get_center())
print(mobject.get_width())
# Visual debugging
self.add(Dot(mobject.get_center(), color=RED))If you find this project useful, please consider supporting its development.
Support Project