Skip to content

Instantly share code, notes, and snippets.

@shuuji3
Created September 15, 2021 03:32
Show Gist options
  • Save shuuji3/c4793459e7134e20d324cf724aafb22a to your computer and use it in GitHub Desktop.
Save shuuji3/c4793459e7134e20d324cf724aafb22a to your computer and use it in GitHub Desktop.
Run `montage` commands to create go-mochi 4 bits counters.
# Run `montage` commands to create go-mochi 4 bits counters.
import subprocess
import itertools
mochi_bit = ['mochi-dark2.png', 'mochi.png']
bits_list = itertools.product((0, 1), (0, 1), (0, 1), (0, 1))
# => [(0, 0, 0, 0), (0, 0, 0, 1), ...]
for bits, n in zip(bits_list, range(16)):
mochi_list = ' '.join(map(lambda bit: mochi_bit[bit], bits))
filename = f'go-mochi-{n:04b}.png'
command = f'montage {mochi_list} -geometry 128x128+2+2 {filename}'.split(
' ')
# => montage mochi-dark2.png mochi-dark2.png mochi-dark2.png mochi-dark2.png -geometry 48x48+2+2 go-mochi-0000.png
subprocess.call(command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment