manim-slides

repository·main·Indexed 21 days ago

https://github.com/jeertmans/manim-slides

A tool for creating live presentations using Manim (Community Edition) or ManimGL. It allows developers to turn animations into interactive slides by inserting pause points into the code. Supports multiple presentation methods including a native interactive mode, HTML conversion with Firebase real-time synchronization, PPTX export, and static PDF rendering.

Tokens
16.6K
Snippets
71
Records
93
Agent score
74%

What's inside manim-slides

  1. Overview of Manim Slides

    main

    Manim Slides is a Python package designed to make presenting Manim animations straightforward. It allows you to present animations in a PowerPoint-like manner (with the ability to pause, rewind, and control the pace) or share them online.

    Key capabilities include:

    • Local Presentation: Use a Graphical User Interface (GUI) to control animations.
    • Exporting: Convert slides to an HTML page (using RevealJS) or a PowerPoint (.pptx) file.
    • Compatibility: Works with both ManimCE (Community Edition) and ManimGL.
    • Advanced Features: Supports 3D scenes, playing slides in reverse, recording presentations, and hiding the mouse cursor during presentation.
  2. Compare Manim Slides with manim-presentation

    main

    While Manim Slides is derived from manim-presentation, it provides several additional features that distinguish it:

    FeatureManim Slides
    ManimGL SupportYes
    Reverse PlaybackYes
    Export FormatsHTML and PowerPoint (.pptx)
    3D ScenesSupported
    Input MappingMultiple key inputs can map to the same action
    Mouse ControlOption to hide cursor
    RecordingSupported
    Video ScalingMultiple methods for speed-vs-quality tradeoff
    Parameter DetectionAutomatic detection of resolution and background color
  3. Compare Manim Slides presentation methods

    main

    Manim Slides supports four primary ways to present or export your animations. Choose the method based on your requirements for interactivity, platform compatibility, and dependencies:

    • present: The native interactive mode. Best for live presentations where you need full control (replay, pause, reverse animations). Requires Python and Manim Slides installed.
    • convert --to=html: Best for web-based sharing. Supports auto-play and loops. Highly customizable via the --use-template option. Requires a modern web browser.
    • convert --to=pptx: Best for integration into slide decks. Supports auto-play and loops. Requires PowerPoint or LibreOffice Impress (LibreOffice is recommended on Linux as PowerPoint Online may not support automatic video playback).
    • convert --to=pdf: Best for static documents. Slides are rendered as static images. Does not support animation playback or slide counts.
    | Feature / Constraint | `present` | `convert --to=html` | `convert --to=pptx` | `convert --to=pdf` |
    | :--- | :---: | :---: | :---: | :---: |
    | Basic navigation through slides | Yes | Yes | Yes | Yes (static image) |
    | Replay slide | Yes | No | No | N/A |
    | Pause animation | Yes | Yes | No | N/A |
    | Play slide in reverse | Yes | No | No | N/A |
    | Slide count | Yes | Yes (optional) | Yes (optional) | N/A |
    | Needs Python with Manim Slides installed | Yes | No | No | No |
    | Requires internet access | No | Depends | No | No |
    | Auto. play slides | Yes | Yes | Yes | N/A |
    | Loops support | Yes | Yes | Yes | N/A |
    | Fully customizable | No | Yes (`--use-template` option) | No | No |
    | Other dependencies | None | A modern web browser | PowerPoint or LibreOffice Impress | None |
    | Works cross-platforms | Yes | Yes | Partly | Yes |
  4. How to use Manim Slides

    main

    Using Manim Slides involves a two-step workflow:

    1. Code your animations: Instead of using the standard Scene (or ThreeDScene) class, inherit from Slide (or ThreeDSlide). Use self.next_slide() to define points where the presentation should pause and wait for user input. Use self.next_slide(loop=True) to create a looping slide that repeats animations until the user continues.

    2. Render and Run: Render your Python file using the manim-slides render command, then run the resulting scenes using the manim-slides CLI command.

    from manim import *  # or: from manimlib import *
    from manim_slides import Slide
    
    class BasicExample(Slide):
        def construct(self):
            circle = Circle(radius=3, color=BLUE)
            self.play(GrowFromCenter(circle))
            self.next_slide()  # Waits for user to press continue
    
            self.next_slide(loop=True)  # Starts a loop
            self.play(circle.animate.set_color(RED))
            self.next_slide()  # Moves to next non-looping slide
  5. Structure large presentations using multiple Slide subclasses

    main

    Avoid putting an entire presentation into a single construct() method. This makes debugging difficult and forces a full re-render of everything if any part changes.

    Instead, split logical sections into independent Slide subclasses. This allows you to render each section separately and then stitch them together into a single presentation using manim-slides convert.

    from manim import *
    from manim_slides import Slide
    
    class Introduction(Slide):
        def construct(self):
            ...
    
    class ExplainConcepts(Slide):
        def construct(self):
            ...
    
    class ShowResults(Slide):
        def construct(self):
            ...
  6. Choose between Manim (Community Edition) and ManimGL

    main

    Manim Slides is compatible with both manim (Community Edition) and manimlib (ManimGL). Because these two libraries have different APIs, you must ensure manim_slides detects the correct one.

    By default, manim_slides inspects sys.modules to see which package is already imported. If both are present, it prefers manim. To ensure the correct behavior, always import your chosen Manim API before importing manim_slides.

    # For Manim (Community Edition)
    from manim import *
    from manim_slides import Slide
    
    # For ManimGL
    from manimlib import *
    from manim_slides import Slide
  7. Sync presentations across devices using Firebase

    main

    Manim Slides includes a built-in template (firebase_sync.html) that enables real-time synchronization of slide progression across multiple devices. This allows a presenter to control slides on one device while guests view the same slides on their own devices (e.g., during a virtual conference) without the lag of screen sharing.

    This feature requires a Firebase Realtime Database.

    Roles and URLs

    • Presenter: Append ?role=presenter or #presenter to the URL to access presenter controls.
    • Guest: The presenter can generate a guest URL containing a room ID (e.g., ?room=room-1234abcd). Guests opening this URL will see the current slide and follow the presenter's progression in real-time.
    manim-slides convert MainScene --one-file --use-template firebase_sync.html
  8. Quickstart with Manim Slides

    main
    Manim Slides allows you to create presentation slides using Manim. You can generate slides and present them using either a dedicated GUI or directly in your web browser. To get started, follow the quickstart guide to learn the basic workflow of creating and presenting slides.
  9. Configure your own Firebase project for slide syncing

    main

    The default template uses a public Firebase project for testing. For production, you must create your own Firebase project and provide your credentials during the conversion process.

    Setup Steps:

    1. Create a Firebase Project in the Firebase Console.
    2. Enable Realtime Database: Create a database and choose a location.
    3. Enable Anonymous Authentication: In Authentication > Sign-in method, enable the Anonymous provider. This allows presenters to claim rooms without a full login.
    4. Get Web App Config: In Project Settings, add a Web app to retrieve your apiKey, authDomain, databaseURL, and projectId.
    5. Render with Variables: Pass these credentials as configuration variables when running the manim-slides convert command.

    Required Configuration Variables:

    When rendering firebase_sync.html, you must provide:

    • firebase_api_key
    • firebase_auth_domain
    • firebase_database_url
    • firebase_project_id
  10. Install Manim Slides with minimal dependencies

    main

    To have more control over your installation, you can install the bare minimal dependencies and add extras later.

    Warning: If using pipx, you must manually ensure either manim or manimgl is included in your environment to make the package functional.

    pipx install -U manim-slides
    # To add Manim support:
    pipx install -U "manim-slides[manim]"
    # To add ManimGL support:
    pipx install -U "manim-slides[manimgl]"
  11. Render slides using the manim-slides CLI

    main

    Instead of calling manim or manimgl directly, use the manim-slides render command. This command acts as a wrapper that ensures the rendering process uses the specific manim or manimlib library installed in your current Python environment.

    manim-slides render [ARGS]...