[PYTHON] Manim's method 13

Overview

I checked manim's method. I tried using VMobject.

Sample code

from manimlib.imports import *

class test(GraphScene):
	CONFIG = {
		"x_labeled_nums": [],
		"y_labeled_nums": [],
		"x_axis_label": "Temperature",
		"y_axis_label": "Pressure",
		"graph_origin": 2.5 * DOWN + 2 * LEFT,
		"corner_square_width": 4,
		"example_point_coords": (2, 5),
	}
	def construct(self):
		self.setup_axes()
		self.draw_arrow()
		self.add_example_coordinates()
		self.wander_continuously()
	def draw_arrow(self):
		square = Square(side_length = self.corner_square_width, stroke_color = WHITE, stroke_width = 0, )
		square.to_corner(UP + LEFT, buff = 0)
		arrow = Arrow(square.get_right(), self.coords_to_point(*self.example_point_coords))
		self.play(ShowCreation(arrow))
	def add_example_coordinates(self):
		dot = Dot(self.coords_to_point(*self.example_point_coords))
		dot.set_color(YELLOW)
		tex = TexMobject("(25^\\circ\\text{C}, 101 \\text{ kPa})")
		tex.next_to(dot, UP + RIGHT, buff = SMALL_BUFF)
		self.play(ShowCreation(dot))
		self.play(Write(tex))
		self.wait()
		self.play(FadeOut(tex))
	def wander_continuously(self):
		path = VMobject().set_points_smoothly([ORIGIN, 2 * UP + RIGHT, 2 * DOWN + RIGHT, 5 * RIGHT, 4 * RIGHT + UP, 3 * RIGHT + 2 * DOWN, DOWN + LEFT, 2 * RIGHT])
		point = self.coords_to_point(*self.example_point_coords)
		path.shift(point)
		path.set_color(GREEN)
		self.play(ShowCreation(path, run_time = 10, rate_func = linear))
		self.wait()





Generated video

https://www.youtube.com/watch?v=sbNJTUT4G2c

that's all.

Recommended Posts

Manim's method 7
Manim's method 13
Manim's method 2
Manim's method 18
Manim's method 17
Manim's method 5
Manim's method 3
Manim's method 15
Manim's method 11
Manim's method 16
Manim's method 20
Manim's method 10
Manim's method 9
Manim's method 6
Manim's method 21
Manim's method 4
Manim's method 8
Manim's method 14
Manim's method 22
Manim's method 19
Manim's method 12
Manim's method part 23
manim's manners
Binary method
Special method
Special method
Understand k-means method
Clustering of clustering method
Dictionary items method
[PyTorch] Installation method
N cross method
Image collection method
Regression analysis method
Gradient method implementation 1
Python-peewee connection method
Class method static method
youtube-dl update method
Monte Carlo method
Mode-Matching Method Simulation_Python
Johnson method (python)
[Python] Semi-Lagrange method