Support Fluxion Engine
If you find this project useful, please consider supporting its development.
Support ProjectComplete reference for Scene classes in Fluxion.
The base class for all Fluxion animations.
from fluxion import *
class MyScene(Scene):
def construct(self):
# Your animation code here
passPlay one or more animations:
self.play(animation)
self.play(animation1, animation2)
self.play(animation, run_time=2, rate_func=smooth)Parameters:
*animations: One or more Animation objectsrun_time: Duration in seconds (default: 1)rate_func: Timing function (linear, smooth, etc.)Pause the animation:
self.wait() # Wait 1 second
self.wait(2) # Wait 2 seconds
self.wait(0.5) # Wait 0.5 secondsAdd mobjects to the scene instantly:
self.add(mobject)
self.add(mob1, mob2, mob3)Remove mobjects from the scene:
self.remove(mobject)
self.remove(mob1, mob2, mob3)Access the scene's camera:
self.camera.background_color = BLACK
self.camera.frame.move_to(RIGHT * 3)List of all mobjects in the scene:
for mob in self.mobjects:
print(mob)For 3D animations:
class My3DScene(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(axes)3D Methods:
# Set camera orientation
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
# Move camera
self.move_camera(phi=60 * DEGREES, theta=45 * DEGREES, run_time=2)
# Begin rotation
self.begin_ambient_camera_rotation(rate=0.1)
# Stop rotation
self.stop_ambient_camera_rotation()For scenes with voiceovers:
from fluxion_voiceover import VoiceoverScene
class MyVoiceover(VoiceoverScene):
def construct(self):
with self.voiceover("Hello!") as tracker:
circle = Circle()
self.play(Create(circle), run_time=tracker.duration)Bring mobjects to front:
self.bring_to_front(mobject)Send mobjects to back:
self.bring_to_back(mobject)Get all top-level mobjects:
mobjects = self.get_top_level_mobjects()Add dynamic updates:
def update_func(mob, dt):
mob.rotate(dt * PI / 2)
mobject.add_updater(update_func)
self.add(mobject)
self.wait(2)
mobject.remove_updater(update_func)Override for initialization:
class MyScene(Scene):
def setup(self):
# Runs before construct()
self.camera.background_color = "#1a1a1a"
def construct(self):
# Your animation code
passCleanup after scene:
def tear_down(self):
# Cleanup code
passSkip to end of animation:
self.skip_animations = TrueGet current scene time:
current_time = self.timeclass BasicScene(Scene):
def construct(self):
circle = Circle()
self.play(Create(circle))
self.wait()class MultiObject(Scene):
def construct(self):
circle = Circle().shift(LEFT)
square = Square().shift(RIGHT)
self.play(
Create(circle),
Create(square)
)
self.wait()class AnimatedScene(Scene):
def construct(self):
square = Square()
self.play(Create(square))
self.play(square.animate.shift(UP * 2))
self.play(square.animate.rotate(PI / 4))
self.play(square.animate.set_fill(BLUE, opacity=0.5))
self.wait()If you find this project useful, please consider supporting its development.
Support Project