forked from HarleyCoops/Math-To-Manim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerated_scene.py
More file actions
40 lines (35 loc) · 1.2 KB
/
Copy pathgenerated_scene.py
File metadata and controls
40 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from manim import *
import numpy as np
class DiffusionScene(Scene):
def construct(self):
# Create initial and final distributions
alpha_0 = VGroup(*[Dot(radius=0.05, color=BLUE) for _ in range(50)])
alpha_0.arrange_in_grid(rows=5, cols=10, buff=0.2)
alpha_0.shift(LEFT * 3)
alpha_1 = VGroup(*[Dot(radius=0.05, color=GOLD) for _ in range(50)])
alpha_1.arrange_in_grid(rows=5, cols=10, buff=0.2)
alpha_1.shift(RIGHT * 3)
# Create interpolation path
def get_alpha_t(t):
return VGroup(*[
Dot(
radius=0.05,
color=interpolate_color(BLUE, GOLD, t),
point=interpolate(
alpha_0[i].get_center(),
alpha_1[i].get_center(),
t
)
)
for i in range(len(alpha_0))
])
# Animations
self.play(Create(alpha_0), Create(alpha_1))
self.play(
UpdateFromAlphaFunc(
alpha_0,
lambda m, t: m.become(get_alpha_t(t))
),
run_time=3
)
self.wait()