All skills
adithya-s-k avatar

/manimgl-best-practices

@2375ac0
by Adithya S Kadithya-s-k/manim_skill1.1k stars
94

Trigger when: (1) User mentions "manimgl" or "ManimGL" or "3b1b manim", (2) Code contains `from manimlib import *`, (3) User runs `manimgl` CLI commands, (4) Working with InteractiveScene, self.frame, self.embed(), ShowCreation(), or ManimGL-specific patterns. Best practices for ManimGL (Grant Sanderson's 3Blue1Brown version) - OpenGL-based animation engine with interactive development. Covers InteractiveScene, Tex with t2c, camera frame control, interactive mode (-se flag), 3D rendering, and checkpoint_paste() workflow. NOT for Manim Community Edition (which uses `manim` imports and `manim` CLI).

Use this Skill: https://skilld.dev/gh/adithya-s-k/manim_skill/manimgl-best-practices

This session only. Nothing lands on disk.

referencesspring_mass_system.md

≈756 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Spring-Mass System - Reference Guide

Example file: examples/spring_mass_system.py

User Query Scenarios

This example addresses queries like:

  • "Create a spring animation with oscillation"
  • "Show damped harmonic motion"
  • "Visualize physics simulation with a mass on a spring"
  • "Animate a spring-mass system with real-time graph"
  • "Compare different damping coefficients"

Scene Thinking Process (3b1b Style)

1. Identify the Core Concept

Damped Harmonic Motion: A mass attached to a spring oscillates, with amplitude decreasing over time due to friction/damping. The equation is: x'' = -kx - μv

2. Visual Design Decisions

Why a parametric helix for the spring?

  • Looks realistic with 3D coils
  • Stretches naturally when mass moves
  • Uses ParametricCurve for smooth rendering

Why track position on a number line?

  • Gives quantitative feedback
  • Shows exact displacement values
  • Easy to understand motion direction

3. Technical Implementation

Creating a Self-Contained Physics Component
class SpringMassSystem(VGroup):
    def __init__(self, x0=0, v0=0, k=3, mu=0.1, ...):
        # Store physics state
        self.k = k
        self.mu = mu
        self.velocity = v0

        # Add physics updater
        self.add_updater(lambda m, dt: m.time_step(dt))

Key insight: Encapsulate physics + visuals in one VGroup subclass. This makes it reusable and keeps animation code clean.

Physics Integration (Euler Method)
def time_step(self, delta_t, dt_size=0.01):
    state = [self.get_x(), self.velocity]
    for _ in range(sub_steps):
        x, v = state
        acceleration = -self.k * x - self.mu * v
        state[0] += v * true_dt
        state[1] += acceleration * true_dt
Dynamic Velocity/Force Vectors
def get_velocity_vector(self, scale_factor=0.5, color=GREEN):
    vector = Vector(RIGHT, fill_color=color)
    vector.add_updater(lambda m: m.put_start_and_end_on(
        self.mass.get_center(),
        self.mass.get_center() + scale_factor * self.velocity * RIGHT
    ))
    return vector

4. Scene Variants

Scene Purpose
SpringMassDemo Basic oscillation with velocity/force vectors
SpringWithGraph Real-time x(t) graph using TracedPath
MultipleSprings Compare different damping values

Key Patterns Demonstrated

Pattern: Pausable Physics

def pause(self):
    self._is_running = False

def unpause(self):
    self._is_running = True

Pattern: TracedPath for Graphs

tracking_point = Point()
tracking_point.add_updater(lambda p: p.move_to(
    axes.c2p(time_tracker.get_value(), spring.get_x())
))
position_graph = TracedPath(tracking_point.get_center, stroke_color=BLUE)

Run Commands

# Basic demo
manimgl spring_mass_system.py SpringMassDemo -w

# With real-time graph
manimgl spring_mass_system.py SpringWithGraph -w

# Compare damping
manimgl spring_mass_system.py MultipleSprings -w

Source: SKILL.md on GitHub

No alerts17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    The skill is an educational resource for the ManimGL mathematical animation library, providing best practices and functional examples. All code patterns, including CLI boilerplate and external asset references, are standard and safe for the intended use cases.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    1/107 files flagged

  • ZeroLeaks5mo

    1 finding · Score: 86/100

Signed by skilld at 2375ac0. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago

README badge

README badge for adithya-s-k/manim_skill/manimgl-best-practices