mirror of
https://github.com/enzet/map-machine.git
synced 2025-07-27 05:19:00 +02:00
Fix icon collection.
This commit is contained in:
parent
3600088bb4
commit
eacb6c8ee1
2 changed files with 18 additions and 25 deletions
BIN
doc/grid.png
BIN
doc/grid.png
Binary file not shown.
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
|
@ -4,7 +4,7 @@ Icon grid drawing.
|
||||||
import logging
|
import logging
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, Union
|
from typing import Optional
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from colour import Color
|
from colour import Color
|
||||||
|
@ -50,58 +50,51 @@ class IconCollection:
|
||||||
"""
|
"""
|
||||||
icons: list[Icon] = []
|
icons: list[Icon] = []
|
||||||
|
|
||||||
def add() -> Optional[Icon]:
|
def add(current_set: list[dict[str, str]]) -> None:
|
||||||
"""Construct icon and add it to the list."""
|
"""Construct icon and add it to the list."""
|
||||||
specifications: list[ShapeSpecification] = []
|
specifications: list[ShapeSpecification] = []
|
||||||
for shape_specification in current_set:
|
for shape_specification in current_set:
|
||||||
if "#" in shape_specification["shape"]:
|
if "#" in shape_specification["shape"]:
|
||||||
return None
|
return
|
||||||
scheme.get_shape_specification(shape_specification, extractor)
|
specifications.append(
|
||||||
|
scheme.get_shape_specification(
|
||||||
|
shape_specification, extractor
|
||||||
|
)
|
||||||
|
)
|
||||||
constructed_icon: Icon = Icon(specifications)
|
constructed_icon: Icon = Icon(specifications)
|
||||||
constructed_icon.recolor(color, white=background_color)
|
constructed_icon.recolor(color, white=background_color)
|
||||||
if constructed_icon not in icons:
|
if constructed_icon not in icons:
|
||||||
icons.append(constructed_icon)
|
icons.append(constructed_icon)
|
||||||
|
|
||||||
return constructed_icon
|
|
||||||
|
|
||||||
current_set: list[Union[str, dict[str, str]]]
|
|
||||||
|
|
||||||
for matcher in scheme.node_matchers:
|
for matcher in scheme.node_matchers:
|
||||||
matcher: NodeMatcher
|
matcher: NodeMatcher
|
||||||
if matcher.shapes:
|
if matcher.shapes:
|
||||||
current_set = matcher.shapes
|
add(matcher.shapes)
|
||||||
add()
|
|
||||||
if matcher.add_shapes:
|
if matcher.add_shapes:
|
||||||
current_set = matcher.add_shapes
|
add(matcher.add_shapes)
|
||||||
add()
|
|
||||||
if not matcher.over_icon:
|
if not matcher.over_icon:
|
||||||
continue
|
continue
|
||||||
if matcher.under_icon:
|
if matcher.under_icon:
|
||||||
for icon_id in matcher.under_icon:
|
for icon_id in matcher.under_icon:
|
||||||
current_set = [icon_id] + matcher.over_icon
|
add([icon_id] + matcher.over_icon)
|
||||||
add()
|
|
||||||
if not (matcher.under_icon and matcher.with_icon):
|
if not (matcher.under_icon and matcher.with_icon):
|
||||||
continue
|
continue
|
||||||
for icon_id in matcher.under_icon:
|
for icon_id in matcher.under_icon:
|
||||||
for icon_2_id in matcher.with_icon:
|
for icon_2_id in matcher.with_icon:
|
||||||
current_set: list[str] = (
|
add([icon_id] + [icon_2_id] + matcher.over_icon)
|
||||||
[icon_id] + [icon_2_id] + matcher.over_icon
|
|
||||||
)
|
|
||||||
add()
|
|
||||||
for icon_2_id in matcher.with_icon:
|
for icon_2_id in matcher.with_icon:
|
||||||
for icon_3_id in matcher.with_icon:
|
for icon_3_id in matcher.with_icon:
|
||||||
current_set = (
|
|
||||||
[icon_id]
|
|
||||||
+ [icon_2_id]
|
|
||||||
+ [icon_3_id]
|
|
||||||
+ matcher.over_icon
|
|
||||||
)
|
|
||||||
if (
|
if (
|
||||||
icon_2_id != icon_3_id
|
icon_2_id != icon_3_id
|
||||||
and icon_2_id != icon_id
|
and icon_2_id != icon_id
|
||||||
and icon_3_id != icon_id
|
and icon_3_id != icon_id
|
||||||
):
|
):
|
||||||
add()
|
add(
|
||||||
|
[icon_id]
|
||||||
|
+ [icon_2_id]
|
||||||
|
+ [icon_3_id]
|
||||||
|
+ matcher.over_icon
|
||||||
|
)
|
||||||
|
|
||||||
specified_ids: set[str] = set()
|
specified_ids: set[str] = set()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue