#概要
manimの作法、調べてみた。
Clock、使ってみた。
#サンプルコード
from manimlib.imports import *
def rev_to_rgba(alpha):
alpha = (0.5 - alpha) % 1
hue_list = [0, 0.5 / 6.0, 1 / 6.0, 1.1 / 6.0, 2 / 6.0, 3 / 6.0, 4 / 6.0, 5 / 6.0]
num_hues = len(hue_list)
start_index = int(np.floor(num_hues * alpha)) % num_hues
end_index = (start_index + 1) % num_hues
beta = (alpha % (1.0 / num_hues)) * num_hues
start_hue = hue_list[start_index]
end_hue = hue_list[end_index]
if end_hue < start_hue:
end_hue = end_hue + 1
hue = interpolate(start_hue, end_hue, beta)
return color_to_rgba(Color(hue = hue, saturation = 1, luminance = 0.5))
def rev_to_color(alpha):
return rgba_to_color(rev_to_rgba(alpha))
class test(Scene):
CONFIG = {
"run_time" : 90,
}
def construct(self):
clock = Clock()
clock.set_height(FRAME_HEIGHT - 1)
clock.to_edge(LEFT)
lines = [clock.hour_hand, clock.minute_hand]
def update_line(line):
rev = line.get_angle() / TAU
line.set_color(rev_to_color(rev))
for line in lines:
self.add(Mobject.add_updater(line, update_line))
run_time = self.run_time
self.play(ClockPassesTime(clock, run_time = run_time, hours_passed = 0.1 * run_time))
#生成した動画
#以上。