manim 0.17.3__py3-none-any.whl → 0.18.0.post0__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.

Potentially problematic release.


This version of manim might be problematic. Click here for more details.

Files changed (84) hide show
  1. manim/__init__.py +1 -0
  2. manim/__main__.py +2 -0
  3. manim/_config/__init__.py +0 -1
  4. manim/_config/logger_utils.py +1 -0
  5. manim/_config/utils.py +14 -5
  6. manim/animation/changing.py +9 -5
  7. manim/animation/creation.py +8 -3
  8. manim/animation/indication.py +4 -4
  9. manim/animation/speedmodifier.py +2 -4
  10. manim/animation/updaters/mobject_update_utils.py +134 -16
  11. manim/camera/camera.py +31 -17
  12. manim/cli/checkhealth/__init__.py +0 -0
  13. manim/cli/checkhealth/checks.py +173 -0
  14. manim/cli/checkhealth/commands.py +81 -0
  15. manim/cli/render/global_options.py +6 -0
  16. manim/constants.py +58 -54
  17. manim/mobject/geometry/__init__.py +1 -0
  18. manim/mobject/geometry/arc.py +126 -91
  19. manim/mobject/geometry/boolean_ops.py +6 -10
  20. manim/mobject/geometry/labeled.py +155 -0
  21. manim/mobject/geometry/line.py +66 -50
  22. manim/mobject/geometry/polygram.py +23 -15
  23. manim/mobject/geometry/shape_matchers.py +24 -15
  24. manim/mobject/geometry/tips.py +62 -40
  25. manim/mobject/graph.py +3 -4
  26. manim/mobject/graphing/coordinate_systems.py +190 -139
  27. manim/mobject/graphing/number_line.py +5 -2
  28. manim/mobject/graphing/probability.py +4 -3
  29. manim/mobject/graphing/scale.py +7 -7
  30. manim/mobject/logo.py +108 -22
  31. manim/mobject/matrix.py +33 -37
  32. manim/mobject/mobject.py +327 -260
  33. manim/mobject/opengl/opengl_image_mobject.py +1 -1
  34. manim/mobject/opengl/opengl_mobject.py +18 -12
  35. manim/mobject/opengl/opengl_point_cloud_mobject.py +1 -1
  36. manim/mobject/opengl/opengl_surface.py +1 -1
  37. manim/mobject/opengl/opengl_vectorized_mobject.py +21 -17
  38. manim/mobject/svg/brace.py +3 -1
  39. manim/mobject/svg/svg_mobject.py +9 -11
  40. manim/mobject/table.py +50 -54
  41. manim/mobject/text/numbers.py +48 -6
  42. manim/mobject/text/tex_mobject.py +8 -12
  43. manim/mobject/text/text_mobject.py +32 -24
  44. manim/mobject/three_d/three_d_utils.py +13 -8
  45. manim/mobject/three_d/three_dimensions.py +61 -43
  46. manim/mobject/types/image_mobject.py +5 -4
  47. manim/mobject/types/point_cloud_mobject.py +8 -6
  48. manim/mobject/types/vectorized_mobject.py +385 -258
  49. manim/mobject/vector_field.py +19 -11
  50. manim/plugins/import_plugins.py +1 -1
  51. manim/plugins/plugins_flags.py +1 -6
  52. manim/renderer/shader.py +2 -2
  53. manim/scene/scene.py +15 -7
  54. manim/scene/scene_file_writer.py +1 -2
  55. manim/scene/three_d_scene.py +1 -1
  56. manim/scene/vector_space_scene.py +17 -7
  57. manim/typing.py +133 -0
  58. manim/utils/bezier.py +267 -83
  59. manim/utils/color/AS2700.py +234 -0
  60. manim/utils/color/BS381.py +315 -0
  61. manim/utils/color/X11.py +530 -0
  62. manim/utils/color/XKCD.py +949 -0
  63. manim/utils/color/__init__.py +58 -0
  64. manim/utils/color/core.py +1036 -0
  65. manim/utils/color/manim_colors.py +220 -0
  66. manim/utils/docbuild/autocolor_directive.py +92 -0
  67. manim/utils/docbuild/manim_directive.py +40 -6
  68. manim/utils/file_ops.py +1 -1
  69. manim/utils/hashing.py +1 -1
  70. manim/utils/iterables.py +1 -1
  71. manim/utils/rate_functions.py +33 -0
  72. manim/utils/simple_functions.py +0 -18
  73. manim/utils/space_ops.py +55 -42
  74. manim/utils/testing/frames_comparison.py +9 -0
  75. manim/utils/tex.py +2 -0
  76. manim/utils/tex_file_writing.py +29 -2
  77. {manim-0.17.3.dist-info → manim-0.18.0.post0.dist-info}/METADATA +14 -14
  78. {manim-0.17.3.dist-info → manim-0.18.0.post0.dist-info}/RECORD +82 -71
  79. {manim-0.17.3.dist-info → manim-0.18.0.post0.dist-info}/WHEEL +1 -1
  80. manim/communitycolors.py +0 -9
  81. manim/utils/color.py +0 -552
  82. {manim-0.17.3.dist-info → manim-0.18.0.post0.dist-info}/LICENSE +0 -0
  83. {manim-0.17.3.dist-info → manim-0.18.0.post0.dist-info}/LICENSE.community +0 -0
  84. {manim-0.17.3.dist-info → manim-0.18.0.post0.dist-info}/entry_points.txt +0 -0
