-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeProceduralGeneration.py
More file actions
59 lines (47 loc) · 1.5 KB
/
CodeProceduralGeneration.py
File metadata and controls
59 lines (47 loc) · 1.5 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
from manim import *
# SetConfigFlags(FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE);
class CodeFromString(Scene):
def construct(self):
code = '''
typedef struct axis {
int x;
int y;
} Vector2;
typedef struct room {
Vector2 position;
int width; int height;
Vector2 center;
} Room;
'''
code2 = '''
newRoom.center = {
newRoom.position.x + (newRoom.width / 2),
newRoom.position.y + (newRoom.height / 2) };
}
'''
rendered_code = Code(code=code, tab_width=4,background_stroke_color=BLACK,
insert_line_no=False,
style="monokai",
language="cpp",
font="Fira Code")
rendered_code2 = Code(code=code2, tab_width=4,background_stroke_color=BLACK,
insert_line_no=False,
style="monokai",
language="cpp",
font="Fira Code").to_edge(DOWN, buff=1)
self.play(Write(rendered_code), run_time=3)
self.play(rendered_code.animate.shift(UP))
self.play(Write(rendered_code2), run_time=3)
self.wait(2)
class CodeVsync(Scene):
def construct(self):
code = '''
SetConfigFlags(FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE);
'''
rendered_code = Code(code=code, tab_width=4,background_stroke_color=BLACK,
insert_line_no=False,
style="monokai",
language="python",
font="Fira Code").scale(0.7)
self.play(Write(rendered_code), run_time=3)
self.wait(2)