Skip to content

Instantly share code, notes, and snippets.

@taktoa
Last active July 17, 2021 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taktoa/68381c5622b9a43ba9a4070351b95f7d to your computer and use it in GitHub Desktop.
Save taktoa/68381c5622b9a43ba9a4070351b95f7d to your computer and use it in GitHub Desktop.
manim 0.8.0 for nix

First, clone this gist.

Then run nix-shell -A shell -Q --pure

Finally, inside the Nix shell, run manim render -p -ql example.py OpeningManim && reset.

The && reset part is because for some reason the shell gets broken after you run that command. I suspect it would not happen with previewing (-p) disabled.

from manim import *
class OpeningManim(Scene):
def construct(self):
title = Tex(r"This is some \LaTeX")
basel = MathTex(r"\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}")
VGroup(title, basel).arrange(DOWN)
self.play(
Write(title),
FadeIn(basel, shift=DOWN),
)
self.wait()
transform_title = Tex("That was a transform")
transform_title.to_corner(UP + LEFT)
self.play(
Transform(title, transform_title),
LaggedStart(*[FadeOut(obj, shift=DOWN) for obj in basel]),
)
self.wait()
grid = NumberPlane()
grid_title = Tex("This is a grid")
grid_title.scale(1.5)
grid_title.move_to(transform_title)
self.add(grid, grid_title) # Make sure title is on top of grid
self.play(
FadeOut(title),
FadeIn(grid_title, shift=UP),
Create(grid, run_time=3, lag_ratio=0.1),
)
self.wait()
grid_transform_title = Tex(
r"That was a non-linear function \\ applied to the grid"
)
grid_transform_title.move_to(grid_title, UL)
grid.prepare_for_nonlinear_transform()
self.play(
grid.animate.apply_function(
lambda p: p
+ np.array(
[
np.sin(p[1]),
np.sin(p[0]),
0,
]
)
),
run_time=3,
)
self.wait()
self.play(Transform(grid_title, grid_transform_title))
self.wait()
rec {
nixpkgs = fetchTarball {
url = "https://github.com/taktoa/nixpkgs/archive/manim.tar.gz";
# rev is be99eb8b781c48d84291673c515da68c066f2e34
sha256 = "0xrksidk6v1as9x0qncrbg379cd1z5barnvclpscnhmarbb0j9h5";
};
pkgs = import nixpkgs { config = {}; overlays = []; };
fakeBrowser = pkgs.writeScriptBin "x-www-browser" ''
${pkgs.mpv}/bin/mpv "$@"
'';
shell = pkgs.mkShell {
buildInputs = [
pkgs.busybox
pkgs.manim
pkgs.sox
pkgs.ffmpeg
pkgs.texlive.combined.scheme-full
fakeBrowser
];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment