mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
(Maybe temporary?) upates to Tracers
This commit is contained in:
parent
d5a88d0fa4
commit
4ce123be44
1 changed files with 17 additions and 12 deletions
|
@ -8,7 +8,6 @@ from manimlib.mobject.mobject import Mobject
|
|||
from manimlib.mobject.types.vectorized_mobject import VMobject
|
||||
from manimlib.mobject.types.vectorized_mobject import VGroup
|
||||
from manimlib.utils.rate_functions import smooth
|
||||
from manimlib.utils.space_ops import get_norm
|
||||
|
||||
|
||||
class AnimatedBoundary(VGroup):
|
||||
|
@ -82,7 +81,7 @@ class TracedPath(VMobject):
|
|||
"stroke_color": WHITE,
|
||||
"time_traced": np.inf,
|
||||
"fill_opacity": 0,
|
||||
"time_per_anchor": 0.1,
|
||||
"time_per_anchor": 1 / 15,
|
||||
}
|
||||
|
||||
def __init__(self, traced_point_func, **kwargs):
|
||||
|
@ -99,22 +98,28 @@ class TracedPath(VMobject):
|
|||
self.traced_points.append(point)
|
||||
|
||||
if self.time_traced < np.inf:
|
||||
n_relevant_points = int(self.time_traced / dt)
|
||||
n_anchors = int(self.time_traced / self.time_per_anchor)
|
||||
n_relevant_points = int(self.time_traced / dt + 0.5)
|
||||
# n_anchors = int(self.time_traced / self.time_per_anchor)
|
||||
n_tps = len(self.traced_points)
|
||||
points = [
|
||||
self.traced_points[max(n_tps - int(alpha * n_relevant_points) - 1, 0)]
|
||||
for alpha in np.linspace(1, 0, n_anchors)
|
||||
]
|
||||
if n_tps < n_relevant_points:
|
||||
points = self.traced_points + [point] * (n_relevant_points - n_tps)
|
||||
else:
|
||||
points = self.traced_points[n_tps - n_relevant_points:]
|
||||
# points = [
|
||||
# self.traced_points[max(n_tps - int(alpha * n_relevant_points) - 1, 0)]
|
||||
# for alpha in np.linspace(1, 0, n_anchors)
|
||||
# ]
|
||||
# Every now and then refresh the list
|
||||
if n_tps > 10 * n_relevant_points:
|
||||
self.traced_points = self.traced_points[-n_relevant_points:]
|
||||
else:
|
||||
sparseness = max(int(self.time_per_anchor / dt), 1)
|
||||
points = self.traced_points[::sparseness]
|
||||
points[-1] = self.traced_points[-1]
|
||||
# sparseness = max(int(self.time_per_anchor / dt), 1)
|
||||
# points = self.traced_points[::sparseness]
|
||||
# points[-1] = self.traced_points[-1]
|
||||
points = self.traced_points
|
||||
|
||||
self.set_points_smoothly(points)
|
||||
if points:
|
||||
self.set_points_smoothly(points)
|
||||
|
||||
self.time += dt
|
||||
return self
|
||||
|
|
Loading…
Add table
Reference in a new issue