NickLarsenNZ / jupyter-manim

Jupyter Lab with 3b1b/manim integration thanks to krassowski/jupyter-manim
https://hub.docker.com/r/nicklarsennz/jupyter-manim
1 stars 0 forks source link

nicklarsennz/jupyter-manim

Jupyter Lab with 3b1b/manim integration thanks to krassowski/jupyter-manim

Jupyter Lab with Manim Integration

Run

quickstart

Note, no data will be saved and the container will auto-remove once it's stopped.

docker run --rm nicklarsennz/jupyter-manim

Then visit http://localhost:8999

mount notebooks (read-write)

If you want to save notebooks, or access existing notebooks.

docker run --rm -v $HOME/notebooks:/data:rw nicklarsennz/jupyter-manim

Then visit http://localhost:8999

Change the exposed port

If you need to expose the container on a different port.

PORT=8000 docker run --rm -p ${PORT}:8080 -e EXTERNAL_PORT=${PORT} nicklarsennz/jupyter-manim

Then visit http://localhost:8000

Working Example

Mandatory import at the start of the notebook

import jupyter_manim

Simple Shapes Scene

%%manim Shapes
from manimlib.imports import *

class Shapes(Scene):

    def construct(self):
        circle = Circle()
        square = Square()
        self.play(ShowCreation(circle))
        self.play(Transform(circle, square))
        self.play(GrowFromCenter(square))

Linear Transformation Scene

%%manim ExampleTransformation
from manimlib.imports import *

EXAMPLE_TRANFORM = [[0, 1], [-1, 1]]
TRANFORMED_VECTOR = [[1], [2]]

class ExampleTransformation(LinearTransformationScene):
    def construct(self):
        self.setup()
        self.add_vector(np.array(TRANFORMED_VECTOR).flatten())
        self.apply_matrix(EXAMPLE_TRANFORM)
        self.wait()