[1]:
from manim_presenter import *

config.media_embed = True
config.media_width = "100%"

_RV = "-v WARNING -qm --fps=15 --progress_bar None --disable_caching Example"
_RI = "-v WARNING -s --progress_bar None --disable_caching Example"

config.disable_caching = True
Manim Community v0.17.3

Workflow#

Use preview_slide = "slide_name"#

One way to work is to save the slides in variables and then create the class.

[2]:
jt = lambda mob: JustifyText(mob, tex_width=8)

def LaggedFadeIn(mob, *args, **kwargs):
  return LaggedStartMap(FadeIn, mob[0], *args, **kwargs)

SLIDES = [
  # SLIDE 1
  {
    "slide": "s01",
    "arrange": [lambda mob: mob.arrange(DOWN, buff=1)],
    "remove_same_time": FadeOut,
    "elements" : [
      {
        "name": "p01",
        "type": jt,
        "creation": PopUp
      },{
        "name": "p02",
        "type": jt,
        "creation": ShowWithBounce
      }
    ],
  },
  # SLIDE 2
  {
    "slide": "s02",
    "arrange": [lambda mob: mob.arrange(DOWN, buff=1)],
    "remove_same_time": FadeOut,
    "elements" : [
      {
        "name": "p03",
        "type": jt,
        "creation": ShowFromPolygon,
      },{
        "name": "p04",
        "type": jt,
        "creation": FadeInFromBlackRectangle,
      }
    ],
  },
]

class Example(Presentation):
  file = "slides02.txt"
  slides = SLIDES
  preview_slide = "s01"

%manim $_RI
_images/CHP4_2_0.png

This way you can change the preview_slide more easily.

[3]:
class Example(Presentation):
  file = "slides02.txt"
  slides = SLIDES
  preview_slide = "s02"

%manim $_RI
_images/CHP4_4_0.png

Add progress to slides and use preview_anims.#

[4]:
SLIDES = [
  # SLIDE 1
  {
    "slide": "s01",
    "arrange": [lambda mob: mob.arrange(DOWN, buff=1)],
    "remove_same_time": FadeOut,
    "elements" : [
      {
        "name": "p01",
        "type": jt,
        "creation": PopUp
      },{
        "name": "p02",
        "type": jt,
        "creation": ShowWithBounce
      }
    ],
    "progress": [
      {"create": "p01", "run_time": 7},
      {"create": "p02", "run_time": 7},
    ]
  },
  # SLIDE 2
  {
    "slide": "s02",
    "arrange": [lambda mob: mob.arrange(DOWN, buff=1)],
    "remove_same_time": FadeOut,
    "elements" : [
      {
        "name": "p03",
        "type": jt,
        "creation": ShowFromPolygon,
      },{
        "name": "p04",
        "type": jt,
        "creation": FadeInFromBlackRectangle,
      }
    ],
    "progress": [
      {"create": "p03", "run_time": 7},
      {"create": "p04", "run_time": 7},
    ]
  },
]

class Example(Presentation):
  file = "slides02.txt"
  slides = SLIDES
  preview_anims = ["s01"]

%manim $_RV
[5]:
class Example(Presentation):
  file = "slides02.txt"
  slides = SLIDES
  preview_anims = ["s02"]

%manim $_RV

You can add more to the preview_anims list

[6]:
class Example(Presentation):
  file = "slides02.txt"
  slides = SLIDES
  preview_anims = ["s01", "s02"]

%manim $_RV

Enable Manim-Slides#

You must have ManimSlides installed.

[7]:
from manim_slides import Slide
[9]:
class ExampleInSlides(Slide, Presentation):
  file = "slides02.txt"
  slides = SLIDES

%manim -qh --fps=30 -v WARNING  --disable_caching ExampleInSlides

And then run manim-slides Example --start-paused -r 1280 720