LoginSignup
1
0

More than 3 years have passed since last update.

manimの作法 その30

Posted at

概要

manimの作法、調べてみた。
ValueTracker、 always_redraw使ってみた。

サンプルコード

from manimlib.imports import *

class test(Scene):
    def construct(self):
        angle_tracker = ValueTracker(90 * DEGREES)
        get_angle = angle_tracker.get_value
        formula = always_redraw(lambda: self.get_sine_formula(get_angle()))
        self.add(formula)
        self.play(angle_tracker.set_value, 0, run_time = 5, )
        self.wait()
        self.play(angle_tracker.set_value, 90 * DEGREES, run_time = 5, )
        self.wait()
    def get_sine_formula(self, angle):
        sin, lp, rp = TexMobject("\\sin", "(", ") = ")
        input_part = Integer(angle / DEGREES, unit = "^\\circ", )
        input_part.set_color(YELLOW)
        output_part = DecimalNumber(np.sin(input_part.get_value() * DEGREES), num_decimal_places = 3, )
        result = VGroup(sin, lp, input_part, rp, output_part)
        result.arrange(RIGHT, buff = SMALL_BUFF)
        sin.scale(1.1, about_edge = DOWN)
        lp.align_to(rp, UP)
        return result


生成した動画

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0