forked from 3b1b/manim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_scenes.py
135 lines (114 loc) · 4.35 KB
/
example_scenes.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env python
from helpers import *
from mobject.tex_mobject import TexMobject
from mobject import Mobject
from mobject.image_mobject import ImageMobject
from mobject.vectorized_mobject import *
from animation.animation import Animation
from animation.transform import *
from animation.simple_animations import *
from animation.playground import *
from topics.geometry import *
from topics.characters import *
from topics.functions import *
from topics.number_line import *
from topics.combinatorics import *
from scene import Scene
from camera import Camera
from mobject.svg_mobject import *
from mobject.tex_mobject import *
from mobject.vectorized_mobject import *
from old_projects import three_dimensions
from old_projects.eola import *
import sys
## To watch one of these scenes, run the following:
## python extract_scenes.py -p file_name <SceneName>
class showRatio(Scene):
def construct(self):
ratioR = float(sys.argv[4])
ratioG = float(sys.argv[5])
ratioB = float(sys.argv[6])
ratioRv = float(sys.argv[7])
red = Vector((RIGHT*4.2)*ratioR, color=RED)
blue = Vector((UP*4)*ratioB, color=BLUE)
green = Vector((UP*4-1.4)*ratioG, color=GREEN)
redv = Vector((RIGHT*4.2)*ratioRv, color=RED)
help = TextMobject("with the help of 3blue1brown's Lib")
for mob in help.submobjects[13:13+5]:
mob.highlight(BLUE)
for mob in help.submobjects[18:18+6]:
mob.highlight('#B1695F')
Title = TexMobject("Colors Ratio", color=TEAL)
Ratio = TextMobject([str(round(ratioR*100, 2)), str(round(ratioG*100, 2)),str(round(ratioB*100, 2))])
Ratio2 = TextMobject([str(round(ratioRv*100, 2)), str(round(ratioG*100, 2)),str(round(ratioB*100, 2))])
Ratio.split()[0].highlight(RED)
Ratio.split()[1].highlight(GREEN)
Ratio.split()[2].highlight(BLUE)
Ratio.next_to(Title, DOWN, buff=0.5)
Ratio2.split()[0].highlight(RED)
Ratio2.split()[1].highlight(GREEN)
Ratio2.split()[2].highlight(BLUE)
Ratio2.next_to(Title, DOWN, buff=0.5)
self.play(Write(Title.highlight(YELLOW).to_edge(DOWN), run_time=1))
self.play(ShowCreation(red, run_time=2))
self.play(ShowCreation(blue, run_time=2))
self.play(ShowCreation(green, run_time=2))
self.play(Write(Ratio))
self.dither(4)
self.remove(Ratio)
self.play(Transform(red, redv))
self.play(Write(Ratio2))
self.dither(3)
self.clear()
self.play(Write(TextMobject("Made by : M.Selim :]", color=YELLOW).scale(2), run_time = 2))
self.play(Write(help.to_edge(DOWN)), run_time=4)
self.dither(7)
class SquareToCircle(Scene):
def construct(self):
circle = Circle()
square = Square()
square.rotate(np.pi/8)
self.play(ShowCreation(square))
self.play(Transform(square, circle))
self.dither()
class WarpSquare(Scene):
def construct(self):
square = Square()
self.play(ApplyPointwiseFunction(
lambda (x, y, z) : complex_to_R3(np.exp(complex(x, y))),
square
))
self.dither()
class WriteStuff(Scene):
def construct(self):
self.play(Write(TextMobject("Stuff").scale(3)))
class Det(Scene):
def construct(self):
red = Vector((RIGHT*4.2)*0.137, color = RED)
blue = Vector((UP*4), color = BLUE)
green = Vector((UP*4-1.4)*0.054, color = GREEN)
self.play(ShowCreation(red, run_time = 2))
self.play(ShowCreation(blue, run_time = 2))
self.play(ShowCreation(green, run_time = 2))
class DefineColumnSpace(Scene):
def construct(self):
left_words = TextMobject(
"Set of all possible\\\\",
"outputs",
"$A\\vec{\\textbf{v}}$",
)
left_words[1].highlight(TEAL)
VMobject(*left_words[-1][1:]).highlight(YELLOW)
arrow = DoubleArrow(LEFT, RIGHT).to_edge(UP)
right_words = TextMobject("``Column space''", "of $A$")
right_words[0].highlight(left_words[1].get_color())
everyone = VMobject(left_words, arrow, right_words)
everyone.arrange_submobjects(RIGHT)
everyone.to_edge(UP)
self.play(Write(left_words))
self.dither()
self.play(
ShowCreation(arrow),
Write(right_words)
)
self.dither()