3

我发现当文本超过 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()
4

1 回答 1

0

编译时,可以使用低质量模式,这将显着加快编译速度,(这对于预览来说已经足够了)

于 2020-06-03T16:21:21.570 回答