manim 0.17.0__py3-none-any.whl → 0.19.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. manim/__init__.py +11 -6
  2. manim/__main__.py +62 -19
  3. manim/_config/__init__.py +10 -9
  4. manim/_config/cli_colors.py +26 -9
  5. manim/_config/default.cfg +1 -3
  6. manim/_config/logger_utils.py +23 -13
  7. manim/_config/utils.py +662 -468
  8. manim/animation/animation.py +164 -18
  9. manim/animation/changing.py +34 -23
  10. manim/animation/composition.py +265 -67
  11. manim/animation/creation.py +208 -26
  12. manim/animation/fading.py +16 -18
  13. manim/animation/growing.py +35 -15
  14. manim/animation/indication.py +150 -76
  15. manim/animation/movement.py +56 -22
  16. manim/animation/numbers.py +64 -6
  17. manim/animation/rotation.py +78 -7
  18. manim/animation/specialized.py +6 -7
  19. manim/animation/speedmodifier.py +13 -10
  20. manim/animation/transform.py +14 -11
  21. manim/animation/transform_matching_parts.py +3 -4
  22. manim/animation/updaters/mobject_update_utils.py +152 -30
  23. manim/animation/updaters/update.py +10 -7
  24. manim/camera/camera.py +182 -118
  25. manim/camera/mapping_camera.py +34 -3
  26. manim/camera/moving_camera.py +95 -74
  27. manim/camera/multi_camera.py +23 -15
  28. manim/camera/three_d_camera.py +70 -52
  29. manim/cli/__init__.py +17 -0
  30. manim/cli/cfg/group.py +76 -44
  31. manim/cli/checkhealth/checks.py +192 -0
  32. manim/cli/checkhealth/commands.py +90 -0
  33. manim/cli/default_group.py +158 -25
  34. manim/cli/init/commands.py +33 -25
  35. manim/cli/plugins/commands.py +16 -3
  36. manim/cli/render/commands.py +72 -60
  37. manim/cli/render/ease_of_access_options.py +4 -3
  38. manim/cli/render/global_options.py +59 -17
  39. manim/cli/render/output_options.py +6 -5
  40. manim/cli/render/render_options.py +98 -33
  41. manim/constants.py +109 -59
  42. manim/data_structures.py +31 -0
  43. manim/mobject/frame.py +8 -5
  44. manim/mobject/geometry/__init__.py +1 -0
  45. manim/mobject/geometry/arc.py +277 -135
  46. manim/mobject/geometry/boolean_ops.py +32 -31
  47. manim/mobject/geometry/labeled.py +376 -0
  48. manim/mobject/geometry/line.py +192 -87
  49. manim/mobject/geometry/polygram.py +224 -58
  50. manim/mobject/geometry/shape_matchers.py +61 -25
  51. manim/mobject/geometry/tips.py +122 -48
  52. manim/mobject/graph.py +1027 -419
  53. manim/mobject/graphing/coordinate_systems.py +533 -278
  54. manim/mobject/graphing/functions.py +53 -32
  55. manim/mobject/graphing/number_line.py +123 -65
  56. manim/mobject/graphing/probability.py +88 -62
  57. manim/mobject/graphing/scale.py +33 -19
  58. manim/mobject/logo.py +118 -28
  59. manim/mobject/matrix.py +87 -83
  60. manim/mobject/mobject.py +912 -442
  61. manim/mobject/opengl/dot_cloud.py +16 -5
  62. manim/mobject/opengl/opengl_compatibility.py +4 -2
  63. manim/mobject/opengl/opengl_geometry.py +254 -153
  64. manim/mobject/opengl/opengl_image_mobject.py +3 -1
  65. manim/mobject/opengl/opengl_mobject.py +779 -482
  66. manim/mobject/opengl/opengl_point_cloud_mobject.py +41 -14
  67. manim/mobject/opengl/opengl_surface.py +14 -92
  68. manim/mobject/opengl/opengl_three_dimensions.py +12 -8
  69. manim/mobject/opengl/opengl_vectorized_mobject.py +98 -100
  70. manim/mobject/svg/brace.py +173 -41
  71. manim/mobject/svg/svg_mobject.py +139 -53
  72. manim/mobject/table.py +61 -68
  73. manim/mobject/text/code_mobject.py +193 -539
  74. manim/mobject/text/numbers.py +81 -34
  75. manim/mobject/text/tex_mobject.py +130 -78
  76. manim/mobject/text/text_mobject.py +288 -164
  77. manim/mobject/three_d/polyhedra.py +111 -13
  78. manim/mobject/three_d/three_d_utils.py +17 -8
  79. manim/mobject/three_d/three_dimensions.py +239 -106
  80. manim/mobject/types/image_mobject.py +50 -30
  81. manim/mobject/types/point_cloud_mobject.py +120 -75
  82. manim/mobject/types/vectorized_mobject.py +841 -408
  83. manim/mobject/value_tracker.py +105 -38
  84. manim/mobject/vector_field.py +50 -31
  85. manim/opengl/__init__.py +3 -3
  86. manim/plugins/__init__.py +14 -1
  87. manim/plugins/plugins_flags.py +10 -14
  88. manim/renderer/cairo_renderer.py +65 -50
  89. manim/renderer/opengl_renderer.py +89 -69
  90. manim/renderer/opengl_renderer_window.py +39 -18
  91. manim/renderer/shader.py +123 -87
  92. manim/renderer/shader_wrapper.py +44 -28
  93. manim/renderer/vectorized_mobject_rendering.py +38 -10
  94. manim/scene/moving_camera_scene.py +32 -3
  95. manim/scene/scene.py +507 -242
  96. manim/scene/scene_file_writer.py +371 -220
  97. manim/scene/section.py +20 -16
  98. manim/scene/three_d_scene.py +14 -22
  99. manim/scene/vector_space_scene.py +223 -129
  100. manim/scene/zoomed_scene.py +46 -41
  101. manim/typing.py +990 -0
  102. manim/utils/bezier.py +1823 -371
  103. manim/utils/caching.py +12 -5
  104. manim/utils/color/AS2700.py +236 -0
  105. manim/utils/color/BS381.py +318 -0
  106. manim/utils/color/DVIPSNAMES.py +96 -0
  107. manim/utils/color/SVGNAMES.py +179 -0
  108. manim/utils/color/X11.py +533 -0
  109. manim/utils/color/XKCD.py +952 -0
  110. manim/utils/color/__init__.py +61 -0
  111. manim/utils/color/core.py +1667 -0
  112. manim/utils/color/manim_colors.py +218 -0
  113. manim/utils/commands.py +48 -20
  114. manim/utils/config_ops.py +39 -19
  115. manim/utils/debug.py +8 -7
  116. manim/utils/deprecation.py +86 -39
  117. manim/utils/docbuild/__init__.py +17 -0
  118. manim/utils/docbuild/autoaliasattr_directive.py +236 -0
  119. manim/utils/docbuild/autocolor_directive.py +99 -0
  120. manim/utils/docbuild/manim_directive.py +94 -41
  121. manim/utils/docbuild/module_parsing.py +245 -0
  122. manim/utils/exceptions.py +6 -0
  123. manim/utils/family.py +5 -3
  124. manim/utils/family_ops.py +17 -4
  125. manim/utils/file_ops.py +27 -17
  126. manim/utils/hashing.py +55 -45
  127. manim/utils/images.py +13 -7
  128. manim/utils/ipython_magic.py +13 -7
  129. manim/utils/iterables.py +163 -120
  130. manim/utils/module_ops.py +66 -24
  131. manim/utils/opengl.py +77 -24
  132. manim/utils/parameter_parsing.py +32 -0
  133. manim/utils/paths.py +30 -33
  134. manim/utils/polylabel.py +235 -0
  135. manim/utils/qhull.py +218 -0
  136. manim/utils/rate_functions.py +98 -32
  137. manim/utils/simple_functions.py +25 -33
  138. manim/utils/sounds.py +7 -1
  139. manim/utils/space_ops.py +188 -115
  140. manim/utils/testing/__init__.py +17 -0
  141. manim/utils/testing/_frames_testers.py +13 -8
  142. manim/utils/testing/_show_diff.py +5 -3
  143. manim/utils/testing/_test_class_makers.py +34 -18
  144. manim/utils/testing/frames_comparison.py +37 -19
  145. manim/utils/tex.py +130 -198
  146. manim/utils/tex_file_writing.py +77 -47
  147. manim/utils/tex_templates.py +2 -1
  148. manim/utils/unit.py +6 -5
  149. {manim-0.17.0.dist-info → manim-0.19.1.dist-info}/METADATA +64 -65
  150. manim-0.19.1.dist-info/RECORD +220 -0
  151. {manim-0.17.0.dist-info → manim-0.19.1.dist-info}/WHEEL +1 -1
  152. manim-0.19.1.dist-info/entry_points.txt +3 -0
  153. {manim-0.17.0.dist-info → manim-0.19.1.dist-info/licenses}/LICENSE.community +1 -1
  154. manim/cli/new/group.py +0 -189
  155. manim/communitycolors.py +0 -9
  156. manim/gui/__init__.py +0 -0
  157. manim/gui/gui.py +0 -82
  158. manim/plugins/import_plugins.py +0 -43
  159. manim/utils/color.py +0 -552
  160. manim-0.17.0.dist-info/RECORD +0 -206
  161. manim-0.17.0.dist-info/entry_points.txt +0 -4
  162. /manim/cli/{new → checkhealth}/__init__.py +0 -0
  163. {manim-0.17.0.dist-info → manim-0.19.1.dist-info/licenses}/LICENSE +0 -0
