Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 7 additions & 12 deletions manim/mobject/opengl/opengl_vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import itertools as it
import operator as op
import typing
from functools import reduce, wraps
from typing import Callable, Iterable, Optional, Sequence

Expand Down Expand Up @@ -1013,7 +1014,7 @@ def proportion_from_point(

return alpha

def get_anchors_and_handles(self):
def get_anchors_and_handles(self) -> typing.Iterable[np.ndarray]:
"""
Returns anchors1, handles, anchors2,
where (anchors1[i], handles[i], anchors2[i])
Expand Down Expand Up @@ -1045,7 +1046,7 @@ 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) -> typing.Iterable[np.ndarray]:
"""Returns the anchors of the curves forming the OpenGLVMobject.

Returns
Expand All @@ -1056,16 +1057,10 @@ def get_anchors(self) -> np.ndarray:
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 [s[i // 2] if i % 2 == 0 else e[i // 2] for i in range(len(s) + len(e))]

def get_points_without_null_curves(self, atol=1e-9):
nppc = self.n_points_per_curve
Expand Down
9 changes: 5 additions & 4 deletions manim/mobject/types/vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ 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
Expand All @@ -1402,9 +1402,10 @@ def get_anchors(self) -> np.ndarray:
"""
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 [s[i // 2] if i % 2 == 0 else e[i // 2] for i in range(len(s) + len(e))]

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