mirror of
https://github.com/enzet/map-machine.git
synced 2025-08-06 10:09:52 +02:00
Speed up tests.
This commit is contained in:
parent
f1702ece36
commit
b7ed5353f8
4 changed files with 14 additions and 14 deletions
10
roentgen.py
10
roentgen.py
|
@ -135,8 +135,8 @@ def draw_element(target: str, tags_description: str):
|
||||||
comma, key from value is separated by equals sign.
|
comma, key from value is separated by equals sign.
|
||||||
"""
|
"""
|
||||||
tags = dict([x.split("=") for x in tags_description.split(",")])
|
tags = dict([x.split("=") for x in tags_description.split(",")])
|
||||||
scheme = Scheme(Path("scheme/default.yml"))
|
scheme: Scheme = Scheme(Path("scheme/default.yml"))
|
||||||
extractor = ShapeExtractor(
|
extractor: ShapeExtractor = ShapeExtractor(
|
||||||
Path("icons/icons.svg"), Path("icons/config.json")
|
Path("icons/icons.svg"), Path("icons/config.json")
|
||||||
)
|
)
|
||||||
icon, priority = scheme.get_icon(extractor, tags)
|
icon, priority = scheme.get_icon(extractor, tags)
|
||||||
|
@ -166,7 +166,11 @@ def draw_grid() -> None:
|
||||||
Draw all possible icon shapes combinations as grid.
|
Draw all possible icon shapes combinations as grid.
|
||||||
"""
|
"""
|
||||||
os.makedirs("icon_set", exist_ok=True)
|
os.makedirs("icon_set", exist_ok=True)
|
||||||
draw_all_icons("icon_grid.svg", "icon_set")
|
scheme: Scheme = Scheme(Path("scheme/default.yml"))
|
||||||
|
extractor: ShapeExtractor = ShapeExtractor(
|
||||||
|
Path("icons/icons.svg"), Path("icons/config.json")
|
||||||
|
)
|
||||||
|
draw_all_icons(scheme, extractor, "icon_grid.svg", "icon_set")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -17,6 +17,7 @@ __email__ = "me@enzet.ru"
|
||||||
|
|
||||||
|
|
||||||
def draw_all_icons(
|
def draw_all_icons(
|
||||||
|
scheme: Scheme, extractor: ShapeExtractor,
|
||||||
output_file_name: str, output_directory: str, columns: int = 16,
|
output_file_name: str, output_directory: str, columns: int = 16,
|
||||||
step: float = 24, background_color: Color = Color("white"),
|
step: float = 24, background_color: Color = Color("white"),
|
||||||
color: Color = Color("black")
|
color: Color = Color("black")
|
||||||
|
@ -24,6 +25,8 @@ def draw_all_icons(
|
||||||
"""
|
"""
|
||||||
Draw all possible icon combinations in grid.
|
Draw all possible icon combinations in grid.
|
||||||
|
|
||||||
|
:param scheme: tag specification
|
||||||
|
:param extractor: shape extractor for icon creation
|
||||||
:param output_file_name: output SVG file name for icon grid
|
:param output_file_name: output SVG file name for icon grid
|
||||||
:param output_directory: path to the directory to store individual SVG files
|
:param output_directory: path to the directory to store individual SVG files
|
||||||
for icons
|
for icons
|
||||||
|
@ -32,15 +35,8 @@ def draw_all_icons(
|
||||||
:param background_color: background color
|
:param background_color: background color
|
||||||
:param color: icon color
|
:param color: icon color
|
||||||
"""
|
"""
|
||||||
scheme: Scheme = Scheme(Path("scheme/default.yml"))
|
|
||||||
|
|
||||||
icons: List[Icon] = []
|
icons: List[Icon] = []
|
||||||
|
|
||||||
icons_file_name: str = "icons/icons.svg"
|
|
||||||
extractor: ShapeExtractor = ShapeExtractor(
|
|
||||||
Path(icons_file_name), Path("icons/config.json")
|
|
||||||
)
|
|
||||||
|
|
||||||
def add() -> None:
|
def add() -> None:
|
||||||
"""
|
"""
|
||||||
Construct icon and add it to the list.
|
Construct icon and add it to the list.
|
||||||
|
|
|
@ -4,7 +4,7 @@ from roentgen.icon import ShapeExtractor
|
||||||
from roentgen.scheme import Scheme
|
from roentgen.scheme import Scheme
|
||||||
|
|
||||||
SCHEME: Scheme = Scheme(Path("scheme/default.yml"))
|
SCHEME: Scheme = Scheme(Path("scheme/default.yml"))
|
||||||
ICON_EXTRACTOR: ShapeExtractor = ShapeExtractor(
|
SCHEME_EXTRACTOR: ShapeExtractor = ShapeExtractor(
|
||||||
Path("icons/icons.svg"), Path("icons/config.json")
|
Path("icons/icons.svg"), Path("icons/config.json")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from typing import Dict
|
||||||
|
|
||||||
from roentgen.grid import draw_all_icons
|
from roentgen.grid import draw_all_icons
|
||||||
|
|
||||||
from test import SCHEME, ICON_EXTRACTOR
|
from test import SCHEME, SCHEME_EXTRACTOR
|
||||||
|
|
||||||
__author__ = "Sergey Vartanov"
|
__author__ = "Sergey Vartanov"
|
||||||
__email__ = "me@enzet.ru"
|
__email__ = "me@enzet.ru"
|
||||||
|
@ -15,11 +15,11 @@ __email__ = "me@enzet.ru"
|
||||||
def test_icons() -> None:
|
def test_icons() -> None:
|
||||||
""" Test grid drawing. """
|
""" Test grid drawing. """
|
||||||
makedirs("icon_set", exist_ok=True)
|
makedirs("icon_set", exist_ok=True)
|
||||||
draw_all_icons("temp.svg", "icon_set")
|
draw_all_icons(SCHEME, SCHEME_EXTRACTOR, "temp.svg", "icon_set")
|
||||||
|
|
||||||
|
|
||||||
def get_icon(tags: Dict[str, str]):
|
def get_icon(tags: Dict[str, str]):
|
||||||
icon, _ = SCHEME.get_icon(ICON_EXTRACTOR, tags)
|
icon, _ = SCHEME.get_icon(SCHEME_EXTRACTOR, tags)
|
||||||
return icon
|
return icon
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue