Add background option to enable/disable background.

This commit is contained in:
Natanael Arndt 2024-07-22 23:33:34 +02:00
parent 825eb34191
commit e5b65b59c0
3 changed files with 16 additions and 3 deletions

View file

@ -63,6 +63,7 @@ class MapConfiguration:
show_overlapped: bool = False show_overlapped: bool = False
credit: Optional[str] = "© OpenStreetMap contributors" credit: Optional[str] = "© OpenStreetMap contributors"
show_credit: bool = True show_credit: bool = True
draw_background: bool = True
@classmethod @classmethod
def from_options( def from_options(
@ -85,6 +86,7 @@ class MapConfiguration:
options.building_colors, options.building_colors,
options.show_overlapped, options.show_overlapped,
show_credit=not options.hide_credit, show_credit=not options.hide_credit,
draw_background=options.background,
) )
def is_wireframe(self) -> bool: def is_wireframe(self) -> bool:

View file

@ -57,9 +57,14 @@ class Map:
def draw(self, constructor: Constructor) -> None: def draw(self, constructor: Constructor) -> None:
"""Draw map.""" """Draw map."""
self.svg.add( if self.configuration.draw_background:
Rect((0.0, 0.0), self.flinger.size, fill=self.background_color) logging.info("Drawing background...")
) self.svg.add(
Rect((0.0, 0.0), self.flinger.size, fill=self.background_color)
)
else:
logging.info("Drawing no background")
logging.info("Drawing ways...") logging.info("Drawing ways...")
figures: list[StyledFigure] = constructor.get_sorted_figures() figures: list[StyledFigure] = constructor.get_sorted_figures()

View file

@ -214,6 +214,12 @@ def add_map_arguments(parser: argparse.ArgumentParser) -> None:
action=argparse.BooleanOptionalAction, action=argparse.BooleanOptionalAction,
default=False, default=False,
) )
parser.add_argument(
"--background",
help="enable or disable the background e.g. to use it as layer",
action=argparse.BooleanOptionalAction,
default=True,
)
def add_tile_arguments(parser: argparse.ArgumentParser) -> None: def add_tile_arguments(parser: argparse.ArgumentParser) -> None: