generated from othneildrew/Best-README-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scene.py
95 lines (84 loc) · 3.25 KB
/
scene.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
from manim import *
from pathlib import Path
from scripts.fetch_data import fetch_char_data, fetch_enemy_data
from utils import Circle, circle_collide_sim
config.pixel_height = 1080 * 3
config.pixel_width = 1920 * 3
class ArkVisChar(Scene):
def construct(self):
self.camera.background_color = "#ece6e2"
x_range, y_range = [300, 1550, 100], [0, 1050, 100]
axes = Axes(
x_range=x_range,
y_range=y_range,
x_axis_config={
"numbers_to_include": np.arange(*x_range),
},
y_axis_config={
"numbers_to_include": np.arange(*y_range),
},
axis_config= {
'include_ticks': True,
'font_size': 24,
},
tips=False
)
axes.set_color(BLACK)
self.add(axes)
char_data = fetch_char_data()
img_obj_list, circles = [], []
for px, py, pz, image_path in char_data:
if not Path(image_path).exists(): continue
img = ImageMobject(image_path)
img.scale(0.1 * pz / 1500.)
self.add(img)
img.move_to(axes.c2p(px, py))
img_obj_list.append(img)
circles.append(Circle(axes.c2p(px, py)[0], axes.c2p(px, py)[1], img.height/2))
for _ in range(10):
circle_collide_sim(circles)
# animations = []
for i, circle in enumerate(circles):
px, py = circle.x, circle.y
# animations.append(ApplyMethod(img_obj_list[i].move_to, np.array([px, py, 0])))
img_obj_list[i].move_to(np.array([px, py, 0]))
# self.play(*animations, run_time=2)
class ArkVisEnemy(Scene):
def construct(self):
self.camera.background_color = "#ece6e2"
x_range, y_range = [0, 3000, 100], [0, 3000, 100]
axes = Axes(
x_range=x_range,
y_range=y_range,
x_axis_config={
"numbers_to_include": np.arange(*x_range),
},
y_axis_config={
"numbers_to_include": np.arange(*y_range),
},
axis_config= {
'include_ticks': True,
'font_size': 16,
},
tips=False
)
axes.set_color(BLACK)
self.add(axes)
enemy_data = fetch_enemy_data(download_images=False)
img_obj_list, circles = [], []
for px, py, pz, image_path in enemy_data:
if not Path(image_path).exists(): continue
img = ImageMobject(image_path)
img.scale(0.1 * pz / pz) # TODO: image size should be adjusted by pz
self.add(img)
img.move_to(axes.c2p(px, py))
img_obj_list.append(img)
circles.append(Circle(axes.c2p(px, py)[0], axes.c2p(px, py)[1], img.height/2))
for _ in range(10):
circle_collide_sim(circles, lr=0.5)
# animations = []
for i, circle in enumerate(circles):
px, py = circle.x, circle.y
# animations.append(ApplyMethod(img_obj_list[i].move_to, np.array([px, py, 0])))
img_obj_list[i].move_to(np.array([px, py, 0]))
# self.play(*animations, run_time=2)