mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-23 21:17:10 +02:00
Refactor constructor; change code style.
This commit is contained in:
parent
8509e3c0e2
commit
21be74a8a2
18 changed files with 759 additions and 683 deletions
44
test.py
44
test.py
|
@ -6,8 +6,8 @@ import os
|
|||
import random
|
||||
import yaml
|
||||
|
||||
from roentgen import extract_icon
|
||||
from roentgen.flinger import map_
|
||||
from roentgen.grid import draw_grid
|
||||
|
||||
|
||||
def test_flinger_map():
|
||||
|
@ -15,44 +15,4 @@ def test_flinger_map():
|
|||
|
||||
|
||||
def test_icons():
|
||||
tags_file_name = 'data/tags.yml'
|
||||
icons_file_name = 'icons/icons.svg'
|
||||
|
||||
scheme = yaml.load(open(tags_file_name))
|
||||
|
||||
extracter = extract_icon.IconExtractor(icons_file_name)
|
||||
|
||||
to_draw = []
|
||||
|
||||
for element in scheme['tags']:
|
||||
if 'icon' in element:
|
||||
if not (set(element['icon']) in to_draw):
|
||||
to_draw.append(set(element['icon']))
|
||||
if 'add_icon' in element:
|
||||
if not (set(element['add_icon']) in to_draw):
|
||||
to_draw.append(set(element['add_icon']))
|
||||
if 'over_icon' in element:
|
||||
with_icons = []
|
||||
if 'under_icon' in element:
|
||||
for icon in element['under_icon']:
|
||||
if not (set([icon] + element['over_icon']) in to_draw):
|
||||
to_draw.append(set([icon] + element['over_icon']))
|
||||
if 'under_icon' in element and 'with_icon' in element:
|
||||
for icon in element['under_icon']:
|
||||
for icon2 in element['with_icon']:
|
||||
if not (set([icon] + [icon2] + element['over_icon']) in to_draw):
|
||||
to_draw.append(set([icon] + [icon2] + element['over_icon']))
|
||||
for icon2 in element['with_icon']:
|
||||
for icon3 in element['with_icon']:
|
||||
if icon2 != icon3 and icon2 != icon and icon3 != icon:
|
||||
if not (set([icon] + [icon2] + [icon3] + element['over_icon']) in to_draw):
|
||||
to_draw.append(set([icon] + [icon2] + [icon3] + element['over_icon']))
|
||||
|
||||
for icons_to_draw in to_draw:
|
||||
icon_set = {'icons': []}
|
||||
for icon in icons_to_draw:
|
||||
path, xx, yy, is_shape = extracter.get_path(icon)
|
||||
assert is_shape, icon
|
||||
icon_set['icons'].append({'path': path,
|
||||
'x': (- 8.0 - xx * 16),
|
||||
'y': (- 8.0 - yy * 16)})
|
||||
draw_grid()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue