Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions manim/mobject/opengl/opengl_vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ def proportion_from_point(

return alpha

def get_anchors_and_handles(self):
def get_anchors_and_handles(self) -> Iterable[np.ndarray]:
"""
Returns anchors1, handles, anchors2,
where (anchors1[i], handles[i], anchors2[i])
Expand Down Expand Up @@ -1045,27 +1045,21 @@ def get_end_anchors(self) -> np.ndarray:
nppc = self.n_points_per_curve
return self.points[nppc - 1 :: nppc]

def get_anchors(self) -> np.ndarray:
def get_anchors(self) -> Iterable[np.ndarray]:
"""Returns the anchors of the curves forming the OpenGLVMobject.

Returns
-------
np.ndarray
Iterable[np.ndarray]
The anchors.
"""
points = self.points
if len(points) == 1:
return points
return np.array(
list(
it.chain(
*zip(
self.get_start_anchors(),
self.get_end_anchors(),
)
),
),
)

s = self.get_start_anchors()
e = self.get_end_anchors()
return list(it.chain.from_iterable(zip(s, t)))

def get_points_without_null_curves(self, atol=1e-9):
nppc = self.n_points_per_curve
Expand Down
11 changes: 6 additions & 5 deletions manim/mobject/types/vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,19 +1392,20 @@ def get_end_anchors(self) -> np.ndarray:
nppcc = self.n_points_per_cubic_curve
return self.points[nppcc - 1 :: nppcc]

def get_anchors(self) -> np.ndarray:
def get_anchors(self) -> typing.Iterable[np.ndarray]:
"""Returns the anchors of the curves forming the VMobject.

Returns
-------
np.ndarray
typing.Iterable[np.ndarray]
The anchors.
"""
if self.points.shape[0] == 1:
return self.points
return np.array(
list(it.chain(*zip(self.get_start_anchors(), self.get_end_anchors()))),
)

s = self.get_start_anchors()
e = self.get_end_anchors()
return list(it.chain.from_iterable(zip(s, e)))

def get_points_defining_boundary(self):
# Probably returns all anchors, but this is weird regarding the name of the method.
Expand Down