0
0

wslでmanim その3

Posted at

概要

wslでmanimやってみた。
manim見つけたので、やってみた。

参考にしたページ

サンプルコード

from manim import *
import numpy as np

class RightAngleExample(Scene):
	def construct(self):
		vertex_1 = np.array([-1, -1, 0])
		vertex_2 = np.array([-3, -1, 0])
		vertex_3 = np.array([-1, 1, 0])
		line1 = Line(vertex_1, vertex_2)
		line2 = Line(vertex_1, vertex_3)
		line3 = Line(vertex_2, vertex_3)
		RightTriangle = Polygon(vertex_1, vertex_2, vertex_3, color = RED, fill_opacity = 0.5)
		vertex_hex_1 = np.array([0, -1, 0])
		vertex_hex_2 = np.array([2, -1, 0])
		vertex_hex_3 = np.array([2, 0, 0])
		vertex_hex_4 = np.array([1, 0, 0])
		vertex_hex_5 = np.array([1, 1, 0])
		vertex_hex_6 = np.array([0, 1, 0])
		line_hex_1 = Line(vertex_hex_1, vertex_hex_2)
		line_hex_2 = Line(vertex_hex_2, vertex_hex_3)
		line_hex_3 = Line(vertex_hex_3, vertex_hex_4)
		line_hex_4 = Line(vertex_hex_4, vertex_hex_5)
		line_hex_5 = Line(vertex_hex_5, vertex_hex_6)
		line_hex_6 = Line(vertex_hex_6, vertex_hex_1)
		hexagon = Polygon(vertex_hex_1, vertex_hex_2, vertex_hex_3, vertex_hex_4, vertex_hex_5, vertex_hex_6, color = BLUE, fill_opacity = 0.5)
		start_pos = np.array([3, 0, 0])
		middle_pos_1 = np.array([2, 0, 0])
		middle_pos_2 = np.array([1, 0, 0])
		end_pos = np.array([0, 0, 0])
		RightTriangle.move_to(start_pos).set_fill(RED, opacity = 0.5)
		self.add(hexagon)
		self.play(RightTriangle.animate.move_to(middle_pos_1), rate_func = linear, run_time = 1) 
		self.wait()
		self.play(RightTriangle.animate.move_to(middle_pos_2), rate_func = linear, run_time = 1)
		self.wait()
		self.play(RightTriangle.animate.move_to(end_pos), rate_func = linear, run_time = 1)
		self.wait()



成果物

RightAngleExample_ManimCE_v0.18.1.gif

以上。

0
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
0
0