Skip to main content

Manim Vision: spatial collision intelligence for Manim scenes, with LLM-friendly check digests and telemetry.

Project description

Manim Vision

Manim Vision adds spatial collision awareness to Manim Community scenes. It watches your scene as add, play, and remove run, detects meaningful overlaps, and emits compact summaries that an LLM can use to fix layout problems without reading video frames.

PyPI pip install manim-vision
Python 3.10, 3.11, or 3.12
License MIT

What it does

  • Hooks a live Scene without changing your source class at import time.
  • Converts tracked VMobject geometry to Shapely shapes and checks overlap with an STRtree.
  • Suppresses obvious noise such as glyph-on-glyph kerning, centered text-in-cell layouts, and tiny dust overlaps.
  • Tracks overlap events, so a collision that persists for 100 plays is reported once until the objects separate.
  • Labels collisions with scene-meaningful names instead of raw memory ids.
  • Produces a compact scene summary by default, with optional human-readable or silent modes.

Installation

pip install manim-vision

Dependencies are declared in pyproject.toml and include manim, shapely, wrapt, numpy, and jsonschema.

Quick start

Call ManimVision.monitor(self) early in construct(), then shut it down at the end so queued collision work can flush.

from manim import BLUE, RED, Create, Circle, RIGHT, Scene, Square
from manim_vision import ManimVision


class MyScene(Scene):
    def construct(self):
        ManimVision.monitor(self)  # default: compact LLM summary

        circle = Circle(radius=1, color=BLUE)
        square = Square(side_length=1.2, color=RED)
        square.next_to(circle, RIGHT, buff=0)

        self.add(circle, square)
        self.play(Create(circle), Create(square))

        ManimVision.shutdown(self)
        print(ManimVision.results(self))

Output modes

ManimVision.monitor(scene, output_mode=...) accepts one optional mode:

  • "llm": default. Collects collision events during the scene and writes one compact JSON summary at shutdown to media/manim_vision/<SceneName>_check_digest.jsonl.
  • "human": collects the same events but writes a readable text summary for developers.
  • "silent": writes nothing to disk or stdout and keeps results available through ManimVision.results(scene).

Example:

ManimVision.monitor(self, output_mode="silent")
# ...
ManimVision.shutdown(self)
summary = ManimVision.results(self)

Output files

By default, Manim Vision writes under your Manim media directory:

  • media/manim_vision/<SceneName>_check_digest.jsonl: compact scene summary in LLM mode.
  • media/manim_vision/<SceneName>_spatial_log.txt: human summary in human mode.
  • media/manim_vision/<SceneName>_spatial.jsonl: legacy per-event JSONL, only when MANIM_VISION_PER_PAIR_JSONL=1.

Override the directory with MANIM_VISION_REPORT_DIR.

Public API

  • ManimVision.monitor(scene, output_mode="llm")
  • ManimVision.shutdown(scene)
  • ManimVision.results(scene)

Exceptions re-exported from manim_vision:

  • ManimVisionError
  • ManimVisionGeometryError
  • ManimVisionSchemaError
  • ManimVisionProxyError

How it works

  1. ManimVision.monitor(scene) attaches an engine, solver, dispatcher, lock, and worker executor to the live scene instance.
  2. A mixin is inserted at runtime so add, play, and remove can register, resync, and deregister geometry.
  3. Collision checks run on a single-worker background executor under a scene lock.
  4. Raw collisions are filtered, semantically grouped, deduplicated across continuous overlap events, and summarized on shutdown.

Notes

  • Analysis is 2D and based on overlap area, not full 3D physics.
  • Touching edges without positive overlap are ignored.
  • Some concave cases use centroid-based fallbacks for fix hints.
  • Internal lock-bearing state stays on proxies, so Manim creation-style animations still deep-copy safely.

Development

python -m venv .venv
.venv\Scripts\activate
pip install -e ".[dev]"
python -m pytest

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

manim_vision-0.1.7.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

manim_vision-0.1.7-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file manim_vision-0.1.7.tar.gz.

File metadata

  • Download URL: manim_vision-0.1.7.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for manim_vision-0.1.7.tar.gz
Algorithm Hash digest
SHA256 d551684a2681611af58b4280ad3a243c445c68bcd22c43fe10ec8a7cf8d0d087
MD5 6990d0d39d033477a0935576a1af4524
BLAKE2b-256 ff7c195fa10b738c9ebad587e7859cab6b554797e1b9e5c65c117f6a4e49cbcc

See more details on using hashes here.

File details

Details for the file manim_vision-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: manim_vision-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 33.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for manim_vision-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d523c9e9f61b5e1968c56ced7a6e7e96fb9f989755d07f7cf509b99ee69d4d42
MD5 765e015d3e4619158785fd6f951e67fe
BLAKE2b-256 9320a84a17089e2d71d0ef8d1670aa3d124221ab0f7e5be78309b4849ef3ceee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page