A domain-specific programming language for mathematical animations
Project description
MathViz
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.
Features
- 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)
- Fast Iteration — REPL mode and file watcher for rapid development
Installation
Using pipx (Recommended)
pipx install git+https://github.com/CyberSnakeH/MathViz.git
Using uv
git clone https://github.com/CyberSnakeH/MathViz.git
cd MathViz
uv sync --dev
Using pip
git clone https://github.com/CyberSnakeH/MathViz.git
cd MathViz
pip install -e ".[dev]"
Prerequisites
Quick Start
Hello World
Create a file hello.mviz:
fn main() {
println("Hello, MathViz!")
}
Run it:
mathviz exec hello.mviz
Your First Animation
Create 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
Language Features
// 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}
CLI Reference
# 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 tests
Editor
MathViz includes a cross-platform desktop editor built with Tauri and React.
Features
- Syntax highlighting for
.mvizfiles - Live animation preview
- Integrated terminal
- File explorer
- Command palette (
Ctrl+P)
Keyboard Shortcuts
| 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 |
Running the Editor
cd editor
npm install
npm run tauri dev
Building
npm run tauri build
Binaries will be in editor/src-tauri/target/release/bundle/.
Project Structure
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
├── examples/ # Example programs
├── tests/ # Test suite
└── docs/ # Documentation
Examples
Explore the examples/ directory:
hello_world.mviz— Basic syntaxcircle_animation.mviz— Simple animationset_operations.mviz— Unicode mathvenn_diagram.mviz— Complex animationmultimodule/— Multi-file project
Development
Running Tests
uv run pytest
Code Quality
# Format
uv run ruff format src tests
# Lint
uv run ruff check src tests
# Type check
uv run mypy src
Language Server
pip install -e ".[lsp]"
mathviz-lsp
Contributing
Contributions 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 PR
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Manim Community — The animation engine
- Tauri — Desktop app framework
- Monaco Editor — Code editor
Made with ❤️ by CyberSnakeH
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mathviz-0.1.7.tar.gz.
File metadata
- Download URL: mathviz-0.1.7.tar.gz
- Upload date:
- Size: 969.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57424c7a8753b9320b973e1e00157fe35cc89e9b039fdd9795e966393a4a66bf
|
|
| MD5 |
1dbd8fe2a589cb0e1fb6fa8c869850e3
|
|
| BLAKE2b-256 |
bc589175791a1d5dfeaa4a02c4c73b2a50318cdb3567921d4a73fc0649e83abe
|
File details
Details for the file mathviz-0.1.7-py3-none-any.whl.
File metadata
- Download URL: mathviz-0.1.7-py3-none-any.whl
- Upload date:
- Size: 304.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
798cba457e800adb9745f389dde1566c83d9a76a6a8885502debd53988fb0d65
|
|
| MD5 |
8ae10b8ade3982b645066b4a80bea01c
|
|
| BLAKE2b-256 |
457c096f4b39db00759185bbbbe4ed31a7305e5ce0bf38c68c079334ef0e5854
|