mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
First version
This commit is contained in:
parent
69a091748b
commit
15d582e673
3 changed files with 77 additions and 2 deletions
75
active_projects/name_animation.py
Normal file
75
active_projects/name_animation.py
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
|
NAME_WITH_SPACES = "Prime Meridian"
|
||||||
|
DIAMETER = 3.0
|
||||||
|
RADIUS = DIAMETER / 2
|
||||||
|
LETTER_SCALE = 1
|
||||||
|
|
||||||
|
class NameAnimationScene(Scene):
|
||||||
|
|
||||||
|
def construct(self):
|
||||||
|
|
||||||
|
name = ''.join(NAME_WITH_SPACES.split(' '))
|
||||||
|
letters = list(name)
|
||||||
|
nb_letters = len(letters)
|
||||||
|
randy = PiCreature()
|
||||||
|
randy.move_to(ORIGIN).scale_to_fit_height(0.5 * DIAMETER)
|
||||||
|
randy.set_color(BLUE_E)
|
||||||
|
randy.look_at(UP + RIGHT)
|
||||||
|
self.add(randy)
|
||||||
|
dtheta = TAU/nb_letters
|
||||||
|
angles = np.arange(TAU/4,-3 * TAU / 4,-dtheta)
|
||||||
|
name_mob = VGroup()
|
||||||
|
for (letter, angle) in zip(letters, angles):
|
||||||
|
letter_mob = TextMobject(letter).scale(LETTER_SCALE)
|
||||||
|
pos = RADIUS * np.cos(angle) * RIGHT + RADIUS * np.sin(angle) * UP
|
||||||
|
letter_mob.move_to(pos)
|
||||||
|
name_mob.add(letter_mob)
|
||||||
|
|
||||||
|
pos2 = RADIUS * np.cos(angles[2]) * RIGHT + RADIUS * np.sin(angles[2]) * UP
|
||||||
|
|
||||||
|
self.play(
|
||||||
|
LaggedStart(Write, name_mob, run_time = 3),
|
||||||
|
ApplyMethod(randy.look_at, pos2, run_time = 3)
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in range(2,nb_letters + 2):
|
||||||
|
|
||||||
|
group = []
|
||||||
|
|
||||||
|
for (j,letter_mob) in enumerate(name_mob.submobjects):
|
||||||
|
|
||||||
|
new_angle = TAU / 4 - i * j * dtheta
|
||||||
|
new_pos = RADIUS * np.cos(new_angle) * RIGHT + RADIUS * np.sin(new_angle) * UP
|
||||||
|
letter_mob.target = letter_mob.copy().move_to(new_pos)
|
||||||
|
anim = MoveToTarget(letter_mob, path_arc = - j * dtheta)
|
||||||
|
group.append(anim)
|
||||||
|
|
||||||
|
self.play(
|
||||||
|
AnimationGroup(*group, run_time = 3),
|
||||||
|
ApplyMethod(randy.look_at,name_mob.submobjects[2], run_time = 3)
|
||||||
|
)
|
||||||
|
self.wait(0.5)
|
||||||
|
|
||||||
|
|
||||||
|
thank_you = TextMobject("Thank You!").next_to(randy, DOWN)
|
||||||
|
new_randy = randy.copy()
|
||||||
|
new_randy.change("hooray")
|
||||||
|
new_randy.set_color(BLUE_E)
|
||||||
|
new_randy.look_at(ORIGIN)
|
||||||
|
self.play(
|
||||||
|
Transform(name_mob, thank_you),
|
||||||
|
Transform(randy, new_randy)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
\usepackage{mathrsfs}
|
\usepackage{mathrsfs}
|
||||||
\usepackage{calligra}
|
\usepackage{calligra}
|
||||||
\usepackage{wasysym}
|
\usepackage{wasysym}
|
||||||
\usepackage[UTF8]{ctex}
|
%\usepackage[UTF8]{ctex}
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\centering
|
\centering
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
\usepackage{ragged2e}
|
\usepackage{ragged2e}
|
||||||
\usepackage{physics}
|
\usepackage{physics}
|
||||||
\usepackage{xcolor}
|
\usepackage{xcolor}
|
||||||
\usepackage[UTF8]{ctex}
|
%\usepackage[UTF8]{ctex}
|
||||||
\linespread{1}
|
\linespread{1}
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
|
|
Loading…
Add table
Reference in a new issue