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
@@ -14,7 +14,6 @@ from math import ceil, floor
14
14
  from typing import Callable, Iterable, Sequence
15
15
 
16
16
  import numpy as np
17
- from colour import Color
18
17
  from PIL import Image
19
18
 
20
19
  from manim.animation.updaters.update import UpdateFromAlphaFunc
@@ -30,7 +29,16 @@ from ..mobject.mobject import Mobject
30
29
  from ..mobject.types.vectorized_mobject import VGroup
31
30
  from ..mobject.utils import get_vectorized_mobject_class
32
31
  from ..utils.bezier import interpolate, inverse_interpolate
33
- from ..utils.color import BLUE_E, GREEN, RED, YELLOW, color_to_rgb, rgb_to_color
32
+ from ..utils.color import (
33
+ BLUE_E,
34
+ GREEN,
35
+ RED,
36
+ YELLOW,
37
+ ManimColor,
38
+ ParsableManimColor,
39
+ color_to_rgb,
40
+ rgb_to_color,
41
+ )
34
42
  from ..utils.rate_functions import ease_out_sine, linear
35
43
  from ..utils.simple_functions import sigmoid
36
44
 
@@ -66,11 +74,11 @@ class VectorField(VGroup):
66
74
  def __init__(
67
75
  self,
68
76
  func: Callable[[np.ndarray], np.ndarray],
69
- color: Color | None = None,
77
+ color: ParsableManimColor | None = None,
70
78
  color_scheme: Callable[[np.ndarray], float] | None = None,
71
79
  min_color_scheme_value: float = 0,
72
80
  max_color_scheme_value: float = 2,
73
- colors: Sequence[Color] = DEFAULT_SCALAR_FIELD_COLORS,
81
+ colors: Sequence[ParsableManimColor] = DEFAULT_SCALAR_FIELD_COLORS,
74
82
  **kwargs,
75
83
  ):
76
84
  super().__init__(**kwargs)
@@ -107,7 +115,7 @@ class VectorField(VGroup):
107
115
  self.pos_to_color = lambda pos: rgb_to_color(self.pos_to_rgb(pos))
108
116
  else:
109
117
  self.single_color = True
110
- self.color = color
118
+ self.color = ManimColor.parse(color)
111
119
  self.submob_movement_updater = None
112
120
 
113
121
  @staticmethod
@@ -409,7 +417,7 @@ class VectorField(VGroup):
409
417
  self,
410
418
  start: float,
411
419
  end: float,
412
- colors: Iterable,
420
+ colors: Iterable[ParsableManimColor],
413
421
  ):
414
422
  """
415
423
  Generates a gradient of rgbas as a numpy array
@@ -533,11 +541,11 @@ class ArrowVectorField(VectorField):
533
541
  def __init__(
534
542
  self,
535
543
  func: Callable[[np.ndarray], np.ndarray],
536
- color: Color | None = None,
544
+ color: ParsableManimColor | None = None,
537
545
  color_scheme: Callable[[np.ndarray], float] | None = None,
538
546
  min_color_scheme_value: float = 0,
539
547
  max_color_scheme_value: float = 2,
540
- colors: Sequence[Color] = DEFAULT_SCALAR_FIELD_COLORS,
548
+ colors: Sequence[ParsableManimColor] = DEFAULT_SCALAR_FIELD_COLORS,
541
549
  # Determining Vector positions:
542
550
  x_range: Sequence[float] = None,
543
551
  y_range: Sequence[float] = None,
@@ -613,7 +621,7 @@ class ArrowVectorField(VectorField):
613
621
  The root point of the vector.
614
622
 
615
623
  """
616
- output = np.asarray(self.func(point))
624
+ output = np.array(self.func(point))
617
625
  norm = np.linalg.norm(output)
618
626
  if norm != 0:
619
627
  output *= self.length_func(norm) / norm
@@ -707,11 +715,11 @@ class StreamLines(VectorField):
707
715
  def __init__(
708
716
  self,
709
717
  func: Callable[[np.ndarray], np.ndarray],
710
- color: Color | None = None,
718
+ color: ParsableManimColor | None = None,
711
719
  color_scheme: Callable[[np.ndarray], float] | None = None,
712
720
  min_color_scheme_value: float = 0,
713
721
  max_color_scheme_value: float = 2,
714
- colors: Sequence[Color] = DEFAULT_SCALAR_FIELD_COLORS,
722
+ colors: Sequence[ParsableManimColor] = DEFAULT_SCALAR_FIELD_COLORS,
715
723
  # Determining stream line starting positions:
716
724
  x_range: Sequence[float] = None,
717
725
  y_range: Sequence[float] = None,
@@ -9,7 +9,7 @@ from .. import config, logger
9
9
  __all__ = []
10
10
 
11
11
 
12
- plugins_requested: list = config["plugins"]
12
+ plugins_requested: list[str] = config["plugins"]
13
13
  if "" in plugins_requested:
14
14
  plugins_requested.remove("")
15
15
  for plugin in pkg_resources.iter_entry_points("manim.plugins"):
@@ -1,9 +1,4 @@
1
- """
2
- plugins_flags.py
3
- ------------
4
-
5
- Plugin Managing Utility.
6
- """
1
+ """Plugin Managing Utility"""
7
2
 
8
3
  from __future__ import annotations
9
4
 
manim/renderer/shader.py CHANGED
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import inspect
3
4
  import re
4
5
  import textwrap
5
6
  from pathlib import Path
@@ -9,7 +10,6 @@ import numpy as np
9
10
 
10
11
  from .. import config
11
12
  from ..utils import opengl
12
- from ..utils.simple_functions import get_parameters
13
13
 
14
14
  SHADER_FOLDER = Path(__file__).parent / "shaders"
15
15
  shader_program_cache: dict = {}
@@ -199,7 +199,7 @@ class Object3D:
199
199
  return self.time_based_updaters + self.non_time_updaters
200
200
 
201
201
  def add_updater(self, update_function, index=None, call_updater=True):
202
- if "dt" in get_parameters(update_function):
202
+ if "dt" in inspect.signature(update_function).parameters:
203
203
  updater_list = self.time_based_updaters
204
204
  else:
205
205
  updater_list = self.non_time_updaters
manim/scene/scene.py CHANGED
@@ -385,10 +385,8 @@ class Scene:
385
385
  or self.updaters
386
386
  or wait_animation.stop_condition is not None
387
387
  or any(
388
- [
389
- mob.has_time_based_updater()
390
- for mob in self.get_mobject_family_members()
391
- ],
388
+ mob.has_time_based_updater()
389
+ for mob in self.get_mobject_family_members()
392
390
  )
393
391
  )
394
392
  wait_animation.is_static_wait = not should_update
@@ -1319,12 +1317,20 @@ class Scene:
1319
1317
  # Allow for calling scene methods without prepending 'self.'.
1320
1318
  local_namespace[method] = embedded_method
1321
1319
 
1320
+ from sqlite3 import connect
1321
+
1322
+ from IPython.core.getipython import get_ipython
1322
1323
  from IPython.terminal.embed import InteractiveShellEmbed
1323
1324
  from traitlets.config import Config
1324
1325
 
1325
1326
  cfg = Config()
1326
1327
  cfg.TerminalInteractiveShell.confirm_exit = False
1327
- shell = InteractiveShellEmbed(config=cfg)
1328
+ if get_ipython() is None:
1329
+ shell = InteractiveShellEmbed.instance(config=cfg)
1330
+ else:
1331
+ shell = InteractiveShellEmbed(config=cfg)
1332
+ hist = get_ipython().history_manager
1333
+ hist.db = connect(hist.hist_file, check_same_thread=False)
1328
1334
 
