### Manim Scene Lifecycle with Setup Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/scenes.md Demonstrates using the `setup` method in Manim for pre-animation initialization. In this example, the background color is set before the `construct` method is called to draw a circle. ```python class MyScene(Scene): def setup(self): self.camera.background_color = BLUE_E def construct(self): circle = Circle() self.play(Create(circle)) ``` -------------------------------- ### Manim Command Line Rendering Examples Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/references/parallax_starfield.md These are command-line examples for rendering Manim animations. They show how to perform a full render with file output (`-w`), a preview without file output (`-p`), and how to render multiple scenes from the same script. ```bash # Full render manimgl parallax_starfield.py ParallaxStarfield -w # Preview (no file output) manimgl parallax_starfield.py ParallaxStarfield -p # All three scenes manimgl parallax_starfield.py ParallaxStarfield ParallaxFromObserverPOV LayeredParallax -w ``` -------------------------------- ### Basic 3D Scene Setup in ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/3d.md Demonstrates how to set up a basic 3D scene in ManimGL. It includes getting the camera frame, setting its 3D orientation using reorient(), and adding a 3D object like a Sphere. Dependencies include the manimlib library. ```python from manimlib import * class Basic3DScene(Scene): def construct(self): # Get camera frame frame = self.camera.frame # Set 3D orientation frame.reorient(20, 70) # theta, phi in degrees # Create 3D objects sphere = Sphere(radius=2) sphere.set_color(BLUE, opacity=0.7) self.add(sphere) ``` -------------------------------- ### Install ManimGL and Check Version Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/SKILL.md Provides the necessary commands to install ManimGL using pip and verify the installation by checking the installed version. ```bash # Install ManimGL pip install manimgl # Check installation manimgl --version ``` -------------------------------- ### Install Manim Community Edition Source: https://github.com/adithya-s-k/manim_skill/blob/main/README.md Installs the Manim Community Edition using pip or uv. Includes verification of the installation by checking the version. Assumes Python 3.7+ is installed. ```bash # Using pip pip install manim # Using uv (recommended for this project) uv pip install manim # Verify installation manim --version ``` -------------------------------- ### Install Manim Skills with npx Source: https://github.com/adithya-s-k/manim_skill/blob/main/README.md Installs Manim Community Edition and ManimGL best practices as AI agent skills using the skills.sh integration. This allows AI assistants to automatically access domain-specific knowledge and code examples. ```bash npx skills add adithya-s-k/manim_skill/skills/manimce-best-practices npx skills add adithya-s-k/manim_skill/skills/manimgl-best-practices # Or install both npx skills add adithya-s-k/manim_skill/skills/manimce-best-practices adithya-s-k/manim_skill/skills/manimgl-best-practices ``` -------------------------------- ### Run Manim Vector Field Examples Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/references/vector_fields.md Command-line instructions to render specific Manim scenes from the `vector_fields.py` file. Each command specifies the Manim executable, the script file, the scene name to render (e.g., `SimpleVectorField`), and the `-w` flag to write the output video file. ```bash manimgl vector_fields.py SimpleVectorField -w manimgl vector_fields.py GradientFieldDemo -w manimgl vector_fields.py ParticleFlow -w manimgl vector_fields.py ElectricDipole -w ``` -------------------------------- ### Comprehensive Text Rendering Example in ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/text.md A full example demonstrating the use of Text and TexText classes in ManimGL, including title creation, description styling, and mathematical descriptions, along with animations. ```python class ComprehensiveTextExample(Scene): def construct(self): # Title with custom font title = Text( "Text Rendering in ManimGL", font="Arial", font_size=72, color=BLUE ) title.to_edge(UP) # Description with mixed styling desc = Text( "Mix different fonts, colors, and styles", font="Helvetica", font_size=36, t2c={"fonts": RED, "colors": GREEN, "styles": YELLOW}, t2w={"Mix": BOLD} ) desc.next_to(title, DOWN, buff=0.5) # Mathematical description using TexText math_desc = TexText( "For equations like $E = mc^2$, use Tex or TexText", font_size=30 ) math_desc.next_to(desc, DOWN, buff=1) # Add all with animations self.play(Write(title)) self.play(FadeIn(desc, shift=DOWN)) self.play(Write(math_desc)) self.wait() ``` -------------------------------- ### ManimGL Complete Styling Example Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/styling.md Provides a scene example in ManimGL that demonstrates setting multiple styling properties (fill, stroke, backstroke) on a single mobject. This showcases comprehensive control over appearance. ```python class CompleteStyling(Scene): def construct(self): shape = Circle(radius=2) # Set all properties shape.set_fill(BLUE, opacity=0.7) shape.set_stroke(WHITE, width=4, opacity=1.0) shape.set_backstroke(BLACK, width=6) self.add(shape) ``` -------------------------------- ### Project-Specific Configuration Example Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/config.md An example of a `manim.cfg` file placed in the project root, overriding default settings for quality, preview, frame rate, background color, and media directory. ```ini [CLI] quality = high_quality preview = True frame_rate = 60 [renderer] background_color = #0d1117 [output] media_dir = ./renders ``` -------------------------------- ### Manim Configuration File (manim.cfg) Example Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/config.md An example of a `manim.cfg` file, demonstrating common settings for the CLI, output directory, renderer background color, and default font. ```ini [CLI] # Preview after rendering preview = True # Default quality quality = medium_quality # Output format format = mp4 # Frame rate frame_rate = 30 [output] # Custom output directory media_dir = ./media # Save last frame as PNG save_last_frame = False [renderer] # Background color background_color = BLACK [style] # Default font font = Arial ``` -------------------------------- ### Full ManimGL Custom Configuration Example (custom_config.yml) Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/config.md Provides a comprehensive example of a `custom_config.yml` file, detailing various configuration sections such as directories, camera settings, window preferences, styles, TeX compilation, and universal imports. This serves as a template for setting up project-wide ManimGL configurations. ```yaml # Directory Configuration directories: output: "./media/videos" temporary_storage: "/tmp/manim" raster_images: "./assets/images" vector_images: "./assets/svg" sounds: "./assets/audio" data: "./assets/data" tex_templates: "./assets/tex" fonts: "./assets/fonts" # Camera Configuration camera_config: pixel_width: 1920 pixel_height: 1080 frame_rate: 60 background_color: "#0a0a0a" frame_height: 8.0 frame_width: 14.222222222222221 # Window Configuration window_config: size: "default" position: "UR" monitor: 0 window_title: "ManimGL Preview" show_file_name_in_title: true # Style Configuration style: background_color: "#0a0a0a" font: "Consolas" tex_font: "Latin Modern Math" stroke_width: 4 default_animation_run_time: 1.0 # TeX Configuration tex_config: tex_compiler: "latex" tex_template: "tex_template.tex" tex_packages: - "amsmath" - "amssymb" - "mathtools" - "physics" # Universal Imports universal_import_line: | from manimlib import * import numpy as np import itertools as it import random # Logging log_level: "INFO" # DEBUG, INFO, WARNING, ERROR ``` -------------------------------- ### ManimGL construct Method Example Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/scenes.md An example demonstrating the typical workflow within the `construct` method of a ManimGL scene. It covers creating mobjects (Circle, Square), positioning them, animating their creation, and waiting for a specified duration. ```python class MyScene(InteractiveScene): def construct(self): # 1. Create mobjects circle = Circle(color=BLUE) square = Square(color=RED) # 2. Position them circle.shift(LEFT * 2) square.shift(RIGHT * 2) # 3. Animate self.play(ShowCreation(circle), ShowCreation(square)) # 4. Wait for viewer self.wait(2) ``` -------------------------------- ### Install Manim Community Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/SKILL.md Install the Manim Community version using pip. This command fetches and installs the latest stable release. After installation, `manim checkhealth` can be used to verify that Manim is set up correctly and all dependencies are met. ```bash # Install Manim Community pip install manim # Check installation manim checkhealth ``` -------------------------------- ### Create a 3D Scene with ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/scenes.md Shows how to set up and create a 3D animation using ManimGL's ThreeDScene. This scene type provides a proper camera setup for 3D environments. The example adds ThreeDAxes and reorients the camera. ```python from manimlib import * class My3DScene(ThreeDScene): def construct(self): axes = ThreeDAxes() self.add(axes) self.camera.frame.reorient(-45*DEGREES, 75*DEGREES) ``` -------------------------------- ### Manim Utility Commands Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/cli.md Lists essential Manim utility commands for checking installation health, initializing new projects, managing configuration, and listing installed plugins. ```bash # Check installation and dependencies manim checkhealth # Initialize new project manim init # Show config values manim cfg show # Write current config to file manim cfg write # List installed plugins manim plugins -l ``` -------------------------------- ### Install LaTeX on Ubuntu/Debian Source: https://github.com/adithya-s-k/manim_skill/blob/main/README.md Installs the full TeX Live distribution of LaTeX on Ubuntu or Debian-based Linux distributions using apt. LaTeX is necessary for mathematical typesetting in Manim. ```bash sudo apt install texlive-full ``` -------------------------------- ### Install FFmpeg on Ubuntu/Debian Source: https://github.com/adithya-s-k/manim_skill/blob/main/README.md Installs FFmpeg on Ubuntu or Debian-based Linux distributions using apt. FFmpeg is required for video encoding with Manim. ```bash sudo apt update sudo apt install ffmpeg ``` -------------------------------- ### Install ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/README.md Installs ManimGL using pip or uv, including verification of the installation. For macOS ARM users, additional dependencies like pkg-config and cairo are required. ```bash # Using pip pip install manimgl # Using uv (recommended for this project) uv pip install manimgl # Verify installation manimgl --version # Additional macOS (ARM) requirement: arch -arm64 brew install pkg-config cairo ``` -------------------------------- ### Practical Example: Text Appearing Word by Word (Python) Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/animation-groups.md A practical example of text appearing word by word using LaggedStart. This requires Manim and demonstrates animating a VGroup of Text mobjects. The input is a VGroup of words, and the output is their sequential Write animation. ```python class WordByWord(Scene): def construct(self): words = VGroup( Text("Hello"), Text("World"), Text("!") ).arrange(RIGHT) self.play(LaggedStart( *[Write(w) for w in words], lag_ratio=0.5 )) ``` -------------------------------- ### Install LaTeX on macOS Source: https://github.com/adithya-s-k/manim_skill/blob/main/README.md Installs the TeX Live distribution of LaTeX on macOS using Homebrew. LaTeX is a prerequisite for mathematical typesetting in Manim. ```bash brew install mactex ``` -------------------------------- ### Manim Plugin Management (CLI) Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/config.md Demonstrates how to manage Manim plugins using the command line, including listing installed plugins and installing new ones via pip. ```bash # List installed plugins manim plugins -l # Install a plugin pip install manim-pluginname ``` -------------------------------- ### ManimGL Backstroke Example with Complex Background Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/styling.md Provides a scene example in ManimGL demonstrating how text with a backstroke stands out clearly against a complex, randomized background. This highlights the practical use of the backstroke feature. ```python class BackstrokeExample(Scene): def construct(self): # Create complex background background = VGroup(*[ Circle(radius=2 * np.random.random(), color=random_color()) for _ in range(20) ]) background.set_opacity(0.3) self.add(background) # Text with backstroke stands out text = Text("Clear and Readable", font_size=72, color=WHITE) text.set_backstroke(BLACK, width=10) self.add(text) ``` -------------------------------- ### ManimGL Example: Displaying Color Variations Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/colors.md A Python scene demonstrating how to create and arrange circles with different color variations using ManimGL. ```python from manimlib import * class ColorExample(Scene): def construct(self): # Create circles with different color variations circles = VGroup(*[ Circle(radius=0.5, color=color) for color in [BLUE_E, BLUE_D, BLUE_C, BLUE_B, BLUE_A] ]) circles.arrange(RIGHT, buff=0.5) self.add(circles) ``` -------------------------------- ### Manim ThreeDScene Example Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/scenes.md Provides an example of a Manim `ThreeDScene` for creating 3D animations. It includes setting the camera orientation and adding 3D objects like axes and a sphere. ```python class My3DScene(ThreeDScene): def construct(self): self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES) axes = ThreeDAxes() sphere = Sphere() self.add(axes, sphere) ``` -------------------------------- ### Initialize ThreeDScene and Camera Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/3d.md Demonstrates the basic setup for a 3D scene in Manim. It initializes the ThreeDScene and sets the initial camera orientation. Dependencies include the Manim library. ```python from manim import * class Basic3D(ThreeDScene): def construct(self): # Set camera angle self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES) # Add 3D axes axes = ThreeDAxes() self.add(axes) ``` -------------------------------- ### Development Workflow Example in ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/cli.md Outlines a typical development workflow using ManimGL commands. It progresses from initial fast testing with low quality to interactive debugging, checking the final frame, and finally rendering a high-quality output. ```bash # 1. Initial testing (low quality, fast) manimgl scene.py MyScene -l # 2. Interactive debugging at specific point manimgl scene.py MyScene -l -se 25 # 3. Check final frame manimgl scene.py MyScene -s # 4. Final render (high quality, save and open) manimgl scene.py MyScene -h -o ``` -------------------------------- ### Manim Interactive Development Pattern Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/embedding.md This pattern involves starting a Manim scene with minimal setup and `self.embed()`, then building the entire animation logic within the interactive shell. Successful commands are then copied back into the script. ```python # Start with minimal setup class Scene(Scene): def construct(self): self.embed() # Build everything in the shell # Copy successful commands back to code ``` -------------------------------- ### AnimationGroup: Staggered Animations with lag_ratio (Python) Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/animation-groups.md Illustrates using AnimationGroup with a specific lag_ratio to control the start delay between animations. This example uses FadeIn on squares and requires Manim. The input is a VGroup of squares, and the output is their staggered fade-in animation. ```python class LagRatioDemo(Scene): def construct(self): squares = VGroup(*[Square() for _ in range(4)]).arrange(RIGHT) # Staggered start - each begins when previous is 25% done self.play(AnimationGroup( *[FadeIn(s) for s in squares], lag_ratio=0.25, run_time=2 )) ``` -------------------------------- ### Setup and Animate Camera in Manim Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/references/three_d_surfaces.md Configures the camera's orientation and position in a 3D scene. The `reorient` method sets the camera's angles (phi, theta, gamma) and optionally the center and height. Animations can be created to smoothly transition the camera to a new orientation. ```python frame = self.frame frame.reorient(-30, 70, 0) # phi, theta, gamma frame.set_height(10) # Animate camera self.play(frame.animate.reorient(30, 60, 0), run_time=3) ``` -------------------------------- ### Comprehensive Styling Example in Manim Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/styling.md Illustrates a wide range of styling options in Manim, including filled, outlined, transparent with border, backstroke effects, and gradients. It also shows how to animate multiple style changes simultaneously. ```python class ComprehensiveStyleExample(Scene): def construct(self): # Different styling approaches shapes = VGroup() # Filled shape filled = Circle(radius=0.8) filled.set_fill(BLUE, opacity=0.8) filled.set_stroke(width=0) shapes.add(filled) # Outlined shape outlined = Circle(radius=0.8) outlined.set_fill(opacity=0) outlined.set_stroke(WHITE, width=4) shapes.add(outlined) # Transparent with border transparent = Circle(radius=0.8) transparent.set_fill(GREEN, opacity=0.3) transparent.set_stroke(GREEN, width=3) shapes.add(transparent) # With backstroke backstroke = Circle(radius=0.8) backstroke.set_fill(YELLOW, opacity=0.6) backstroke.set_stroke(WHITE, width=2) backstroke.set_backstroke(BLACK, width=5) shapes.add(backstroke) # Gradient (multiple submobjects) gradient_circles = VGroup(*[ Circle(radius=0.15).shift(i * 0.3 * RIGHT) for i in range(-2, 3) ]) gradient_circles.set_submobject_colors_by_gradient(RED, YELLOW) shapes.add(gradient_circles) # Arrange and display shapes.arrange(RIGHT, buff=1) self.play(LaggedStart(*[ FadeIn(shape) for shape in shapes ], lag_ratio=0.2)) self.wait() # Animate style transitions self.play( filled.animate.set_opacity(0.3), outlined.animate.set_stroke(YELLOW, width=8), transparent.animate.set_fill(RED, opacity=0.8) ) self.wait() ``` -------------------------------- ### 3D Camera Control and Coordinate System Setup Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/references/parallax_starfield.md This code demonstrates how to control the 3D camera in Manim, specifically reorienting the view and setting the floor plane. `set_floor_plane("xz")` is used to align the coordinate system with common astronomical conventions where Z is vertical. Smooth reorientation is achieved using `frame.animate.reorient()`. ```python frame = self.frame self.set_floor_plane("xz") # Z is now vertical # Smooth camera reorientation self.play(frame.animate.reorient(-40, -26, 0), run_time=2) ``` -------------------------------- ### ManimGL CLI Rendering Commands Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/SKILL.md Provides examples of common ManimGL command-line interface (CLI) commands for rendering scenes. This includes basic rendering and previewing, entering interactive mode for debugging at a specific line, writing output to a file, and rendering in low quality for faster testing. ```bash # Render and preview manimgl scene.py MyScene # Interactive mode - drop into shell at line 15 manimgl scene.py MyScene -se 15 # Write to file manimgl scene.py MyScene -w # Low quality for testing manimgl scene.py MyScene -l ``` -------------------------------- ### Verify Manim Installation (Shell) Source: https://github.com/adithya-s-k/manim_skill/blob/main/README.md Checks if Manim is installed in the current Python environment. This command lists installed packages and filters for 'manim'. ```shell pip list | grep manim ``` -------------------------------- ### ManimGL Detailed Configuration: Window Options Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/config.md Explains the window configuration parameters in `custom_config.yml`. Options include window size (default, fullscreen, or custom dimensions), position on screen, monitor selection, and title bar settings. ```yaml window_config: # Window size: "default", "fullscreen", or [width, height] size: "default" # size: "fullscreen" # size: [1280, 720] # Window position on screen position: "UR" # Upper right # Options: UL, UR, DL, DR, TOP, BOTTOM, LEFT, RIGHT, CENTER # Monitor to display on (for multi-monitor setups) monitor: 0 # Window title window_title: "ManimGL Preview" # Show file name in title show_file_name_in_title: true ``` -------------------------------- ### Parametric Curve Examples (Python) Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/graphing.md Provides examples of plotting various parametric curves, including a Lissajous curve, a spiral, and a heart curve. These examples demonstrate the flexibility of plot_parametric_curve for generating complex shapes. Requires Manim and NumPy. ```python # Lissajous curve curve = axes.plot_parametric_curve( lambda t: np.array([np.sin(3*t), np.sin(2*t), 0]), t_range=[0, 2*PI], ) # Spiral curve = axes.plot_parametric_curve( lambda t: np.array([t*np.cos(t), t*np.sin(t), 0]), t_range=[0, 4*PI], ) # Heart curve curve = axes.plot_parametric_curve( lambda t: np.array([ 16 * np.sin(t)**3, 13*np.cos(t) - 5*np.cos(2*t) - 2*np.cos(3*t) - np.cos(4*t), 0 ]) / 10, t_range=[0, 2*PI], ) ``` -------------------------------- ### ManimCE CLI Render Commands Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/SKILL.md Provides examples of using the Manim Community Edition command-line interface (CLI) to render scenes. It shows basic rendering with preview and demonstrates how to use quality flags for different output resolutions. ```bash # Basic render with preview manim -pql scene.py MyScene # Quality flags: -ql (low), -qm (medium), -qh (high), -qk (4k) manim -pqh scene.py MyScene ``` -------------------------------- ### Install FFmpeg on macOS Source: https://github.com/adithya-s-k/manim_skill/blob/main/README.md Installs FFmpeg on macOS using the Homebrew package manager. FFmpeg is a prerequisite for video encoding in Manim. ```bash brew install ffmpeg ``` -------------------------------- ### Running ManimGL Scenes from Different Directories Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/cli.md Illustrates how to execute ManimGL scenes when the command is run from various directory locations. It shows examples using paths relative to the `manimlib` directory, absolute paths, and relative paths from other project directories. ```bash # From same directory as manimlib/ manimgl project/scene.py MyScene # With absolute path manimgl /full/path/to/scene.py MyScene # With relative path manimgl ../other_project/scene.py MyScene ``` -------------------------------- ### Viewing Current Manim Configuration Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/config.md Provides command-line examples for viewing Manim's current configuration settings, including showing all values, a specific section, or writing the config to a file. ```bash # Show all config values manim cfg show # Show specific section manim cfg show CLI # Write current config to file manim cfg write ``` -------------------------------- ### Quick Preview Workflow in ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/cli.md Describes a streamlined workflow for quickly previewing animations in ManimGL. It focuses on using the `-s` flag to show the final frame immediately, followed by a full render if the preview is satisfactory. ```bash # Show final frame immediately manimgl scene.py MyScene -s # If it looks good, render full animation manimgl scene.py MyScene -o ``` -------------------------------- ### Check FFmpeg Installation (Shell) Source: https://github.com/adithya-s-k/manim_skill/blob/main/README.md Verifies if FFmpeg is installed and accessible in the system's PATH. FFmpeg is crucial for Manim's video rendering capabilities. ```shell ffmpeg -version ``` -------------------------------- ### Access and Move Light Source in 3D Scene in Python Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/camera.md This example shows how to access the scene's light source using `self.camera.light_source` and manipulate its position. It includes creating a 3D object (Sphere) and visualizing the light's position with a Dot indicator, then animating the light's movement. ```python class LightControl(Scene): def construct(self): frame = self.camera.frame frame.reorient(20, 70) # Get light source light = self.camera.light_source # Create 3D object sphere = Sphere(radius=2, color=BLUE) sphere.set_gloss(0.8) self.add(sphere) # Show light position (for debugging) light_indicator = Dot(color=YELLOW) light_indicator.add_updater(lambda m: m.move_to(light.get_center())) self.add(light_indicator) # Move light around self.play(light.animate.move_to([5, 5, 5]), run_time=2) self.wait() self.play(light.animate.move_to([-5, -5, 5]), run_time=2) self.wait() ``` -------------------------------- ### Batch Rendering Multiple Scenes in ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/cli.md Provides a bash script example for rendering multiple ManimGL scenes efficiently. It uses a `for` loop to iterate through a list of scene names and apply common rendering flags. ```bash # Render multiple scenes for scene in Scene1 Scene2 Scene3; do manimgl scenes.py $scene -h -w done ``` -------------------------------- ### Animate Multi-line Mathematical Content Line by Line Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/creation-animations.md This example shows how to display multiple lines of mathematical content sequentially. It uses `VGroup` to group `Tex` objects and iterates through them, playing `Write` for each line with a short wait in between. ```python class MultiLineWrite(Scene): def construct(self): lines = VGroup( Tex(R"a^2 + b^2 = c^2"), Tex(R"e^{i\pi} + 1 = 0"), Tex(R"\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}") ) lines.arrange(DOWN, buff=0.5) # Write line by line for line in lines: self.play(Write(line)) self.wait(0.5) ``` -------------------------------- ### always_redraw Example in Manim Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/updaters.md Illustrates the use of `always_redraw` in Manim to dynamically recreate a mobject based on changing values. This example creates a line whose length is controlled by a `ValueTracker`. ```python from manim import * class AlwaysRedrawExample(Scene): def construct(self): tracker = ValueTracker(1) # Line that always connects two points based on tracker line = always_redraw( lambda: Line( LEFT * 2, RIGHT * 2 * tracker.get_value() ) ) self.add(line) self.play(tracker.animate.set_value(2), run_time=2) self.play(tracker.animate.set_value(0.5), run_time=2) ``` -------------------------------- ### Animate Camera Tour Through Multiple Positions in Python Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/camera.md This example shows how to create a camera tour that moves to and focuses on multiple objects sequentially. The camera's width and position are adjusted for each object, followed by a return to an overview state. ```python class CameraTour(Scene): def construct(self): frame = self.camera.frame # Create scene objects = VGroup( Square(side_length=2, color=RED).shift(LEFT * 3), Circle(radius=1, color=BLUE), Triangle(color=GREEN).shift(RIGHT * 3) ) self.add(objects) # Tour each object for obj in objects: self.play( frame.animate.set_width(3).move_to(obj), run_time=2 ) self.wait() # Return to overview self.play( frame.animate.set_width(14).move_to(ORIGIN), run_time=2 ) ``` -------------------------------- ### Basic Scene Rendering in ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/cli.md Demonstrates the fundamental command for rendering a specific scene from a Python file. It shows the basic syntax and an example of how to execute a scene named 'SquareToCircle' from 'my_animation.py'. ```bash # Basic syntax manimgl scene_file.py SceneName # Example manimgl my_animation.py SquareToCircle ``` -------------------------------- ### TracedPath Example in Manim Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/updaters.md Shows the usage of `TracedPath`, a built-in Manim updater specifically designed for drawing the path of a moving mobject. This example creates a path that follows a moving dot. ```python from manim import * class TracedPathExample(Scene): def construct(self): dot = Dot() path = TracedPath(dot.get_center, stroke_width=2, stroke_color=BLUE) self.add(dot, path) self.play( dot.animate.shift(RIGHT * 2), dot.animate.shift(UP * 2), run_time=3 ) ``` -------------------------------- ### Manim MovingCameraScene Example Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/scenes.md Illustrates a Manim `MovingCameraScene` for animations involving camera movement, such as zooming or panning. The example shows scaling and moving the camera frame to focus on a circle. ```python class ZoomScene(MovingCameraScene): def construct(self): circle = Circle() self.add(circle) self.play(self.camera.frame.animate.scale(0.5).move_to(circle)) ``` -------------------------------- ### Execute Manim Rendering Commands Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/SKILL.md A collection of common Manim commands for rendering scenes. These commands allow for previewing animations at different qualities (`-pql`, `-pqh`), exporting in various formats like GIF, checking the installation health, and listing available plugins. ```bash manim -pql scene.py Scene # Preview low quality (development) manim -pqh scene.py Scene # Preview high quality manim --format gif scene.py # Output as GIF manim checkhealth # Verify installation manim plugins -l # List plugins ``` -------------------------------- ### ValueTracker Example in Manim Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/updaters.md Shows how to use `ValueTracker` to manage a numeric value that can be animated. This example demonstrates animating a number display and a circle's width based on the tracker's value. ```python from manim import * class ValueTrackerExample(Scene): def construct(self): # Create tracker tracker = ValueTracker(0) # Create number display number = DecimalNumber(0, num_decimal_places=2) number.add_updater(lambda m: m.set_value(tracker.get_value())) # Create circle that grows with tracker circle = Circle() circle.add_updater(lambda m: m.set_width(tracker.get_value())) self.add(number, circle) # Animate the tracker self.play(tracker.animate.set_value(4), run_time=3) self.play(tracker.animate.set_value(1), run_time=2) ``` -------------------------------- ### Basic Manim Scene Rendering Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/cli.md Demonstrates the fundamental command to render a Manim scene from a Python file. Includes options for previewing the video after rendering. ```bash # Render a scene manim file.py SceneName # With preview (opens video after rendering) manim -p file.py SceneName # Preview with low quality (fast) manim -pql file.py SceneName ``` -------------------------------- ### Comprehensive Color Example Scene in Manim Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/colors.md A Manim scene demonstrating various color functionalities including shades, gradients, custom RGB colors, and colored text. ```python from manim import Scene, VGroup, Circle, Square, Text, FadeIn, ShowCreation, Write, RIGHT, UP, DOWN, BLUE_E, BLUE_D, BLUE_C, BLUE_B, BLUE_A, RED, YELLOW, GREEN, BLUE, PURPLE, ORANGE, TEAL # Assuming rgb_to_color is available def rgb_to_color(rgb_list): # Placeholder for actual implementation if not globally available # Example: return Color(rgb_list[0], rgb_list[1], rgb_list[2]) pass class ComprehensiveColorExample(Scene): def construct(self): # Color variations showcase blue_shades = VGroup(*[ Circle(radius=0.4, color=color) for color in [BLUE_E, BLUE_D, BLUE_C, BLUE_B, BLUE_A] ]) blue_shades.arrange(RIGHT, buff=0.3) blue_shades.to_edge(UP, buff=1) # Gradient squares = VGroup(*[Square(side_length=0.6) for _ in range(8)]) squares.arrange(RIGHT, buff=0.2) squares.set_submobject_colors_by_gradient(RED, YELLOW, GREEN, BLUE) # Custom RGB color custom_circle = Circle( radius=1, color=rgb_to_color([0.8, 0.2, 0.6]), fill_opacity=0.7 ) custom_circle.shift(DOWN * 2) # Colored text text = Text( "Colorful Text", font_size=48, t2c={"Colorful": BLUE, "Text": GREEN} ) text.next_to(custom_circle, UP, buff=0.5) # Add everything self.play( FadeIn(blue_shades, lag_ratio=0.1), FadeIn(squares, lag_ratio=0.1), ShowCreation(custom_circle), Write(text) ) self.wait() # Animate color changes self.play( squares.animate.set_submobject_colors_by_gradient(PURPLE, ORANGE), custom_circle.animate.set_color(TEAL) ) self.wait() ``` -------------------------------- ### FadeIn Animation with Scale in ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/creation-animations.md Shows how to use FadeIn in conjunction with scaling. The mobject fades in while its size changes, either starting smaller and growing to its original size (scale=0.5) or starting larger and shrinking (scale=2). ```python # Fade in while scaling circle = Circle() self.play(FadeIn(circle, scale=0.5)) # Starts at half size # Shrink while fading in square = Square() self.play(FadeIn(square, scale=2)) # Starts at double size ``` -------------------------------- ### ManimGL Command Line: Quality Presets Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/config.md Shows how to use command-line flags to quickly select predefined quality presets for rendering. These presets adjust camera resolution and frame rate for faster iteration or higher fidelity output. ```bash # Use low quality preset manimgl scene.py MyScene -l # Use medium quality manimgl scene.py MyScene -m # Use high quality manimgl scene.py MyScene -h # Use 4K quality manimgl scene.py MyScene --uhd ``` -------------------------------- ### Styling Mobjects Based on Position in Manim (Gradient Example) Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/styling.md Demonstrates how to dynamically apply styles to mobjects based on their position within a group. This example uses a loop to set the fill opacity of squares arranged horizontally, creating a gradient effect. ```python from manim import * class GradientFill(Scene): def construct(self): squares = VGroup(*[Square() for _ in range(5)]).arrange(RIGHT) for i, sq in enumerate(squares): opacity = (i + 1) / 5 sq.set_fill(BLUE, opacity=opacity) self.add(squares) ``` -------------------------------- ### Create a Basic Scene with ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/scenes.md Illustrates the creation of a basic Scene in ManimGL. This is the base class for scenes and does not include interactive features. The example shows a simple animation writing the text 'Hello'. ```python class BasicScene(Scene): def construct(self): self.play(Write(Text("Hello"))) ``` -------------------------------- ### Staggered Animation Start with LaggedStart in ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/animation-groups.md LaggedStart executes a list of animations with a staggered delay, controlled by the lag_ratio parameter. A lag_ratio of 0.2 means each subsequent animation starts after 20% of the previous one's duration has passed. This creates a cascading effect. ```python class LaggedStartExample(Scene): def construct(self): circles = VGroup(*[ Circle(radius=0.5).shift(i * RIGHT) for i in range(-3, 4) ]) # Staggered creation self.play(LaggedStart( *[ShowCreation(c) for c in circles], lag_ratio=0.2, # Delay ratio between animations run_time=3 )) self.wait() ``` -------------------------------- ### ManimGL Setting Opacity and Transparency Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/colors.md Demonstrates how to control the opacity of ManimGL Mobjects, including fill opacity, stroke opacity, and overall transparency. ```python # Transparent circle circle = Circle(color=BLUE, fill_opacity=0.5) # Change opacity circle.set_opacity(0.7) # Fill vs Stroke opacity square = Square() square.set_fill(BLUE, opacity=0.5) square.set_stroke(WHITE, width=4, opacity=1.0) ``` -------------------------------- ### Complete 3D Scene Example with Camera Control in ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/frame.md A comprehensive example of a ManimGL scene (`Camera3DDemo`) showcasing 3D camera control. It includes adding a fixed background and title, a 3D object (Cube), and animating the camera's orientation and position over time. ```python class Camera3DDemo(InteractiveScene): def construct(self): # Background bg = FullScreenRectangle() bg.set_fill(GREY_E, 1) bg.fix_in_frame() self.add(bg) # Title fixed in frame title = Text("3D Demo") title.to_edge(UP) title.fix_in_frame() self.add(title) # 3D content cube = Cube(side_length=2) cube.set_color(BLUE) self.add(cube) # Animate camera self.play( self.frame.animate.reorient(60, -45, 0, ORIGIN, 8), run_time=3 ) # Rotate around self.play( self.frame.animate.reorient(60, 45, 0), run_time=4 ) ``` -------------------------------- ### Comprehensive Animation Grouping Example Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/animation-groups.md A full Manim example demonstrating various animation techniques including writing text, creating a grid of colored dots with lagged fade-in, synchronized color changes, and a cascade disappearance. It showcases `LaggedStart`, `FadeIn`, `animate`, `FadeOut`, and `VGroup` for complex choreography. ```python class ComprehensiveGrouping(Scene): def construct(self): # Title title = Text("Animation Groups", font_size=60) title.to_edge(UP) self.play(Write(title)) self.wait() # Create grid of dots dots = VGroup(*[ Dot(color=interpolate_color(BLUE, RED, i/20)) .shift([ (i % 7 - 3) * 0.8, (i // 7 - 1.5) * 0.8, 0 ]) for i in range(21) ]) # Lagged appearance self.play(LaggedStart( *[FadeIn(dot, scale=0.5) for dot in dots], lag_ratio=0.05, run_time=3 )) self.wait() # Synchronized color change self.play(*[ dot.animate.set_color(YELLOW) for dot in dots ]) self.wait() # Cascade disappearance self.play(LaggedStart( *[FadeOut(dot, shift=DOWN) for dot in dots], lag_ratio=0.05, run_time=2 )) # Clean up self.play(FadeOut(title)) self.wait() ``` -------------------------------- ### Combining ManimGL Flags for Common Workflows Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/cli.md Presents examples of combining multiple ManimGL command-line flags to achieve specific rendering and output behaviors efficiently. This includes combinations for quality, output, and interactive modes. ```bash # High quality, write and open manimgl scene.py MyScene -h -o # Low quality, fullscreen, for testing manimgl scene.py MyScene -l -f # Skip animations, final frame only manimgl scene.py MyScene -s --skip_animations # Interactive at line 20, low quality manimgl scene.py MyScene -l -se 20 # Save as GIF, high quality manimgl scene.py MyScene -h --format gif -o ``` -------------------------------- ### Setting Up 3D Axes in ManimGL Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/3d.md Demonstrates how to create and configure 3D axes in ManimGL using the `ThreeDAxes` class. It shows how to define the range for each axis, set dimensions, and add coordinate labels for better visualization and reference within the 3D space. ```python axes = ThreeDAxes( x_range=(-5, 5, 1), y_range=(-5, 5, 1), z_range=(-5, 5, 1), width=10, height=10, depth=10 ) axes.add_coordinate_labels(font_size=20) ``` -------------------------------- ### Run Manim Integration Visualization Scenes Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/references/integration_visualization.md Command-line interface commands to render specific Manim scenes from the `integration_visualization.py` file. The `-w` flag enables the preview window during rendering. ```bash manimgl integration_visualization.py AreaUnderCurve -w manimgl integration_visualization.py RiemannSums -w manimgl integration_visualization.py ExponentialDecay -w ``` -------------------------------- ### Manim Community Edition CLI: Health Check Source: https://context7.com/adithya-s-k/manim_skill/llms.txt Command to verify the Manim installation and check for any health issues. ```bash # Check installation manim checkhealth ``` -------------------------------- ### Basic Scene Creation in Manim Community Edition Source: https://github.com/adithya-s-k/manim_skill/blob/main/README.md Demonstrates the creation of a simple circle object and its animation using Manim Community Edition. Requires the 'manim' library to be installed. ```python from manim import * class BasicExample(Scene): def construct(self): circle = Circle() circle.set_fill(BLUE, opacity=0.5) circle.set_stroke(BLUE_E, width=4) self.play(Create(circle)) self.wait() ``` -------------------------------- ### Manim Fade to Color Animation Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimgl-best-practices/rules/colors.md Example of animating a Manim mobject to change its color over a specified duration. ```python from manim import Circle, RED # Assuming 'circle' is a Manim mobject # Example: # circle = Circle() # self.add(circle) self.play( circle.animate.set_color(RED), run_time=2 ) ``` -------------------------------- ### Chained Transformations Example Source: https://github.com/adithya-s-k/manim_skill/blob/main/skills/manimce-best-practices/rules/transform-animations.md Shows how to chain multiple transformations sequentially, morphing a single mobject through a series of different shapes over time. ```python class ChainedExample(Scene): def construct(self): shape = Square() self.play(Create(shape)) # Chain of transformations for target in [Circle(), Triangle(), Star()]: self.play(Transform(shape, target)) self.wait(0.5) ```