manim/constants.py CHANGED
@@ -1,15 +1,16 @@
1
- """
2
- Constant definitions.
3
- """
1
+ """Constant definitions."""
4
2
 
5
3
  from __future__ import annotations
6
4
 
7
5
  from enum import Enum
6
+ from typing import TypedDict
8
7
 
9
8
  import numpy as np
10
9
  from cloup import Context
11
10
  from PIL.Image import Resampling
12
11
 
12
+ from manim.typing import Vector3D
13
+
13
14
  __all__ = [
14
15
  "SCENE_NOT_FOUND_MESSAGE",
15
16
  "CHOOSE_NUMBER_MESSAGE",
@@ -62,6 +63,7 @@ __all__ = [
62
63
  "DEFAULT_POINT_DENSITY_1D",
63
64
  "DEFAULT_STROKE_WIDTH",
64
65
  "DEFAULT_FONT_SIZE",
66
+ "SCALE_FACTOR_PER_FONT_POINT",
65
67
  "PI",
66
68
  "TAU",
67
69
  "DEGREES",
@@ -73,37 +75,38 @@ __all__ = [
73
75
  "CTRL_VALUE",
74
76
  "RendererType",
75
77
  "LineJointType",
78
+ "CapStyleType",
76
79
  ]
77
80
  # Messages
78
81
 
79
- SCENE_NOT_FOUND_MESSAGE: str = """
82
+ SCENE_NOT_FOUND_MESSAGE = """
80
83
  {} is not in the script
81
84
  """
82
- CHOOSE_NUMBER_MESSAGE: str = """
85
+ CHOOSE_NUMBER_MESSAGE = """
83
86
  Choose number corresponding to desired scene/arguments.
84
- (Use comma separated list for multiple entries)
87
+ (Use comma separated list for multiple entries or use "*" to select all scenes.)
85
88
  Choice(s): """
86
- INVALID_NUMBER_MESSAGE: str = "Invalid scene numbers have been specified. Aborting."
87
- NO_SCENE_MESSAGE: str = """
89
+ INVALID_NUMBER_MESSAGE = "Invalid scene numbers have been specified. Aborting."
90
+ NO_SCENE_MESSAGE = """
88
91
  There are no scenes inside that module
89
92
  """
90
93
 
91
94
  # Pango stuff
92
- NORMAL: str = "NORMAL"
93
- ITALIC: str = "ITALIC"
94
- OBLIQUE: str = "OBLIQUE"
95
- BOLD: str = "BOLD"
95
+ NORMAL = "NORMAL"
96
+ ITALIC = "ITALIC"
97
+ OBLIQUE = "OBLIQUE"
98
+ BOLD = "BOLD"
96
99
  # Only for Pango from below
97
- THIN: str = "THIN"
98
- ULTRALIGHT: str = "ULTRALIGHT"
99
- LIGHT: str = "LIGHT"
100
- SEMILIGHT: str = "SEMILIGHT"
101
- BOOK: str = "BOOK"
102
- MEDIUM: str = "MEDIUM"
103
- SEMIBOLD: str = "SEMIBOLD"
104
- ULTRABOLD: str = "ULTRABOLD"
105
- HEAVY: str = "HEAVY"
106
- ULTRAHEAVY: str = "ULTRAHEAVY"
100
+ THIN = "THIN"
101
+ ULTRALIGHT = "ULTRALIGHT"
102
+ LIGHT = "LIGHT"
103
+ SEMILIGHT = "SEMILIGHT"
104
+ BOOK = "BOOK"
105
+ MEDIUM = "MEDIUM"
106
+ SEMIBOLD = "SEMIBOLD"
107
+ ULTRABOLD = "ULTRABOLD"
108
+ HEAVY = "HEAVY"
109
+ ULTRAHEAVY = "ULTRAHEAVY"
107
110
 
108
111
  RESAMPLING_ALGORITHMS = {
109
112
  "nearest": Resampling.NEAREST,
@@ -119,83 +122,92 @@ RESAMPLING_ALGORITHMS = {
119
122
  }
120
123
 
121
124
  # Geometry: directions
122
- ORIGIN: np.ndarray = np.array((0.0, 0.0, 0.0))
125
+ ORIGIN: Vector3D = np.array((0.0, 0.0, 0.0))
123
126
  """The center of the coordinate system."""
124
127
 
125
- UP: np.ndarray = np.array((0.0, 1.0, 0.0))
128
+ UP: Vector3D = np.array((0.0, 1.0, 0.0))
126
129
  """One unit step in the positive Y direction."""
127
130
 
128
- DOWN: np.ndarray = np.array((0.0, -1.0, 0.0))
131
+ DOWN: Vector3D = np.array((0.0, -1.0, 0.0))
129
132
  """One unit step in the negative Y direction."""
130
133
 
131
- RIGHT: np.ndarray = np.array((1.0, 0.0, 0.0))
134
+ RIGHT: Vector3D = np.array((1.0, 0.0, 0.0))
132
135
  """One unit step in the positive X direction."""
133
136
 
134
- LEFT: np.ndarray = np.array((-1.0, 0.0, 0.0))
137
+ LEFT: Vector3D = np.array((-1.0, 0.0, 0.0))
135
138
  """One unit step in the negative X direction."""
136
139
 
137
- IN: np.ndarray = np.array((0.0, 0.0, -1.0))
140
+ IN: Vector3D = np.array((0.0, 0.0, -1.0))
138
141
  """One unit step in the negative Z direction."""
139
142
 
140
- OUT: np.ndarray = np.array((0.0, 0.0, 1.0))
143
+ OUT: Vector3D = np.array((0.0, 0.0, 1.0))
141
144
  """One unit step in the positive Z direction."""
142
145
 
143
146
  # Geometry: axes
144
- X_AXIS: np.ndarray = np.array((1.0, 0.0, 0.0))
145
- Y_AXIS: np.ndarray = np.array((0.0, 1.0, 0.0))
146
- Z_AXIS: np.ndarray = np.array((0.0, 0.0, 1.0))
147
+ X_AXIS: Vector3D = np.array((1.0, 0.0, 0.0))
148
+ Y_AXIS: Vector3D = np.array((0.0, 1.0, 0.0))
149
+ Z_AXIS: Vector3D = np.array((0.0, 0.0, 1.0))
147
150
 
148
151
  # Geometry: useful abbreviations for diagonals
149
- UL: np.ndarray = UP + LEFT
152
+ UL: Vector3D = UP + LEFT
150
153
  """One step up plus one step left."""
151
154
 
152
- UR: np.ndarray = UP + RIGHT
155
+ UR: Vector3D = UP + RIGHT
153
156
  """One step up plus one step right."""
154
157
 
155
- DL: np.ndarray = DOWN + LEFT
158
+ DL: Vector3D = DOWN + LEFT
156
159
  """One step down plus one step left."""
157
160
 
158
- DR: np.ndarray = DOWN + RIGHT
161
+ DR: Vector3D = DOWN + RIGHT
159
162
  """One step down plus one step right."""
160
163
 
161
164
  # Geometry
162
- START_X: int = 30
163
- START_Y: int = 20
164
- DEFAULT_DOT_RADIUS: float = 0.08
165
- DEFAULT_SMALL_DOT_RADIUS: float = 0.04
166
- DEFAULT_DASH_LENGTH: float = 0.05
167
- DEFAULT_ARROW_TIP_LENGTH: float = 0.35
165
+ START_X = 30
166
+ START_Y = 20
167
+ DEFAULT_DOT_RADIUS = 0.08
168
+ DEFAULT_SMALL_DOT_RADIUS = 0.04
169
+ DEFAULT_DASH_LENGTH = 0.05
170
+ DEFAULT_ARROW_TIP_LENGTH = 0.35
168
171
 
169
172
  # Default buffers (padding)
170
- SMALL_BUFF: float = 0.1
171
- MED_SMALL_BUFF: float = 0.25
172
- MED_LARGE_BUFF: float = 0.5
173
- LARGE_BUFF: float = 1
174
- DEFAULT_MOBJECT_TO_EDGE_BUFFER: float = MED_LARGE_BUFF
175
- DEFAULT_MOBJECT_TO_MOBJECT_BUFFER: float = MED_SMALL_BUFF
173
+ SMALL_BUFF = 0.1
174
+ MED_SMALL_BUFF = 0.25
175
+ MED_LARGE_BUFF = 0.5
176
+ LARGE_BUFF = 1
177
+ DEFAULT_MOBJECT_TO_EDGE_BUFFER = MED_LARGE_BUFF
178
+ DEFAULT_MOBJECT_TO_MOBJECT_BUFFER = MED_SMALL_BUFF
176
179
 
177
180
  # Times in seconds
178
- DEFAULT_POINTWISE_FUNCTION_RUN_TIME: float = 3.0
179
- DEFAULT_WAIT_TIME: float = 1.0
181
+ DEFAULT_POINTWISE_FUNCTION_RUN_TIME = 3.0
182
+ DEFAULT_WAIT_TIME = 1.0
180
183
 
181
184
  # Misc
182
- DEFAULT_POINT_DENSITY_2D: int = 25
183
- DEFAULT_POINT_DENSITY_1D: int = 10
184
- DEFAULT_STROKE_WIDTH: int = 4
185
- DEFAULT_FONT_SIZE: float = 48
185
+ DEFAULT_POINT_DENSITY_2D = 25
186
+ DEFAULT_POINT_DENSITY_1D = 10
187
+ DEFAULT_STROKE_WIDTH = 4
188
+ DEFAULT_FONT_SIZE = 48
189
+ SCALE_FACTOR_PER_FONT_POINT = 1 / 960
186
190
 
187
191
  # Mathematical constants
188
- PI: float = np.pi
192
+ PI = np.pi
189
193
  """The ratio of the circumference of a circle to its diameter."""
190
194
 
191
- TAU: float = 2 * PI
195
+ TAU = 2 * PI
192
196
  """The ratio of the circumference of a circle to its radius."""
193
197
 
194
- DEGREES: float = TAU / 360
198
+ DEGREES = TAU / 360
195
199
  """The exchange rate between radians and degrees."""
196
200
 
201
+
202
+ class QualityDict(TypedDict):
203
+ flag: str | None
204
+ pixel_height: int
205
+ pixel_width: int
206
+ frame_rate: int
207
+
208
+
197
209
  # Video qualities
198
- QUALITIES: dict[str, dict[str, str | int | None]] = {
210
+ QUALITIES: dict[str, QualityDict] = {
199
211
  "fourk_quality": {
200
212
  "flag": "k",
201
213
  "pixel_height": 2160,
@@ -234,7 +246,7 @@ QUALITIES: dict[str, dict[str, str | int | None]] = {
234
246
  },
235
247
  }
236
248
 
237
- DEFAULT_QUALITY: str = "high_quality"
249
+ DEFAULT_QUALITY = "high_quality"
238
250
 
239
251
  EPILOG = "Made with <3 by Manim Community developers."
240
252
  SHIFT_VALUE = 65505
@@ -301,3 +313,41 @@ class LineJointType(Enum):
301
313
  ROUND = 1
302
314
  BEVEL = 2
303
315
  MITER = 3
316
+
317
+
318
+ class CapStyleType(Enum):
319
+ """Collection of available cap styles.
320
+
321
+ See the example below for a visual illustration of the different
322
+ cap styles.
323
+
324
+ Examples
325
+ --------
326
+
327
+ .. manim:: CapStyleVariants
328
+ :save_last_frame:
329
+
330
+ class CapStyleVariants(Scene):
331
+ def construct(self):
332
+ arcs = VGroup(*[
333
+ Arc(
334
+ radius=1,
335
+ start_angle=0,
336
+ angle=TAU / 4,
337
+ stroke_width=20,
338
+ color=GREEN,
339
+ cap_style=cap_style,
340
+ )
341
+ for cap_style in CapStyleType
342
+ ])
343
+ arcs.arrange(RIGHT, buff=1)
344
+ self.add(arcs)
345
+ for arc in arcs:
346
+ label = Text(arc.cap_style.name, font_size=24).next_to(arc, DOWN)
347
+ self.add(label)
348
+ """
349
+
350
+ AUTO = 0
351
+ ROUND = 1
352
+ BUTT = 2
353
+ SQUARE = 3
@@ -0,0 +1,31 @@
1
+ """Data classes and other necessary data structures for use in Manim."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Iterable
6
+ from dataclasses import dataclass
7
+ from types import MethodType
8
+ from typing import Any
9
+
10
+
11
+ @dataclass
12
+ class MethodWithArgs:
13
+ """Object containing a :attr:`method` which is intended to be called later
14
+ with the positional arguments :attr:`args` and the keyword arguments
15
+ :attr:`kwargs`.
16
+
17
+ Attributes
18
+ ----------
19
+ method : MethodType
20
+ A callable representing a method of some class.
21
+ args : Iterable[Any]
22
+ Positional arguments for :attr:`method`.
23
+ kwargs : dict[str, Any]
24
+ Keyword arguments for :attr:`method`.
25
+ """
26
+
27
+ __slots__ = ["method", "args", "kwargs"]
28
+
29
+ method: MethodType
30
+ args: Iterable[Any]
31
+ kwargs: dict[str, Any]
manim/mobject/frame.py CHANGED
@@ -8,31 +8,34 @@ __all__ = [
8
8
  ]
9
9
 
10
10
 
11
+ from typing import Any
12
+
11
13
  from manim.mobject.geometry.polygram import Rectangle
12
14
 
13
15
  from .. import config
14
16
 
15
17
 
16
18
  class ScreenRectangle(Rectangle):
17
- def __init__(self, aspect_ratio=16.0 / 9.0, height=4, **kwargs):
19
+ def __init__(
20
+ self, aspect_ratio: float = 16.0 / 9.0, height: float = 4, **kwargs: Any
21
+ ) -> None:
18
22
  super().__init__(width=aspect_ratio * height, height=height, **kwargs)
19
23
 
20
24
  @property
21
- def aspect_ratio(self):
25
+ def aspect_ratio(self) -> float:
22
26
  """The aspect ratio.
23
27
 
24
28
  When set, the width is stretched to accommodate
25
29
  the new aspect ratio.
26
30
  """
27
-
28
31
  return self.width / self.height
29
32
 
30
33
  @aspect_ratio.setter
31
- def aspect_ratio(self, value):
34
+ def aspect_ratio(self, value: float) -> None:
32
35
  self.stretch_to_fit_width(value * self.height)
33
36
 
34
37
 
35
38
  class FullScreenRectangle(ScreenRectangle):
36
- def __init__(self, **kwargs):
39
+ def __init__(self, **kwargs: Any) -> None:
37
40
  super().__init__(**kwargs)
38
41
  self.height = config["frame_height"]
@@ -8,6 +8,7 @@ Modules
8
8
 
9
9
  ~arc
10
10
  ~boolean_ops
11
+ ~labeled
11
12
  ~line
12
13
  ~polygram
13
14
  ~shape_matchers