mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-06 21:01:53 +02:00
Add white and black modes.
This commit is contained in:
parent
7a8f9c49b0
commit
b777d7bb4f
3 changed files with 45 additions and 5 deletions
|
@ -238,6 +238,10 @@ class Constructor:
|
||||||
color = get_user_color(line.user, self.configuration.seed)
|
color = get_user_color(line.user, self.configuration.seed)
|
||||||
elif self.configuration.drawing_mode == DrawingMode.TIME:
|
elif self.configuration.drawing_mode == DrawingMode.TIME:
|
||||||
color = get_time_color(line.timestamp, self.osm_data.time)
|
color = get_time_color(line.timestamp, self.osm_data.time)
|
||||||
|
elif self.configuration.drawing_mode == DrawingMode.WHITE:
|
||||||
|
color = Color("#666666")
|
||||||
|
elif self.configuration.drawing_mode == DrawingMode.BLACK:
|
||||||
|
color = Color("#BBBBBB")
|
||||||
elif self.configuration.drawing_mode != DrawingMode.NORMAL:
|
elif self.configuration.drawing_mode != DrawingMode.NORMAL:
|
||||||
logging.fatal(
|
logging.fatal(
|
||||||
f"Drawing mode {self.configuration.drawing_mode} is not "
|
f"Drawing mode {self.configuration.drawing_mode} is not "
|
||||||
|
@ -416,6 +420,8 @@ class Constructor:
|
||||||
def construct_node(self, node: OSMNode) -> None:
|
def construct_node(self, node: OSMNode) -> None:
|
||||||
"""Draw one node."""
|
"""Draw one node."""
|
||||||
tags: dict[str, str] = node.tags
|
tags: dict[str, str] = node.tags
|
||||||
|
if not tags:
|
||||||
|
return
|
||||||
if not self.check_level(tags):
|
if not self.check_level(tags):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -427,9 +433,10 @@ class Constructor:
|
||||||
icon_set: IconSet
|
icon_set: IconSet
|
||||||
draw_outline: bool = True
|
draw_outline: bool = True
|
||||||
|
|
||||||
if self.configuration.is_wireframe():
|
if self.configuration.drawing_mode in (
|
||||||
if not tags:
|
DrawingMode.AUTHOR,
|
||||||
return
|
DrawingMode.TIME,
|
||||||
|
):
|
||||||
color: Color = DEFAULT_COLOR
|
color: Color = DEFAULT_COLOR
|
||||||
if self.configuration.drawing_mode == DrawingMode.AUTHOR:
|
if self.configuration.drawing_mode == DrawingMode.AUTHOR:
|
||||||
color = get_user_color(node.user, self.configuration.seed)
|
color = get_user_color(node.user, self.configuration.seed)
|
||||||
|
@ -451,6 +458,29 @@ class Constructor:
|
||||||
self.points.append(point)
|
self.points.append(point)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.configuration.drawing_mode in (
|
||||||
|
DrawingMode.WHITE,
|
||||||
|
DrawingMode.BLACK,
|
||||||
|
):
|
||||||
|
if self.configuration.drawing_mode == DrawingMode.WHITE:
|
||||||
|
color = Color("#CCCCCC")
|
||||||
|
if self.configuration.drawing_mode == DrawingMode.BLACK:
|
||||||
|
color = Color("#444444")
|
||||||
|
icon_set, priority = self.scheme.get_icon(
|
||||||
|
self.extractor, tags, processed, self.configuration
|
||||||
|
)
|
||||||
|
icon_set.main_icon.recolor(color)
|
||||||
|
point: Point = Point(
|
||||||
|
icon_set,
|
||||||
|
[],
|
||||||
|
tags,
|
||||||
|
processed,
|
||||||
|
flung,
|
||||||
|
add_tooltips=self.configuration.show_tooltips,
|
||||||
|
)
|
||||||
|
self.points.append(point)
|
||||||
|
return
|
||||||
|
|
||||||
icon_set, priority = self.scheme.get_icon(
|
icon_set, priority = self.scheme.get_icon(
|
||||||
self.extractor, tags, processed, self.configuration
|
self.extractor, tags, processed, self.configuration
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,9 +2,12 @@
|
||||||
Map drawing configuration.
|
Map drawing configuration.
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
|
from colour import Color
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
__author__ = "Sergey Vartanov"
|
__author__ = "Sergey Vartanov"
|
||||||
__email__ = "me@enzet.ru"
|
__email__ = "me@enzet.ru"
|
||||||
|
|
||||||
|
@ -15,6 +18,8 @@ class DrawingMode(Enum):
|
||||||
NORMAL = "normal"
|
NORMAL = "normal"
|
||||||
AUTHOR = "author"
|
AUTHOR = "author"
|
||||||
TIME = "time"
|
TIME = "time"
|
||||||
|
WHITE = "white"
|
||||||
|
BLACK = "black"
|
||||||
|
|
||||||
|
|
||||||
class LabelMode(Enum):
|
class LabelMode(Enum):
|
||||||
|
@ -73,3 +78,8 @@ class MapConfiguration:
|
||||||
def is_wireframe(self) -> bool:
|
def is_wireframe(self) -> bool:
|
||||||
"""Whether drawing mode is special."""
|
"""Whether drawing mode is special."""
|
||||||
return self.drawing_mode != DrawingMode.NORMAL
|
return self.drawing_mode != DrawingMode.NORMAL
|
||||||
|
|
||||||
|
def backghround_color(self) -> Optional[Color]:
|
||||||
|
if self.drawing_mode not in (DrawingMode.NORMAL, DrawingMode.BLACK):
|
||||||
|
return Color("#111111")
|
||||||
|
return None
|
||||||
|
|
|
@ -48,8 +48,8 @@ class Map:
|
||||||
self.configuration = configuration
|
self.configuration = configuration
|
||||||
|
|
||||||
self.background_color: Color = self.scheme.get_color("background_color")
|
self.background_color: Color = self.scheme.get_color("background_color")
|
||||||
if self.configuration.is_wireframe():
|
if self.configuration.backghround_color():
|
||||||
self.background_color: Color = Color("#111111")
|
self.background_color = self.configuration.backghround_color()
|
||||||
|
|
||||||
def draw(self, constructor: Constructor) -> None:
|
def draw(self, constructor: Constructor) -> None:
|
||||||
"""Draw map."""
|
"""Draw map."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue