Skip to content

Instantly share code, notes, and snippets.

@tbnorth
Created March 28, 2018 15:35
Show Gist options
  • Save tbnorth/f49f1e00e331d3822f912a126dbd2a10 to your computer and use it in GitHub Desktop.
Save tbnorth/f49f1e00e331d3822f912a126dbd2a10 to your computer and use it in GitHub Desktop.
my Leo icons
"""
make_icons.py - make simple 4 color icons for the box00.png...box15.png
Could be adapted for other icon styles, iterates the 16 states in the
correct order.
WARNING: saves box00.png...box15.png in current directory
Terry Brown, [email protected], Tue Mar 27 12:01:11 2018
"""
from itertools import product
from PIL import Image
# ordered list of staes
states = ['clean', 'dirty'], ['no_clone', 'clone'], ['unmarked', 'marked'], ['empty', 'content']
# solarized colors
sol = {'base03': '002b36', 'base02': '073642', 'base01': '586e75', 'base00': '657b83',
'base0': '839496', 'base1': '93a1a1', 'base2': 'eee8d5', 'base3': 'fdf6e3',
'yellow': 'b58900', 'orange': 'cb4b16', 'red': 'dc322f', 'magenta': 'd33682',
'violet': '6c71c4', 'blue': '268bd2', 'cyan': '2aa198', 'green': '859900'}
for k in sol:
sol[k] = tuple([int(sol[k][i*2:i*2+2], base=16) for i in range(3)] + [255])
w, h = 10, 8
# states for which marks are made on the transparent icon
# pos (0,0) top left, (1,1) bottom right quarter
marks = {
'dirty': {'color': sol['yellow'], 'pos': (range(0, h), range(0, 3))},
'clone': {'color': sol['magenta'], 'pos': (range(0, h), range(3, 6))},
'marked': {'color': sol['cyan'], 'pos': (range(0, h), range(6, 9))},
'empty': {'color': sol['base01'], 'pos': (range(0, h), range(9, 10))},
}
for n, state in enumerate(product(*states)):
print(n, state)
img = Image.new('RGBA', (w, h), (0, 0, 0, 0))
pix = img.load()
for mark, opt in marks.items():
if mark in state:
for row in opt['pos'][0]:
for col in opt['pos'][1]:
pix[col, row] = opt['color']
img.save('box%02d.png' % n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment