Turn static graphs into beautiful animations
Project description
🎬 Viviphi
Turn static graphs into beautiful animations!
Viviphi transforms your Mermaid.js diagrams into stunning animated SVGs with customizable themes and smooth transitions. Perfect for presentations, documentation, or just making your diagrams come alive.
✨ Features
- 🎨 Multiple Themes: Cyberpunk, Corporate, and Hand-drawn styles
- ⚡ Easy to Use: Simple Python API with just a few lines of code
- 🎯 Mermaid Compatible: Works with standard Mermaid.js syntax
- 🚀 Fast Rendering: Powered by Playwright for reliable SVG generation
- 🎛️ Customizable: Adjustable animation speeds and timing
🚀 Quick Start
Installation
# Install viviphi
uv add viviphi
# Install browser dependencies
uv run playwright install chromium
Basic Usage
from viviphi import Graph, CYBERPUNK
# Define your Mermaid graph
mermaid_code = """
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Action 1]
B -->|No| D[Action 2]
C --> E[End]
D --> E
"""
# Create and animate
graph = Graph(mermaid_code)
animated_svg = graph.animate(theme=CYBERPUNK, output="my_graph.svg")
That's it! Your animated SVG is ready.
🎨 Themes
Viviphi comes with three built-in themes:
Cyberpunk 🌆
from viviphi import Graph, CYBERPUNK
graph = Graph(mermaid_code)
graph.animate(theme=CYBERPUNK, output="cyberpunk_graph.svg")
Corporate 💼
from viviphi import Graph, CORPORATE
graph = Graph(mermaid_code)
graph.animate(theme=CORPORATE, output="corporate_graph.svg")
Hand Drawn ✏️
from viviphi import Graph, HAND_DRAWN
graph = Graph(mermaid_code)
graph.animate(theme=HAND_DRAWN, output="hand_drawn_graph.svg")
⚡ Animation Speed
Control the animation speed with the speed parameter:
# Slow and dramatic
graph.animate(theme=CYBERPUNK, speed="slow")
# Default speed
graph.animate(theme=CYBERPUNK, speed="normal")
# Quick and snappy
graph.animate(theme=CYBERPUNK, speed="fast")
📊 Supported Diagram Types
Viviphi works with all standard Mermaid diagram types:
Flowcharts
flowchart = """
graph LR
A[User] --> B[Login]
B --> C{Valid?}
C -->|Yes| D[Dashboard]
C -->|No| E[Error]
"""
Sequence Diagrams
sequence = """
sequenceDiagram
participant A as Alice
participant B as Bob
A->>B: Hello Bob
B->>A: Hello Alice
"""
Class Diagrams
class_diagram = """
classDiagram
class Vehicle {
+String make
+String model
+start()
+stop()
}
class Car {
+openTrunk()
}
Vehicle <|-- Car
"""
State Diagrams
state_diagram = """
stateDiagram-v2
[*] --> Idle
Idle --> Running: start()
Running --> Idle: stop()
Running --> [*]: shutdown()
"""
🔧 Advanced Usage
Batch Processing
Process multiple diagrams at once:
from pathlib import Path
from viviphi import Graph, CYBERPUNK, CORPORATE, HAND_DRAWN
def animate_all_diagrams(input_dir: Path, output_dir: Path):
themes = {
"cyberpunk": CYBERPUNK,
"corporate": CORPORATE,
"hand_drawn": HAND_DRAWN
}
for mermaid_file in input_dir.glob("*.mmd"):
content = mermaid_file.read_text()
graph = Graph(content)
for theme_name, theme in themes.items():
output_file = output_dir / f"{mermaid_file.stem}_{theme_name}.svg"
graph.animate(theme=theme, output=str(output_file))
Custom Timing
Fine-tune animation timing:
from viviphi import Graph, Theme
# Create a custom theme with specific timing
custom_theme = Theme(
primary_color="#ff6b6b",
background="#2d3748",
edge_style="neon",
animation_duration=2.5, # Longer animations
stagger_delay=0.5 # More delay between elements
)
graph = Graph(mermaid_code)
graph.animate(theme=custom_theme)
🎯 Real-World Examples
Documentation Workflow
from viviphi import Graph, CORPORATE
# Load your workflow diagram
workflow = """
graph TD
A[Write Code] --> B[Create Mermaid Diagram]
B --> C[Generate Animated SVG]
C --> D[Include in Documentation]
D --> E[Profit! 🎉]
"""
# Generate for docs
graph = Graph(workflow)
graph.animate(theme=CORPORATE, speed="normal", output="docs/workflow.svg")
System Architecture
from viviphi import Graph, CYBERPUNK
architecture = """
graph TB
subgraph "Frontend"
UI[React App]
API[API Client]
end
subgraph "Backend"
SERVER[Express Server]
DB[(PostgreSQL)]
CACHE[(Redis)]
end
UI --> API
API --> SERVER
SERVER --> DB
SERVER --> CACHE
"""
graph = Graph(architecture)
graph.animate(theme=CYBERPUNK, output="architecture.svg")
📁 Project Structure
viviphi/
├── viviphi/ # Main package
│ ├── animator.py # SVG animation engine
│ ├── graph.py # Main Graph class
│ ├── mermaid.py # Mermaid rendering
│ └── themes.py # Theme definitions
├── examples/ # Usage examples
├── resources/ # Sample Mermaid files
└── tests/ # Test suite
🛠️ Development
# Clone the repository
git clone <repository-url>
cd viviphi
# Install dependencies
uv sync --no-install-project
# Run tests
uv run pytest
# Check code quality
ruff check
ruff format
🤝 Contributing
We welcome contributions! Please feel free to submit issues and pull requests.
📄 License
This project is open source. See LICENSE file for details.
Made with ❤️ by the Viviphi team
Transform your static diagrams into dynamic stories!
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
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 viviphi-1.1.0.tar.gz.
File metadata
- Download URL: viviphi-1.1.0.tar.gz
- Upload date:
- Size: 28.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a02b2f41cc7a133717e2ed57758194b44a1035619580c1362d4dc97d9bece8a
|
|
| MD5 |
8337319c5ce2e60e8b3d3be332859126
|
|
| BLAKE2b-256 |
2a93ebd7fa8a137ff5e1f2df24298c24cbc845014851e05a270ab0cc2f23d6d8
|
Provenance
The following attestation bundles were made for viviphi-1.1.0.tar.gz:
Publisher:
publish.yml on dbudaghyan/viviphi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
viviphi-1.1.0.tar.gz -
Subject digest:
6a02b2f41cc7a133717e2ed57758194b44a1035619580c1362d4dc97d9bece8a - Sigstore transparency entry: 788150186
- Sigstore integration time:
-
Permalink:
dbudaghyan/viviphi@7c61a6c3c94d03b3681b33ada88c7184a46635ec -
Branch / Tag:
refs/heads/master - Owner: https://github.com/dbudaghyan
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7c61a6c3c94d03b3681b33ada88c7184a46635ec -
Trigger Event:
push
-
Statement type:
File details
Details for the file viviphi-1.1.0-py3-none-any.whl.
File metadata
- Download URL: viviphi-1.1.0-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88e51e26d6d6a4096c591a3057f29f8fe408e354cd80c871e7210f51ffedda3f
|
|
| MD5 |
a542356d909fc3934a511fdf5813f195
|
|
| BLAKE2b-256 |
e41977cfdb09e0317f2d8ef6110b56ce7f1b92e90bedc692f0b840749832d7bf
|
Provenance
The following attestation bundles were made for viviphi-1.1.0-py3-none-any.whl:
Publisher:
publish.yml on dbudaghyan/viviphi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
viviphi-1.1.0-py3-none-any.whl -
Subject digest:
88e51e26d6d6a4096c591a3057f29f8fe408e354cd80c871e7210f51ffedda3f - Sigstore transparency entry: 788150196
- Sigstore integration time:
-
Permalink:
dbudaghyan/viviphi@7c61a6c3c94d03b3681b33ada88c7184a46635ec -
Branch / Tag:
refs/heads/master - Owner: https://github.com/dbudaghyan
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7c61a6c3c94d03b3681b33ada88c7184a46635ec -
Trigger Event:
push
-
Statement type: