A small python script used to generate Atom Icons inspired from Flags of different countries.
Check out the atom-icons project for these and other such icons for Atom
You can find the flagColors.json file here
A small python script used to generate Atom Icons inspired from Flags of different countries.
Check out the atom-icons project for these and other such icons for Atom
You can find the flagColors.json file here
import json | |
import os | |
json_data = open('flagColors.json') | |
data = json.load(json_data) | |
configs = [] | |
if not os.path.exists('svg'): | |
os.makedirs('svg') | |
for flag in data: | |
colors = flag['colors'] | |
count = 0 | |
for color in colors: | |
if color['percent'] > 2: | |
count += 1 | |
if count >= 3: | |
if round(colors[0]['percent']) == round(colors[1]['percent']) == round(colors[2]['percent']): | |
configs.extend([ | |
{'name': flag['name']+"-1", 'colors': [colors[0]['hex'],colors[1]['hex'],colors[2]['hex']]}, | |
{'name': flag['name']+"-2", 'colors': [colors[1]['hex'],colors[2]['hex'],colors[0]['hex']]}, | |
{'name': flag['name']+"-3", 'colors': [colors[2]['hex'],colors[0]['hex'],colors[1]['hex']]}, | |
]) | |
elif round(colors[0]['percent']) == round(colors[1]['percent']): | |
configs.extend([ | |
{'name': flag['name']+"-1", 'colors': [colors[0]['hex'],colors[1]['hex'],colors[2]['hex']]}, | |
{'name': flag['name']+"-2", 'colors': [colors[1]['hex'],colors[0]['hex'],colors[2]['hex']]} | |
]) | |
else: | |
configs.append( | |
{'name': flag['name'], 'colors': [colors[0]['hex'],colors[1]['hex'],colors[2]['hex']]} | |
) | |
else: | |
if round(colors[0]['percent']) == round(colors[1]['percent']): | |
configs.extend([ | |
{'name': flag['name']+"-1", 'colors': [colors[0]['hex'],colors[0]['hex'],colors[1]['hex']]}, | |
{'name': flag['name']+"-2", 'colors': [colors[0]['hex'],colors[1]['hex'],colors[1]['hex']]}, | |
{'name': flag['name']+"-3", 'colors': [colors[1]['hex'],colors[0]['hex'],colors[0]['hex']]}, | |
{'name': flag['name']+"-4", 'colors': [colors[1]['hex'],colors[1]['hex'],colors[0]['hex']]} | |
]) | |
else: | |
configs.append( | |
{'name': flag['name'], 'colors': [colors[0]['hex'],colors[1]['hex'],colors[1]['hex']]} | |
) | |
for config in configs: | |
src = open('icon.svg').read() | |
src = src.replace('color_1', config['colors'][0]) | |
src = src.replace('color_2', config['colors'][1]) | |
src = src.replace('color_3', config['colors'][2]) | |
f = open("svg/"+"flag_"+config['name'].replace(" ", '-') + '.svg','w') | |
f.write(src) | |
f.close() |