Manim's method 7

Overview

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

Sample code

from manimlib.imports import *
import numpy as np
from enum import Enum

class Color(Enum):
	WHITE = (255, 255, 255)
	YELLOW = (0, 255, 255)
	CYAN = (255, 255, 0)
	GREEN = (0, 255, 0)
	MAGENTA = (255, 0, 255)
	RED = (0, 0, 255)
	BLUE = (255, 0, 0)
	BLACK = (0, 0, 0)

class test(Scene):
	def construct(self):
		n = 256
		imageArray = np.uint8([[i * 256 / n for i in range(0, n)] for _ in range(0, n)])
		img0 = ImageMobject(imageArray)
		img0.set_height(7)
		img0.shift(2 * UP)
		img1 = ImageMobject(np.uint8([[0, 100, 30, 200], [255, 0, 5, 33]]))
		img1.set_height(7)
		img1.shift(2 * UP)
		width = 256
		height = 256
		color_img = np.zeros((height, width, 3), dtype = np.uint8)
		bar_width = 32
		i = 0
		for c in Color:
			color_img[0: height, i: i + bar_width] = c.value
			i += bar_width
		img2 = ImageMobject(color_img)
		img2.set_height(7)
		img2.shift(2 * UP)
		matrix = np.uint8([[0, 0, 200], [255, 0, 33]])
		img3 = ImageMobject(matrix)
		img3.scale(3)
		mat = np.uint8([[[0, 0, 0], [0, 0, 0], [0, 0, 200]], [[0, 0, 255], [0, 0, 0], [0, 0, 33]]])
		img4 = ImageMobject(mat)
		img4.scale(3)
		self.play(ShowCreation(img0))
		self.wait()
		self.play(ShowCreation(img1))
		self.wait()
		self.play(ShowCreation(img2))
		self.wait()
		self.play(ShowCreation(img3))
		self.wait()
		self.play(ShowCreation(img4))
		self.wait()





Generated video

https://www.youtube.com/watch?v=mDAbs6f-PGQ

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