@@ -4,13 +4,17 @@ from __future__ import annotations
4
4
 
5
5
  __all__ = ["SurroundingRectangle", "BackgroundRectangle", "Cross", "Underline"]
6
6
 
7
+ from typing import Any
8
+
9
+ from typing_extensions import Self
10
+
7
11
  from manim import config, logger
8
12
  from manim.constants import *
9
13
  from manim.mobject.geometry.line import Line
10
14
  from manim.mobject.geometry.polygram import RoundedRectangle
11
15
  from manim.mobject.mobject import Mobject
12
16
  from manim.mobject.types.vectorized_mobject import VGroup
13
- from manim.utils.color import BLACK, RED, YELLOW, Color, Colors
17
+ from manim.utils.color import BLACK, RED, YELLOW, ManimColor, ParsableManimColor
14
18
 
15
19
 
16
20
  class SurroundingRectangle(RoundedRectangle):
@@ -38,8 +42,13 @@ class SurroundingRectangle(RoundedRectangle):
38
42
  """
39
43
 
40
44
  def __init__(
41
- self, mobject, color=YELLOW, buff=SMALL_BUFF, corner_radius=0.0, **kwargs
42
- ):
45
+ self,
46
+ mobject: Mobject,
47
+ color: ParsableManimColor = YELLOW,
48
+ buff: float = SMALL_BUFF,
49
+ corner_radius: float = 0.0,
50
+ **kwargs,
51
+ ) -> None:
43
52
  super().__init__(
44
53
  color=color,
45
54
  width=mobject.width + 2 * buff,
@@ -78,8 +87,8 @@ class BackgroundRectangle(SurroundingRectangle):
78
87
 
79
88
  def __init__(
80
89
  self,
81
- mobject,
82
- color: Colors | None = None,
90
+ mobject: Mobject,
91
+ color: ParsableManimColor | None = None,
83
92
  stroke_width: float = 0,
84
93
  stroke_opacity: float = 0,
85
94
  fill_opacity: float = 0.75,
@@ -98,13 +107,13 @@ class BackgroundRectangle(SurroundingRectangle):
98
107
  buff=buff,
99
108
  **kwargs,
100
109
  )
101
- self.original_fill_opacity = self.fill_opacity
110
+ self.original_fill_opacity: float = self.fill_opacity
102
111
 
103
- def pointwise_become_partial(self, mobject, a, b):
112
+ def pointwise_become_partial(self, mobject: Mobject, a: Any, b: float) -> Self:
104
113
  self.set_fill(opacity=b * self.original_fill_opacity)
105
114
  return self
106
115
 
107
- def set_style(self, fill_opacity, **kwargs):
116
+ def set_style(self, fill_opacity: float, **kwargs) -> Self:
108
117
  # Unchangeable style, except for fill_opacity
109
118
  # All other style arguments are ignored
110
119
  super().set_style(
@@ -120,8 +129,8 @@ class BackgroundRectangle(SurroundingRectangle):
120
129
  )
121
130
  return self
122
131
 
123
- def get_fill_color(self):
124
- return Color(self.color)
132
+ def get_fill_color(self) -> ManimColor:
133
+ return self.color
125
134
 
126
135
 
127
136
  class Cross(VGroup):
@@ -152,11 +161,11 @@ class Cross(VGroup):
152
161
  def __init__(
153
162
  self,
154
163
  mobject: Mobject | None = None,
155
- stroke_color: Color = RED,
156
- stroke_width: float = 6,
157
- scale_factor: float = 1,
164
+ stroke_color: ParsableManimColor = RED,
165
+ stroke_width: float = 6.0,
166
+ scale_factor: float = 1.0,
158
167
  **kwargs,
159
- ):
168
+ ) -> None:
160
169
  super().__init__(
161
170
  Line(UP + LEFT, DOWN + RIGHT), Line(UP + RIGHT, DOWN + LEFT), **kwargs
162
171
  )
@@ -181,7 +190,7 @@ class Underline(Line):
181
190
  self.add(man, ul)
182
191
  """
