#概要
manimの作法、調べてみた。
VectorScene使ってみた。
#サンプルコード
from manimlib.imports import *
class test(VectorScene):
def construct(self):
two_dot = TexMobject("2\\cdot")
equals = TexMobject("=")
self.add_axes()
v = self.add_vector([3, 1])
v_coords, vx_line, vy_line = self.vector_to_coords(v, clean_up = False)
self.play(ApplyMethod(v_coords.to_edge, UP))
two_dot.next_to(v_coords, LEFT)
equals.next_to(v_coords, RIGHT)
two_v = self.add_vector([6, 2], animate = False)
self.remove(two_v)
self.play(Transform(v.copy(), two_v), Write(two_dot, run_time = 1))
two_v_coords, two_v_x_line, two_v_y_line = self.vector_to_coords(two_v, clean_up = False)
self.play(ApplyMethod(two_v_coords.next_to, equals, RIGHT),Write(equals, run_time = 1))
self.wait(2)
x, y = v_coords.get_mob_matrix().flatten()
two_v_elems = two_v_coords.get_mob_matrix().flatten()
x_sym, y_sym = list(map(TexMobject, ["x", "y"]))
two_x_sym, two_y_sym = list(map(TexMobject, ["2x", "2y"]))
#VMobject(x_sym, two_x_sym).set_color(X_COLOR)
#VMobject(y_sym, two_y_sym).set_color(Y_COLOR)
syms = [x_sym, y_sym, two_x_sym, two_y_sym]
#VMobject(*syms).scale(VECTOR_LABEL_SCALE_FACTOR)
for sym, num in zip(syms, [x, y] + list(two_v_elems)):
sym.move_to(num)
#self.play(Transform(x, x_sym), Transform(y, y_sym), FadeOut(VMobject(*two_v_elems)))
self.wait()
#self.play(Transform(VMobject(two_dot.copy(), x.copy()), two_x_sym), Transform(VMobject(two_dot.copy(), y.copy() ), two_y_sym))
#self.wait(2)
#生成した動画
以上。