Skip to content

Commit bfea7da

Browse files
Mark some methods as internal on Mobject/VMobject
1 parent 8d7bb13 commit bfea7da

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

manim/mobject/mobject.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
color_gradient,
3535
interpolate_color,
3636
)
37+
from ..utils.decorators import internal
3738
from ..utils.exceptions import MultiAnimationOverrideException
3839
from ..utils.iterables import list_update, remove_list_redundancies
3940
from ..utils.paths import straight_path
@@ -83,6 +84,7 @@ class Mobject:
8384

8485
animation_overrides = {}
8586

87+
@internal
8688
@classmethod
8789
def __init_subclass__(cls, **kwargs) -> None:
8890
super().__init_subclass__(**kwargs)
@@ -1712,6 +1714,7 @@ def stretch_to_fit_depth(self, depth: float, **kwargs) -> Self:
17121714

17131715
return self.rescale_to_fit(depth, 2, stretch=True, **kwargs)
17141716

1717+
@internal
17151718
def set_coord(self, value, dim: int, direction: Vector3D = ORIGIN) -> Self:
17161719
curr = self.get_coord(dim, direction)
17171720
shift_vect = np.zeros(self.dim)
@@ -1902,6 +1905,7 @@ def set_colors_by_radial_gradient(
19021905
)
19031906
return self
19041907

