3b1b-manim/generate_logo.py

50 lines
1.3 KiB
Python
Raw Normal View History

#!/usr/bin/env python
from PIL import Image
2015-04-03 16:41:25 -07:00
from animation import *
from mobject import *
from constants import *
from helpers import *
2015-04-14 17:55:25 -07:00
from scene import *
from image_mobject import *
import itertools as it
import os
import numpy as np
DARK_BLUE = "#236B8E"
DARK_BROWN = "#8B4513"
LIGHT_BROWN = "#CD853F"
2015-04-14 17:55:25 -07:00
LOGO_RADIUS = 1.5
2015-04-03 16:41:25 -07:00
if __name__ == '__main__':
2015-04-14 17:55:25 -07:00
circle = Circle(density = 100, color = 'skyblue').repeat(5).scale(LOGO_RADIUS)
sphere = Sphere(density = 100, color = DARK_BLUE).scale(LOGO_RADIUS)
2015-04-03 16:41:25 -07:00
sphere.rotate(-np.pi / 7, [1, 0, 0])
sphere.rotate(-np.pi / 7)
alpha = 0.3
iris = Mobject()
Mobject.interpolate(circle, sphere, iris, alpha)
for mob, color in [(iris, LIGHT_BROWN), (circle, DARK_BROWN)]:
mob.highlight(color, lambda (x, y, z) : x < 0 and y > 0)
2015-04-14 17:55:25 -07:00
mob.highlight("black", lambda point: np.linalg.norm(point) < 0.55*LOGO_RADIUS)
2015-04-14 17:55:25 -07:00
name = tex_mobject(r"\text{3Blue1Brown}").center()
2015-04-03 16:41:25 -07:00
name.highlight("gray")
name.shift((0, -2, 0))
2015-04-14 17:55:25 -07:00
sc = Scene()
sc.animate(Transform(
2015-04-03 16:41:25 -07:00
circle, iris,
2015-04-14 17:55:25 -07:00
run_time = DEFAULT_ANIMATION_RUN_TIME
))
sc.add(name)
sc.dither()
sc.frames = drag_pixels(sc.frames)
sc.write_to_movie("LogoGeneration", end_dither_time = 0)
# index = int(DEFAULT_ANIMATION_RUN_TIME / DEFAULT_ANIMATION_PAUSE_TIME)
# create_eye.frames[index].save(LOGO_PATH)