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.

referencesvector_fields.md

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

Vector Fields - Reference Guide

Example file: examples/vector_fields.py

User Query Scenarios

This example addresses queries like:

  • "Create a vector field visualization"
  • "Show particles flowing through a field"
  • "Visualize electric field from charges"
  • "Animate gradient descent"
  • "Show fluid flow"

Scene Thinking Process (3b1b Style)

1. Core Concept

Vector Fields: At each point in space, there's a vector showing direction and magnitude. Particles follow the field, revealing flow patterns.

2. Technical Implementation

Manual Arrow Field (Portable Approach)
arrows = VGroup()
for x in np.arange(-3.5, 4, 0.7):
    for y in np.arange(-2.5, 3, 0.7):
        vx, vy = -y * 0.15, x * 0.15  # Rotation field
        arrow = Arrow(
            start=[x, y, 0],
            end=[x + vx, y + vy, 0],
            buff=0,
            stroke_width=2,
        )
        # Color by magnitude
        mag = np.sqrt(vx**2 + vy**2)
        arrow.set_color(interpolate_color(BLUE, YELLOW, mag / 0.5))
        arrows.add(arrow)
Particle Following Field
def follow_field(mob, dt):
    x, y = mob.get_center()[:2]
    vx, vy = field_func(x, y)
    mob.shift(np.array([vx, vy, 0]) * dt)

dot.add_updater(follow_field)
trail = TracedPath(dot.get_center, stroke_color=RED)
Electric Dipole Field
def E_field(pos):
    r1, r2 = pos - q1_pos, pos - q2_pos
    d1, d2 = np.linalg.norm(r1), np.linalg.norm(r2)
    E1 = r1 / d1**3   # From + charge
    E2 = -r2 / d2**3  # From - charge
    return E1 + E2

3. Scene Variants

Scene Purpose
SimpleVectorField Rotation field with particle
GradientFieldDemo Scalar field + gradient arrows
ParticleFlow Multiple particles in vortex
ElectricDipole Field from +/- charges

Key Patterns

Pattern: Color by Magnitude

mag = np.linalg.norm([vx, vy])
color = interpolate_color(BLUE, YELLOW, min(mag * scale, 1))
arrow.set_color(color)

Pattern: LaggedStartMap for Many Arrows

self.play(LaggedStartMap(GrowArrow, arrows, lag_ratio=0.02, run_time=2))

Pattern: Closure for Updaters in Loops

for i in range(n):
    dot = Dot(...)
    def make_updater():  # Closure captures current state
        def update(mob, dt):
            # use mob, not dot
            ...
        return update
    dot.add_updater(make_updater())

Run Commands

manimgl vector_fields.py SimpleVectorField -w
manimgl vector_fields.py GradientFieldDemo -w
manimgl vector_fields.py ParticleFlow -w
manimgl vector_fields.py ElectricDipole -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