-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsprite_micro_gen.py
163 lines (153 loc) · 4.83 KB
/
sprite_micro_gen.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
"""Basic UI and main function for the sprite micro generator."""
import os
import sys
import draw_sprite_animations as dsa
import draw_initial as init_draw
import saving as save
def main(
start_x,
start_y,
frames,
seed,
pixel_number,
mode,
wiggle,
xml,
pixel_size,
file_name,
server_mode,
):
"""Main function for the sprite micro generator."""
int_x = start_x
int_y = start_y
filename = []
filename_2 = []
server_file_wiggle_name = []
server_file_explode_name = []
cur_file_loc = os.path.dirname(os.path.realpath(__file__))
filecount = 0
if mode == "1":
guide_array_x, guide_array_y, color_array = init_draw.draw_random_image_intial(
int_x, int_y, seed, pixel_number, file_name, pixel_size
)
elif mode == "2":
guide_array_x, guide_array_y, guide_array_size, color_array = init_draw.parse_xml(xml, file_name)
elif mode == "3":
guide_array_x, guide_array_y, color_array = init_draw.draw_planet(
int_x, int_y, seed, pixel_number, file_name, pixel_size
)
for i in range(frames):
name, server_name = dsa.draw_image_guided_wiggle(
guide_array_x, guide_array_y, color_array, i, wiggle, guide_array_size, file_name
)
if server_name != "":
filename.append(name)
server_file_wiggle_name.append(server_name)
for i in range(frames):
name_2, server_name = dsa.draw_image_guided_explode(
int_x,
int_y,
guide_array_x,
guide_array_y,
color_array,
i,
wiggle,
guide_array_size,
file_name,
)
if server_name != "":
filename_2.append(name_2)
server_file_explode_name.append(server_name)
gif_loc_1 = save.gif_maker(file_name+"wiggle",filename, cur_file_loc, seed, pixel_number, frames, filecount)
gif_loc_2 = save.gif_maker(file_name+"explode",
filename_2, cur_file_loc, seed, pixel_number, frames, filecount
)
if server_mode == True:
return server_file_wiggle_name, server_file_explode_name, gif_loc_1, gif_loc_2
if __name__ == "__main__":
"""Terminal interface for the sprite micro generator."""
mode = "0"
count = 25
start_x = 50
start_y = 50
seed = 3
pixel_number = 300
wiggle = 1
xml = "rockball.xml"
pixel_size = 1
file_name = "asteroid"
server_mode = False
while True:
print(
"Press 1 to run in random mode or 2 for xml mode,press 3 to draw a planet, 4 for drawing settings, 5 to set xml file"
)
print("Press e to exit")
mode = input()
if mode == "1":
main(
start_x,
start_y,
count,
seed,
pixel_number,
mode,
wiggle,
xml,
pixel_size,
file_name,
server_mode,
)
elif mode == "2":
main(
start_x,
start_y,
count,
seed,
pixel_number,
mode,
wiggle,
xml,
pixel_size,
file_name,
server_mode,
)
elif mode == "3":
main(
start_x,
start_y,
count,
seed,
pixel_number,
mode,
wiggle,
xml,
pixel_size,
file_name,
server_mode,
)
elif mode == "4":
print("Enter the number of frames, current frames is " + str(count))
count = int(input())
print("Enter the seed, current seed is " + str(seed))
seed = int(input())
print(
"Enter the number of pixels, current pixel number is "
+ str(pixel_number)
)
pixel_number = int(input())
print("Enter the wiggle, current wiggle is " + str(wiggle))
wiggle = int(input())
print("Enter the pixel size, current pixel size is " + str(pixel_size))
pixel_size = int(input())
print("Enter the file name, current file name is " + str(file_name))
file_name = input()
elif mode == "5":
print("Enter the xml file name with extension, likely .xml or .oxs")
xml = input()
current_file_path = os.path.dirname(os.path.realpath(__file__))
if not os.path.isfile(current_file_path + "\\patterns\\" + xml):
print(f"The file 'patterns/{xml}' does not exist.")
elif mode == "e":
sys.exit()
else:
print("Invalid input")