1329
1335
  keyboard_thread = threading.Thread(
1330
1336
  target=ipython,
@@ -1524,8 +1530,10 @@ class Scene:
1524
1530
  subtitle = srt.Subtitle(
1525
1531
  index=len(self.renderer.file_writer.subcaptions),
1526
1532
  content=content,
1527
- start=datetime.timedelta(seconds=self.renderer.time + offset),
1528
- end=datetime.timedelta(seconds=self.renderer.time + offset + duration),
1533
+ start=datetime.timedelta(seconds=float(self.renderer.time + offset)),
1534
+ end=datetime.timedelta(
1535
+ seconds=float(self.renderer.time + offset + duration)
1536
+ ),
1529
1537
  )
1530
1538
  self.renderer.file_writer.subcaptions.append(subtitle)
1531
1539
 
@@ -700,9 +700,8 @@ class SceneFileWriter:
700
700
  )
701
701
  oldest_files_to_delete = sorted(
702
702
  cached_partial_movies,
703
- key=os.path.getatime,
703
+ key=lambda path: path.stat().st_atime,
704
704
  )[:number_files_to_delete]
705
- # oldest_file_path = min(cached_partial_movies, key=os.path.getatime)
706
705
  for file_to_delete in oldest_files_to_delete:
707
706
  file_to_delete.unlink()
708
707
  logger.info(
@@ -329,7 +329,7 @@ class ThreeDScene(Scene):
329
329
  camera_mobjects = self.renderer.camera.get_value_trackers() + [
330
330
  self.renderer.camera._frame_center,
331
331
  ]
332
- if any([cm in moving_mobjects for cm in camera_mobjects]):
332
+ if any(cm in moving_mobjects for cm in camera_mobjects):
333
333
  return self.mobjects
334
334
  return moving_mobjects
335
335
 
@@ -7,7 +7,6 @@ __all__ = ["VectorScene", "LinearTransformationScene"]
7
7
  from typing import Callable
8
8
 
9
9
  import numpy as np
10
- from colour import Color
11
10
 
12
11
  from manim.mobject.geometry.arc import Dot
13
12
  from manim.mobject.geometry.line import Arrow, Line, Vector
@@ -28,7 +27,17 @@ from ..mobject.matrix import Matrix
28
27
  from ..mobject.mobject import Mobject
29
28
  from ..mobject.types.vectorized_mobject import VGroup, VMobject
30
29
  from ..scene.scene import Scene
31
- from ..utils.color import BLUE_D, GREEN_C, GREY, RED_C, WHITE, YELLOW
30
+ from ..utils.color import (
31
+ BLACK,
32
+ BLUE_D,
33
+ GREEN_C,
34
+ GREY,
35
+ RED_C,
36
+ WHITE,
37
+ YELLOW,
38
+ ManimColor,
39
+ ParsableManimColor,
40
+ )
32
41
  from ..utils.rate_functions import rush_from, rush_into
33
42
  from ..utils.space_ops import angle_of_vector
34
43
 
@@ -558,11 +567,12 @@ class LinearTransformationScene(VectorScene):
558
567
  .. manim:: LinearTransformationSceneExample
559
568
 
560
569
  class LinearTransformationSceneExample(LinearTransformationScene):
561
- def __init__(self):
570
+ def __init__(self, **kwargs):
562
571
  LinearTransformationScene.__init__(
563
572
  self,
564
573
  show_coordinates=True,
565
574
  leave_ghost_vectors=True,
575
+ *kwargs
566
576
  )
567
577
 
568
578
  def construct(self):
@@ -580,8 +590,8 @@ class LinearTransformationScene(VectorScene):
580
590
  show_coordinates: bool = False,
581
591
  show_basis_vectors: bool = True,
582
592
  basis_vector_stroke_width: float = 6,
583
- i_hat_color: Color = X_COLOR,
584
- j_hat_color: Color = Y_COLOR,
593
+ i_hat_color: ParsableManimColor = X_COLOR,
594
+ j_hat_color: ParsableManimColor = Y_COLOR,
585
595
  leave_ghost_vectors: bool = False,
586
596
  **kwargs,
587
597
  ):
@@ -592,8 +602,8 @@ class LinearTransformationScene(VectorScene):
592
602
  self.show_coordinates = show_coordinates
