Add white and black modes.

This commit is contained in:
Sergey Vartanov 2021-11-12 03:32:17 +03:00
parent 7a8f9c49b0
commit b777d7bb4f
3 changed files with 45 additions and 5 deletions

View file

@ -238,6 +238,10 @@ class Constructor:
color = get_user_color(line.user, self.configuration.seed)
elif self.configuration.drawing_mode == DrawingMode.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:
logging.fatal(
f"Drawing mode {self.configuration.drawing_mode} is not "
@ -416,6 +420,8 @@ class Constructor:
def construct_node(self, node: OSMNode) -> None:
"""Draw one node."""
tags: dict[str, str] = node.tags
if not tags:
return
if not self.check_level(tags):
return
@ -427,9 +433,10 @@ class Constructor:
icon_set: IconSet
draw_outline: bool = True
if self.configuration.is_wireframe():
if not tags:
return
if self.configuration.drawing_mode in (
DrawingMode.AUTHOR,
DrawingMode.TIME,
):
color: Color = DEFAULT_COLOR
if self.configuration.drawing_mode == DrawingMode.AUTHOR:
color = get_user_color(node.user, self.configuration.seed)
@ -451,6 +458,29 @@ class Constructor:
self.points.append(point)
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(
self.extractor, tags, processed, self.configuration
)

View file

@ -2,9 +2,12 @@
Map drawing configuration.
"""
import argparse
from colour import Color
from dataclasses import dataclass
from enum import Enum
from typing import Optional
__author__ = "Sergey Vartanov"
__email__ = "me@enzet.ru"
@ -15,6 +18,8 @@ class DrawingMode(Enum):
NORMAL = "normal"
AUTHOR = "author"
TIME = "time"
WHITE = "white"
BLACK = "black"
class LabelMode(Enum):
@ -73,3 +78,8 @@ class MapConfiguration:
def is_wireframe(self) -> bool:
"""Whether drawing mode is special."""
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

View file

@ -48,8 +48,8 @@ class Map:
self.configuration = configuration
self.background_color: Color = self.scheme.get_color("background_color")
if self.configuration.is_wireframe():
self.background_color: Color = Color("#111111")
if self.configuration.backghround_color():
self.background_color = self.configuration.backghround_color()
def draw(self, constructor: Constructor) -> None:
"""Draw map."""