Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
9e77b0d
Consolidate window configuration
3b1b Dec 10, 2024
1276724
Pull out the initial Window.to_default_position from init_for_scene
3b1b Dec 10, 2024
c02259a
Remove import
3b1b Dec 10, 2024
178cca0
Factor out get_window_position
3b1b Dec 10, 2024
d4c5c47
Move logic for window size and position into Window class
3b1b Dec 10, 2024
4cc2e5e
Consolidate camera configuration
3b1b Dec 10, 2024
4b483b7
Minor tweak
3b1b Dec 10, 2024
858d8c1
Rename "file_writer_config" in default_config to simply "file_writer"
3b1b Dec 10, 2024
6b38011
Refactor config.py
3b1b Dec 10, 2024
bcc4235
Move embed configuration out of Scene, and get rid of error sound option
3b1b Dec 10, 2024
f9fa8ac
Make scene configuration part of the global configuration
3b1b Dec 10, 2024
d1080aa
Add run configuration to global config
3b1b Dec 10, 2024
c61e0bc
Move window_config out of run_config
3b1b Dec 10, 2024
667cfaf
Remove args from ReloadManager
3b1b Dec 10, 2024
cd74402
Minor reorganization of ReloadManager.retrieve_scenes_and_run
3b1b Dec 10, 2024
07bb347
Add simple function descriptions
3b1b Dec 10, 2024
1d67768
Move reload out of Scene, instead have it directly update the global …
3b1b Dec 10, 2024
ae93d8f
Move update to is_reload status of run_config out of ReloadManager
3b1b Dec 10, 2024
284c1d8
Move message for no scenes found to extract_scene
3b1b Dec 10, 2024
d21fbd0
Minor tweak to reload_scene
3b1b Dec 10, 2024
2469737
Make the fact that the global configuration is a mutable global dicti…
3b1b Dec 10, 2024
8cf95ec
Move ReloadManager logic into __main__.py
3b1b Dec 10, 2024
32d36a0
Update commend on reload_scene
3b1b Dec 10, 2024
2359ed9
Remove tempfile from requirements.txt
3b1b Dec 10, 2024
3d3f825
Merge branch 'master' of github.com:3b1b/manim into video-work
3b1b Dec 11, 2024
2c43d29
Move arbitrary constant definitions into default_config
3b1b Dec 11, 2024
c9b6ee5
Make default_wait_time a piece of scene configuration
3b1b Dec 11, 2024
d5c36de
DEFAULT_MOBJECT_TO_MOBJECT_BUFFER -> DEFAULT_MOBJECT_TO_MOBJECT_BUFF
3b1b Dec 11, 2024
f9a44c9
Make ffmpeg_bin specification a piece of file_writer_config
3b1b Dec 11, 2024
7d3758c
Move joint_type_map out of constants to VMobject
3b1b Dec 11, 2024
a03accf
Rename local colors variable in constants.py
3b1b Dec 11, 2024
9f785a5
Move key to int constants to interactive_scene.py
3b1b Dec 11, 2024
9fcdd0d
Use pyglet.window.key for key constant values
3b1b Dec 11, 2024
8744c87
Make log_level configurable in default_config
3b1b Dec 11, 2024
9ac16ab
Remove DEFAULT_FPS constant
3b1b Dec 11, 2024
2d7b9d5
Move comment
3b1b Dec 11, 2024
37a0509
Small comment changes
3b1b Dec 11, 2024
4d7f609
Update how tex configuration default is passed in
3b1b Dec 11, 2024
1794e4d
Better align docs description of configuration with the updated format
3b1b Dec 11, 2024
8246d0d
Fix bug with xelatex rendering
3b1b Dec 11, 2024
4a6a125
Change "style" in default config to "text"
3b1b Dec 11, 2024
185f642
Focus and sync window when initialized for a scene
3b1b Dec 11, 2024
fce9234
Replace get_global_config() with manim_config, and make it an addict …
3b1b Dec 11, 2024
13fdc96
No need for the shortcuts into the manim_config
3b1b Dec 11, 2024
b470a47
Remove unnecessary import
3b1b Dec 11, 2024
7148d6b
Add addict to requirements
3b1b Dec 11, 2024
0b350e2
Change global_attrs back to global_config in Text
3b1b Dec 11, 2024
9ae5b4d
Use addict.Dict for scene config
3b1b Dec 11, 2024
f9fc543
Merge branch 'master' of github.com:3b1b/manim into video-work
3b1b Dec 11, 2024
6d753a2
Remove stray imports
3b1b Dec 11, 2024
c6c1a49
Update setup.cfg
3b1b Dec 11, 2024
e2e785d
Remove init_config.py
3b1b Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 20 additions & 28 deletions docs/source/documentation/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,35 @@ they are only used inside manim.
Frame and pixel shape
---------------------

These values will be determined based on the ``camera`` configuration in default_config.yml or custom_config.yml

.. code-block:: python