183
192
 
184
- def __init__(self, mobject, buff=SMALL_BUFF, **kwargs):
193
+ def __init__(self, mobject: Mobject, buff: float = SMALL_BUFF, **kwargs) -> None:
185
194
  super().__init__(LEFT, RIGHT, buff=buff, **kwargs)
186
195
  self.match_width(mobject)
187
196
  self.next_to(mobject, DOWN, buff=self.buff)
@@ -13,6 +13,8 @@ __all__ = [
13
13
  "StealthTip",
14
14
  ]
15
15
 
16
+ from typing import TYPE_CHECKING
17
+
16
18
  import numpy as np
17
19
 
18
20
  from manim.constants import *
@@ -22,6 +24,9 @@ from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
22
24
  from manim.mobject.types.vectorized_mobject import VMobject
23
25
  from manim.utils.space_ops import angle_of_vector
24
26
 
27
+ if TYPE_CHECKING:
28
+ from manim.typing import Point3D, Vector
29
+
25
30
 
26
31
  class ArrowTip(VMobject, metaclass=ConvertToOpenGL):
27
32
  r"""Base class for arrow tips.
@@ -76,30 +81,41 @@ class ArrowTip(VMobject, metaclass=ConvertToOpenGL):
76
81
  .. manim:: ArrowTipsShowcase
77
82
  :save_last_frame:
78
83
 
79
- from manim.mobject.geometry.tips import ArrowTriangleTip,\
80
- ArrowSquareTip, ArrowSquareFilledTip,\
81
- ArrowCircleTip, ArrowCircleFilledTip
82
84
  class ArrowTipsShowcase(Scene):
83
85
  def construct(self):
84
- a00 = Arrow(start=[-2, 3, 0], end=[2, 3, 0], color=YELLOW)
85
- a11 = Arrow(start=[-2, 2, 0], end=[2, 2, 0], tip_shape=ArrowTriangleTip)
86
- a12 = Arrow(start=[-2, 1, 0], end=[2, 1, 0])
87
- a21 = Arrow(start=[-2, 0, 0], end=[2, 0, 0], tip_shape=ArrowSquareTip)
88
- a22 = Arrow([-2, -1, 0], [2, -1, 0], tip_shape=ArrowSquareFilledTip)
89
- a31 = Arrow([-2, -2, 0], [2, -2, 0], tip_shape=ArrowCircleTip)
90
- a32 = Arrow([-2, -3, 0], [2, -3, 0], tip_shape=ArrowCircleFilledTip)
91
- b11 = a11.copy().scale(0.5, scale_tips=True).next_to(a11, RIGHT)
92
- b12 = a12.copy().scale(0.5, scale_tips=True).next_to(a12, RIGHT)
93
- b21 = a21.copy().scale(0.5, scale_tips=True).next_to(a21, RIGHT)
94
- self.add(a00, a11, a12, a21, a22, a31, a32, b11, b12, b21)
95
-
86
+ tip_names = [
87
+ 'Default (YELLOW)', 'ArrowTriangleTip', 'Default', 'ArrowSquareTip',
88
+ 'ArrowSquareFilledTip', 'ArrowCircleTip', 'ArrowCircleFilledTip', 'StealthTip'
89
+ ]
90
+
91
+ big_arrows = [
92
+ Arrow(start=[-4, 3.5, 0], end=[2, 3.5, 0], color=YELLOW),
93
+ Arrow(start=[-4, 2.5, 0], end=[2, 2.5, 0], tip_shape=ArrowTriangleTip),
94
+ Arrow(start=[-4, 1.5, 0], end=[2, 1.5, 0]),
95
+ Arrow(start=[-4, 0.5, 0], end=[2, 0.5, 0], tip_shape=ArrowSquareTip),
96
+
97
+ Arrow([-4, -0.5, 0], [2, -0.5, 0], tip_shape=ArrowSquareFilledTip),
98
+ Arrow([-4, -1.5, 0], [2, -1.5, 0], tip_shape=ArrowCircleTip),
99
+ Arrow([-4, -2.5, 0], [2, -2.5, 0], tip_shape=ArrowCircleFilledTip),
100
+ Arrow([-4, -3.5, 0], [2, -3.5, 0], tip_shape=StealthTip)
101
+ ]
102
+
103
+ small_arrows = (
104
+ arrow.copy().scale(0.5, scale_tips=True).next_to(arrow, RIGHT) for arrow in big_arrows
105
+ )
106
+
107
+ labels = (
108
+ Text(tip_names[i], font='monospace', font_size=20, color=BLUE).next_to(big_arrows[i], LEFT) for i in range(len(big_arrows))
109
+ )
110
+
111
+ self.add(*big_arrows, *small_arrows, *labels)
96
112
  """
