3b1b-manim/old_projects/generate_logo.py

67 lines
2.1 KiB
Python
Raw Normal View History

2019-05-02 20:36:14 -07:00
from manimlib.imports import *
2015-10-29 13:45:28 -07:00
## Warning, much of what is in this class
## likely not supported anymore.
2015-10-29 13:45:28 -07:00
class LogoGeneration(Scene):
2016-02-27 16:32:53 -08:00
CONFIG = {
2015-10-29 13:45:28 -07:00
"radius" : 1.5,
"inner_radius_ratio" : 0.55,
"circle_density" : 100,
"circle_blue" : "skyblue",
"circle_brown" : DARK_BROWN,
"circle_repeats" : 5,
"sphere_density" : 50,
"sphere_blue" : DARK_BLUE,
"sphere_brown" : LIGHT_BROWN,
"interpolation_factor" : 0.3,
2015-10-29 17:00:46 -07:00
"frame_duration" : 0.03,
"run_time" : 3,
2015-10-29 13:45:28 -07:00
}
def construct(self):
2015-10-29 17:00:46 -07:00
digest_config(self, {})
## Usually shouldn't need this...
2016-02-27 18:50:33 -08:00
self.frame_duration = self.CONFIG["frame_duration"]
2015-10-29 17:00:46 -07:00
##
2015-10-29 13:45:28 -07:00
digest_config(self, {})
circle = Circle(
density = self.circle_density,
color = self.circle_blue
)
circle.repeat(self.circle_repeats)
circle.scale(self.radius)
sphere = Sphere(
density = self.sphere_density,
color = self.sphere_blue
)
sphere.scale(self.radius)
sphere.rotate(-np.pi / 7, [1, 0, 0])
sphere.rotate(-np.pi / 7)
iris = Mobject()
iris.interpolate(
circle, sphere,
2015-10-29 13:45:28 -07:00
self.interpolation_factor
)
for mob, color in [(iris, self.sphere_brown), (circle, self.circle_brown)]:
mob.set_color(color, lambda x_y_z : x_y_z[0] < 0 and x_y_z[1] > 0)
2018-03-30 11:51:31 -07:00
mob.set_color(
2015-10-29 13:45:28 -07:00
"black",
2018-08-15 17:30:24 -07:00
lambda point: get_norm(point) < \
2015-10-29 13:45:28 -07:00
self.inner_radius_ratio*self.radius
)
self.name_mob = TextMobject("3Blue1Brown").center()
2018-03-30 11:51:31 -07:00
self.name_mob.set_color("grey")
self.name_mob.shift(2*DOWN)
2015-10-29 13:45:28 -07:00
self.play(Transform(
circle, iris,
2015-10-29 17:00:46 -07:00
run_time = self.run_time
2015-10-29 13:45:28 -07:00
))
self.frames = drag_pixels(self.frames)
2015-10-29 17:00:46 -07:00
self.save_image(IMAGE_DIR)
self.logo = MobjectFromPixelArray(self.frames[-1])
self.add(self.name_mob)
2018-01-15 19:15:05 -08:00
self.wait()
2015-10-29 13:45:28 -07:00