Numbers

ChangingDecimal

class manimlib.animation.numbers.ChangingDecimal(decimal_mob: DecimalNumber, number_update_func: Callable[[float], float], **kwargs)
ChangingDecimalExample
class ChangingDecimalExample(Scene):
    def construct(self):
        number = DecimalNumber(0, text_config={"font": "monospace"}).scale(2)

        def update_func(t):
            return t * 10
        self.add(number)
        self.wait()
        self.play(ChangingDecimal(number, update_func), run_time=3)
        self.wait()

ChangeDecimalToValue

class manimlib.animation.numbers.ChangeDecimalToValue(decimal_mob: manimlib.mobject.numbers.DecimalNumber, target_number: float | complex, **kwargs)

从当前数字播放到目标数字

ChangeDecimalToValueExample
class ChangeDecimalToValueExample(Scene):
    def construct(self):
        number = DecimalNumber(0, text_config={"font": "monospace"}).scale(2)
        self.add(number)
        self.wait()
        self.play(ChangeDecimalToValue(number, 20), run_time=3)
        self.wait()

CountInFrom

class manimlib.animation.numbers.CountInFrom(decimal_mob: manimlib.mobject.numbers.DecimalNumber, source_number: float | complex = 0, **kwargs)

从 source_number 开始播放到当前数字

ChangeDecimalToValueExample
class CountInFromExample(Scene):
    def construct(self):
        number = DecimalNumber(10, text_config={"font": "monospace"}).scale(2)
        self.add(number)
        self.play(CountInFrom(number, 0))
        self.wait()