ASPECT_RATIO = 16.0 / 9.0
FRAME_HEIGHT = 8.0
FRAME_WIDTH = FRAME_HEIGHT * ASPECT_RATIO
FRAME_Y_RADIUS = FRAME_HEIGHT / 2
FRAME_X_RADIUS = FRAME_WIDTH / 2
ASPECT_RATIO
FRAME_HEIGHT
FRAME_WIDTH
FRAME_Y_RADIUS
FRAME_X_RADIUS

DEFAULT_PIXEL_HEIGHT = 1080
DEFAULT_PIXEL_WIDTH = 1920
DEFAULT_FPS = 30
DEFAULT_PIXEL_HEIGHT
DEFAULT_PIXEL_WIDTH
DEFAULT_FPS

Buffs
-----

.. code-block:: python

SMALL_BUFF = 0.1
MED_SMALL_BUFF = 0.25
MED_LARGE_BUFF = 0.5
LARGE_BUFF = 1
These values will be determined based on the ``size`` configuration in default_config.yml or custom_config.yml

DEFAULT_MOBJECT_TO_EDGE_BUFFER = MED_LARGE_BUFF # Distance between object and edge
DEFAULT_MOBJECT_TO_MOBJECT_BUFFER = MED_SMALL_BUFF # Distance between objects

Run times
---------

.. code-block:: python

DEFAULT_POINTWISE_FUNCTION_RUN_TIME = 3.0
DEFAULT_WAIT_TIME = 1.0
SMALL_BUFF
MED_SMALL_BUFF
MED_LARGE_BUFF
LARGE_BUFF

DEFAULT_MOBJECT_TO_EDGE_BUFF
DEFAULT_MOBJECT_TO_MOBJECT_BUFF

Coordinates
-----------
Expand Down Expand Up @@ -89,16 +86,11 @@ Text
OBLIQUE = "OBLIQUE"
BOLD = "BOLD"

Stroke width
------------

.. code-block:: python

DEFAULT_STROKE_WIDTH = 4

Colours
-------

Color constants are determined based on the ``color`` configuration in default_config.yml or custom_config.yml

Here are the preview of default colours. (Modified from
`elteoremadebeethoven <https://elteoremadebeethoven.github.io/manim_3feb_docs.github.io/html/_static/colors/colors.html>`_)

Expand Down
135 changes: 77 additions & 58 deletions docs/source/documentation/custom_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ custom_config
running file under the ``output`` path, and save the output (``images/``
or ``videos/``) in it.

- ``base``
The root directory that will hold files, such as video files manim renders,
or image resources that it pulls from

- ``output``
Output file path, the videos will be saved in the ``videos/`` folder under it,
and the pictures will be saved in the ``images/`` folder under it.
Expand Down Expand Up @@ -66,92 +70,107 @@ custom_config
The directory for storing sound files to be used in ``Scene.add_sound()`` (
including ``.wav`` and ``.mp3``).

- ``temporary_storage``
- ``cache``
The directory for storing temporarily generated cache files, including
``Tex`` cache, ``Text`` cache and storage of object points.

``tex``
-------

- ``executable``
The executable program used to compile LaTeX (``latex`` or ``xelatex -no-pdf``
is recommended)
``window``
----------

- ``template_file``
LaTeX template used, in ``manimlib/tex_templates``
- ``position_string``
The relative position of the playback window on the display (two characters,
the first character means upper(U) / middle(O) / lower(D), the second character
means left(L) / middle(O) / right(R)).

- ``intermediate_filetype``
The type of intermediate vector file generated after compilation (``dvi`` if
``latex`` is used, ``xdv`` if ``xelatex`` is used)

- ``text_to_replace``
The text to be replaced in the template (needn't to change)
- ``monitor_index``
If using multiple monitors, which one should the window show up in?

``universal_import_line``
-------------------------
- ``full_screen``
Should the preview window be full screen. If not, it defaults to half the screen

Import line that need to execute when entering interactive mode directly.
- ``position``
This is an option to more manually set the default window position, in pixel
coordinates, e.g. (500, 300)

``style``
---------
- ``size``
Option to more manually set the default window size, in pixel coordinates,
e.g. (1920, 1080)

- ``font``
Default font of Text

- ``text_alignment``
Default text alignment for LaTeX
``camera``
----------

- ``background_color``
Default background color
- ``resolution``
Resolution to render at, e.g. (1920, 1080)

``window_position``
-------------------
- ``background_color``
Default background color of scenes

The relative position of the playback window on the display (two characters,
the first character means upper(U) / middle(O) / lower(D), the second character
means left(L) / middle(O) / right(R)).
- ``fps``
Framerate

``window_monitor``
------------------
- ``background_opacity``
Opacity of the background

The number of the monitor you want the preview window to pop up on. (default is 0)

``full_screen``
``file_writer``
---------------
Configuration specifying how files are written, e.g. what ffmpeg parameters to use

Whether open the window in full screen. (default is false)

``break_into_partial_movies``
-----------------------------
``scene``
-------
Some default configuration for the Scene class

If this is set to ``True``, then many small files will be written corresponding
to each ``Scene.play`` and ``Scene.wait`` call, and these files will then be combined
to form the full scene.

Sometimes video-editing is made easier when working with the broken up scene, which
effectively has cuts at all the places you might want.
``text``
-------

``camera_resolutions``
----------------------
- ``font``
Default font of Text

Export resolutions
- ``text_alignment``
Default text alignment for LaTeX

- ``low``
Low resolutions (default is 480p)
``tex``
-------

- ``medium``
Medium resolutions (default is 720p)
- ``template``
Which configuration from the manimlib/tex_template.yml file should be used
to determine the latex compiler to use, and what preamble to include for
rendering tex.

- ``high``
High resolutions (default is 1080p)

- ``ultra_high``
Ultra high resolutions (default is 4K)
``sizes``
---------

- ``default_resolutions``
Default resolutions (one of the above four, default is high)
Valuess for various constants used in manimm to specify distances, like the height
of the frame, the value of SMALL_BUFF, LARGE_BUFF, etc.

``fps``
-------

Export frame rate. (default is 30)
``colors``
----------

Color pallete to use, determining values of color constants like RED, BLUE_E, TEAL, etc.

``loglevel``
------------

Can be DEBUG / INFO / WARNING / ERROR / CRITICAL


``universal_import_line``
-------------------------

Import line that need to execute when entering interactive mode directly.


``ignore_manimlib_modules_on_reload``
-------------------------------------

When calling ``reload`` during the interactive mode, imported modules are
by default reloaded, in case the user writing a scene which pulls from various
other files they have written. By default, modules withinn the manim library will
be ignored, but one developing manim may want to set this to be False so that
edits to the library are reloaded as well.
1 change: 0 additions & 1 deletion docs/source/getting_started/structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ Below is the directory structure of manim:
├── family_ops.py # Process family members
├── file_ops.py # Process files and directories
├── images.py # Read image
├── init_config.py # Configuration guide
├── iterables.py # Functions related to list/dictionary processing
├── paths.py # Curve path
├── rate_functions.py # Some defined rate_functions
Expand Down
58 changes: 45 additions & 13 deletions manimlib/__main__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,48 @@
#!/usr/bin/env python
from addict import Dict

from manimlib import __version__
import manimlib.config
import manimlib.logger
import manimlib.utils.init_config
from manimlib.reload_manager import ReloadManager
from manimlib.config import manim_config
from manimlib.config import parse_cli
import manimlib.extract_scene
from manimlib.window import Window


from IPython.terminal.embed import KillEmbedded


from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import Namespace


def run_scenes():
"""
Runs the scenes in a loop and detects when a scene reload is requested.
"""
# Create a new dict to be able to upate without
# altering global configuration
scene_config = Dict(manim_config.scene)
run_config = manim_config.run

if run_config.show_in_window:
# Create a reusable window
window = Window(**manim_config.window)
scene_config.update(window=window)

while True:
try:
# Blocking call since a scene may init an IPython shell()
scenes = manimlib.extract_scene.main(scene_config, run_config)
for scene in scenes:
scene.run()
return
except KillEmbedded:
# Requested via the `exit_raise` IPython runline magic
# by means of the reload_scene() command
pass
except KeyboardInterrupt:
break


def main():
Expand All @@ -12,18 +51,11 @@ def main():
"""
print(f"ManimGL \033[32mv{__version__}\033[0m")

args = manimlib.config.parse_cli()
args = parse_cli()
if args.version and args.file is None:
return
if args.log_level:
manimlib.logger.log.setLevel(args.log_level)

if args.config:
manimlib.utils.init_config.init_customization()
return

reload_manager = ReloadManager(args)
reload_manager.run()
run_scenes()


if __name__ == "__main__":
Expand Down
14 changes: 6 additions & 8 deletions manimlib/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

from manimlib.camera.camera_frame import CameraFrame
from manimlib.constants import BLACK
from manimlib.constants import DEFAULT_FPS
from manimlib.constants import DEFAULT_PIXEL_HEIGHT, DEFAULT_PIXEL_WIDTH
from manimlib.constants import DEFAULT_RESOLUTION
from manimlib.constants import FRAME_HEIGHT
from manimlib.constants import FRAME_WIDTH
from manimlib.mobject.mobject import Mobject
Expand All @@ -29,10 +28,9 @@ def __init__(
window: Optional[Window] = None,
background_image: Optional[str] = None,
frame_config: dict = dict(),
pixel_width: int = DEFAULT_PIXEL_WIDTH,
pixel_height: int = DEFAULT_PIXEL_HEIGHT,
fps: int = DEFAULT_FPS,
# Note: frame height and width will be resized to match the pixel aspect ratio
# Note: frame height and width will be resized to match this resolution aspect ratio
resolution=DEFAULT_RESOLUTION,
fps: int = 30,
background_color: ManimColor = BLACK,
background_opacity: float = 1.0,
# Points in vectorized mobjects with norm greater
Expand All @@ -47,9 +45,9 @@ def __init__(
# to set samples to be greater than 0.
samples: int = 0,
):
self.background_image = background_image
self.window = window
self.default_pixel_shape = (pixel_width, pixel_height)
self.background_image = background_image
self.default_pixel_shape = resolution # Rename?
self.fps = fps
self.max_allowable_norm = max_allowable_norm
self.image_mode = image_mode
Expand Down
Loading
Loading