97
113
 
98
- def __init__(self, *args, **kwargs):
114
+ def __init__(self, *args, **kwargs) -> None:
99
115
  raise NotImplementedError("Has to be implemented in inheriting subclasses.")
100
116
 
101
117
  @property
102
- def base(self):
118
+ def base(self) -> Point3D:
103
119
  r"""The base point of the arrow tip.
104
120
 
105
121
  This is the point connecting to the arrow line.
@@ -117,7 +133,7 @@ class ArrowTip(VMobject, metaclass=ConvertToOpenGL):
117
133
  return self.point_from_proportion(0.5)
118
134
 
119
135
  @property
120
- def tip_point(self):
136
+ def tip_point(self) -> Point3D:
121
137
  r"""The tip point of the arrow tip.
122
138
 
123
139
  Examples
@@ -133,7 +149,7 @@ class ArrowTip(VMobject, metaclass=ConvertToOpenGL):
133
149
  return self.points[0]
134
150
 
135
151
  @property
136
- def vector(self):
152
+ def vector(self) -> Vector:
137
153
  r"""The vector pointing from the base point to the tip point.
138
154
 
139
155
  Examples
@@ -149,7 +165,7 @@ class ArrowTip(VMobject, metaclass=ConvertToOpenGL):
149
165
  return self.tip_point - self.base
150
166
 
151
167
  @property
152
- def tip_angle(self):
168
+ def tip_angle(self) -> float:
153
169
  r"""The angle of the arrow tip.
154
170
 
155
171
  Examples
@@ -165,7 +181,7 @@ class ArrowTip(VMobject, metaclass=ConvertToOpenGL):
165
181
  return angle_of_vector(self.vector)
166
182
 
167
183
  @property
168
- def length(self):
184
+ def length(self) -> np.floating:
169
185
  r"""The length of the arrow tip.
170
186
 
171
187
  Examples
@@ -227,13 +243,13 @@ class ArrowTriangleTip(ArrowTip, Triangle):
227
243
 
228
244
  def __init__(
229
245
  self,
230
- fill_opacity=0,
231
- stroke_width=3,
232
- length=DEFAULT_ARROW_TIP_LENGTH,
233
- width=DEFAULT_ARROW_TIP_LENGTH,
234
- start_angle=PI,
246
+ fill_opacity: float = 0,
247
+ stroke_width: float = 3,
248
+ length: float = DEFAULT_ARROW_TIP_LENGTH,
249
+ width: float = DEFAULT_ARROW_TIP_LENGTH,
250
+ start_angle: float = PI,
235
251
  **kwargs,
236
- ):
252
+ ) -> None:
237
253
  Triangle.__init__(
238
254
  self,
239
255
  fill_opacity=fill_opacity,
@@ -253,7 +269,9 @@ class ArrowTriangleFilledTip(ArrowTriangleTip):
253
269
  This is the default arrow tip shape.
254
270
  """
