-
-
Save zeffii/0cb7489cb21736aa278f to your computer and use it in GitHub Desktop.
bash generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate(from_file, x, y, filenames, type='.png'): | |
filenames = filenames.split() | |
yield "# this file is generated automatically." | |
yield "convert {0} local01.miff".format(from_file) | |
for i, filename in enumerate(filenames): | |
l = "convert local01.miff -crop {0}x{1}+{2}+0 {3}{4}" | |
yield l.format(x, y, i*x, filename, type) | |
yield "rm local01.miff" | |
icons = "VTX V2X XALL BIX PERP CCEN EXM" | |
file_strings = generate("RENDERED_icons.png", 32, 32, icons) | |
for l in file_strings: | |
print(l) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
def generate(from_file, x, y, filenames, type='.png'): | |
filenames = filenames.split() | |
yield "# this file is generated automatically.\n" | |
yield "convert {0} local01.miff\n".format(from_file) | |
for i, filename in enumerate(filenames): | |
l = "convert local01.miff -crop {0}x{1}+{2}+0 {3}{4}\n" | |
yield l.format(x, y, i * x, filename, type) | |
yield "rm local01.miff\n" | |
def create_rsnatch(rendered_name, icons): | |
file_strings = generate(rendered_name, 32, 32, icons) | |
with open('rsnatch.sh', 'w') as rsnatch: | |
rsnatch.writelines(file_strings) | |
def run_rsnatch(): | |
dirname = os.path.dirname(__file__) | |
path_to_rsnatch = os.path.join(dirname, "rsnatch.sh") | |
subprocess.Popen(['sh', path_to_rsnatch]) | |
def main(): | |
rendered_name = 'RENDERED_ARRAY.png' | |
icons = "VTX V2X XALL BIX PERP CCEN EXM" | |
create_rsnatch(rendered_name, icons) | |
run_rsnatch() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment