3b1b-manim/scripts/old_scripts/generate_logo.py

67 lines
1.8 KiB
Python
Raw Normal View History

#!/usr/bin/env python
2015-06-13 19:00:23 -07:00
import numpy as np
2015-06-27 04:49:10 -07:00
import itertools as it
from copy import deepcopy
import sys
2015-06-13 19:00:23 -07:00
2015-04-03 16:41:25 -07:00
from animation import *
from mobject import *
from constants import *
2015-06-27 04:49:10 -07:00
from region import *
from scene import Scene
from script_wrapper import command_line_create_scene
class LogoGeneration(Scene):
LOGO_RADIUS = 1.5
INNER_RADIUS_RATIO = 0.55
CIRCLE_DENSITY = 100
CIRCLE_BLUE = "skyblue"
SPHERE_DENSITY = 50
SPHERE_BLUE = DARK_BLUE
CIRCLE_SPHERE_INTERPOLATION = 0.3
2015-09-18 14:22:59 -07:00
FRAME_DURATION = 0.01
2015-06-27 04:49:10 -07:00
def construct(self):
2015-09-18 14:22:59 -07:00
self.frame_duration = FRAME_DURATION
2015-06-27 04:49:10 -07:00
circle = Circle(
density = self.CIRCLE_DENSITY,
color = self.CIRCLE_BLUE
).repeat(5).scale(self.LOGO_RADIUS)
sphere = Sphere(
density = self.SPHERE_DENSITY,
color = self.SPHERE_BLUE
).scale(self.LOGO_RADIUS)
sphere.rotate(-np.pi / 7, [1, 0, 0])
sphere.rotate(-np.pi / 7)
alpha = 0.3
iris = Mobject()
Mobject.interpolate(
circle, sphere, iris,
self.CIRCLE_SPHERE_INTERPOLATION
)
for mob, color in [(iris, LIGHT_BROWN), (circle, DARK_BROWN)]:
mob.highlight(color, lambda (x, y, z) : x < 0 and y > 0)
mob.highlight(
"black",
lambda point: np.linalg.norm(point) < \
self.INNER_RADIUS_RATIO*self.LOGO_RADIUS
)
name = text_mobject("3Blue1Brown").center()
name.highlight("grey")
name.shift(2*DOWN)
self.play(Transform(
2015-06-27 04:49:10 -07:00
circle, iris,
run_time = DEFAULT_ANIMATION_RUN_TIME
))
self.add(name)
self.dither()
print "Dragging pixels..."
self.frames = drag_pixels(self.frames)
if __name__ == "__main__":
command_line_create_scene()