forked from YishiMichael/manim3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
74 lines (60 loc) · 2.22 KB
/
Copy pathexamples.py
File metadata and controls
74 lines (60 loc) · 2.22 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
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
from scipy.spatial.transform import Rotation
from manim3 import *
class ShapeTransformExample(Scene):
def construct(self) -> None:
circle = Circle()
circle.set_fill(color=PINK, opacity=0.9)
circle.set_stroke(color=YELLOW, width=4)
square = Square()
square.set_fill(opacity=1.0)
self.add(square)
self.play(Transform(square, circle, replace=False))
self.wait()
self.wait(5)
class TexTransformExample(Scene):
def construct(self) -> None:
text = Text("Text").scale(3).add_stroke(width=0.2, color=BLUE).add_stroke(width=0.4, color=GREEN).concatenate()
tex = Tex("Tex").scale(3).set_fill(color=BLUE).set_stroke(width=0.3, color=PINK).concatenate()
self.add(text)
self.play(Transform(text, tex.shift(RIGHT * 2), replace=True))
self.wait()
self.play(Transform(tex, tex.copy().shift(LEFT * 2)))
self.wait()
class Rotating(Animation):
def __init__(
self,
mobject: Mobject
) -> None:
def alpha_animate_func(
alpha_0: float,
alpha: float
) -> None:
mobject.rotate(Rotation.from_rotvec(DOWN * (alpha - alpha_0) * 0.5))
super().__init__(
alpha_animate_func=alpha_animate_func,
alpha_regroup_items=[],
start_time=0.0,
stop_time=None
)
class ThreeDTextExample(Scene):
def construct(self) -> None:
self.add_point_light(position=4 * RIGHT + 4 * UP + 2 * OUT)
text = Text("Text").concatenate()
text_3d = MeshMobject()
text_3d._geometry_ = PrismoidGeometry(text._shape_)
text_3d._model_matrix_ = text._model_matrix_
text_3d.scale(5.0).stretch_to_fit_depth(0.5)
text_3d.set_style(color="#00FFAA99")
self.add(text_3d)
self.prepare(Rotating(text_3d))
self.wait(10)
if __name__ == "__main__":
config = Config()
#config.tex.use_mathjax = True
#config.rendering.time_span = (2.0, 3.0)
#config.rendering.fps = 3
#config.rendering.preview = False
#config.rendering.write_video = True
#config.size.pixel_size = (960, 540)
#config.rendering.write_last_frame = True
ThreeDTextExample.render(config)