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.

referencesintegration_visualization.md

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

Integration Visualization - Reference Guide

Example file: examples/integration_visualization.py

User Query Scenarios

This example addresses queries like:

  • "Show the area under a curve"
  • "Visualize Riemann sums converging to integral"
  • "Animate definite integral accumulation"
  • "Show integral of e^(-x) equals 1"

Scene Thinking Process (3b1b Style)

1. Core Concept

Definite Integral: The integral ∫f(x)dx represents accumulated area under curve f(x). Riemann sums with shrinking rectangles converge to the true integral.

2. Technical Implementation

Animated Area Fill (Using Polygon)
def get_area_polygon():
    t = t_tracker.get_value()
    xs = np.linspace(0, t, 50)
    # Points along curve
    points = [axes.c2p(x, f(x)) for x in xs]
    # Close the polygon along x-axis
    points.append(axes.c2p(t, 0))
    points.append(axes.c2p(0, 0))
    poly = Polygon(*points)
    poly.set_fill(BLUE_E, opacity=0.5)
    poly.set_stroke(width=0)
    return poly

area = always_redraw(get_area_polygon)

Key insight: ManimGL doesn't have axes.get_area(), so build polygons manually from curve points.

Riemann Sum Rectangles
for i in range(n):
    x = start + i * dx
    height = f(x)
    rect = Rectangle(
        width=dx * axes.x_axis.get_unit_size(),
        height=height * axes.y_axis.get_unit_size(),
    )
    rect.move_to(axes.c2p(x + dx/2, height/2))

3. Scene Variants

Scene Purpose
AreaUnderCurve Basic accumulating area animation
RiemannSums Rectangles converging (n=4,8,16,32)
ExponentialDecay ∫e^(-x)dx = 1 with live area counter

Key Patterns

Pattern: Live Value Display

value_label = Tex(r"\text{Area} \approx 0.00")
value_num = value_label.make_number_changeable("0.00")
value_num.add_updater(lambda m: m.set_value(computed_area))

Pattern: Progressive Rectangle Refinement

for n in [4, 8, 16, 32]:
    new_rects = create_rectangles(n)
    self.play(ReplacementTransform(current_rects, new_rects))
    current_rects = new_rects

Run Commands

manimgl integration_visualization.py AreaUnderCurve -w
manimgl integration_visualization.py RiemannSums -w
manimgl integration_visualization.py ExponentialDecay -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