### Install LaTeX Dependencies Source: https://github.com/3b1b/videos/blob/master/README.md Install the necessary LaTeX packages on Ubuntu to support Manim rendering. ```bash sudo apt install texlive sudo apt install texlive-latex-extra sudo apt install texlive-fonts-extra sudo apt install texlive-science ``` -------------------------------- ### Configure project directory and imports Source: https://github.com/3b1b/videos/blob/master/README.md Navigate to the project directory and update the Python path to ensure local modules are discoverable. ```sh cd _2023/optics_puzzles vi e_field.py ``` ```python import sys sys.path.append(".") sys.path.append("..") sys.path.append("../..") ``` -------------------------------- ### Configure Project Settings via custom_config.yml Source: https://context7.com/3b1b/videos/llms.txt Define directory paths, camera resolution, and text styling in the YAML configuration file. ```yaml # custom_config.yml directories: mirror_module_path: True base: "/path/to/3Blue1Brown/" subdirs: raster_images: "images/raster" vector_images: "images/vector" pi_creature_images: "images/pi_creature/svg" camera: resolution: (3840, 2160) # 4K rendering background_color: "#000000" fps: 30 text: font: "CMU Serif" alignment: "CENTER" universal_import_line: "from manim_imports_ext import *" ``` -------------------------------- ### Render and Preview Scenes Source: https://github.com/3b1b/videos/blob/master/CLAUDE.md Commands for rendering, debugging, and previewing animation scenes via the command line. ```bash manimgl ``` ```bash manimgl -se ``` ```bash manimgl -p ``` -------------------------------- ### Custom Mobjects: Logo and Visual Elements Source: https://context7.com/3b1b/videos/llms.txt Demonstrates instantiation and animation of complex parametric mobjects like the 3Blue1Brown logo. ```python from manim_imports_ext import * class LogoDemo(Scene): def construct(self): # Create the 3Blue1Brown logo logo = Logo() logo.set_height(4) # Access logo components iris_back = logo.iris_background spikes = logo.spike_layers pupil = logo.pupil # Get separated blue and brown parts blue_part, brown_part = logo.get_blue_part_and_brown_part() # Animate logo appearance self.play(Write(logo, run_time=3, lag_ratio=5e-3)) self.wait() # Add channel name name = Text("3Blue1Brown") name.scale(2.5) name.next_to(logo, DOWN, buff=MED_LARGE_BUFF) self.play(Write(name)) self.wait() ``` -------------------------------- ### Stage Scenes for Modules Source: https://github.com/3b1b/videos/blob/master/CLAUDE.md Command to stage rendered scenes in order for a video module. ```bash python stage_scenes.py ``` -------------------------------- ### Mathematical Typesetting with Tex Source: https://context7.com/3b1b/videos/llms.txt Shows how to create LaTeX-rendered equations with custom color mapping for specific terms using Manim's Tex class. Requires manim_imports_ext. ```python from manim_imports_ext import * class DrivenHarmonicOscillatorEquation(InteractiveScene): def construct(self): # Color gradient for derivatives colors = color_gradient([TEAL, RED], 3, interp_by_hsl=True) # Create equation with colored terms equation = Tex( R"m x''(t) + \mu x'(t) + k x(t) = F_0 \cos(\omega t)", t2c={ "x(t)": colors[0], "x'(t)": colors[1], "x''(t)": colors[2], R"\omega": PINK, } ) self.add(equation) # Animate parts of the equation sum_tex = Tex(R"\cos(t) = \frac{1}{2} e^{+it} + \frac{1}{2} e^{-it}", t2c={"+i": YELLOW, "-i": YELLOW}) self.play(Write(sum_tex)) self.wait() ``` -------------------------------- ### Preview Scene with manimgl Source: https://context7.com/3b1b/videos/llms.txt Use the -p flag with manimgl to preview a scene without rendering it to a file. ```bash manimgl _2025/grover/state_vectors.py ContrstClassicalAndQuantum -p ``` -------------------------------- ### Clone Repository Source: https://github.com/3b1b/videos/blob/master/README.md Clone the 3b1b videos repository to access the video samples. ```bash git clone git@github.com:3b1b/videos.git cd videos ``` -------------------------------- ### Create Animated Graph with InteractiveScene Source: https://context7.com/3b1b/videos/llms.txt Demonstrates creating axes, a graph of a function, and a dynamic dot that follows the graph using Manim's InteractiveScene. Requires manim_imports_ext. ```python from manim_imports_ext import * class SimpleCosGraph(InteractiveScene): rotation_frequency = TAU / 4 def construct(self): # Create axes with custom configuration axes = Axes((0, 20), (-1, 1), x_axis_config=dict(unit_size=0.6)) axes.scale(1.25).to_edge(LEFT) # Define the function to graph def cos_func(t): return np.cos(self.rotation_frequency * t) # Create animated graph graph = axes.get_graph(cos_func) graph.set_stroke(TEAL, 3) # Add dynamic elements with updaters output_dot = Group(TrueDot(), GlowDot()).set_color(YELLOW) output_dot.add_updater(lambda m: m.move_to(axes.y_axis.n2p(cos_func(self.time)))) self.add(axes, graph, output_dot) self.wait(10) # Animation runs for 10 seconds ``` -------------------------------- ### TeacherStudentsScene for Educational Dialogues Source: https://context7.com/3b1b/videos/llms.txt Provides a pre-configured classroom environment with a teacher and three students. Use teacher_says and student_says to manage dialogue and target_mode for character gestures. ```python from manim_imports_ext import * class ClassroomExample(TeacherStudentsScene): student_colors = [BLUE_D, BLUE_E, BLUE_C] teacher_color = GREY_BROWN def construct(self): # Teacher speaks self.teacher_says( Tex(R"e^{i\pi} + 1 = 0"), target_mode="raise_right_hand" ) self.wait() # Students react with different modes self.play_student_changes("pondering", "thinking", "happy") self.wait() # A student asks a question self.student_says( "Why is this beautiful?", target_mode="raise_left_hand", index=2 ) self.wait() # Teacher holds up a mobject formula = Tex(R"\cos(\theta) + i\sin(\theta) = e^{i\theta}") self.teacher_holds_up(formula, target_mode="happy") self.wait() ``` -------------------------------- ### Render Scene with manimgl Source: https://context7.com/3b1b/videos/llms.txt Use manimgl to render scenes to video files. Ensure the correct Python file and scene class are specified. ```bash manimgl _2025/laplace/main_equations.py DrivenHarmonicOscillatorEquation ``` -------------------------------- ### PiCreature Character Animations Source: https://context7.com/3b1b/videos/llms.txt Demonstrates controlling the Pi creature's expressions, speech bubbles, and gaze direction within a PiCreatureScene. Requires manim_imports_ext. ```python from manim_imports_ext import * class PiCreatureDemo(PiCreatureScene): default_pi_creature_kwargs = dict(color=BLUE, flip_at_start=False) default_pi_creature_start_corner = DL def construct(self): pi = self.pi_creature # Change expression modes self.play(pi.change("thinking")) self.wait() # Make pi creature speak with a speech bubble self.play(pi.says("Hello, math lovers!", mode="speaking")) self.wait(2) # Remove bubble and change mode self.play(pi.debubble(mode="happy")) # Look at a specific point target = Circle().shift(RIGHT * 3) self.add(target) self.play(pi.animate.look_at(target)) self.wait() ``` -------------------------------- ### Execute ManimGL animations Source: https://github.com/3b1b/videos/blob/master/README.md Run the animation script using the manimgl command, optionally specifying a class name. ```sh manimgl e_field.py ``` ```sh manimgl e_field.py WavesIn3D ``` -------------------------------- ### Configure Sublime Text Keybindings Source: https://github.com/3b1b/videos/blob/master/README.md Add these keybindings to your Sublime Text configuration to trigger custom Manim commands. ```json { "keys": ["shift+super+r"], "command": "manim_run_scene" }, { "keys": ["super+r"], "command": "manim_checkpoint_paste" }, { "keys": ["super+alt+r"], "command": "manim_recorded_checkpoint_paste" }, { "keys": ["super+ctrl+r"], "command": "manim_skipped_checkpoint_paste" }, { "keys": ["super+e"], "command": "manim_exit" }, { "keys": ["super+option+/"], "command": "comment_fold"}, ``` -------------------------------- ### Sequential Overlapping Animations Source: https://github.com/3b1b/videos/blob/master/CLAUDE.md Implement sequential overlapping animations using LaggedStart. Specify the animations and a lag ratio to control the timing and overlap between them. ```python LaggedStart(*animations, lag_ratio=0.1) ``` -------------------------------- ### Animation and LaTeX Patterns Source: https://github.com/3b1b/videos/blob/master/CLAUDE.md Common syntax for animations and mathematical typesetting using the 3b1b Manim library. ```python Tex(R"\pi") ``` ```python Tex(R"\frac{1}{2}") ``` ```python FadeIn(objects, lag_ratio=0.1) ``` ```python Tex(formula, t2c={"x": BLUE, "y": RED}) ``` -------------------------------- ### Define Patreon and Side-Scroll End Screens Source: https://context7.com/3b1b/videos/llms.txt Inherit from PatreonEndScreen or SideScrollEndScreen to customize credit scrolling, patron display, and support links. ```python from manim_imports_ext import * class MyEndScreen(PatreonEndScreen): title_text = "Thanks for Watching" show_pis = True patron_scale_val = 0.8 n_patron_columns = 4 scroll_time = 20 thanks_words = """ These videos are supported by viewers. Special thanks to patrons listed below. """ def construct(self): # Automatically builds scrolling credits from patron data files super().construct() class CustomEndScreen(SideScrollEndScreen): # Side-scrolling variant with video recommendations thanks_text = "Special Thanks to\nthese channel supporters" scroll_time = 21 support_url = "https://3b1b.co/support" ``` -------------------------------- ### Interactive Development with checkpoint_paste Source: https://context7.com/3b1b/videos/llms.txt Use checkpoint_paste in an iPython terminal to execute code from the clipboard, with options for skipping animations or recording state. ```python # In terminal after running: manimgl scene_file.py SceneName -se 50 # Basic checkpoint paste - runs code from clipboard checkpoint_paste() # Skip animations (instant execution) checkpoint_paste(skip=True) # Record the animation to file checkpoint_paste(record=True) # Code with checkpoint comment - state saved on first run, restored on subsequent runs # Copy this to clipboard and run checkpoint_paste(): """ # checkpoint: setup_graph axes = Axes((-5, 5), (-3, 3)) graph = axes.get_graph(lambda x: x**2) self.add(axes, graph) """ ``` -------------------------------- ### Animation Composition with LaggedStart Source: https://context7.com/3b1b/videos/llms.txt Enables staggered, sequential animations using lag_ratio for smooth visual transitions. LaggedStartMap is available for applying animations to collections of mobjects. ```python from manim_imports_ext import * class AnimationCompositionExample(InteractiveScene): def construct(self): # Create a group of objects circles = VGroup(*[Circle() for _ in range(5)]) circles.arrange(RIGHT) circles.set_color_by_gradient(BLUE, GREEN) # Staggered fade in with lag_ratio self.play(LaggedStart( *[FadeIn(c, shift=UP) for c in circles], lag_ratio=0.3, run_time=2 )) self.wait() # Simultaneous transformations self.play( circles[0].animate.shift(UP), circles[2].animate.scale(1.5), circles[4].animate.set_color(RED), run_time=1.5 ) # LaggedStartMap for applying same animation to many objects self.play(LaggedStartMap( FadeOut, circles, shift=DOWN, lag_ratio=0.1, run_time=2 )) ``` -------------------------------- ### Interactive Development Checkpoints Source: https://github.com/3b1b/videos/blob/master/CLAUDE.md Functions for managing animation state and execution during interactive development sessions. ```python checkpoint_paste() ``` ```python checkpoint_paste(skip=True) ``` ```python checkpoint_paste(record=True) ``` -------------------------------- ### VideoWrapper and Backdrop Scenes Source: https://context7.com/3b1b/videos/llms.txt Defines scenes that wrap external video content with animated borders and titles. Inherit from VideoWrapper or Spotlight to configure the framing behavior. ```python from manim_imports_ext import * class MyVideoWrapper(VideoWrapper): title = "Understanding Euler's Identity" animate_boundary = True animated_boundary_config = {"cycle_rate": 0.25} wait_time = 32 screen_height = 6.25 title_config = dict(font_size=60) def construct(self): # Parent class handles screen rectangle and boundary animation super().construct() # Video plays inside the black rectangle for wait_time seconds class CustomSpotlight(Spotlight): title = "Featured Video" title_font_size = 60 def construct(self): super().construct() # Creates fullscreen with animated border screen rectangle ``` -------------------------------- ### Dynamic Positioning with Updaters Source: https://github.com/3b1b/videos/blob/master/CLAUDE.md Use updaters to dynamically control object positioning. This method is suitable for animations where an object's position needs to change based on other elements or conditions. ```python object.add_updater(lambda m: m.move_to(target.get_center())) ``` ```python object.f_always.move_to(reference.get_center) ``` -------------------------------- ### Interactive Debugging with manimgl Source: https://context7.com/3b1b/videos/llms.txt Use the -se flag with manimgl to enter interactive debugging mode at a specific line number for a scene. ```bash manimgl _2025/laplace/main_equations.py TranslateToNewLanguage -se 50 ``` -------------------------------- ### Updaters for Dynamic Animations Source: https://context7.com/3b1b/videos/llms.txt Attaches continuous update functions to mobjects to maintain relationships during animations. Use f_always for a cleaner syntax when binding properties to reference objects. ```python from manim_imports_ext import * class UpdaterExample(InteractiveScene): def construct(self): # Create reference point that moves dot = Dot(color=YELLOW) # Label that always follows the dot label = Text("Point") label.add_updater(lambda m: m.next_to(dot, UP)) # Line from origin to dot line = Line(ORIGIN, dot.get_center()) line.add_updater(lambda m: m.put_start_and_end_on(ORIGIN, dot.get_center())) # Alternative f_always syntax for cleaner code arrow = Arrow(ORIGIN, RIGHT) arrow.f_always.put_start_and_end_on(ORIGIN, dot.get_center) self.add(line, dot, label) # Animate the reference - dependent objects update automatically self.play(dot.animate.move_to(RIGHT * 3 + UP * 2), run_time=3) self.play(dot.animate.move_to(LEFT * 2 + DOWN), run_time=2) self.wait() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.