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

Last updated at Posted at 2021-01-04

#概要

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

#サンプルコード

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





#生成した動画

以上。

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?