1908+
@internal
19051909
def set_submobject_colors_by_gradient(self, *colors: Iterable[ParsableManimColor]):
19061910
if len(colors) == 0:
19071911
raise ValueError("Need at least one color")
@@ -1915,6 +1919,7 @@ def set_submobject_colors_by_gradient(self, *colors: Iterable[ParsableManimColor
19151919
mob.set_color(color, family=False)
19161920
return self
19171921

1922+
@internal
19181923
def set_submobject_colors_by_radial_gradient(
19191924
self,
19201925
center: Point3D | None = None,
@@ -2044,6 +2049,7 @@ def get_points_defining_boundary(self) -> Point3D_Array:
20442049
def get_num_points(self) -> int:
20452050
return len(self.points)
20462051

2052+
@internal
20472053
def get_extremum_along_dim(
20482054
self, points: Point3D_Array | None = None, dim: int = 0, key: int = 0
20492055
) -> np.ndarray | float:
@@ -2160,6 +2166,7 @@ def length_over_dim(self, dim: int) -> float:
21602166
dim,
21612167
) - self.reduce_across_dimension(min, dim)
21622168

2169+
@internal
21632170
def get_coord(self, dim: int, direction: Vector3D = ORIGIN):
21642171
"""Meant to generalize ``get_x``, ``get_y`` and ``get_z``"""
21652172
return self.get_extremum_along_dim(dim=dim, key=direction[dim])
@@ -2196,6 +2203,7 @@ def point_from_proportion(self, alpha: float) -> Point3D:
21962203
def proportion_from_point(self, point: Point3D) -> float:
21972204
raise NotImplementedError("Please override in a child class.")
21982205

2206+
@internal
21992207
def get_pieces(self, n_pieces: float) -> Group:
22002208
template = self.copy()
22012209
template.submobjects = []
@@ -2312,11 +2320,13 @@ def split(self) -> list[Self]:
23122320
result = [self] if len(self.points) > 0 else []
23132321
return result + self.submobjects
23142322

2323+
@internal
23152324
def get_family(self, recurse: bool = True) -> list[Self]:
2316-
sub_families = [x.get_family() for x in self.submobjects]
2325+
sub_families = [x.get_family(recurse=recurse) for x in self.submobjects]
23172326
all_mobjects = [self] + list(it.chain(*sub_families))
23182327
return remove_list_redundancies(all_mobjects)
23192328

2329+
@internal
23202330
def family_members_with_points(self) -> list[Self]:
23212331
return [m for m in self.get_family() if m.get_num_points() > 0]
23222332

@@ -2683,6 +2693,7 @@ def construct(self):
26832693
return self.shuffle(*args, **kwargs)
26842694

26852695
# Alignment
2696+
@internal
26862697
def align_data(self, mobject: Mobject, skip_point_alignment: bool = False) -> None:
26872698
"""Aligns the data of this mobject with another mobject.
26882699
@@ -2784,6 +2795,7 @@ def add_n_more_submobjects(self, n: int) -> Self | None:
27842795
def repeat_submobject(self, submob: Mobject) -> Self:
27852796
return submob.copy()
27862797

2798+
@internal
27872799
def interpolate(
27882800
self,
27892801
mobject1: Mobject,
@@ -2967,6 +2979,7 @@ def construct(self):
29672979
return self
29682980

29692981
# Errors
2982+
@internal
29702983
def throw_error_if_no_points(self) -> None:
29712984
if self.has_no_points():
29722985
caller_name = sys._getframe(1).f_code.co_name

manim/mobject/types/vectorized_mobject.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
proportions_along_bezier_curve_for_point,
3939
)
4040
from manim.utils.color import BLACK, WHITE, ManimColor, ParsableManimColor
41+
from manim.utils.decorators import internal
4142
from manim.utils.iterables import (
4243
make_even,
4344
resize_array,
@@ -191,6 +192,7 @@ def get_mobject_type_class() -> type[VMobject]:
191192
return VMobject
192193

193194
# Colors
195+
@internal
194196
def init_colors(self, propagate_colors: bool = True) -> Self:
195197
self.set_fill(
196198
color=self.fill_color,
@@ -221,6 +223,7 @@ def init_colors(self, propagate_colors: bool = True) -> Self:
221223

222224
return self
223225

226+
@internal
224227
def generate_rgbas_array(
225228
self, color: ManimColor | list[ManimColor], opacity: float | Iterable[float]
226229
) -> RGBA_Array_Float:
@@ -249,6 +252,7 @@ def generate_rgbas_array(
249252
rgbas = np.append(rgbas, light_rgbas, axis=0)
250253
return rgbas
251254

255+
@internal
252256
def update_rgbas_array(
253257
self,
254258
array_name: str,
@@ -708,6 +712,7 @@ def set_shade_in_3d(
708712
submob.z_index_group = self
709713
return self
710714

715+
@internal
711716
def set_points(self, points: Point3D_Array) -> Self:
712717
self.points: Point3D_Array = np.array(points)
713718
return self
@@ -795,6 +800,7 @@ def append_points(self, new_points: Point3D_Array) -> Self:
795800
self.points = points
796801
return self
797802

803+
@internal
798804
def start_new_path(self, point: Point3D) -> Self:
799805
"""Append a ``point`` to the :attr:`VMobject.points`, which will be the
800806
beginning of a new Bézier curve in the path given by the points. If
@@ -825,6 +831,7 @@ def start_new_path(self, point: Point3D) -> Self:
825831
self.append_points([point])
826832
return self
827833

834+
@internal
828835
def add_cubic_bezier_curve(
829836
self,
830837
anchor1: CubicBezierPoints,
@@ -836,9 +843,11 @@ def add_cubic_bezier_curve(
836843
self.append_points([anchor1, handle1, handle2, anchor2])
837844

838845
# what type is curves?
846+
@internal
839847
def add_cubic_bezier_curves(self, curves) -> None:
840848
self.append_points(curves.flatten())
841849

850+
@internal
842851
def add_cubic_bezier_curve_to(
843852
self,
844853
handle1: CubicBezierPoints,
@@ -871,6 +880,7 @@ def add_cubic_bezier_curve_to(
871880
self.append_points([self.get_last_point()] + new_points)
872881
return self
873882

883+
@internal
874884
def add_quadratic_bezier_curve_to(
875885
self,
876886
handle: QuadraticBezierPoints,
@@ -1114,11 +1124,13 @@ def make_smooth(self) -> Self:
11141124
def make_jagged(self) -> Self:
11151125
return self.change_anchor_mode("jagged")
11161126

1127+
@internal
11171128
def add_subpath(self, points: Point3D_Array) -> Self:
11181129
assert len(points) % 4 == 0
11191130
self.append_points(points)
11201131
return self
11211132

1133+
@internal
11221134
def append_vectorized_mobject(self, vectorized_mobject: VMobject) -> None:
11231135
if self.has_new_path_started():
11241136
# Remove last point, which is starting
@@ -1146,6 +1158,7 @@ def rotate(
11461158
super().rotate(angle, axis, about_point, **kwargs)
11471159
return self
11481160

1161+
@internal
11491162
def scale_handle_to_anchor_distances(self, factor: float) -> Self:
11501163
"""If the distance between a given handle point H and its associated
11511164
anchor point A is d, then it changes H to be a distances factor*d
@@ -1177,10 +1190,11 @@ def scale_handle_to_anchor_distances(self, factor: float) -> Self:
11771190
submob.set_anchors_and_handles(a1, new_h1, new_h2, a2)
11781191
return self
11791192

1180-
#
1193+
@internal
11811194
def consider_points_equals(self, p0: Point3D, p1: Point3D) -> bool:
11821195
return np.allclose(p0, p1, atol=self.tolerance_for_point_equality)
11831196

1197+
@internal
11841198
def consider_points_equals_2d(self, p0: Point2D, p1: Point2D) -> bool:
11851199
"""Determine if two points are close enough to be considered equal.
11861200
@@ -1207,11 +1221,13 @@ def consider_points_equals_2d(self, p0: Point2D, p1: Point2D) -> bool:
12071221
return True
12081222

12091223
# Information about line
1224+
@internal
12101225
def get_cubic_bezier_tuples_from_points(
12111226
self, points: Point3D_Array
12121227
) -> npt.NDArray[Point3D_Array]:
12131228
return np.array(self.gen_cubic_bezier_tuples_from_points(points))
12141229

1230+
@internal
12151231
def gen_cubic_bezier_tuples_from_points(
12161232
self, points: Point3D_Array
12171233
) -> tuple[Point3D_Array]:
@@ -1238,6 +1254,7 @@ def gen_cubic_bezier_tuples_from_points(
12381254
# Basically take every nppcc element.
12391255
return tuple(points[i : i + nppcc] for i in range(0, len(points), nppcc))
12401256

1257+
@internal
12411258
def get_cubic_bezier_tuples(self) -> npt.NDArray[Point3D_Array]:
12421259
return self.get_cubic_bezier_tuples_from_points(self.points)
12431260

@@ -1275,6 +1292,7 @@ def _gen_subpaths_from_points(
12751292
if (i2 - i1) >= nppcc
12761293
)
12771294

1295+
@internal
12781296
def get_subpaths_from_points(self, points: Point3D_Array) -> list[Point3D_Array]:
12791297
return list(
12801298
self._gen_subpaths_from_points(
@@ -1283,6 +1301,7 @@ def get_subpaths_from_points(self, points: Point3D_Array) -> list[Point3D_Array]
12831301
),
12841302
)
12851303

1304+
@internal
12861305
def gen_subpaths_from_points_2d(
12871306
self, points: Point3D_Array
12881307
) -> Generator[Point3D_Array]:
@@ -1291,6 +1310,7 @@ def gen_subpaths_from_points_2d(
12911310
lambda n: not self.consider_points_equals_2d(points[n - 1], points[n]),
12921311
)
12931312

1313+
@internal
12941314
def get_subpaths(self) -> list[Point3D_Array]:
12951315
"""Returns subpaths formed by the curves of the VMobject.
12961316
@@ -1303,6 +1323,7 @@ def get_subpaths(self) -> list[Point3D_Array]:
13031323
"""
13041324
return self.get_subpaths_from_points(self.points)
13051325

1326+
@internal
13061327
def get_nth_curve_points(self, n: int) -> Point3D_Array:
13071328
"""Returns the points defining the nth curve of the vmobject.
13081329
@@ -1320,6 +1341,7 @@ def get_nth_curve_points(self, n: int) -> Point3D_Array:
13201341
nppcc = self.n_points_per_cubic_curve
13211342
return self.points[nppcc * n : nppcc * (n + 1)]
13221343

1344+
@internal
13231345
def get_nth_curve_function(self, n: int) -> Callable[[float], Point3D]:
13241346
"""Returns the expression of the nth curve.
13251347
@@ -1335,6 +1357,7 @@ def get_nth_curve_function(self, n: int) -> Callable[[float], Point3D]:
13351357
"""
13361358
return bezier(self.get_nth_curve_points(n))
13371359

1360+
@internal
13381361
def get_nth_curve_length_pieces(
13391362
self,
13401363
n: int,
@@ -1363,6 +1386,7 @@ def get_nth_curve_length_pieces(
13631386

13641387
return norms
13651388

1389+
@internal
13661390
def get_nth_curve_length(
13671391
self,
13681392
n: int,
@@ -1387,6 +1411,7 @@ def get_nth_curve_length(
13871411

13881412
return length
13891413

1414+
@internal
13901415
def get_nth_curve_function_with_length(
13911416
self,
13921417
n: int,
@@ -1426,6 +1451,7 @@ def get_num_curves(self) -> int:
14261451
nppcc = self.n_points_per_cubic_curve
14271452
return len(self.points) // nppcc
14281453

1454+
@internal
14291455
def get_curve_functions(
14301456
self,
14311457
) -> Generator[Callable[[float], Point3D]]:
@@ -1442,6 +1468,7 @@ def get_curve_functions(
14421468
for n in range(num_curves):
14431469
yield self.get_nth_curve_function(n)
14441470

1471+
@internal
14451472
def get_curve_functions_with_lengths(
14461473
self, **kwargs
14471474
) -> Generator[tuple[Callable[[float], Point3D], float]]:
@@ -1582,6 +1609,7 @@ def proportion_from_point(
15821609

15831610
return alpha
15841611

1612+
@internal
15851613
def get_anchors_and_handles(self) -> list[Point3D_Array]:
15861614
"""Returns anchors1, handles1, handles2, anchors2,
15871615
where (anchors1[i], handles1[i], handles2[i], anchors2[i])
@@ -1596,6 +1624,7 @@ def get_anchors_and_handles(self) -> list[Point3D_Array]:
15961624
nppcc = self.n_points_per_cubic_curve
15971625
return [self.points[i::nppcc] for i in range(nppcc)]
15981626

1627+
@internal
15991628
def get_start_anchors(self) -> Point3D_Array:
16001629
"""Returns the start anchors of the bezier curves.
16011630
@@ -1606,6 +1635,7 @@ def get_start_anchors(self) -> Point3D_Array:
16061635
"""
16071636
return self.points[:: self.n_points_per_cubic_curve]
16081637

1638+
@internal
16091639
def get_end_anchors(self) -> Point3D_Array:
16101640
"""Return the end anchors of the bezier curves.
16111641
@@ -1617,6 +1647,7 @@ def get_end_anchors(self) -> Point3D_Array:
16171647
nppcc = self.n_points_per_cubic_curve
16181648
return self.points[nppcc - 1 :: nppcc]
16191649

1650+
@internal
16201651
def get_anchors(self) -> Point3D_Array:
16211652
"""Returns the anchors of the curves forming the VMobject.
16221653
@@ -1731,6 +1762,7 @@ def get_nth_subpath(path_list, n):
17311762
vmobject.set_points(new_path2)
17321763
return self
17331764

1765+
@internal
17341766
def insert_n_curves(self, n: int) -> Self:
17351767
"""Inserts n curves to the bezier curves of the vmobject.
17361768
@@ -1755,6 +1787,7 @@ def insert_n_curves(self, n: int) -> Self:
17551787
self.append_points([new_path_point])
17561788
return self
17571789

1790+
@internal
17581791
def insert_n_curves_to_point_list(
17591792
self, n: int, points: Point3D_Array
17601793
) -> npt.NDArray[BezierPoints]:
@@ -1782,6 +1815,7 @@ def insert_n_curves_to_point_list(
17821815
new_points = new_bezier_tuples.reshape(-1, 3)
17831816
return new_points
17841817

1818+
@internal
17851819
def align_rgbas(self, vmobject: VMobject) -> Self:
17861820
attrs = ["fill_rgbas", "stroke_rgbas", "background_stroke_rgbas"]
17871821
for attr in attrs:
@@ -1802,6 +1836,7 @@ def get_point_mobject(self, center: Point3D | None = None) -> VectorizedPoint:
18021836
point.match_style(self)
18031837
return point
18041838

1839+
@internal
18051840
def interpolate_color(
18061841
self, mobject1: VMobject, mobject2: VMobject, alpha: float
18071842
) -> None:
@@ -1826,6 +1861,7 @@ def interpolate_color(
18261861
val = val.copy()
18271862
setattr(self, attr, val)
18281863

1864+
@internal
18291865
def pointwise_become_partial(
18301866
self,
18311867
vmobject: VMobject,
@@ -1888,6 +1924,7 @@ def pointwise_become_partial(
18881924
)
18891925
return self
18901926

1927+
@internal
18911928
def get_subcurve(self, a: float, b: float) -> Self:
18921929
"""Returns the subcurve of the VMobject between the interval [a, b].
18931930
The curve is a VMobject itself.

0 commit comments

Comments
 (0)