forked from 3b1b/manim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfractal_charm.py
111 lines (101 loc) · 3.01 KB
/
fractal_charm.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
from manimlib.imports import *
class FractalCreation(Scene):
CONFIG = {
"fractal_class" : PentagonalFractal,
"max_order" : 5,
"transform_kwargs" : {
"path_arc" : np.pi/6,
"lag_ratio" : 0.5,
"run_time" : 2,
},
"fractal_kwargs" : {},
}
def construct(self):
fractal = self.fractal_class(order = 0, **self.fractal_kwargs)
self.play(FadeIn(fractal))
for order in range(1, self.max_order+1):
new_fractal = self.fractal_class(
order = order,
**self.fractal_kwargs
)
fractal.align_data(new_fractal)
self.play(Transform(
fractal, new_fractal,
**self.transform_kwargs
))
self.wait()
self.wait()
self.fractal = fractal
class PentagonalFractalCreation(FractalCreation):
pass
class DiamondFractalCreation(FractalCreation):
CONFIG = {
"fractal_class" : DiamondFractal,
"max_order" : 6,
"fractal_kwargs" : {"height" : 6}
}
class PiCreatureFractalCreation(FractalCreation):
CONFIG = {
"fractal_class" : PiCreatureFractal,
"max_order" : 6,
"fractal_kwargs" : {"height" : 6},
"transform_kwargs" : {
"lag_ratio" : 0,
"run_time" : 2,
},
}
def construct(self):
FractalCreation.construct(self)
fractal = self.fractal
smallest_pi = fractal[0][0]
zoom_factor = 0.1/smallest_pi.get_height()
fractal.generate_target()
fractal.target.shift(-smallest_pi.get_corner(UP+LEFT))
fractal.target.scale(zoom_factor)
self.play(MoveToTarget(fractal, run_time = 10))
self.wait()
class QuadraticKochFractalCreation(FractalCreation):
CONFIG = {
"fractal_class" : QuadraticKoch,
"max_order" : 5,
"fractal_kwargs" : {"radius" : 10},
# "transform_kwargs" : {
# "lag_ratio" : 0,
# "run_time" : 2,
# },
}
class KochSnowFlakeFractalCreation(FractalCreation):
CONFIG = {
"fractal_class" : KochSnowFlake,
"max_order" : 6,
"fractal_kwargs" : {
"radius" : 6,
"num_submobjects" : 100,
},
"transform_kwargs" : {
"lag_ratio" : 0.5,
"path_arc" : np.pi/6,
"run_time" : 2,
},
}
class WonkyHexagonFractalCreation(FractalCreation):
CONFIG = {
"fractal_class" : WonkyHexagonFractal,
"max_order" : 5,
"fractal_kwargs" : {"height" : 6},
}
class SierpinskiFractalCreation(FractalCreation):
CONFIG = {
"fractal_class" : Sierpinski,
"max_order" : 6,
"fractal_kwargs" : {"height" : 6},
"transform_kwargs" : {
"path_arc" : 0,
},
}
class CircularFractalCreation(FractalCreation):
CONFIG = {
"fractal_class" : CircularFractal,
"max_order" : 5,
"fractal_kwargs" : {"height" : 6},
}