manim 0.18.1__py3-none-any.whl → 0.19.0__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.
- manim/__main__.py +45 -12
- manim/_config/__init__.py +2 -2
- manim/_config/cli_colors.py +8 -4
- manim/_config/default.cfg +0 -2
- manim/_config/logger_utils.py +5 -0
- manim/_config/utils.py +29 -38
- manim/animation/animation.py +148 -8
- manim/animation/composition.py +16 -13
- manim/animation/creation.py +184 -8
- manim/animation/fading.py +5 -8
- manim/animation/indication.py +93 -26
- manim/animation/movement.py +21 -3
- manim/animation/rotation.py +2 -1
- manim/animation/specialized.py +3 -5
- manim/animation/speedmodifier.py +3 -3
- manim/animation/transform.py +4 -5
- manim/animation/updaters/mobject_update_utils.py +17 -14
- manim/camera/camera.py +2 -2
- manim/cli/__init__.py +17 -0
- manim/cli/cfg/group.py +52 -36
- manim/cli/checkhealth/checks.py +92 -76
- manim/cli/checkhealth/commands.py +12 -5
- manim/cli/default_group.py +148 -24
- manim/cli/init/commands.py +28 -23
- manim/cli/plugins/commands.py +13 -3
- manim/cli/render/commands.py +47 -42
- manim/cli/render/global_options.py +43 -9
- manim/cli/render/render_options.py +84 -19
- manim/constants.py +11 -4
- manim/mobject/frame.py +0 -1
- manim/mobject/geometry/arc.py +109 -75
- manim/mobject/geometry/boolean_ops.py +20 -17
- manim/mobject/geometry/labeled.py +300 -77
- manim/mobject/geometry/line.py +120 -60
- manim/mobject/geometry/polygram.py +109 -25
- manim/mobject/geometry/shape_matchers.py +35 -15
- manim/mobject/geometry/tips.py +36 -27
- manim/mobject/graph.py +48 -40
- manim/mobject/graphing/coordinate_systems.py +110 -45
- manim/mobject/graphing/functions.py +16 -10
- manim/mobject/graphing/number_line.py +23 -9
- manim/mobject/graphing/probability.py +2 -10
- manim/mobject/graphing/scale.py +6 -5
- manim/mobject/matrix.py +17 -19
- manim/mobject/mobject.py +149 -103
- manim/mobject/opengl/opengl_geometry.py +4 -8
- manim/mobject/opengl/opengl_mobject.py +506 -343
- manim/mobject/opengl/opengl_point_cloud_mobject.py +3 -7
- manim/mobject/opengl/opengl_surface.py +1 -2
- manim/mobject/opengl/opengl_vectorized_mobject.py +27 -65
- manim/mobject/svg/brace.py +61 -13
- manim/mobject/svg/svg_mobject.py +2 -1
- manim/mobject/table.py +11 -12
- manim/mobject/text/code_mobject.py +186 -550
- manim/mobject/text/numbers.py +7 -7
- manim/mobject/text/tex_mobject.py +22 -13
- manim/mobject/text/text_mobject.py +29 -20
- manim/mobject/three_d/polyhedra.py +98 -1
- manim/mobject/three_d/three_dimensions.py +59 -31
- manim/mobject/types/image_mobject.py +37 -23
- manim/mobject/types/point_cloud_mobject.py +103 -67
- manim/mobject/types/vectorized_mobject.py +387 -214
- manim/mobject/value_tracker.py +2 -1
- manim/mobject/vector_field.py +2 -4
- manim/opengl/__init__.py +3 -3
- manim/plugins/__init__.py +2 -3
- manim/plugins/plugins_flags.py +3 -3
- manim/renderer/cairo_renderer.py +11 -11
- manim/renderer/opengl_renderer.py +19 -20
- manim/renderer/shader.py +2 -3
- manim/renderer/shader_wrapper.py +3 -2
- manim/scene/moving_camera_scene.py +23 -0
- manim/scene/scene.py +72 -41
- manim/scene/scene_file_writer.py +313 -164
- manim/scene/section.py +15 -15
- manim/scene/three_d_scene.py +8 -15
- manim/scene/vector_space_scene.py +3 -6
- manim/typing.py +326 -66
- manim/utils/bezier.py +1658 -381
- manim/utils/caching.py +11 -5
- manim/utils/color/AS2700.py +2 -0
- manim/utils/color/BS381.py +2 -0
- manim/utils/color/DVIPSNAMES.py +96 -0
- manim/utils/color/SVGNAMES.py +179 -0
- manim/utils/color/X11.py +3 -0
- manim/utils/color/XKCD.py +2 -0
- manim/utils/color/__init__.py +8 -5
- manim/utils/color/core.py +818 -301
- manim/utils/color/manim_colors.py +7 -9
- manim/utils/commands.py +40 -19
- manim/utils/config_ops.py +18 -13
- manim/utils/debug.py +8 -6
- manim/utils/deprecation.py +92 -43
- manim/utils/docbuild/autoaliasattr_directive.py +45 -8
- manim/utils/docbuild/autocolor_directive.py +12 -13
- manim/utils/docbuild/manim_directive.py +35 -29
- manim/utils/docbuild/module_parsing.py +74 -27
- manim/utils/family.py +3 -3
- manim/utils/family_ops.py +12 -4
- manim/utils/file_ops.py +22 -16
- manim/utils/hashing.py +7 -7
- manim/utils/images.py +10 -4
- manim/utils/ipython_magic.py +12 -8
- manim/utils/iterables.py +161 -119
- manim/utils/module_ops.py +55 -19
- manim/utils/opengl.py +68 -23
- manim/utils/parameter_parsing.py +3 -2
- manim/utils/paths.py +11 -5
- manim/utils/polylabel.py +168 -0
- manim/utils/qhull.py +218 -0
- manim/utils/rate_functions.py +69 -32
- manim/utils/simple_functions.py +24 -15
- manim/utils/sounds.py +7 -1
- manim/utils/space_ops.py +48 -37
- manim/utils/testing/_frames_testers.py +13 -8
- manim/utils/testing/_show_diff.py +5 -3
- manim/utils/testing/_test_class_makers.py +33 -18
- manim/utils/testing/frames_comparison.py +20 -14
- manim/utils/tex.py +4 -2
- manim/utils/tex_file_writing.py +45 -45
- manim/utils/tex_templates.py +1 -1
- manim/utils/unit.py +6 -5
- {manim-0.18.1.dist-info → manim-0.19.0.dist-info}/METADATA +16 -9
- manim-0.19.0.dist-info/RECORD +221 -0
- {manim-0.18.1.dist-info → manim-0.19.0.dist-info}/WHEEL +1 -1
- manim-0.18.1.dist-info/RECORD +0 -217
- {manim-0.18.1.dist-info → manim-0.19.0.dist-info}/LICENSE +0 -0
- {manim-0.18.1.dist-info → manim-0.19.0.dist-info}/LICENSE.community +0 -0
- {manim-0.18.1.dist-info → manim-0.19.0.dist-info}/entry_points.txt +0 -0
manim/mobject/graph.py
CHANGED
|
@@ -8,8 +8,9 @@ __all__ = [
|
|
|
8
8
|
]
|
|
9
9
|
|
|
10
10
|
import itertools as it
|
|
11
|
+
from collections.abc import Hashable, Iterable, Sequence
|
|
11
12
|
from copy import copy
|
|
12
|
-
from typing import TYPE_CHECKING, Any,
|
|
13
|
+
from typing import TYPE_CHECKING, Any, Literal, Protocol, cast
|
|
13
14
|
|
|
14
15
|
import networkx as nx
|
|
15
16
|
import numpy as np
|
|
@@ -17,7 +18,8 @@ import numpy as np
|
|
|
17
18
|
if TYPE_CHECKING:
|
|
18
19
|
from typing_extensions import TypeAlias
|
|
19
20
|
|
|
20
|
-
from manim.
|
|
21
|
+
from manim.scene.scene import Scene
|
|
22
|
+
from manim.typing import Point3D, Point3DLike
|
|
21
23
|
|
|
22
24
|
NxGraph: TypeAlias = nx.classes.graph.Graph | nx.classes.digraph.DiGraph
|
|
23
25
|
|
|
@@ -266,9 +268,9 @@ class LayoutFunction(Protocol):
|
|
|
266
268
|
|
|
267
269
|
Parameters
|
|
268
270
|
----------
|
|
269
|
-
graph
|
|
271
|
+
graph
|
|
270
272
|
The underlying NetworkX graph to be laid out. DO NOT MODIFY.
|
|
271
|
-
scale
|
|
273
|
+
scale
|
|
272
274
|
Either a single float value, or a tuple of three float values specifying the scale along each axis.
|
|
273
275
|
|
|
274
276
|
Returns
|
|
@@ -282,7 +284,7 @@ class LayoutFunction(Protocol):
|
|
|
282
284
|
def _partite_layout(
|
|
283
285
|
nx_graph: NxGraph,
|
|
284
286
|
scale: float = 2,
|
|
285
|
-
partitions:
|
|
287
|
+
partitions: Sequence[Sequence[Hashable]] | None = None,
|
|
286
288
|
**kwargs: Any,
|
|
287
289
|
) -> dict[Hashable, Point3D]:
|
|
288
290
|
if partitions is None or len(partitions) == 0:
|
|
@@ -336,10 +338,7 @@ def _tree_layout(
|
|
|
336
338
|
parent = {u: root_vertex for u in children[root_vertex]}
|
|
337
339
|
pos = {}
|
|
338
340
|
obstruction = [0.0] * len(T)
|
|
339
|
-
if orientation == "down"
|
|
340
|
-
o = -1
|
|
341
|
-
else:
|
|
342
|
-
o = 1
|
|
341
|
+
o = -1 if orientation == "down" else 1
|
|
343
342
|
|
|
344
343
|
def slide(v, dx):
|
|
345
344
|
"""
|
|
@@ -402,15 +401,9 @@ def _tree_layout(
|
|
|
402
401
|
if isinstance(scale, (float, int)) and (width > 0 or height > 0):
|
|
403
402
|
sf = 2 * scale / max(width, height)
|
|
404
403
|
elif isinstance(scale, tuple):
|
|
405
|
-
if scale[0] is not None and width > 0
|
|
406
|
-
sw = 2 * scale[0] / width
|
|
407
|
-
else:
|
|
408
|
-
sw = 1
|
|
404
|
+
sw = 2 * scale[0] / width if scale[0] is not None and width > 0 else 1
|
|
409
405
|
|
|
410
|
-
if scale[1] is not None and height > 0
|
|
411
|
-
sh = 2 * scale[1] / height
|
|
412
|
-
else:
|
|
413
|
-
sh = 1
|
|
406
|
+
sh = 2 * scale[1] / height if scale[1] is not None and height > 0 else 1
|
|
414
407
|
|
|
415
408
|
sf = np.array([sw, sh, 0])
|
|
416
409
|
else:
|
|
@@ -450,10 +443,10 @@ _layouts: dict[LayoutName, LayoutFunction] = {
|
|
|
450
443
|
|
|
451
444
|
def _determine_graph_layout(
|
|
452
445
|
nx_graph: nx.classes.graph.Graph | nx.classes.digraph.DiGraph,
|
|
453
|
-
layout: LayoutName | dict[Hashable,
|
|
446
|
+
layout: LayoutName | dict[Hashable, Point3DLike] | LayoutFunction = "spring",
|
|
454
447
|
layout_scale: float | tuple[float, float, float] = 2,
|
|
455
448
|
layout_config: dict[str, Any] | None = None,
|
|
456
|
-
) -> dict[Hashable,
|
|
449
|
+
) -> dict[Hashable, Point3DLike]:
|
|
457
450
|
if layout_config is None:
|
|
458
451
|
layout_config = {}
|
|
459
452
|
|
|
@@ -480,7 +473,7 @@ def _determine_graph_layout(
|
|
|
480
473
|
raise ValueError(
|
|
481
474
|
f"The layout '{layout}' is neither a recognized layout, a layout function,"
|
|
482
475
|
"nor a vertex placement dictionary.",
|
|
483
|
-
)
|
|
476
|
+
) from e
|
|
484
477
|
|
|
485
478
|
|
|
486
479
|
class GenericGraph(VMobject, metaclass=ConvertToOpenGL):
|
|
@@ -559,6 +552,7 @@ class GenericGraph(VMobject, metaclass=ConvertToOpenGL):
|
|
|
559
552
|
all other configuration options for a vertex.
|
|
560
553
|
edge_type
|
|
561
554
|
The mobject class used for displaying edges in the scene.
|
|
555
|
+
Must be a subclass of :class:`~.Line` for default updaters to work.
|
|
562
556
|
edge_config
|
|
563
557
|
Either a dictionary containing keyword arguments to be passed
|
|
564
558
|
to the class specified via ``edge_type``, or a dictionary whose
|
|
@@ -568,18 +562,18 @@ class GenericGraph(VMobject, metaclass=ConvertToOpenGL):
|
|
|
568
562
|
|
|
569
563
|
def __init__(
|
|
570
564
|
self,
|
|
571
|
-
vertices:
|
|
572
|
-
edges:
|
|
565
|
+
vertices: Sequence[Hashable],
|
|
566
|
+
edges: Sequence[tuple[Hashable, Hashable]],
|
|
573
567
|
labels: bool | dict = False,
|
|
574
568
|
label_fill_color: str = BLACK,
|
|
575
|
-
layout: LayoutName | dict[Hashable,
|
|
569
|
+
layout: LayoutName | dict[Hashable, Point3DLike] | LayoutFunction = "spring",
|
|
576
570
|
layout_scale: float | tuple[float, float, float] = 2,
|
|
577
571
|
layout_config: dict | None = None,
|
|
578
572
|
vertex_type: type[Mobject] = Dot,
|
|
579
573
|
vertex_config: dict | None = None,
|
|
580
574
|
vertex_mobjects: dict | None = None,
|
|
581
575
|
edge_type: type[Mobject] = Line,
|
|
582
|
-
partitions:
|
|
576
|
+
partitions: Sequence[Sequence[Hashable]] | None = None,
|
|
583
577
|
root_vertex: Hashable | None = None,
|
|
584
578
|
edge_config: dict | None = None,
|
|
585
579
|
) -> None:
|
|
@@ -683,15 +677,16 @@ class GenericGraph(VMobject, metaclass=ConvertToOpenGL):
|
|
|
683
677
|
def _create_vertex(
|
|
684
678
|
self,
|
|
685
679
|
vertex: Hashable,
|
|
686
|
-
position:
|
|
680
|
+
position: Point3DLike | None = None,
|
|
687
681
|
label: bool = False,
|
|
688
682
|
label_fill_color: str = BLACK,
|
|
689
683
|
vertex_type: type[Mobject] = Dot,
|
|
690
684
|
vertex_config: dict | None = None,
|
|
691
685
|
vertex_mobject: dict | None = None,
|
|
692
686
|
) -> tuple[Hashable, Point3D, dict, Mobject]:
|
|
693
|
-
|
|
694
|
-
position
|
|
687
|
+
np_position: Point3D = (
|
|
688
|
+
self.get_center() if position is None else np.asarray(position)
|
|
689
|
+
)
|
|
695
690
|
|
|
696
691
|
if vertex_config is None:
|
|
697
692
|
vertex_config = {}
|
|
@@ -720,14 +715,14 @@ class GenericGraph(VMobject, metaclass=ConvertToOpenGL):
|
|
|
720
715
|
if vertex_mobject is None:
|
|
721
716
|
vertex_mobject = vertex_type(**vertex_config)
|
|
722
717
|
|
|
723
|
-
vertex_mobject.move_to(
|
|
718
|
+
vertex_mobject.move_to(np_position)
|
|
724
719
|
|
|
725
|
-
return (vertex,
|
|
720
|
+
return (vertex, np_position, vertex_config, vertex_mobject)
|
|
726
721
|
|
|
727
722
|
def _add_created_vertex(
|
|
728
723
|
self,
|
|
729
724
|
vertex: Hashable,
|
|
730
|
-
position:
|
|
725
|
+
position: Point3DLike,
|
|
731
726
|
vertex_config: dict,
|
|
732
727
|
vertex_mobject: Mobject,
|
|
733
728
|
) -> Mobject:
|
|
@@ -753,7 +748,7 @@ class GenericGraph(VMobject, metaclass=ConvertToOpenGL):
|
|
|
753
748
|
def _add_vertex(
|
|
754
749
|
self,
|
|
755
750
|
vertex: Hashable,
|
|
756
|
-
position:
|
|
751
|
+
position: Point3DLike | None = None,
|
|
757
752
|
label: bool = False,
|
|
758
753
|
label_fill_color: str = BLACK,
|
|
759
754
|
vertex_type: type[Mobject] = Dot,
|
|
@@ -823,7 +818,7 @@ class GenericGraph(VMobject, metaclass=ConvertToOpenGL):
|
|
|
823
818
|
labels = {v: labels for v in vertices}
|
|
824
819
|
else:
|
|
825
820
|
assert isinstance(labels, dict)
|
|
826
|
-
base_labels =
|
|
821
|
+
base_labels = dict.fromkeys(vertices, False)
|
|
827
822
|
base_labels.update(labels)
|
|
828
823
|
labels = base_labels
|
|
829
824
|
|
|
@@ -848,7 +843,7 @@ class GenericGraph(VMobject, metaclass=ConvertToOpenGL):
|
|
|
848
843
|
label_fill_color=label_fill_color,
|
|
849
844
|
vertex_type=vertex_type,
|
|
850
845
|
vertex_config=vertex_config[v],
|
|
851
|
-
vertex_mobject=vertex_mobjects
|
|
846
|
+
vertex_mobject=vertex_mobjects.get(v),
|
|
852
847
|
)
|
|
853
848
|
for v in vertices
|
|
854
849
|
]
|
|
@@ -1212,7 +1207,7 @@ class GenericGraph(VMobject, metaclass=ConvertToOpenGL):
|
|
|
1212
1207
|
|
|
1213
1208
|
def change_layout(
|
|
1214
1209
|
self,
|
|
1215
|
-
layout: LayoutName | dict[Hashable,
|
|
1210
|
+
layout: LayoutName | dict[Hashable, Point3DLike] | LayoutFunction = "spring",
|
|
1216
1211
|
layout_scale: float | tuple[float, float, float] = 2,
|
|
1217
1212
|
layout_config: dict[str, Any] | None = None,
|
|
1218
1213
|
partitions: list[list[Hashable]] | None = None,
|
|
@@ -1506,13 +1501,16 @@ class Graph(GenericGraph):
|
|
|
1506
1501
|
VERTEX_CONF = {"radius": 0.25, "color": BLUE_B, "fill_opacity": 1}
|
|
1507
1502
|
|
|
1508
1503
|
def expand_vertex(self, g, vertex_id: str, depth: int):
|
|
1509
|
-
new_vertices = [
|
|
1504
|
+
new_vertices = [
|
|
1505
|
+
f"{vertex_id}/{i}" for i in range(self.CHILDREN_PER_VERTEX)
|
|
1506
|
+
]
|
|
1510
1507
|
new_edges = [(vertex_id, child_id) for child_id in new_vertices]
|
|
1511
1508
|
g.add_edges(
|
|
1512
1509
|
*new_edges,
|
|
1513
1510
|
vertex_config=self.VERTEX_CONF,
|
|
1514
1511
|
positions={
|
|
1515
|
-
k: g.vertices[vertex_id].get_center() + 0.1 * DOWN
|
|
1512
|
+
k: g.vertices[vertex_id].get_center() + 0.1 * DOWN
|
|
1513
|
+
for k in new_vertices
|
|
1516
1514
|
},
|
|
1517
1515
|
)
|
|
1518
1516
|
if depth < self.DEPTH:
|
|
@@ -1556,7 +1554,12 @@ class Graph(GenericGraph):
|
|
|
1556
1554
|
def update_edges(self, graph):
|
|
1557
1555
|
for (u, v), edge in graph.edges.items():
|
|
1558
1556
|
# Undirected graph has a Line edge
|
|
1559
|
-
edge.
|
|
1557
|
+
edge.set_points_by_ends(
|
|
1558
|
+
graph[u].get_center(),
|
|
1559
|
+
graph[v].get_center(),
|
|
1560
|
+
buff=self._edge_config.get("buff", 0),
|
|
1561
|
+
path_arc=self._edge_config.get("path_arc", 0),
|
|
1562
|
+
)
|
|
1560
1563
|
|
|
1561
1564
|
def __repr__(self: Graph) -> str:
|
|
1562
1565
|
return f"Undirected graph on {len(self.vertices)} vertices and {len(self.edges)} edges"
|
|
@@ -1765,10 +1768,15 @@ class DiGraph(GenericGraph):
|
|
|
1765
1768
|
deformed.
|
|
1766
1769
|
"""
|
|
1767
1770
|
for (u, v), edge in graph.edges.items():
|
|
1768
|
-
edge_type = type(edge)
|
|
1769
1771
|
tip = edge.pop_tips()[0]
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
+
# Passing the Mobject instead of the vertex makes the tip
|
|
1773
|
+
# stop on the bounding box of the vertex.
|
|
1774
|
+
edge.set_points_by_ends(
|
|
1775
|
+
graph[u],
|
|
1776
|
+
graph[v],
|
|
1777
|
+
buff=self._edge_config.get("buff", 0),
|
|
1778
|
+
path_arc=self._edge_config.get("path_arc", 0),
|
|
1779
|
+
)
|
|
1772
1780
|
edge.add_tip(tip)
|
|
1773
1781
|
|
|
1774
1782
|
def __repr__(self: DiGraph) -> str:
|