A domain-specific language for mathematical animations
Website • Features • Installation • Quick Start • Editor • Contributing
MathViz is a modern programming language designed specifically for creating mathematical animations. It extends Python with a clean, math-first syntax and compiles to pure Python with first-class Manim integration.
- Unicode Math Operators — Write math naturally:
∈,⊆,∪,∩,∞,π,≤,≥,≠ - Clean Syntax — Modern block syntax with
let,fn,scene, and pattern matching - Manim Integration — First-class support for creating mathematical animations
- Static Analysis — Built-in
check,analyze,typecheck,lint, andfmtcommands - Module System — Multi-file projects with
useimports - Desktop Editor — Cross-platform editor with live preview (Tauri + React)
- VS Code Extension — Syntax highlighting, snippets, and bracket matching for VS Code
- Auto-update — Automatic update detection with PyPI version check
- Fast Iteration — REPL mode and file watcher for rapid development
pipx install mathvizpip install mathvizgit clone https://github.com/CyberSnakeH/MathViz.git
cd MathViz
uv sync --devCreate a file hello.mviz:
fn main() {
println("Hello, MathViz!")
}
Run it:
mathviz exec hello.mvizCreate animation.mviz:
from manim import Circle, Create, FadeOut
scene CircleAnimation {
fn construct(self) {
let circle = Circle()
circle.set_color(BLUE)
self.play(Create(circle))
self.wait(1)
self.play(FadeOut(circle))
}
}
Run with preview:
mathviz run animation.mviz --preview// Variables with type inference
let x = 42
let name = "MathViz"
let pi = 3.14159
// Functions with type annotations
fn add(a: int, b: int) -> int {
return a + b
}
// Pattern matching
let result = match x {
0 -> "zero"
1 -> "one"
_ -> "other"
}
// For loops with ranges
for i in 0..10 {
println(i)
}
// List comprehensions
let squares = [x^2 for x in 1..=10]
// Unicode math
let is_member = 5 ∈ {1, 2, 3, 4, 5}
let union = {1, 2} ∪ {3, 4}
# Compile to Python
mathviz compile file.mviz -o output.py
# Run with Manim (animations)
mathviz run file.mviz --preview
# Execute script (no Manim)
mathviz exec file.mviz
# Static analysis
mathviz check file.mviz # Syntax check
mathviz typecheck file.mviz # Type check
mathviz analyze file.mviz # Full analysis
mathviz lint file.mviz # Linter
# Formatting
mathviz fmt file.mviz
# Development
mathviz watch src/ # Watch mode
mathviz repl # Interactive REPL
# Project management
mathviz new my-project # Create new project
mathviz build # Build project
mathviz test # Run testsInstall the MathViz extension for VS Code with syntax highlighting, 18 code snippets, and smart bracket matching.
cd vscode-mathviz
npx @vscode/vsce package
code --install-extension mathviz-0.1.0.vsixOpen any .mviz or .mvz file and the extension activates automatically.
MathViz includes a cross-platform desktop editor built with Tauri and React.
- Syntax highlighting for
.mvizfiles - Live animation preview
- Integrated terminal
- File explorer
- Command palette (
Ctrl+P)
| Shortcut | Action |
|---|---|
F5 |
Run with Manim |
F6 |
Execute script |
F8 |
Compile only |
Ctrl+S |
Save |
Ctrl+P |
Command palette |
Ctrl+B |
Toggle sidebar |
Ctrl+J |
Toggle terminal |
cd editor
npm install
npm run tauri devnpm run tauri buildBinaries will be in editor/src-tauri/target/release/bundle/.
MathViz/
├── src/mathviz/ # Compiler and runtime
│ ├── compiler/ # Lexer, parser, codegen
│ ├── utils/ # Errors, diagnostics
│ └── cli.py # CLI entry point
├── editor/ # Desktop editor (Tauri)
│ ├── src/ # React frontend
│ └── src-tauri/ # Rust backend
├── vscode-mathviz/ # VS Code extension
│ ├── syntaxes/ # TextMate grammar
│ └── snippets/ # Code snippets
├── examples/ # Example programs
├── tests/ # Test suite
└── docs/ # Documentation
Explore the examples/ directory:
hello_world.mviz— Basic syntaxcircle_animation.mviz— Simple animationset_operations.mviz— Unicode mathvenn_diagram.mviz— Complex animationmultimodule/— Multi-file project
uv run pytest# Format
uv run ruff format src tests
# Lint
uv run ruff check src tests
# Type check
uv run mypy srcpip install -e ".[lsp]"
mathviz-lspContributions are welcome! Please read our Contributing Guide for details on:
- Development environment setup
- Code style and conventions
- Commit message guidelines
- Testing requirements
- Pull request process
Quick start:
# Fork and clone
git clone https://github.com/CyberSnakeH/MathViz.git
cd MathViz
# Create a branch
git checkout -b feature/my-feature
# Make changes, then submit a PRThis project is licensed under the MIT License - see the LICENSE file for details.
- Manim Community — The animation engine
- Tauri — Desktop app framework
- Monaco Editor — Code editor
Made with ❤️ by CyberSnakeH