Python library · deterministic SVG and Manim · built for AI agents
Generate checked SVG diagrams and Manim animations.
Figures and animations that show their work.
Straightedge is an open-source Python library that turns structured data,
formulas, templates, or a natural-language prompt into a deterministic SVG
figure or Manim scene — then exposes the underlying geometry, so an
application or an AI agent can catch overlaps, clipping, and missing
content before accepting the result.
55dependency-free SVG templates
11playable animation examples
0runtime dependencies for figures
What is Straightedge?
Straightedge is an open-source Python library for generating deterministic
SVG diagrams and Manim animations from structured data, formulas,
templates, or natural-language prompts. Unlike screenshot- or image-based
generation, Straightedge exposes the underlying geometry so applications
and AI agents can detect overlaps, clipping, missing content, and other
visible defects before accepting a visual.
The premise is that a visual can render successfully and still be
wrong. A curve can leave the frame, a label can land on a formula,
a chart can come out empty, and nothing in a successful render says so. An
LLM writing figure code is working blind for exactly this reason: it emits
code, the code runs, and no signal comes back. Straightedge is the part
that can tell it what came out — which is why the same design that makes
the output trustworthy for a person makes it usable by an agent.
Two independent lanes share one spec. A structured dictionary becomes an
SVG string using nothing but the Python standard
library. The same intent, sent down the video lane, becomes a
Manim scene rendered to MP4. Neither lane
needs a browser or a rendering service, and the figure lane has no runtime
dependencies at all.
Install
pip install straightedge
Figures only, no dependencies. Add straightedge[render] for
the Manim video lane, or straightedge[mcp] for the
Model Context Protocol server. On
PyPI and
GitHub.
Questions
What is Straightedge?
An open-source Python library for generating deterministic SVG diagrams
and Manim animations from structured data, formulas, templates, or
natural-language prompts. It exposes the underlying geometry of what it
drew, so an application or an AI agent can detect overlaps, clipping,
out-of-frame curves, and missing content before accepting the visual.
How is Straightedge different from Mermaid or Graphviz?
Mermaid and Graphviz turn a text description into a layout, and both are
excellent at that. Straightedge covers a wider set of figure types than
graph layout — Riemann sums, unit circles, Gantt charts, heatmaps,
T-accounts, call stacks — and it returns the geometry it produced
alongside the SVG, so the caller can check the drawing rather than trust
it. It also renders Manim video from the same structured input, which
neither Mermaid nor Graphviz does.
How is Straightedge different from generating a diagram with an image model?
An image model returns pixels, so the same prompt gives a different
picture each time and nothing in the output states where anything is.
Straightedge is deterministic — the same structured input produces the
same geometry — and because the output is constructed rather than
sampled, labels are the text you supplied instead of an approximation of
letters. The geometry is inspectable, so defects are reportable rather
than a matter of opinion.
Can an AI agent use Straightedge?
Yes, and that is the case it is designed for. An agent can enumerate the
template catalog and its parameter contracts, render a figure, read back
structured findings about what came out wrong, and repair its input. An
optional MCP server exposes the library over the Model Context Protocol,
and the errors distinguish a refusal from a failure, so an agent can tell
I will not draw that from something broke.
Does Straightedge require a browser or a network connection?
No. The SVG lane is pure Python standard library with zero runtime
dependencies — no browser, no headless Chrome, no network call, no
rendering service. Manim, Whisper, and the MCP SDK live behind optional
extras, so a caller who only wants figures installs nothing extra.
Can Straightedge generate Manim animations from natural language?
Yes. A prompt is planned into a structured spec, matched against the
deterministic template set where one fits, and otherwise handed to an LLM
writer, reviewer, and bounded repair loop that emits a Manim scene. When
the model path fails, it degrades to a deterministic template rather than
returning nothing.
Can Straightedge validate a generated diagram?
Yes, at three separate moments, because each catches what the others
cannot. Preconditions run before anything is drawn and refuse a plan that
would render beautifully while answering a different question. QC reads
the built scene and reports what is empty, clipped, off-frame, or printed
on top of something else. A label check catches on-screen text that
survived translation untranslated.
Does Straightedge execute LLM-generated code?
Only in the optional prompt-driven agent lane, and never in the
deterministic template lane, which executes no model output at all. When
the agent lane runs, generated scenes are screened by an AST allowlist
that blocks imports and interpreter escapes. That screen is defence in
depth rather than a sandbox, so untrusted input should be run in an
isolated environment.