Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/Text.001
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/0cb7489cb21736aa278f to your computer and use it in GitHub Desktop.
Save zeffii/0cb7489cb21736aa278f to your computer and use it in GitHub Desktop.
bash generator
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)
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