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
@@ -4,9 +4,10 @@ from __future__ import annotations
4
4
 
5
5
  __all__ = ["DecimalNumber", "Integer", "Variable"]
6
6
 
7
- from typing import Sequence
7
+ from typing import Any
8
8
 
9
9
  import numpy as np
10
+ from typing_extensions import Self
10
11
 
11
12
  from manim import config
12
13
  from manim.constants import *
@@ -15,12 +16,41 @@ from manim.mobject.text.tex_mobject import MathTex, SingleStringMathTex, Tex
15
16
  from manim.mobject.text.text_mobject import Text
16
17
  from manim.mobject.types.vectorized_mobject import VMobject
17
18
  from manim.mobject.value_tracker import ValueTracker
19
+ from manim.typing import Vector3DLike
18
20
 
19
- string_to_mob_map = {}
21
+ string_to_mob_map: dict[str, SingleStringMathTex] = {}
20
22
 
21
23
 
22
24
  class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
23
- """An mobject representing a decimal number.
25
+ r"""An mobject representing a decimal number.
26
+
27
+ Parameters
28
+ ----------
29
+ number
30
+ The numeric value to be displayed. It can later be modified using :meth:`.set_value`.
31
+ num_decimal_places
32
+ The number of decimal places after the decimal separator. Values are automatically rounded.
33
+ mob_class
34
+ The class for rendering digits and units, by default :class:`.MathTex`.
35
+ include_sign
36
+ Set to ``True`` to include a sign for positive numbers and zero.
37
+ group_with_commas
38
+ When ``True`` thousands groups are separated by commas for readability.
39
+ digit_buff_per_font_unit
40
+ Additional spacing between digits. Scales with font size.
41
+ show_ellipsis
42
+ When a number has been truncated by rounding, indicate with an ellipsis (``...``).
43
+ unit
44
+ A unit string which can be placed to the right of the numerical values.
45
+ unit_buff_per_font_unit
46
+ An additional spacing between the numerical values and the unit. A value
47
+ of ``unit_buff_per_font_unit=0.003`` gives a decent spacing. Scales with font size.
48
+ include_background_rectangle
49
+ Adds a background rectangle to increase contrast on busy scenes.
50
+ edge_to_fix
51
+ Assuring right- or left-alignment of the full object.
52
+ font_size
53
+ Size of the font.
24
54
 
25
55
  Examples
26
56
  --------
@@ -34,6 +64,8 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
34
64
  show_ellipsis=True,
35
65
  num_decimal_places=3,
36
66
  include_sign=True,
67
+ unit=r"\text{M-Units}",
68
+ unit_buff_per_font_unit=0.003
37
69
  )
38
70
  square = Square().to_edge(UP)
39
71
 
@@ -53,20 +85,21 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
53
85
  self,
54
86
  number: float = 0,
55
87
  num_decimal_places: int = 2,
56
- mob_class: VMobject = MathTex,
88
+ mob_class: type[SingleStringMathTex] = MathTex,
57
89
  include_sign: bool = False,
58
90
  group_with_commas: bool = True,
59
91
  digit_buff_per_font_unit: float = 0.001,
60
92
  show_ellipsis: bool = False,
61
93
  unit: str | None = None, # Aligned to bottom unless it starts with "^"
94
+ unit_buff_per_font_unit: float = 0,
62
95
  include_background_rectangle: bool = False,
63
- edge_to_fix: Sequence[float] = LEFT,
96
+ edge_to_fix: Vector3DLike = LEFT,
64
97
  font_size: float = DEFAULT_FONT_SIZE,
65
98
  stroke_width: float = 0,
66
99
  fill_opacity: float = 1.0,
67
- **kwargs,
100
+ **kwargs: Any,
68
101
  ):
69
- super().__init__(**kwargs)
102
+ super().__init__(**kwargs, fill_opacity=fill_opacity, stroke_width=stroke_width)
70
103
  self.number = number
71
104
  self.num_decimal_places = num_decimal_places
72
105
  self.include_sign = include_sign
@@ -75,10 +108,10 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
75
108
  self.digit_buff_per_font_unit = digit_buff_per_font_unit
76
109
  self.show_ellipsis = show_ellipsis
77
110
  self.unit = unit
111
+ self.unit_buff_per_font_unit = unit_buff_per_font_unit
78
112
  self.include_background_rectangle = include_background_rectangle
79
113
  self.edge_to_fix = edge_to_fix
80
114
  self._font_size = font_size
81
- self.stroke_width = stroke_width
82
115
  self.fill_opacity = fill_opacity
83
116
 
84
117
  self.initial_config = kwargs.copy()
@@ -90,6 +123,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
90
123
  "digit_buff_per_font_unit": digit_buff_per_font_unit,
91
124
  "show_ellipsis": show_ellipsis,
92
125
  "unit": unit,
126
+ "unit_buff_per_font_unit": unit_buff_per_font_unit,
93
127
  "include_background_rectangle": include_background_rectangle,
94
128
  "edge_to_fix": edge_to_fix,
95
129
  "font_size": font_size,
@@ -102,12 +136,13 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
102
136
  self.init_colors()
103
137
 
104
138
  @property
105
- def font_size(self):
139
+ def font_size(self) -> float:
106
140
  """The font size of the tex mobject."""
107
- return self.height / self.initial_height * self._font_size
141
+ return_value: float = self.height / self.initial_height * self._font_size
142
+ return return_value
108
143
 
109
144
  @font_size.setter
110
- def font_size(self, font_val):
145
+ def font_size(self, font_val: float) -> None:
111
146
  if font_val <= 0:
112
147
  raise ValueError("font_size must be greater than 0.")
113
148
  elif self.height > 0:
@@ -118,7 +153,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
118
153
  # font_size does not depend on current size.
119
154
  self.scale(font_val / self.font_size)
120
155
 
121
- def _set_submobjects_from_number(self, number):
156
+ def _set_submobjects_from_number(self, number: float) -> None:
122
157
  self.number = number
123
158
  self.submobjects = []
124
159
 
@@ -131,15 +166,25 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
131
166
  self._string_to_mob("\\dots", SingleStringMathTex, color=self.color),
132
167
  )
133
168
 
134
- if self.unit is not None:
135
- self.unit_sign = self._string_to_mob(self.unit, SingleStringMathTex)
136
- self.add(self.unit_sign)
137
-
138
169
  self.arrange(
139
170
  buff=self.digit_buff_per_font_unit * self._font_size,
140
171
  aligned_edge=DOWN,
141
172
  )
142
173
 
174
+ if self.unit is not None:
175
+ self.unit_sign = self._string_to_mob(self.unit, SingleStringMathTex)
176
+ self.add(
177
+ self.unit_sign.next_to(
178
+ self,
179
+ direction=RIGHT,
180
+ buff=(self.unit_buff_per_font_unit + self.digit_buff_per_font_unit)
181
+ * self._font_size,
182
+ aligned_edge=DOWN,
183
+ )
184
+ )
185
+
186
+ self.move_to(ORIGIN)
187
+
143
188
  # Handle alignment of parts that should be aligned
144
189
  # to the bottom
145
190
  for i, c in enumerate(num_string):
@@ -152,12 +197,12 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
152
197
  self.unit_sign.align_to(self, UP)
153
198
 
154
199
  # track the initial height to enable scaling via font_size
155
- self.initial_height = self.height
200
+ self.initial_height: float = self.height
156
201
 
157
202
  if self.include_background_rectangle:
158
203
  self.add_background_rectangle()
159
204
 
160
- def _get_num_string(self, number):
205
+ def _get_num_string(self, number: float | complex) -> str:
161
206
  if isinstance(number, complex):
162
207
  formatter = self._get_complex_formatter()
163
208
  else:
@@ -166,15 +211,16 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
166
211
 
167
212
  rounded_num = np.round(number, self.num_decimal_places)
168
213
  if num_string.startswith("-") and rounded_num == 0:
169
- if self.include_sign:
170
- num_string = "+" + num_string[1:]
171
- else:
172
- num_string = num_string[1:]
214
+ num_string = "+" + num_string[1:] if self.include_sign else num_string[1:]
173
215
 
174
216
  return num_string
175
217
 
176
- def _string_to_mob(self, string: str, mob_class: VMobject | None = None, **kwargs):
177
-
218
+ def _string_to_mob(
219
+ self,
220
+ string: str,
221
+ mob_class: type[SingleStringMathTex] | None = None,
222
+ **kwargs: Any,
223
+ ) -> VMobject:
178
224
  if mob_class is None:
179
225
  mob_class = self.mob_class
180
226
 
@@ -184,7 +230,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
184
230
  mob.font_size = self._font_size
185
231
  return mob
186
232
 
187
- def _get_formatter(self, **kwargs):
233
+ def _get_formatter(self, **kwargs: Any) -> str:
188
234
  """
189
235
  Configuration is based first off instance attributes,
190
236
  but overwritten by any kew word argument. Relevant
@@ -217,7 +263,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
217
263
  ],
218
264
  )
219
265
 
220
- def _get_complex_formatter(self):
266
+ def _get_complex_formatter(self) -> str:
221
267
  return "".join(
222
268
  [
223
269
  self._get_formatter(field_name="0.real"),
@@ -226,7 +272,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
226
272
  ],
227
273
  )
228
274
 
229
- def set_value(self, number: float):
275
+ def set_value(self, number: float) -> Self:
230
276
  """Set the value of the :class:`~.DecimalNumber` to a new number.
231
277
 
232
278
  Parameters
@@ -263,10 +309,10 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
263
309
  self.init_colors()
264
310
  return self
265
311
 
266
- def get_value(self):
312
+ def get_value(self) -> float:
267
313
  return self.number
268
314
 
269
- def increment_value(self, delta_t=1):
315
+ def increment_value(self, delta_t: float = 1) -> None:
270
316
  self.set_value(self.get_value() + delta_t)
271
317
 
272
318
 
@@ -287,10 +333,12 @@ class Integer(DecimalNumber):
287
333
  self.add(Integer(number=6.28).set_x(-1.5).set_y(-2).set_color(YELLOW).scale(1.4))
288
334
  """
289
335
 
290
- def __init__(self, number=0, num_decimal_places=0, **kwargs):
336
+ def __init__(
337
+ self, number: float = 0, num_decimal_places: int = 0, **kwargs: Any
338
+ ) -> None:
291
339
  super().__init__(number=number, num_decimal_places=num_decimal_places, **kwargs)
292
340
 
293
- def get_value(self):
341
+ def get_value(self) -> int:
294
342
  return int(np.round(super().get_value()))
295
343
 
296
344
 
@@ -401,11 +449,10 @@ class Variable(VMobject, metaclass=ConvertToOpenGL):
401
449
  self,
402
450
  var: float,
403
451
  label: str | Tex | MathTex | Text | SingleStringMathTex,
404
- var_type: DecimalNumber | Integer = DecimalNumber,
452
+ var_type: type[DecimalNumber | Integer] = DecimalNumber,
405
453
  num_decimal_places: int = 2,
406
- **kwargs,
454
+ **kwargs: Any,
407
455
  ):
408
-
409
456
  self.label = MathTex(label) if isinstance(label, str) else label
410
457
  equals = MathTex("=").next_to(self.label, RIGHT)
411
458
  self.label.add(equals)