0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

manimの作法 その5

Last updated at Posted at 2021-01-03

#概要

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




#生成した動画

#以上。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?