mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-05 21:26:46 +02:00
Fix icon extraction.
This commit is contained in:
parent
04f1376641
commit
bae788fd1c
3 changed files with 9 additions and 9 deletions
|
@ -55,18 +55,18 @@ class IconExtractor:
|
||||||
for sub_node in node.childNodes:
|
for sub_node in node.childNodes:
|
||||||
self.parse(sub_node)
|
self.parse(sub_node)
|
||||||
|
|
||||||
def get_path(self, id_: str) -> (str, float, float):
|
def get_path(self, id_: str) -> (str, float, float, bool):
|
||||||
"""
|
"""
|
||||||
Get SVG path of the icon.
|
Get SVG path of the icon.
|
||||||
|
|
||||||
:param id_: string icon ID
|
:param id_: string icon ID
|
||||||
"""
|
"""
|
||||||
if id_ in self.icons:
|
if id_ in self.icons:
|
||||||
return self.icons[id_]
|
return list(self.icons[id_]) + [True]
|
||||||
else:
|
else:
|
||||||
if id_ == "no":
|
if id_ == "no":
|
||||||
return "M 4,4 L 4,10 10,10 10,4 z", 0, 0
|
return "M 4,4 L 4,10 10,10 10,4 z", 0, 0, False
|
||||||
if id_ == "small":
|
if id_ == "small":
|
||||||
return "M 6,6 L 6,8 8,8 8,6 z", 0, 0
|
return "M 6,6 L 6,8 8,8 8,6 z", 0, 0, False
|
||||||
ui.error(f"no such icon ID {id_}")
|
ui.error(f"no such icon ID {id_}")
|
||||||
return "M 4,4 L 4,10 10,10 10,4 z", 0, 0
|
return "M 4,4 L 4,10 10,10 10,4 z", 0, 0, False
|
||||||
|
|
|
@ -375,11 +375,11 @@ class Painter:
|
||||||
name = [name]
|
name = [name]
|
||||||
if self.mode not in ["time", "user-coloring"]:
|
if self.mode not in ["time", "user-coloring"]:
|
||||||
for one_name in name:
|
for one_name in name:
|
||||||
shape, xx, yy = self.icons.get_path(one_name)
|
shape, xx, yy, _ = self.icons.get_path(one_name)
|
||||||
self.draw_point_outline(
|
self.draw_point_outline(
|
||||||
shape, x, y, fill, mode=self.mode, size=16, xx=xx, yy=yy)
|
shape, x, y, fill, mode=self.mode, size=16, xx=xx, yy=yy)
|
||||||
for one_name in name:
|
for one_name in name:
|
||||||
shape, xx, yy = self.icons.get_path(one_name)
|
shape, xx, yy, _ = self.icons.get_path(one_name)
|
||||||
self.draw_point(shape, x, y, fill, size=16, xx=xx, yy=yy, tags=tags)
|
self.draw_point(shape, x, y, fill, size=16, xx=xx, yy=yy, tags=tags)
|
||||||
|
|
||||||
def draw_point(self, shape, x, y, fill, size=16, xx=0, yy=0, tags=None):
|
def draw_point(self, shape, x, y, fill, size=16, xx=0, yy=0, tags=None):
|
||||||
|
|
4
test.py
4
test.py
|
@ -51,8 +51,8 @@ def test_icons():
|
||||||
for icons_to_draw in to_draw:
|
for icons_to_draw in to_draw:
|
||||||
icon_set = {'icons': []}
|
icon_set = {'icons': []}
|
||||||
for icon in icons_to_draw:
|
for icon in icons_to_draw:
|
||||||
path, xx, yy = extracter.get_path(icon)
|
path, xx, yy, is_shape = extracter.get_path(icon)
|
||||||
assert xx
|
assert is_shape, icon
|
||||||
icon_set['icons'].append({'path': path,
|
icon_set['icons'].append({'path': path,
|
||||||
'x': (- 8.0 - xx * 16),
|
'x': (- 8.0 - xx * 16),
|
||||||
'y': (- 8.0 - yy * 16)})
|
'y': (- 8.0 - yy * 16)})
|
||||||
|
|
Loading…
Add table
Reference in a new issue