real-time-manim 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- real_time_manim-0.1.3/LICENSE +21 -0
- real_time_manim-0.1.3/MANIFEST.in +17 -0
- real_time_manim-0.1.3/PKG-INFO +277 -0
- real_time_manim-0.1.3/README.md +248 -0
- real_time_manim-0.1.3/logo.jpg +0 -0
- real_time_manim-0.1.3/native/build.ps1 +241 -0
- real_time_manim-0.1.3/native/draw/draw_arc.c +42 -0
- real_time_manim-0.1.3/native/draw/draw_bezier.c +346 -0
- real_time_manim-0.1.3/native/draw/draw_circle.c +66 -0
- real_time_manim-0.1.3/native/draw/draw_dashed_line.c +53 -0
- real_time_manim-0.1.3/native/draw/draw_ellipse.c +63 -0
- real_time_manim-0.1.3/native/draw/draw_line.c +117 -0
- real_time_manim-0.1.3/native/draw/draw_point.c +24 -0
- real_time_manim-0.1.3/native/draw/draw_polygon.c +103 -0
- real_time_manim-0.1.3/native/draw/draw_rect.c +106 -0
- real_time_manim-0.1.3/native/draw/draw_text.c +248 -0
- real_time_manim-0.1.3/native/draw_common.h +36 -0
- real_time_manim-0.1.3/native/platform.c +552 -0
- real_time_manim-0.1.3/native/platform.h +31 -0
- real_time_manim-0.1.3/native/shared_types.h +92 -0
- real_time_manim-0.1.3/native/stb_truetype.h +5079 -0
- real_time_manim-0.1.3/native/vulkan_core.h +60 -0
- real_time_manim-0.1.3/native/vulkan_draw.c +159 -0
- real_time_manim-0.1.3/native/vulkan_init.c +815 -0
- real_time_manim-0.1.3/native/vulkan_render.h +41 -0
- real_time_manim-0.1.3/pyproject.toml +49 -0
- real_time_manim-0.1.3/real_time_manim/__init__.py +0 -0
- real_time_manim-0.1.3/real_time_manim/animations/__init__.py +47 -0
- real_time_manim-0.1.3/real_time_manim/animations/add.py +17 -0
- real_time_manim-0.1.3/real_time_manim/animations/animation_group.py +95 -0
- real_time_manim-0.1.3/real_time_manim/animations/apply_wave.py +88 -0
- real_time_manim-0.1.3/real_time_manim/animations/base.py +141 -0
- real_time_manim-0.1.3/real_time_manim/animations/blink.py +78 -0
- real_time_manim-0.1.3/real_time_manim/animations/circumscribe.py +56 -0
- real_time_manim-0.1.3/real_time_manim/animations/create.py +15 -0
- real_time_manim-0.1.3/real_time_manim/animations/draw_border_then_fill.py +111 -0
- real_time_manim-0.1.3/real_time_manim/animations/fade_in.py +79 -0
- real_time_manim-0.1.3/real_time_manim/animations/fade_out.py +78 -0
- real_time_manim-0.1.3/real_time_manim/animations/fade_transform.py +142 -0
- real_time_manim-0.1.3/real_time_manim/animations/grow_arrow.py +89 -0
- real_time_manim-0.1.3/real_time_manim/animations/grow_from_center.py +40 -0
- real_time_manim-0.1.3/real_time_manim/animations/grow_from_edge.py +44 -0
- real_time_manim-0.1.3/real_time_manim/animations/grow_from_point.py +48 -0
- real_time_manim-0.1.3/real_time_manim/animations/homotopy.py +53 -0
- real_time_manim-0.1.3/real_time_manim/animations/indicate.py +95 -0
- real_time_manim-0.1.3/real_time_manim/animations/move_along_path.py +18 -0
- real_time_manim-0.1.3/real_time_manim/animations/move_to_target.py +7 -0
- real_time_manim-0.1.3/real_time_manim/animations/replacement_transform.py +7 -0
- real_time_manim-0.1.3/real_time_manim/animations/rotate.py +40 -0
- real_time_manim-0.1.3/real_time_manim/animations/rotating.py +125 -0
- real_time_manim-0.1.3/real_time_manim/animations/show_increasing_subsets.py +66 -0
- real_time_manim-0.1.3/real_time_manim/animations/show_passing_flash.py +36 -0
- real_time_manim-0.1.3/real_time_manim/animations/spin_in_from_nothing.py +42 -0
- real_time_manim-0.1.3/real_time_manim/animations/spiral_in.py +55 -0
- real_time_manim-0.1.3/real_time_manim/animations/succession.py +87 -0
- real_time_manim-0.1.3/real_time_manim/animations/text.py +150 -0
- real_time_manim-0.1.3/real_time_manim/animations/transform.py +100 -0
- real_time_manim-0.1.3/real_time_manim/animations/transform_matching_abstract_base.py +160 -0
- real_time_manim-0.1.3/real_time_manim/animations/transform_matching_shapes.py +23 -0
- real_time_manim-0.1.3/real_time_manim/animations/transform_matching_tex.py +37 -0
- real_time_manim-0.1.3/real_time_manim/animations/type_with_cursor.py +156 -0
- real_time_manim-0.1.3/real_time_manim/animations/uncreate.py +11 -0
- real_time_manim-0.1.3/real_time_manim/animations/untype_with_cursor.py +188 -0
- real_time_manim-0.1.3/real_time_manim/animations/unwrite.py +38 -0
- real_time_manim-0.1.3/real_time_manim/animations/wait.py +16 -0
- real_time_manim-0.1.3/real_time_manim/animations/write.py +33 -0
- real_time_manim-0.1.3/real_time_manim/logo.ico +0 -0
- real_time_manim-0.1.3/real_time_manim/rate_functions.py +61 -0
- real_time_manim-0.1.3/real_time_manim/record.py +291 -0
- real_time_manim-0.1.3/real_time_manim/util.py +179 -0
- real_time_manim-0.1.3/real_time_manim/utils/__init__.py +0 -0
- real_time_manim-0.1.3/real_time_manim/utils/paths.py +59 -0
- real_time_manim-0.1.3/real_time_manim/vulkan_bind.py +1932 -0
- real_time_manim-0.1.3/real_time_manim/vulkan_core.dll +0 -0
- real_time_manim-0.1.3/real_time_manim/vulkan_shapes.py +626 -0
- real_time_manim-0.1.3/real_time_manim/vulkan_text.py +546 -0
- real_time_manim-0.1.3/real_time_manim/vulkan_util.py +81 -0
- real_time_manim-0.1.3/real_time_manim.egg-info/PKG-INFO +277 -0
- real_time_manim-0.1.3/real_time_manim.egg-info/SOURCES.txt +83 -0
- real_time_manim-0.1.3/real_time_manim.egg-info/dependency_links.txt +1 -0
- real_time_manim-0.1.3/real_time_manim.egg-info/requires.txt +2 -0
- real_time_manim-0.1.3/real_time_manim.egg-info/top_level.txt +1 -0
- real_time_manim-0.1.3/setup.cfg +4 -0
- real_time_manim-0.1.3/setup.py +17 -0
- real_time_manim-0.1.3/tests/test_write_latex.py +189 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tagin T
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Native C/C++ sources — shipped in the sdist so users can rebuild the DLL.
|
|
2
|
+
# The compiled vulkan_core.dll itself is bundled as package-data under core/.
|
|
3
|
+
recursive-include native *.c *.h *.ps1
|
|
4
|
+
|
|
5
|
+
# Standard metadata (normally auto-included, listed explicitly for clarity)
|
|
6
|
+
include LICENSE
|
|
7
|
+
include README.md
|
|
8
|
+
include logo.jpg
|
|
9
|
+
|
|
10
|
+
# Keep build artifacts out of the source distribution
|
|
11
|
+
exclude build
|
|
12
|
+
exclude dist
|
|
13
|
+
recursive-exclude build *
|
|
14
|
+
recursive-exclude dist *
|
|
15
|
+
prune tex_cache
|
|
16
|
+
prune media
|
|
17
|
+
prune downloaded_videos
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: real-time-manim
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Vulkan-accelerated real-time rendering backend for ManimCE (Windows)
|
|
5
|
+
Author: Tagin T
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/BEGINWITHF/real-time-manim
|
|
8
|
+
Project-URL: Documentation, https://github.com/BEGINWITHF/real-time-manim#readme
|
|
9
|
+
Project-URL: Source, https://github.com/BEGINWITHF/real-time-manim
|
|
10
|
+
Keywords: manim,vulkan,renderer,animation,gpu,3b1b
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
21
|
+
Classifier: Topic :: Multimedia :: Video
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: manim>=0.20.0
|
|
27
|
+
Requires-Dist: numpy
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Real-Time-Manim(RTM)
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<img src="logo.jpg" alt="real-time-manim logo" width="560"/>
|
|
34
|
+
</p>
|
|
35
|
+
A **Vulkan-accelerated, real-time rendering backend** for
|
|
36
|
+
[ManimCE](https://www.manim.community/). Instead of the default OpenGL/Cairo
|
|
37
|
+
renderer, `real-time-manim` draws every scene through a native Vulkan pipeline —
|
|
38
|
+
so you get a live, interactive window *and* fast GPU-accelerated video output,
|
|
39
|
+
all driven by ordinary Manim scenes.
|
|
40
|
+
|
|
41
|
+
> RTM(Real-Time-Manim) is a vulkan-based manim renderer boosting manim speed, making live-rendering available and compatible for rendering manim. Previous manim render focusing on Opengl ang Cairo renderer is CPU-based, making graphic rendering extremely slow and live-interaction unfeasible. RTM uses a refactored render pipeline (see flow chart below) to make live-render available for math animation, preparing for further development of Manteraction(a app for live interaction manim video creation, animation, and interaction.)
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+

|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
> **Audience.** This README is a short, user-facing guide. For the full picture —
|
|
48
|
+
> architecture, rendering internals, the animation system and building from
|
|
49
|
+
> source — see the [Wiki](https://github.com/BEGINWITHF/real-time-manim/wiki).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Highlights
|
|
54
|
+
|
|
55
|
+
- **Live window.** Render Manim scenes in real time inside a `MLWindow`, not just
|
|
56
|
+
to a rendered file.
|
|
57
|
+
- **GPU backend.** A bundled `vulkan_core.dll` replaces the Cairo/OpenGL raster
|
|
58
|
+
path with a Vulkan vertex pipeline (rects, circles, lines, beziers, text, …).
|
|
59
|
+
- **One-line video capture.** `fast_record_scene(...)` records a scene to an MP4
|
|
60
|
+
— offline and windowless by default — and `record_scene(...)` records against
|
|
61
|
+
a live window. Output defaults to `~/Downloads`.
|
|
62
|
+
- **Auto-cleanup.** Transient `media/` artefacts are removed for you after a run.
|
|
63
|
+
- **LaTeX caching.** `Tex`/`MathTex` scenes reuse compiled SVGs so unchanged math
|
|
64
|
+
is never recompiled.
|
|
65
|
+
- **All Manim Animations Supported** — everything mentioned in the "Animation" part in manim community is supported(we are going to support other features in the future).
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Install
|
|
70
|
+
|
|
71
|
+
The library is currently published to **TestPyPI**. With any Python 3.11+ on
|
|
72
|
+
Windows 10/11:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install --index-url https://test.pypi.org/simple/ \
|
|
76
|
+
--extra-index-url https://pypi.org/simple/ \
|
|
77
|
+
real-time-manim
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The wheel bundles everything you need to render (`vulkan_core.dll` and the
|
|
81
|
+
window icon), so no separate build step is required.
|
|
82
|
+
|
|
83
|
+
> **Prerequisites at runtime:** a Vulkan-capable GPU/driver, and `ffmpeg` on your
|
|
84
|
+
> `PATH` if you want to record video.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Quick start
|
|
89
|
+
|
|
90
|
+
Write a normal Manim `Scene`, open a window, and play. Then **record it to
|
|
91
|
+
`~/Downloads` with a single call**:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from manim import Scene, Square, BLUE
|
|
95
|
+
from real_time_manim.vulkan_bind import MLWindow, Create, Wait
|
|
96
|
+
from real_time_manim.record import fast_record_scene
|
|
97
|
+
|
|
98
|
+
class Hello(Scene):
|
|
99
|
+
def construct(self):
|
|
100
|
+
win = MLWindow(960, 540) # a real-time window opens
|
|
101
|
+
win.scene = self
|
|
102
|
+
sq = Square(side_length=1.5, color=BLUE).set_fill(BLUE, 0.6)
|
|
103
|
+
win.play(Create(sq), run_time=1.0)
|
|
104
|
+
win.play(Wait(0.5))
|
|
105
|
+
win.close()
|
|
106
|
+
|
|
107
|
+
fast_record_scene(Hello) # → C:\Users\<you>\Downloads\output.mp4
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
That's it — recording starts and stops around the scene automatically, and the
|
|
111
|
+
transient `media/` folder is cleaned up afterwards.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Core concepts
|
|
116
|
+
|
|
117
|
+
### `MLWindow` — the live renderer
|
|
118
|
+
|
|
119
|
+
`MLWindow(w, h)` opens a real-time Vulkan window. Inside a scene you bind it and
|
|
120
|
+
drive it with Manim animations:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
render = MLWindow(1280, 720)
|
|
124
|
+
render.scene = scene # bind the Manim scene
|
|
125
|
+
render.play(Create(sq)) # play any supported animation
|
|
126
|
+
render.close()
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`render.play(...)` takes the same animations and keyword arguments you would pass
|
|
130
|
+
to Manim's `Scene.play` (`run_time`, `lag_ratio`, `rate_func`, …).
|
|
131
|
+
|
|
132
|
+
### Two recorders (`real_time_manim.record`)
|
|
133
|
+
|
|
134
|
+
| Function | Mode | Behaviour |
|
|
135
|
+
|----------|------|-----------|
|
|
136
|
+
| `fast_record_scene(scene, out_path=None, *, fps=60, hidden=True, overwrite=True, cleanup=True)` | offline | Fast framebuffer readback piped straight to ffmpeg. **No window** by default; runs at full speed. |
|
|
137
|
+
| `record_scene(scene, out_path=None, *, fps=60, overwrite=True, cleanup=True)` | real-time | Captures a **live, visible** window in a background thread. |
|
|
138
|
+
|
|
139
|
+
Both accept a `Scene` subclass, a `Scene` instance, or a no-arg callable, and
|
|
140
|
+
return a dict `{out_path, windows, files}`. When `out_path` is omitted, output
|
|
141
|
+
lands at `~/Downloads/output.mp4` (a scene opening several windows gets
|
|
142
|
+
`_part2`, `_part3`, … suffixes). `cleanup=True` (default) deletes transient
|
|
143
|
+
manim `media/` after the run; set `cleanup=False` to keep it.
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
fast_record_scene(MyScene) # ~/Downloads/output.mp4
|
|
147
|
+
fast_record_scene(MyScene, "preview.mp4") # current dir, or pass a full path
|
|
148
|
+
fast_record_scene(MyScene, fps=60, hidden=False) # show the window while capturing
|
|
149
|
+
record_scene(MyScene, "live.mp4", fps=30) # record against a live window
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### LaTeX cache helpers (`real_time_manim.util`)
|
|
153
|
+
|
|
154
|
+
Rendering `MathTex`/`Tex` compiles each formula to an SVG. Cache the results so
|
|
155
|
+
unchanged math is reused instead of recompiled on every run:
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
from real_time_manim.util import restore_tex_cache, save_tex_cache
|
|
159
|
+
|
|
160
|
+
restore_tex_cache("tex_cache") # before rendering: warm manim's SVG dir
|
|
161
|
+
# ... run your Tex scene(s) ...
|
|
162
|
+
save_tex_cache("tex_cache") # after: stash newly compiled SVGs
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
All helpers take explicit `media_dir`/`tex_subdir`, `only_ext`, `overwrite`,
|
|
166
|
+
`dry_run` and `verbose` knobs. `clear_media()` force-removes the transient media
|
|
167
|
+
folder (used automatically by the recorders).
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Animations
|
|
172
|
+
|
|
173
|
+
Import animations from `real_time_manim.vulkan_bind` (they re-export the
|
|
174
|
+
`real_time_manim.animations` package):
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
from real_time_manim.vulkan_bind import (
|
|
178
|
+
Create, Write, Transform, ReplacementTransform,
|
|
179
|
+
FadeIn, FadeOut, FadeTransform, GrowFromCenter,
|
|
180
|
+
Rotate, Rotating, ...
|
|
181
|
+
)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Highlights across categories:
|
|
185
|
+
|
|
186
|
+
- **Transforms** — `Transform`, `ReplacementTransform`, `FadeTransform`,
|
|
187
|
+
`TransformMatchingShapes`, `TransformMatchingTex`
|
|
188
|
+
- **Drawing** — `Create`, `Uncreate`, `DrawBorderThenFill`,
|
|
189
|
+
`ShowIncreasingSubsets`, `SpiralIn`
|
|
190
|
+
- **Fading** — `FadeIn`, `FadeOut`
|
|
191
|
+
- **Movement / scaling** — `MoveToTarget`, `MoveAlongPath`, `GrowFromCenter`,
|
|
192
|
+
`GrowFromEdge`, `GrowFromPoint`, `GrowArrow`, `SpinInFromNothing`
|
|
193
|
+
- **Text** — `Write`, `Unwrite`, `TypeWithCursor`, `UntypeWithCursor`
|
|
194
|
+
- **Rotation** — `Rotate`, `Rotating`
|
|
195
|
+
- **Effects** — `ApplyWave`, `Circumscribe`, `Indicate`, `ShowPassingFlash`,
|
|
196
|
+
`Blink`, `Homotopy`
|
|
197
|
+
- **Grouping / timing** — `AnimationGroup`, `Succession`
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## How it works (in brief)
|
|
202
|
+
|
|
203
|
+
```mermaid
|
|
204
|
+
flowchart LR
|
|
205
|
+
subgraph Python
|
|
206
|
+
SC[Manim Scene] --> W[MLWindow<br/>play / animate]
|
|
207
|
+
W --> D[type-dispatch<br/>_send per mobject]
|
|
208
|
+
end
|
|
209
|
+
D -- "ctypes FFI" --> DLL[vulkan_core.dll]
|
|
210
|
+
subgraph Native
|
|
211
|
+
DLL --> C[per-shape vertex builders<br/>rect / circle / line / text / bezier]
|
|
212
|
+
C --> VK[Vulkan instance · device · swapchain]
|
|
213
|
+
VK --> GPU[(GPU pipeline)]
|
|
214
|
+
end
|
|
215
|
+
W -- optional readback --> FF[ffmpeg]
|
|
216
|
+
FF --> MP4[(MP4)]
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
1. A `Scene` builds mobjects and calls `MLWindow.play(...)`.
|
|
220
|
+
2. The Python layer traverses the mobject tree and dispatches each shape to a
|
|
221
|
+
type-specific sender.
|
|
222
|
+
3. Shapes cross a `ctypes` boundary into `vulkan_core.dll`, which emits vertices
|
|
223
|
+
and submits them to a Vulkan pipeline.
|
|
224
|
+
4. Each frame is presented to the window — and can optionally be read back and
|
|
225
|
+
piped to `ffmpeg` as an MP4.
|
|
226
|
+
|
|
227
|
+
Full details (frame lifecycle, coordinate system, animation internals, shape→DLL
|
|
228
|
+
mapping, build steps) live in the [Wiki](https://github.com/BEGINWITHF/real-time-manim/wiki).
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Repository layout
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
real-time-manim/
|
|
236
|
+
├── real_time_manim/ # the Python package
|
|
237
|
+
│ ├── vulkan_bind.py # MLWindow + record hooks (main bridge)
|
|
238
|
+
│ ├── record.py # one-call recorders (fast / real-time)
|
|
239
|
+
│ ├── util.py # LaTeX cache + forced media cleanup
|
|
240
|
+
│ ├── vulkan_shapes.py # shape-specific senders
|
|
241
|
+
│ ├── vulkan_text.py # text / bezier rendering
|
|
242
|
+
│ ├── rate_functions.py # easing functions
|
|
243
|
+
│ ├── animations/ # ~40 animation modules
|
|
244
|
+
│ └── utils/
|
|
245
|
+
├── native/ # C/C++ Vulkan engine (vulkan_core.dll source)
|
|
246
|
+
├── logo.* # project logos
|
|
247
|
+
└── pyproject.toml
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Documentation & Wiki
|
|
253
|
+
|
|
254
|
+
- **[Home](https://github.com/BEGINWITHF/real-time-manim/wiki)** — overview and navigation
|
|
255
|
+
- **[Architecture](https://github.com/BEGINWITHF/real-time-manim/wiki/Architecture)** — layers and data flow
|
|
256
|
+
- **[Getting Started](https://github.com/BEGINWITHF/real-time-manim/wiki/Getting-Started)** — install, run, record
|
|
257
|
+
- **[API Reference](https://github.com/BEGINWITHF/real-time-manim/wiki/API-Reference)** — `MLWindow`, animations,
|
|
258
|
+
recorders, cache helpers
|
|
259
|
+
- **[Animation Reference](https://github.com/BEGINWITHF/real-time-manim/wiki/Animation-Reference)** — supported animations
|
|
260
|
+
with runnable examples
|
|
261
|
+
- **[Recording](https://github.com/BEGINWITHF/real-time-manim/wiki/Recording)** — recorders in depth
|
|
262
|
+
- **[Math Rendering](https://github.com/BEGINWITHF/real-time-manim/wiki/Math-Rendering)** — LaTeX vs. native Unicode mode
|
|
263
|
+
- **[Building the DLL](https://github.com/BEGINWITHF/real-time-manim/wiki/Building-the-DLL)** — compile `vulkan_core.dll`
|
|
264
|
+
- **[Internals](https://github.com/BEGINWITHF/real-time-manim/wiki/Internals)** — rendering pipeline, shape dispatch,
|
|
265
|
+
design decisions
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## License
|
|
270
|
+
|
|
271
|
+
[MIT](LICENSE) © real-time-manim contributors.
|
|
272
|
+
|
|
273
|
+
## Acknowledgments
|
|
274
|
+
|
|
275
|
+
- [ManimCE](https://www.manim.community/) — the mathematical animation engine
|
|
276
|
+
- [stb_truetype](https://github.com/nothings/stb) — TrueType font rasterizer
|
|
277
|
+
- [Vulkan](https://www.vulkan.org/) — the graphics API
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# Real-Time-Manim(RTM)
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="logo.jpg" alt="real-time-manim logo" width="560"/>
|
|
5
|
+
</p>
|
|
6
|
+
A **Vulkan-accelerated, real-time rendering backend** for
|
|
7
|
+
[ManimCE](https://www.manim.community/). Instead of the default OpenGL/Cairo
|
|
8
|
+
renderer, `real-time-manim` draws every scene through a native Vulkan pipeline —
|
|
9
|
+
so you get a live, interactive window *and* fast GPU-accelerated video output,
|
|
10
|
+
all driven by ordinary Manim scenes.
|
|
11
|
+
|
|
12
|
+
> RTM(Real-Time-Manim) is a vulkan-based manim renderer boosting manim speed, making live-rendering available and compatible for rendering manim. Previous manim render focusing on Opengl ang Cairo renderer is CPU-based, making graphic rendering extremely slow and live-interaction unfeasible. RTM uses a refactored render pipeline (see flow chart below) to make live-render available for math animation, preparing for further development of Manteraction(a app for live interaction manim video creation, animation, and interaction.)
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+

|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
> **Audience.** This README is a short, user-facing guide. For the full picture —
|
|
19
|
+
> architecture, rendering internals, the animation system and building from
|
|
20
|
+
> source — see the [Wiki](https://github.com/BEGINWITHF/real-time-manim/wiki).
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Highlights
|
|
25
|
+
|
|
26
|
+
- **Live window.** Render Manim scenes in real time inside a `MLWindow`, not just
|
|
27
|
+
to a rendered file.
|
|
28
|
+
- **GPU backend.** A bundled `vulkan_core.dll` replaces the Cairo/OpenGL raster
|
|
29
|
+
path with a Vulkan vertex pipeline (rects, circles, lines, beziers, text, …).
|
|
30
|
+
- **One-line video capture.** `fast_record_scene(...)` records a scene to an MP4
|
|
31
|
+
— offline and windowless by default — and `record_scene(...)` records against
|
|
32
|
+
a live window. Output defaults to `~/Downloads`.
|
|
33
|
+
- **Auto-cleanup.** Transient `media/` artefacts are removed for you after a run.
|
|
34
|
+
- **LaTeX caching.** `Tex`/`MathTex` scenes reuse compiled SVGs so unchanged math
|
|
35
|
+
is never recompiled.
|
|
36
|
+
- **All Manim Animations Supported** — everything mentioned in the "Animation" part in manim community is supported(we are going to support other features in the future).
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
The library is currently published to **TestPyPI**. With any Python 3.11+ on
|
|
43
|
+
Windows 10/11:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install --index-url https://test.pypi.org/simple/ \
|
|
47
|
+
--extra-index-url https://pypi.org/simple/ \
|
|
48
|
+
real-time-manim
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The wheel bundles everything you need to render (`vulkan_core.dll` and the
|
|
52
|
+
window icon), so no separate build step is required.
|
|
53
|
+
|
|
54
|
+
> **Prerequisites at runtime:** a Vulkan-capable GPU/driver, and `ffmpeg` on your
|
|
55
|
+
> `PATH` if you want to record video.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Quick start
|
|
60
|
+
|
|
61
|
+
Write a normal Manim `Scene`, open a window, and play. Then **record it to
|
|
62
|
+
`~/Downloads` with a single call**:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from manim import Scene, Square, BLUE
|
|
66
|
+
from real_time_manim.vulkan_bind import MLWindow, Create, Wait
|
|
67
|
+
from real_time_manim.record import fast_record_scene
|
|
68
|
+
|
|
69
|
+
class Hello(Scene):
|
|
70
|
+
def construct(self):
|
|
71
|
+
win = MLWindow(960, 540) # a real-time window opens
|
|
72
|
+
win.scene = self
|
|
73
|
+
sq = Square(side_length=1.5, color=BLUE).set_fill(BLUE, 0.6)
|
|
74
|
+
win.play(Create(sq), run_time=1.0)
|
|
75
|
+
win.play(Wait(0.5))
|
|
76
|
+
win.close()
|
|
77
|
+
|
|
78
|
+
fast_record_scene(Hello) # → C:\Users\<you>\Downloads\output.mp4
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
That's it — recording starts and stops around the scene automatically, and the
|
|
82
|
+
transient `media/` folder is cleaned up afterwards.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Core concepts
|
|
87
|
+
|
|
88
|
+
### `MLWindow` — the live renderer
|
|
89
|
+
|
|
90
|
+
`MLWindow(w, h)` opens a real-time Vulkan window. Inside a scene you bind it and
|
|
91
|
+
drive it with Manim animations:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
render = MLWindow(1280, 720)
|
|
95
|
+
render.scene = scene # bind the Manim scene
|
|
96
|
+
render.play(Create(sq)) # play any supported animation
|
|
97
|
+
render.close()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`render.play(...)` takes the same animations and keyword arguments you would pass
|
|
101
|
+
to Manim's `Scene.play` (`run_time`, `lag_ratio`, `rate_func`, …).
|
|
102
|
+
|
|
103
|
+
### Two recorders (`real_time_manim.record`)
|
|
104
|
+
|
|
105
|
+
| Function | Mode | Behaviour |
|
|
106
|
+
|----------|------|-----------|
|
|
107
|
+
| `fast_record_scene(scene, out_path=None, *, fps=60, hidden=True, overwrite=True, cleanup=True)` | offline | Fast framebuffer readback piped straight to ffmpeg. **No window** by default; runs at full speed. |
|
|
108
|
+
| `record_scene(scene, out_path=None, *, fps=60, overwrite=True, cleanup=True)` | real-time | Captures a **live, visible** window in a background thread. |
|
|
109
|
+
|
|
110
|
+
Both accept a `Scene` subclass, a `Scene` instance, or a no-arg callable, and
|
|
111
|
+
return a dict `{out_path, windows, files}`. When `out_path` is omitted, output
|
|
112
|
+
lands at `~/Downloads/output.mp4` (a scene opening several windows gets
|
|
113
|
+
`_part2`, `_part3`, … suffixes). `cleanup=True` (default) deletes transient
|
|
114
|
+
manim `media/` after the run; set `cleanup=False` to keep it.
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
fast_record_scene(MyScene) # ~/Downloads/output.mp4
|
|
118
|
+
fast_record_scene(MyScene, "preview.mp4") # current dir, or pass a full path
|
|
119
|
+
fast_record_scene(MyScene, fps=60, hidden=False) # show the window while capturing
|
|
120
|
+
record_scene(MyScene, "live.mp4", fps=30) # record against a live window
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### LaTeX cache helpers (`real_time_manim.util`)
|
|
124
|
+
|
|
125
|
+
Rendering `MathTex`/`Tex` compiles each formula to an SVG. Cache the results so
|
|
126
|
+
unchanged math is reused instead of recompiled on every run:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from real_time_manim.util import restore_tex_cache, save_tex_cache
|
|
130
|
+
|
|
131
|
+
restore_tex_cache("tex_cache") # before rendering: warm manim's SVG dir
|
|
132
|
+
# ... run your Tex scene(s) ...
|
|
133
|
+
save_tex_cache("tex_cache") # after: stash newly compiled SVGs
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
All helpers take explicit `media_dir`/`tex_subdir`, `only_ext`, `overwrite`,
|
|
137
|
+
`dry_run` and `verbose` knobs. `clear_media()` force-removes the transient media
|
|
138
|
+
folder (used automatically by the recorders).
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Animations
|
|
143
|
+
|
|
144
|
+
Import animations from `real_time_manim.vulkan_bind` (they re-export the
|
|
145
|
+
`real_time_manim.animations` package):
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from real_time_manim.vulkan_bind import (
|
|
149
|
+
Create, Write, Transform, ReplacementTransform,
|
|
150
|
+
FadeIn, FadeOut, FadeTransform, GrowFromCenter,
|
|
151
|
+
Rotate, Rotating, ...
|
|
152
|
+
)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Highlights across categories:
|
|
156
|
+
|
|
157
|
+
- **Transforms** — `Transform`, `ReplacementTransform`, `FadeTransform`,
|
|
158
|
+
`TransformMatchingShapes`, `TransformMatchingTex`
|
|
159
|
+
- **Drawing** — `Create`, `Uncreate`, `DrawBorderThenFill`,
|
|
160
|
+
`ShowIncreasingSubsets`, `SpiralIn`
|
|
161
|
+
- **Fading** — `FadeIn`, `FadeOut`
|
|
162
|
+
- **Movement / scaling** — `MoveToTarget`, `MoveAlongPath`, `GrowFromCenter`,
|
|
163
|
+
`GrowFromEdge`, `GrowFromPoint`, `GrowArrow`, `SpinInFromNothing`
|
|
164
|
+
- **Text** — `Write`, `Unwrite`, `TypeWithCursor`, `UntypeWithCursor`
|
|
165
|
+
- **Rotation** — `Rotate`, `Rotating`
|
|
166
|
+
- **Effects** — `ApplyWave`, `Circumscribe`, `Indicate`, `ShowPassingFlash`,
|
|
167
|
+
`Blink`, `Homotopy`
|
|
168
|
+
- **Grouping / timing** — `AnimationGroup`, `Succession`
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## How it works (in brief)
|
|
173
|
+
|
|
174
|
+
```mermaid
|
|
175
|
+
flowchart LR
|
|
176
|
+
subgraph Python
|
|
177
|
+
SC[Manim Scene] --> W[MLWindow<br/>play / animate]
|
|
178
|
+
W --> D[type-dispatch<br/>_send per mobject]
|
|
179
|
+
end
|
|
180
|
+
D -- "ctypes FFI" --> DLL[vulkan_core.dll]
|
|
181
|
+
subgraph Native
|
|
182
|
+
DLL --> C[per-shape vertex builders<br/>rect / circle / line / text / bezier]
|
|
183
|
+
C --> VK[Vulkan instance · device · swapchain]
|
|
184
|
+
VK --> GPU[(GPU pipeline)]
|
|
185
|
+
end
|
|
186
|
+
W -- optional readback --> FF[ffmpeg]
|
|
187
|
+
FF --> MP4[(MP4)]
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
1. A `Scene` builds mobjects and calls `MLWindow.play(...)`.
|
|
191
|
+
2. The Python layer traverses the mobject tree and dispatches each shape to a
|
|
192
|
+
type-specific sender.
|
|
193
|
+
3. Shapes cross a `ctypes` boundary into `vulkan_core.dll`, which emits vertices
|
|
194
|
+
and submits them to a Vulkan pipeline.
|
|
195
|
+
4. Each frame is presented to the window — and can optionally be read back and
|
|
196
|
+
piped to `ffmpeg` as an MP4.
|
|
197
|
+
|
|
198
|
+
Full details (frame lifecycle, coordinate system, animation internals, shape→DLL
|
|
199
|
+
mapping, build steps) live in the [Wiki](https://github.com/BEGINWITHF/real-time-manim/wiki).
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Repository layout
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
real-time-manim/
|
|
207
|
+
├── real_time_manim/ # the Python package
|
|
208
|
+
│ ├── vulkan_bind.py # MLWindow + record hooks (main bridge)
|
|
209
|
+
│ ├── record.py # one-call recorders (fast / real-time)
|
|
210
|
+
│ ├── util.py # LaTeX cache + forced media cleanup
|
|
211
|
+
│ ├── vulkan_shapes.py # shape-specific senders
|
|
212
|
+
│ ├── vulkan_text.py # text / bezier rendering
|
|
213
|
+
│ ├── rate_functions.py # easing functions
|
|
214
|
+
│ ├── animations/ # ~40 animation modules
|
|
215
|
+
│ └── utils/
|
|
216
|
+
├── native/ # C/C++ Vulkan engine (vulkan_core.dll source)
|
|
217
|
+
├── logo.* # project logos
|
|
218
|
+
└── pyproject.toml
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Documentation & Wiki
|
|
224
|
+
|
|
225
|
+
- **[Home](https://github.com/BEGINWITHF/real-time-manim/wiki)** — overview and navigation
|
|
226
|
+
- **[Architecture](https://github.com/BEGINWITHF/real-time-manim/wiki/Architecture)** — layers and data flow
|
|
227
|
+
- **[Getting Started](https://github.com/BEGINWITHF/real-time-manim/wiki/Getting-Started)** — install, run, record
|
|
228
|
+
- **[API Reference](https://github.com/BEGINWITHF/real-time-manim/wiki/API-Reference)** — `MLWindow`, animations,
|
|
229
|
+
recorders, cache helpers
|
|
230
|
+
- **[Animation Reference](https://github.com/BEGINWITHF/real-time-manim/wiki/Animation-Reference)** — supported animations
|
|
231
|
+
with runnable examples
|
|
232
|
+
- **[Recording](https://github.com/BEGINWITHF/real-time-manim/wiki/Recording)** — recorders in depth
|
|
233
|
+
- **[Math Rendering](https://github.com/BEGINWITHF/real-time-manim/wiki/Math-Rendering)** — LaTeX vs. native Unicode mode
|
|
234
|
+
- **[Building the DLL](https://github.com/BEGINWITHF/real-time-manim/wiki/Building-the-DLL)** — compile `vulkan_core.dll`
|
|
235
|
+
- **[Internals](https://github.com/BEGINWITHF/real-time-manim/wiki/Internals)** — rendering pipeline, shape dispatch,
|
|
236
|
+
design decisions
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
[MIT](LICENSE) © real-time-manim contributors.
|
|
243
|
+
|
|
244
|
+
## Acknowledgments
|
|
245
|
+
|
|
246
|
+
- [ManimCE](https://www.manim.community/) — the mathematical animation engine
|
|
247
|
+
- [stb_truetype](https://github.com/nothings/stb) — TrueType font rasterizer
|
|
248
|
+
- [Vulkan](https://www.vulkan.org/) — the graphics API
|
|
Binary file
|