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の作法 その55

Posted at

概要

manimの作法、調べてみた。
AnimatedStreamLines、使ってみた。

サンプルコード

from manimlib.imports import *

class test(Scene):
	CONFIG = {
		"vector_field_config": {
			"length_func": lambda norm: 0.1 + 0.4 * norm / 4.0,
			"min_magnitude": 0,
			"max_magnitude": 3,
		},
		"stream_lines_config": {
			"start_points_generator_config": {
			#	"delta_x": 0.125,
			#	"delta_y": 0.125,
			},
			"virtual_time": 1,
			"min_magnitude": 0,
			"max_magnitude": 3,
		},
	}
	def construct(self):
		def func(point):
			return 3 * sigmoid(point[0]) * RIGHT
		vector_field = self.vector_field = VectorField(func, **self.vector_field_config)
		circle = Circle(color = WHITE)
		slow_words = TextMobject("Slow flow in")
		fast_words = TextMobject("Fast flow out")
		words = VGroup(slow_words, fast_words)
		for word, vect in zip(words, [LEFT, RIGHT]):
			word.add_background_rectangle()
			word.next_to(circle, vect)
		div_tex = TexMobject("\\text{div}\\,\\textbf{F}(x, y) > 0")
		div_tex.add_background_rectangle()
		div_tex.next_to(circle, UP)
		self.add(vector_field)
		self.add_foreground_mobjects(circle, div_tex)
		self.begin_flow()
		self.wait(2)
		for word in words:
			self.add_foreground_mobjects(word)
			self.play(Write(word))
		self.wait(8)
	def begin_flow(self):
		stream_lines = StreamLines(self.vector_field.func, **self.stream_lines_config)
		stream_line_animation = AnimatedStreamLines(stream_lines)
		stream_line_animation.update(3)
		self.add(stream_line_animation)





生成した動画

https://www.youtube.com/watch?v=vvJ-pm1R_o8
以上。

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?