gb-tarot/misc.py
2025-03-17 15:08:25 -04:00

31 lines
1.2 KiB
Python

def splitfour(the_string):
""" takes a block of sprites output by gb-export.lua from aseprite.
divides it into four line-by-line and returns them as separate sprite maps.
if you arranged your sprites horizontally, this divides them up."""
out = ["", "", "", ""]
for l in the_string.split("\n"):
sub = list(l.strip()[3:].split(","))
length = len(sub)
out[0] += "db " + ", ".join(sub[0:length//4]) + "\n"
out[1] += "db " + ", ".join(sub[length//4 : length//2]) + "\n"
out[2] += "db " + ", ".join(sub[length//2 : 3*length//4]) + "\n"
out[3] += "db " + ", ".join(sub[3*length//4 : length]) + "\n"
for d in out:
print(d)
return out
def splitn(n, the_string):
""" takes a block of sprites output by gb-export.lua from aseprite.
divides it into n line-by-line and returns them as separate sprite maps.
if you arranged your sprites horizontally, this divides them up."""
out = ["" for _ in range(n)]
for l in the_string.split("\n"):
sub = list(l.strip()[3:].split(", "))
length = len(sub)
for i in range(n):
out[i] += "db " + ", ".join(sub[(i*length)//n:((i+1)*length)//n]) + "\n"
for d in out:
print(d)
return out