diff --git a/scripts/sentences.py b/scripts/sentences.py index d66ba54..b29dc80 100644 --- a/scripts/sentences.py +++ b/scripts/sentences.py @@ -2,7 +2,9 @@ import os -TARGET_FILE = os.path.join(os.path.dirname(__file__), "..", "default", "inc_sentences.glsl") +TARGET_FILE = os.path.join( + os.path.dirname(__file__), "..", "default", "inc_sentences.glsl" +) SENTENCES = [ "forge", @@ -24,34 +26,38 @@ SENTENCES = [ "Art as code", ] -MAPPING = { - "π": "0xE3" -} +MAPPING = {"π": "0xE3"} + def code(char: str) -> str: if char in MAPPING: return MAPPING[char] return "0x" + f"{ord(char):02x}".upper() + def convert(txt: str) -> str: out = [] for i in range(20): out += [code(txt[i]) if i < len(txt) else "0x00"] return f"{{{', '.join(out)}}}" + def main() -> None: - with open(TARGET_FILE, mode = 'w') as file: - file.write(f"#ifndef INC_SENTENCES\n") - file.write(f"#define INC_SENTENCES\n\n") + with open(TARGET_FILE, mode="w") as file: + file.write("#ifndef INC_SENTENCES\n") + file.write("#define INC_SENTENCES\n\n") file.write(f"#define SENTENCE_COUNT {len(SENTENCES)}\n\n") file.write("const int sentences[SENTENCE_COUNT][20] = {\n") for sentence in SENTENCES: file.write(" " + convert(sentence) + "," + "\n") file.write("};\n\n") file.write("const int lengths[SENTENCE_COUNT] = {\n") - file.write(" " + ", ".join(str(len(sentence)) for sentence in SENTENCES) + "\n") + file.write( + " " + ", ".join(str(len(sentence)) for sentence in SENTENCES) + "\n" + ) file.write("};\n") file.write("#endif") -if __name__ == '__main__': - main() \ No newline at end of file + +if __name__ == "__main__": + main()