mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-07 05:11:53 +02:00
Add set_opacity command for icons.
This commit is contained in:
parent
f821ea0917
commit
b3560cfdc7
6 changed files with 41 additions and 19 deletions
|
@ -220,7 +220,7 @@ class Constructor:
|
||||||
if not line.tags:
|
if not line.tags:
|
||||||
return
|
return
|
||||||
|
|
||||||
building_mode: BuildingMode = self.configuration.building_mode
|
building_mode: str = self.configuration.building_mode
|
||||||
if "building" in line.tags or (
|
if "building" in line.tags or (
|
||||||
building_mode == BuildingMode.ISOMETRIC
|
building_mode == BuildingMode.ISOMETRIC
|
||||||
and "building:part" in line.tags
|
and "building:part" in line.tags
|
||||||
|
|
|
@ -329,6 +329,7 @@ class Icon:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
shape_specifications: list[ShapeSpecification]
|
shape_specifications: list[ShapeSpecification]
|
||||||
|
opacity: float = 1.0
|
||||||
|
|
||||||
def get_shape_ids(self) -> list[str]:
|
def get_shape_ids(self) -> list[str]:
|
||||||
"""Get all shape identifiers in the icon."""
|
"""Get all shape identifiers in the icon."""
|
||||||
|
@ -356,16 +357,19 @@ class Icon:
|
||||||
:param tags: tags to be displayed as hint
|
:param tags: tags to be displayed as hint
|
||||||
:param outline: draw outline for the icon
|
:param outline: draw outline for the icon
|
||||||
"""
|
"""
|
||||||
bright: bool = is_bright(self.shape_specifications[0].color)
|
target = Group(opacity=self.opacity) if self.opacity != 1.0 else svg
|
||||||
opacity: float = 0.7 if bright else 0.5
|
|
||||||
if outline:
|
if outline:
|
||||||
|
bright: bool = is_bright(self.shape_specifications[0].color)
|
||||||
|
opacity: float = 0.7 if bright else 0.5
|
||||||
outline_group: Group = Group(opacity=opacity)
|
outline_group: Group = Group(opacity=opacity)
|
||||||
for shape_specification in self.shape_specifications:
|
for shape_specification in self.shape_specifications:
|
||||||
shape_specification.draw(outline_group, point, tags, True)
|
shape_specification.draw(outline_group, point, tags, True)
|
||||||
svg.add(outline_group)
|
target.add(outline_group)
|
||||||
else:
|
else:
|
||||||
for shape_specification in self.shape_specifications:
|
for shape_specification in self.shape_specifications:
|
||||||
shape_specification.draw(svg, point, tags)
|
shape_specification.draw(target, point, tags)
|
||||||
|
if self.opacity != 1.0:
|
||||||
|
svg.add(target)
|
||||||
|
|
||||||
def draw_to_file(
|
def draw_to_file(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -159,7 +159,7 @@ class Point(Tagged):
|
||||||
self,
|
self,
|
||||||
svg: svgwrite.Drawing,
|
svg: svgwrite.Drawing,
|
||||||
occupied: Optional[Occupied] = None,
|
occupied: Optional[Occupied] = None,
|
||||||
label_mode: LabelMode = LabelMode.MAIN,
|
label_mode: str = LabelMode.MAIN,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Draw all labels."""
|
"""Draw all labels."""
|
||||||
labels: list[Label]
|
labels: list[Label]
|
||||||
|
|
|
@ -201,6 +201,10 @@ class NodeMatcher(Matcher):
|
||||||
if "set_main_color" in structure:
|
if "set_main_color" in structure:
|
||||||
self.set_main_color = structure["set_main_color"]
|
self.set_main_color = structure["set_main_color"]
|
||||||
|
|
||||||
|
self.set_opacity: Optional[float] = None
|
||||||
|
if "set_opacity" in structure:
|
||||||
|
self.set_opacity = structure["set_opacity"]
|
||||||
|
|
||||||
self.under_icon: Optional[IconDescription] = None
|
self.under_icon: Optional[IconDescription] = None
|
||||||
if "under_icon" in structure:
|
if "under_icon" in structure:
|
||||||
self.under_icon = structure["under_icon"]
|
self.under_icon = structure["under_icon"]
|
||||||
|
@ -408,6 +412,8 @@ class Scheme:
|
||||||
processed |= matcher_tags
|
processed |= matcher_tags
|
||||||
if matcher.set_main_color and main_icon:
|
if matcher.set_main_color and main_icon:
|
||||||
main_icon.recolor(self.get_color(matcher.set_main_color))
|
main_icon.recolor(self.get_color(matcher.set_main_color))
|
||||||
|
if matcher.set_opacity and main_icon:
|
||||||
|
main_icon.opacity = matcher.set_opacity
|
||||||
|
|
||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ BOXES: str = " ▏▎▍▌▋▊▉"
|
||||||
BOXES_LENGTH: int = len(BOXES)
|
BOXES_LENGTH: int = len(BOXES)
|
||||||
|
|
||||||
|
|
||||||
def parse_options(args: argparse.Namespace) -> argparse.Namespace:
|
def parse_options(args: list[str]) -> argparse.Namespace:
|
||||||
"""Parse Röntgen command-line options."""
|
"""Parse Röntgen command-line options."""
|
||||||
parser: argparse.ArgumentParser = argparse.ArgumentParser(
|
parser: argparse.ArgumentParser = argparse.ArgumentParser(
|
||||||
description="Röntgen. OpenStreetMap renderer with custom icon set"
|
description="Röntgen. OpenStreetMap renderer with custom icon set"
|
||||||
|
|
|
@ -949,30 +949,42 @@ node_icons:
|
||||||
shapes: [lander]
|
shapes: [lander]
|
||||||
|
|
||||||
- tags: {man_made: rover, condition: landed}
|
- tags: {man_made: rover, condition: landed}
|
||||||
shapes: [{shape: lunokhod, opacity: 0.8}]
|
shapes: [lunokhod]
|
||||||
|
set_opacity: 0.8
|
||||||
- tags: {man_made: probe, condition: landed}
|
- tags: {man_made: probe, condition: landed}
|
||||||
shapes: [{shape: probe, opacity: 0.8}]
|
shapes: [probe]
|
||||||
|
set_opacity: 0.8
|
||||||
- tags: {man_made: orbiter, condition: landed}
|
- tags: {man_made: orbiter, condition: landed}
|
||||||
shapes: [{shape: orbiter, opacity: 0.8}]
|
shapes: [orbiter]
|
||||||
|
set_opacity: 0.8
|
||||||
- tags: {man_made: descent_stage, condition: landed}
|
- tags: {man_made: descent_stage, condition: landed}
|
||||||
shapes: [{shape: descent_stage, opacity: 0.8}]
|
shapes: [descent_stage]
|
||||||
|
set_opacity: 0.8
|
||||||
- tags: {man_made: third_stage, condition: landed}
|
- tags: {man_made: third_stage, condition: landed}
|
||||||
shapes: [{shape: third_stage, opacity: 0.8}]
|
shapes: [third_stage]
|
||||||
|
set_opacity: 0.8
|
||||||
- tags: {man_made: lander, condition: landed}
|
- tags: {man_made: lander, condition: landed}
|
||||||
shapes: [{shape: lander, opacity: 0.8}]
|
shapes: [lander]
|
||||||
|
set_opacity: 0.8
|
||||||
|
|
||||||
- tags: {man_made: rover, condition: crashed}
|
- tags: {man_made: rover, condition: crashed}
|
||||||
shapes: [{shape: lunokhod, opacity: 0.5}]
|
shapes: [lunokhod]
|
||||||
|
set_opacity: 0.5
|
||||||
- tags: {man_made: probe, condition: crashed}
|
- tags: {man_made: probe, condition: crashed}
|
||||||
shapes: [{shape: probe, opacity: 0.5}]
|
shapes: [probe]
|
||||||
|
set_opacity: 0.5
|
||||||
- tags: {man_made: orbiter, condition: crashed}
|
- tags: {man_made: orbiter, condition: crashed}
|
||||||
shapes: [{shape: orbiter, opacity: 0.5}]
|
shapes: [orbiter]
|
||||||
|
set_opacity: 0.5
|
||||||
- tags: {man_made: descent_stage, condition: crashed}
|
- tags: {man_made: descent_stage, condition: crashed}
|
||||||
shapes: [{shape: descent_stage, opacity: 0.5}]
|
shapes: [descent_stage]
|
||||||
|
set_opacity: 0.5
|
||||||
- tags: {man_made: third_stage, condition: crashed}
|
- tags: {man_made: third_stage, condition: crashed}
|
||||||
shapes: [{shape: third_stage, opacity: 0.5}]
|
shapes: [third_stage]
|
||||||
|
set_opacity: 0.5
|
||||||
- tags: {man_made: lander, condition: crashed}
|
- tags: {man_made: lander, condition: crashed}
|
||||||
shapes: [{shape: lander, opacity: 0.5}]
|
shapes: [lander]
|
||||||
|
set_opacity: 0.5
|
||||||
|
|
||||||
- group: "Important small objects"
|
- group: "Important small objects"
|
||||||
start_zoom_level: 17
|
start_zoom_level: 17
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue