Episode 02: Positioning + Configuration

PART 1

Positioning and Alignment of Mobjects

Coordinates

  • Manim uses 3D coordinate system (internally: points are NumPy arrays)
  • Default (2D) settings: Scene frame is
    • $8$ Munits[Manim Units] in height
    • $14 + 2/9 = 14.2\dot{2}$ Munits in width
  • Origin $(0,0,0)$ is at center of frame; it measures $[-7.1\dot{1}, 7.1\dot{1}] \times [-4, 4]$ Munits
  • Pixel measurements of output depend on quality settings

PART 2

Manim's configuration system

config

  • Idea: Single Source of Truth for "global" settings
  • Documentation and Tutorial
  • Settings can be changed in .py file, but also in separate manim.cfg file
  • Local config generation: manim cfg write -l cwd
[CLI]
notify_outdated_version = True
background_color = WHITE
frame_width = 16
frame_height = 9
frame_rate = 60
pixel_height = 1080
pixel_width = 1920

Changing Mobject default arguments

  • Mobjects have default keyword arguments (e.g., color)
  • Default values can be changed using set_default!
Square.set_default(color=GREEN, fill_opacity=1)
s = Square()  # green, filled square

Square.set_default()  # restores default behavior
s2 = Square()  # white, empty square