mirror of
https://github.com/enzet/map-machine.git
synced 2025-07-18 17:08:00 +02:00
All icons HTML page.
This commit is contained in:
parent
98d1e056d9
commit
ad3227ac37
5 changed files with 285 additions and 85 deletions
65
test.py
65
test.py
|
@ -1,3 +1,7 @@
|
|||
"""
|
||||
Author: Sergey Vartanov (me@enzet.ru).
|
||||
"""
|
||||
|
||||
import copy
|
||||
import extract_icon
|
||||
import sys
|
||||
|
@ -9,20 +13,7 @@ sys.path.append('lib')
|
|||
|
||||
import svg
|
||||
|
||||
step = 24
|
||||
|
||||
width = step * 10
|
||||
|
||||
extracter = extract_icon.IconExtractor('icons.svg')
|
||||
|
||||
output_file = svg.SVG(open('icon_grid.svg', 'w+'))
|
||||
output_file.begin(width, 1000)
|
||||
|
||||
x = step / 2
|
||||
y = step / 2
|
||||
|
||||
def get_icon(tags):
|
||||
print '--------------', tags
|
||||
main_icon = None
|
||||
extra_icons = []
|
||||
for element in scheme['tags']:
|
||||
|
@ -31,7 +22,8 @@ def get_icon(tags):
|
|||
if not tag in tags:
|
||||
matched = False
|
||||
break
|
||||
if element['tags'][tag] != '*' and element['tags'][tag] != tags[tag]:
|
||||
if element['tags'][tag] != '*' and \
|
||||
element['tags'][tag] != tags[tag]:
|
||||
matched = False
|
||||
break
|
||||
if matched:
|
||||
|
@ -43,12 +35,27 @@ def get_icon(tags):
|
|||
if 'add_icon' in element:
|
||||
extra_icons += element['add_icon']
|
||||
if main_icon:
|
||||
print '----', [main_icon] + extra_icons
|
||||
return [main_icon] + extra_icons
|
||||
else:
|
||||
print '----', []
|
||||
return []
|
||||
|
||||
def draw_icon(icon):
|
||||
output_file.write('<path d="' + icon['path'] + '" ' + \
|
||||
'style="fill:#444444;stroke:none;' + \
|
||||
'stroke-width:3;stroke-linejoin:round;" ' + \
|
||||
'transform="translate(' + icon['x'] + ',' + icon['y'] + ')" />\n')
|
||||
|
||||
# Actions
|
||||
|
||||
step = 24
|
||||
|
||||
width = step * 10
|
||||
|
||||
extracter = extract_icon.IconExtractor('icons.svg')
|
||||
|
||||
x = step / 2
|
||||
y = step / 2
|
||||
|
||||
to_draw = {}
|
||||
|
||||
for element in scheme['tags']:
|
||||
|
@ -58,20 +65,21 @@ for element in scheme['tags']:
|
|||
to_draw[','.join(element['add_icon'])] = element['add_icon']
|
||||
if 'over_icon' in element:
|
||||
for icon in element['under_icon']:
|
||||
to_draw[','.join([icon] + element['over_icon'])] = [icon] + element['over_icon']
|
||||
to_draw[','.join([icon] + element['over_icon'])] = [icon] + \
|
||||
element['over_icon']
|
||||
|
||||
icons = []
|
||||
height = 24
|
||||
|
||||
for icon_key in to_draw.keys():
|
||||
icons = to_draw[icon_key]
|
||||
icons_to_draw = to_draw[icon_key]
|
||||
drawed = False
|
||||
for icon in icons:
|
||||
for icon in icons_to_draw:
|
||||
path, xx, yy = extracter.get_path(icon)
|
||||
if path:
|
||||
output_file.write('<path d="' + path + '" ' + \
|
||||
'style="fill:#444444;stroke:none;' + \
|
||||
'stroke-width:3;stroke-linejoin:round;" ' + \
|
||||
'transform="translate(' + \
|
||||
str(x - 8.0 - xx * 16) + ',' + \
|
||||
str(y - 8.0 - yy * 16) + ')" />\n')
|
||||
icons.append({'path': path,
|
||||
'x': str(x - 8.0 - xx * 16),
|
||||
'y': str(y - 8.0 - yy * 16)});
|
||||
drawed = True
|
||||
else:
|
||||
print '\033[31m' + icon + '\033[0m'
|
||||
|
@ -80,5 +88,12 @@ for icon_key in to_draw.keys():
|
|||
if x > width - 8:
|
||||
x = step / 2
|
||||
y += step
|
||||
height += step
|
||||
|
||||
output_file = svg.SVG(open('icon_grid.svg', 'w+'))
|
||||
output_file.begin(width, height)
|
||||
|
||||
for icon in icons:
|
||||
draw_icon(icon)
|
||||
|
||||
output_file.end()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue