From b0d4f79820eecafadaffc443df57eb0d18872b9e Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Wed, 14 Sep 2022 23:30:46 +0200 Subject: Added all patterns to the code and made that you could select between them with j and k and animate them with a and stop the animation with s --- presets/scripts/force42Height.py | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 presets/scripts/force42Height.py (limited to 'presets/scripts/force42Height.py') diff --git a/presets/scripts/force42Height.py b/presets/scripts/force42Height.py new file mode 100755 index 0000000..845252e --- /dev/null +++ b/presets/scripts/force42Height.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 + +import os + +path = "/home/pengu/test/rust-dev/gof-rs/presets/dir/patterns" +newpath = "/home/pengu/test/rust-dev/gof-rs/presets/dir/newpatterns" + +os.chdir(path) + +def get_file_lines(file): + cnt = 0 + with open(f"{path}/{file}", "r") as file: + for _ in file.readlines(): + cnt += 1 + return cnt + +cnt = 0 +for file in os.listdir(): + cnt += 1 + lines = 42 - get_file_lines(file) + upper = 0 + lower = 0 + if lines % 2 == 0: + upper = lines // 2 + lower = lines // 2 + else: + upper = lines // 2 + lower = upper + 1 + with open(f"{path}/{file}", "r") as r: + with open(f"{newpath}/pattern{cnt}.txt", "w") as w: + for _ in range(upper): + w.write("........................................................................\n") + for line in r.readlines(): + w.write(line) + for _ in range(lower): + w.write("........................................................................\n") + + + + + + -- cgit v1.2.3