#概要
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
#生成した動画
以上。