593
603
  self.show_basis_vectors = show_basis_vectors
594
604
  self.basis_vector_stroke_width = basis_vector_stroke_width
595
- self.i_hat_color = i_hat_color
596
- self.j_hat_color = j_hat_color
605
+ self.i_hat_color = ManimColor(i_hat_color)
606
+ self.j_hat_color = ManimColor(j_hat_color)
597
607
  self.leave_ghost_vectors = leave_ghost_vectors
598
608
  self.background_plane_kwargs = {
599
609
  "color": GREY,
manim/typing.py ADDED
@@ -0,0 +1,133 @@
1
+ from __future__ import annotations
2
+
3
+ from os import PathLike
4
+ from typing import Callable, Tuple, Union
5
+
6
+ import numpy as np
7
+ import numpy.typing as npt
8
+ from typing_extensions import TypeAlias
9
+
10
+ # Color Types
11
+
12
+ ManimFloat: TypeAlias = np.float64
13
+ ManimInt: TypeAlias = np.int64
14
+ ManimColorDType: TypeAlias = ManimFloat
15
+
16
+ RGB_Array_Float: TypeAlias = npt.NDArray[ManimFloat]
17
+ RGB_Tuple_Float: TypeAlias = Tuple[float, float, float]
18
+
19
+ RGB_Array_Int: TypeAlias = npt.NDArray[ManimInt]
20
+ RGB_Tuple_Int: TypeAlias = Tuple[int, int, int]
21
+
22
+ RGBA_Array_Float: TypeAlias = npt.NDArray[ManimFloat]
23
+ RGBA_Tuple_Float: TypeAlias = Tuple[float, float, float, float]
24
+
25
+ RGBA_Array_Int: TypeAlias = npt.NDArray[ManimInt]
26
+ RGBA_Tuple_Int: TypeAlias = Tuple[int, int, int, int]
27
+
28
+ HSV_Array_Float: TypeAlias = RGB_Array_Float
29
+ HSV_Tuple_Float: TypeAlias = RGB_Tuple_Float
30
+
31
+ ManimColorInternal: TypeAlias = npt.NDArray[ManimColorDType]
32
+
33
+ # Point Types
34
+
35
+ PointDType: TypeAlias = ManimFloat
36
+ """ DType for all points. """
37
+
38
+ InternalPoint2D: TypeAlias = npt.NDArray[PointDType]
39
+ """ `shape: (2,)` A 2D point. `[float, float]`.
40
+ This type alias is mostly made available for internal use and only includes the numpy type.
41
+ """
42
+
43
+ Point2D: TypeAlias = Union[InternalPoint2D, Tuple[float, float]]
44
+ """ `shape: (2,)` A 2D point. `[float, float]`. """
45
+
46
+ InternalPoint3D: TypeAlias = npt.NDArray[PointDType]
47
+ """ `shape: (3,)` A 3D point. `[float, float, float]`.
48
+ This type alias is mostly made available for internal use and only includes the numpy type.
49
+ """
50
+
51
+ Point3D: TypeAlias = Union[InternalPoint3D, Tuple[float, float, float]]
52
+ """ `shape: (3,)` A 3D point. `[float, float, float]` """
53
+
54
+ # Bezier Types
55
+ QuadraticBezierPoints: TypeAlias = npt.NDArray[PointDType]
56
+ """ `shape: (3,3)` An Array of Quadratic Bezier Handles `[[float, float, float], [float, float, float], [float, float, float]]`. """
57
+
58
+ QuadraticBezierPoints_Array: TypeAlias = npt.NDArray[PointDType]
59
+ """ `shape: (N,3,3)` An Array of Quadratic Bezier Handles `[[[float, float, float], [float, float, float], [float, float, float]], ...]`. """
60
+
61
+ CubicBezierPoints: TypeAlias = npt.NDArray[PointDType]
62
+ """ `shape: (4,3)` An Array of Cubic Bezier Handles `[[float, float, float], [float, float, float], [float, float, float], [float, float, float]]`. """
63
+
64
+ BezierPoints: TypeAlias = npt.NDArray[PointDType]
65
+ """ `shape: (N,3)` An Array of Cubic Bezier Handles `[[float, float, float], ...]`.
66
+ `N` Is always multiples of the degree of the Bezier curve.
67
+ (Please refer to the documentation of the function you are using for further type Information)
68
+ """
69
+
70
+ FlatBezierPoints: TypeAlias = npt.NDArray[PointDType]
71
+ """ `shape: (N)` An Array of Bezier Handles but flattened `[float, ...]`."""
72
+
73
+ Point2D_Array: TypeAlias = npt.NDArray[PointDType]
74
+ """ `shape: (N,2)` An Array of Points in 2D Space `[[float, float], ...]`.
75
+
76
+ (Please refer to the documentation of the function you are using for further type Information)
77
+ """
78
+
79
+ InternalPoint3D_Array: TypeAlias = npt.NDArray[PointDType]
80
+ """ `shape: (N,3)` An Array of Points in 3D Space `[[float, float, float], ...]`.
81
+ This type alias is mostly made available for internal use and only includes the numpy type.
82
+ """
83
+
84
+ Point3D_Array: TypeAlias = Union[
85
+ InternalPoint3D_Array, Tuple[Tuple[float, float, float], ...]
86
+ ]
87
+ """ `shape: (N,3)` An Array of Points in 3D Space `[[float, float, float], ...]`.
88
+
89
+ (Please refer to the documentation of the function you are using for further type Information)
90
+ """
91
+
92
+ BezierPoints_Array: TypeAlias = npt.NDArray[PointDType]
93
+ """ `shape: (N,PPC,3)` An Array of Bezier Handles `[[[float, float, float], ...], ...]`.
94
+ `PPC` Is the number of points per bezier curve. `N` Is the number of bezier curves.
95
+ (Please refer to the documentation of the function you are using for further type Information)
96
+ """
97
+
98
+ # Vector Types
99
+ Vector3: TypeAlias = npt.NDArray[PointDType]
100
+ """ `shape: (3,)` A Vector `[float, float, float]`. """
101
+
102
+ Vector: TypeAlias = npt.NDArray[PointDType]
103
+ """ `shape: (N,)` A Vector `[float, ...]`. """
104
+
105
+ RowVector: TypeAlias = npt.NDArray[PointDType]
106
+ """ `shape: (1,N)` A Row Vector `[[float, ...]]`. """
107
+
108
+ ColVector: TypeAlias = npt.NDArray[PointDType]
109
+ """ `shape: (N,1)` A Column Vector `[[float], [float], ...]`. """
110
+
111
+ MatrixMN: TypeAlias = npt.NDArray[PointDType]
112
+ """ `shape: (M,N)` A Matrix `[[float, ...], [float, ...], ...]`. """
113
+
114
+ Zeros: TypeAlias = npt.NDArray[ManimFloat]
115
+ """A Matrix of Zeros. Typically created with `numpy.zeros((M,N))`"""
116
+
117
+ # Due to current limitations (see https://github.com/python/mypy/issues/14656 / 8263), we don't specify the first argument type (Mobject).
118
+ FunctionOverride: TypeAlias = Callable[..., None]
119
+ """Function type returning an animation for the specified Mobject."""
120
+
121
+
122
+ # Misc
123
+ PathFuncType: TypeAlias = Callable[[Point3D, Point3D, float], Point3D]
124
+ """Function mapping two points and an alpha value to a new point"""
125
+
126
+ MappingFunction: TypeAlias = Callable[[Point3D], Point3D]
127
+ """A function mapping a Point3D to another Point3D"""
128
+
129
+ Image: TypeAlias = np.ndarray
130
+ """An Image"""
131
+
132
+ StrPath: TypeAlias = "str | PathLike[str]"
133
+ StrOrBytesPath: TypeAlias = "str | bytes | PathLike[str] | PathLike[bytes]"