Part 7 · takes and API
Takes in the browser
A take is the engine’s work recorded once; the <manimgx-film> element prints it on the page with ManimGX’s own engine compiled to WebAssembly and WebGPU, with no Python.
Patched engine
The fork’s engine at 9647ce7 does not draw in Chrome: its materials WGSL (materia.wgsl and materia_vector.wgsl) mixes * and ^ without parentheses, which naga accepts and Tint rejects. The one on this page was built from a copy with those parentheses added (6 lines); the fix has been proposed for the fork. Another difference from FORK.md: this web player does not read 0x8000_0001 takes.
0x8000_0002 · the same render as MP40x8000_0002 · the same render as MP4What a take is
A ManimGX scene is recorded once with manimgx render scene.py --take: instead of a video, it keeps the engine’s work (each frame’s objects, their shapes, their passes). Any ManimGX player prints that take again: the Rust library, the app or, here, the browser. The Tórculo fork’s takes carry their own version range, 0x8000_0002 (424-byte records, with the POST and MATERIAL messages), and readers also read 0x8000_0001.
How to put one on a page
<script type="module" src="/medios/motor/manimgx-film.js"></script>
<manimgx-film src="Prensa.take" autoplay></manimgx-film>The element loads the engine (engine.js and engine_bg.wasm, 1.8 MB) and its controls’ font from its own folder. It needs WebGPU: desktop Chrome and Edge, Safari 26 or a recent Firefox. Without WebGPU, this page shows the same render as MP4. Engine built from the fork at 9647ce7.
The scenes
Written with import manimgx as m in the canon palette, and recorded with site/scripts/tomas.sh:
"""El pliego y la película: lo escrito sin números, lo rodado con ellos.
Toma pequeña para la web (parte 7: tomas). Se graba con
tools/pesado manimgx/.venv/bin/manimgx render site/tomas/pliego.py --take -r 960x540 --fps 24
"""
import manimgx as m
PAPEL, TINTA, APAGADA, MINIO, AZURITA, AMARILLO = "#F5F0E8", "#2C1810", "#7A5F4E", "#C1453B", "#2B4C7E", "#E8A838"
m.config.background_color = PAPEL
class Pliego(m.Scene):
def construct(self):
hoja = m.Rectangle(width=4.6, height=5.2, color=APAGADA, stroke_width=2, fill_color="#FAF7F0", fill_opacity=1).shift(m.LEFT * 3.4)
lineas = m.VGroup(
m.Text("== CAPÍTULO 1 ==", font="monospace", color=MINIO, font_size=22),
m.Text("* apertura · sereno", font="monospace", color=AZURITA, font_size=22),
m.Text("di: Una prensa.", font="monospace", color=TINTA, font_size=22),
m.Text("pon: cartulina «PLIEGO»", font="monospace", color=TINTA, font_size=22),
m.Text("> deja posar", font="monospace", color=APAGADA, font_size=22),
).arrange(m.DOWN, aligned_edge=m.LEFT, buff=0.32).move_to(hoja)
self.play(m.FadeIn(hoja), run_time=0.5)
self.play(m.LaggedStart(*[m.Write(l) for l in lineas], lag_ratio=0.35), run_time=2.4)
flecha = m.Arrow(m.LEFT * 0.8, m.RIGHT * 0.8, color=TINTA, stroke_width=5)
pantalla = m.Rectangle(width=4.8, height=2.7, color=TINTA, stroke_width=3).shift(m.RIGHT * 3.6)
carta = m.Rectangle(width=2.6, height=1.0, color=AMARILLO, fill_color=AMARILLO, fill_opacity=1, stroke_width=0).move_to(pantalla)
rotulo = m.Text("PLIEGO", font="serif", color=TINTA, font_size=34).move_to(carta)
self.play(m.GrowArrow(flecha), m.Create(pantalla), run_time=0.9)
self.play(m.FadeIn(carta, shift=m.UP * 0.3), m.Write(rotulo), run_time=0.9)
self.play(m.Indicate(lineas[3], color=MINIO), run_time=0.8)
self.wait(1.0)
"""La prensa: una plancha se trabaja una vez y se estampa muchas.
Toma pequeña para la web (parte 7: tomas). Se graba con
tools/pesado manimgx/.venv/bin/manimgx render site/tomas/prensa.py --take -r 960x540 --fps 24
"""
import manimgx as m
PAPEL, TINTA, MINIO, AZURITA, AMARILLO, ORO = "#F5F0E8", "#2C1810", "#C1453B", "#2B4C7E", "#E8A838", "#D6A03A"
m.config.background_color = PAPEL
def plancha() -> m.VGroup:
marco = m.RoundedRectangle(corner_radius=0.12, width=2.4, height=3.0, color=TINTA, stroke_width=4)
sol = m.Circle(radius=0.55, color=MINIO, fill_color=MINIO, fill_opacity=1, stroke_width=0).shift(m.UP * 0.45)
tierra = m.Rectangle(width=1.8, height=0.5, color=AZURITA, fill_color=AZURITA, fill_opacity=1, stroke_width=0).shift(m.DOWN * 0.85)
raya = m.Line(m.LEFT * 0.9, m.RIGHT * 0.9, color=ORO, stroke_width=6).shift(m.DOWN * 0.35)
return m.VGroup(marco, sol, tierra, raya)
class Prensa(m.Scene):
def construct(self):
p = plancha()
titulo = m.Text("una plancha", font="serif", color=TINTA, font_size=36).to_edge(m.UP, buff=0.5)
self.play(m.Create(p[0]), m.Write(titulo), run_time=1.2)
self.play(m.FadeIn(p[1], scale=0.6), m.GrowFromCenter(p[2]), m.Create(p[3]), run_time=1.0)
self.wait(0.4)
copias = m.VGroup(*[plancha().scale(0.42) for _ in range(8)]).arrange_in_grid(2, 4, buff=0.35).shift(m.DOWN * 0.35)
otro = m.Text("muchas estampas", font="serif", color=TINTA, font_size=36).to_edge(m.UP, buff=0.5)
self.play(p.animate.scale(0.42).move_to(copias[0]), m.Transform(titulo, otro), run_time=0.9)
self.play(m.LaggedStart(*[m.FadeIn(c, scale=1.25) for c in copias[1:]], lag_ratio=0.18), run_time=1.6)
self.wait(1.0)