我发现当文本超过 20 行时,这个动画需要很长时间来渲染。我有什么办法可以加快速度吗?
import itertools as it
class FormulaExample(Scene):
def setup(self):
self.text_example = Text("How are we doing?\nPlease help us\nimprove Stack Overflow.\nThanks!", font="Roboto", stroke_width=0)
class FadeInFromDirections(LaggedStart):
CONFIG = {
"directions":[DL,DOWN,DR,RIGHT,UR,UP,UL,LEFT],
"magnitude":1,
"lag_ratio":.05
}
def __init__(self, text , **kwargs):
digest_config(self, kwargs)
self.reverse_directions=it.cycle(list(reversed(self.directions)))
super().__init__(
*[FadeInFromPoint(obj,point=obj.get_center()+d*self.magnitude)
for obj,d in zip(text,self.reverse_directions)],
**kwargs
)
class FadeInFromDirectionsExample(FormulaExample):
def construct(self):
self.play(
FadeInFromDirections(self.text_example),
run_time=3
)
self.wait()