以下是我当前的代码:
from manimlib.imports import *
class ClockOrganization(VGroup):
CONFIG = {
"numbers" : 4,
"radius" : 3.1,
"color" : WHITE
}
def __init__(self, **kwargs):
digest_config(self, kwargs, locals())
self.generate_nodes()
VGroup.__init__(self, *self.node_list,**kwargs)
def generate_nodes(self):
self.node_list = []
for i in range(self.numbers):
mobject = VMobject()
number = TexMobject(str(i+1))
circle = Circle(radius=0.4,color=self.color)
mobject.add(number)
mobject.add(circle)
mobject.move_to(
self.radius * np.cos((-TAU / self.numbers) * i + 17*TAU / 84) * RIGHT
+ self.radius * np.sin((-TAU / self.numbers) * i + 17*TAU / 84) * UP
)
self.node_list.append(mobject)
def select_node(self, node):
selected_node = self.node_list[node]
selected_node.scale(1.2)
selected_node.set_color(RED)
def deselect_node(self, selected_node):
node = self.node_list[selected_node]
node.scale(0.8)
node.set_color(self.color)
class Testing3(Scene):
def construct(self):
test = ClockOrganization(numbers=21)
self.play(Write(test), run_time=1.5)
animation_steps=[]
for i in range(10):
thing = test.deepcopy()
thing.select_node((19+i)%test.numbers-1)
animation_steps.append(thing)
self.play(Transform(test, animation_steps[0]))
self.wait(2)
for i in range(1,10):
self.play(Transform(test, animation_steps[i]),run_time=0.3)
self.wait()
如果您当前运行它,它会突出显示 19,然后以均匀的速度旋转到 7。是否可以rate_func
为整个过程设置 a,使其开始缓慢旋转,中途加速,然后减慢至 7,就像平滑rate_func
但应用于整个过程?
我尝试将上面的 Scene 类更改为
class Testing3(Scene):
def construct(self):
test = ClockOrganization(numbers=21)
self.play(Write(test), run_time=1.5)
animation_steps=[]
for i in range(10):
thing = test.deepcopy()
thing.select_node((19+i)%test.numbers-1)
animation_steps.append(thing)
self.play(Transform(test, animation_steps[0]))
self.wait(2)
for i in range(1,10):
if i in range(1,6):
time_to_run=(sigmoid(10*(-i/4+.75))-sigmoid(-5))/(1-2*sigmoid(-5)+3)+.1
if i in range(6,10):
time_to_run=(sigmoid(10*(i/4-1.75))-sigmoid(-5))/(1-2*sigmoid(-5)+3)+.1
self.play(Transform(test, animation_steps[i]),run_time=time_to_run)
self.wait()
它接近我想要的,但变换似乎相当波涛汹涌。