-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfreshparser.py
More file actions
41 lines (29 loc) · 1005 Bytes
/
Copy pathfreshparser.py
File metadata and controls
41 lines (29 loc) · 1005 Bytes
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
import sys
infile = sys.argv[1]
outfile = sys.argv[2]
file = open(infile, "r")
data = file.readlines()
out = open(outfile, "w")
metadata = data[0]
w, h, COLORSPACE = metadata.split()
WIDTH = int(w)
HEIGHT = int(h)
HEADER = "global function GetAnimation\n\narray<string> function GetAnimation() {\n array<string> animation = []\n"
FOOTER = "\n printt(\"Loaded animation\")\n return animation\n}"
def list_to_str(arr=list) -> str:
""" Turns a list in to a string """
output = ""
for i in arr:
output += i
return output
# everything = [["x"] * (WIDTH * HEIGHT)] * (len(data))
everything = [["x" for i in range(WIDTH * HEIGHT)] for j in range(len(data))]
for line in range(1, len(data)):
for pixel in range(WIDTH * HEIGHT):
everything[line][pixel] = data[line][pixel]
rotated = list(zip(*everything))[::-1]
# writes it out to the file
out.write(HEADER)
for e in rotated:
out.write(f' animation.append( "{list_to_str(e)}" )\n')
out.write(FOOTER)