Icon colors.

This commit is contained in:
Sergey Vartanov 2015-08-07 12:44:20 +03:00
parent 289327887c
commit b8e68a9745
5 changed files with 96 additions and 33 deletions

View file

@ -4,8 +4,9 @@ Author: Sergey Vartanov (me@enzet.ru).
import copy
import extract_icon
import process
import os
import process
import random
import sys
import yaml
@ -19,16 +20,27 @@ import svg
icons_file_name = '../icons/icons.svg'
icon_grid_file_name = '../icon_grid.svg'
icon_colors_file_name = '../data/icon_colors'
def draw_icon(icon):
def draw_icon(icon, color='444444'):
output_file.write('<path d="' + icon['path'] + '" ' + \
'style="fill:#444444;stroke:none;' + \
'style="fill:#' + color + ';stroke:none;' + \
'stroke-width:3;stroke-linejoin:round;" ' + \
'transform="translate(' + icon['x'] + ',' + icon['y'] + ')" />\n')
# Actions
icon_colors = [('FFFFFF', '444444')]
if os.path.isfile(icon_colors_file_name):
icon_colors_file = open(icon_colors_file_name)
for line in icon_colors_file.read().split('\n'):
background_color = hex(int(line[0:3]))[2:] + hex(int(line[3:6]))[2:] + \
hex(int(line[6:9]))[2:]
foreground_color = hex(int(line[10:13]))[2:] + hex(int(line[13:16]))[2:] + \
hex(int(line[16:19]))[2:]
icon_colors.append((background_color, foreground_color))
step = 24
width = step * 10
@ -64,12 +76,14 @@ for element in scheme['tags']:
if not (set([icon] + [icon2] + [icon3] + element['over_icon']) in to_draw):
to_draw.append(set([icon] + [icon2] + [icon3] + element['over_icon']))
icons = []
height = 24
number = 0
icons = []
for icons_to_draw in to_draw:
drawed = False
icons.append({'xx': x - 8.0, 'yy': y - 8.0})
for icon in icons_to_draw:
path, xx, yy = extracter.get_path(icon)
if path:
@ -91,7 +105,12 @@ output_file = svg.SVG(open(icon_grid_file_name, 'w+'))
output_file.begin(width, height)
for icon in icons:
draw_icon(icon)
if 'xx' in icon:
xx, yy = icon['xx'], icon['yy']
background_color, foreground_color = random.choice(icon_colors)
output_file.rect(xx - 2, yy - 2, 20, 20, color=background_color)
else:
draw_icon(icon, foreground_color)
print 'Icons: ' + str(number) + '.'