255
271
 
256
- def __init__(self, fill_opacity=1, stroke_width=0, **kwargs):
272
+ def __init__(
273
+ self, fill_opacity: float = 1, stroke_width: float = 0, **kwargs
274
+ ) -> None:
257
275
  super().__init__(fill_opacity=fill_opacity, stroke_width=stroke_width, **kwargs)
258
276
 
259
277
 
@@ -262,12 +280,12 @@ class ArrowCircleTip(ArrowTip, Circle):
262
280
 
263
281
  def __init__(
264
282
  self,
265
- fill_opacity=0,
266
- stroke_width=3,
267
- length=DEFAULT_ARROW_TIP_LENGTH,
268
- start_angle=PI,
283
+ fill_opacity: float = 0,
284
+ stroke_width: float = 3,
285
+ length: float = DEFAULT_ARROW_TIP_LENGTH,
286
+ start_angle: float = PI,
269
287
  **kwargs,
270
- ):
288
+ ) -> None:
271
289
  self.start_angle = start_angle
272
290
  Circle.__init__(
273
291
  self, fill_opacity=fill_opacity, stroke_width=stroke_width, **kwargs
@@ -279,7 +297,9 @@ class ArrowCircleTip(ArrowTip, Circle):
279
297
  class ArrowCircleFilledTip(ArrowCircleTip):
280
298
  r"""Circular arrow tip with filled tip."""
281
299
 
282
- def __init__(self, fill_opacity=1, stroke_width=0, **kwargs):
300
+ def __init__(
301
+ self, fill_opacity: float = 1, stroke_width: float = 0, **kwargs
302
+ ) -> None:
283
303
  super().__init__(fill_opacity=fill_opacity, stroke_width=stroke_width, **kwargs)
284
304
 
285
305
 
@@ -288,12 +308,12 @@ class ArrowSquareTip(ArrowTip, Square):
288
308
 
289
309
  def __init__(
290
310
  self,
291
- fill_opacity=0,
292
- stroke_width=3,
293
- length=DEFAULT_ARROW_TIP_LENGTH,
294
- start_angle=PI,
311
+ fill_opacity: float = 0,
312
+ stroke_width: float = 3,
313
+ length: float = DEFAULT_ARROW_TIP_LENGTH,
314
+ start_angle: float = PI,
295
315
  **kwargs,
296
- ):
316
+ ) -> None:
297
317
  self.start_angle = start_angle
298
318
  Square.__init__(
299
319
  self,
@@ -309,5 +329,7 @@ class ArrowSquareTip(ArrowTip, Square):
309
329
  class ArrowSquareFilledTip(ArrowSquareTip):
310
330
  r"""Square arrow tip with filled tip."""
311
331
 
312
- def __init__(self, fill_opacity=1, stroke_width=0, **kwargs):
332
+ def __init__(
333
+ self, fill_opacity: float = 1, stroke_width: float = 0, **kwargs
334
+ ) -> None:
313
335
  super().__init__(fill_opacity=fill_opacity, stroke_width=stroke_width, **kwargs)
manim/mobject/graph.py CHANGED
@@ -112,13 +112,12 @@ def _tree_layout(
112
112
  vertex_spacing: tuple | None = None,
113
113
  orientation: str = "down",
114
114
  ):
115
- children = {root_vertex: list(T.neighbors(root_vertex))}
116
-
117
- if not nx.is_tree(T):
118
- raise ValueError("The tree layout must be used with trees")
119
115
  if root_vertex is None:
120
116
  raise ValueError("The tree layout requires the root_vertex parameter")
117
+ if not nx.is_tree(T):
118
+ raise ValueError("The tree layout must be used with trees")
121
119
 
120
+ children = {root_vertex: list(T.neighbors(root_vertex))}
122
121
  # The following code is SageMath's tree layout implementation, taken from
123
122
  # https://github.com/sagemath/sage/blob/cc60cfebc4576fed8b01f0fc487271bdee3cefed/src/sage/graphs/graph_plot.py#L1447
124
123