Prelim: Updated handling of colour scheme constants

This commit is contained in:
Rory Fewell
2023-04-21 00:32:52 +01:00
parent 6fecdc35fb
commit 0183b2e6f7
23 changed files with 105 additions and 1 deletions

View File

@@ -10,11 +10,14 @@ from PIL import Image, ImageDraw
def main():
parser = argparse.ArgumentParser(prog="Theme Part Composer Utility", description="Composes theme part graphics from source files.", epilog="See README.MD if you want to know the details.")
parser.add_argument("scheme", help="path to the scheme file")
parser.add_argument("inputdir", help="the input directory to scan for files")
parser.add_argument("outputdir", help="the output directory to place composed files")
args = parser.parse_args()
scheme = parse_scheme(args.scheme)
for filename in os.listdir(args.inputdir):
if fnmatch.fnmatch(filename, "*.src.png"):
basename = get_basename(filename)
@@ -30,7 +33,10 @@ def main():
drawing = ImageDraw.Draw(newImage)
drawing.bitmap((0, 0), maskMono, "rgb(128,128,128)")
if "progress" in basename:
drawing.bitmap((0, 0), maskMono, scheme["ACTIVE_TITLE_BAR_BG1"])
else:
drawing.bitmap((0, 0), maskMono, scheme["THREED_OBJECTS_BG"])
composed = Image.alpha_composite(newImage, pngRGB)
@@ -43,5 +49,22 @@ def main():
def get_basename(filename):
return filename[0:filename.find(".")]
def parse_scheme(path):
scheme = dict()
with open(path) as schemefile:
for line in schemefile:
if line == "":
continue
equals_pos = line.find("=")
scheme_id = line[0:equals_pos]
scheme_value = line[equals_pos + 1:len(line)]
scheme[scheme_id] = scheme_value
return scheme
if __name__ == "__main__":
main()