-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathtracks_drawer.py
36 lines (26 loc) · 1.3 KB
/
tracks_drawer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Contains the base class TracksDrawer, which other Drawers inherit from."""
# Copyright 2016-2023 Florian Pigorsch & Contributors. All rights reserved.
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file.
import argparse
import pint # type: ignore
import svgwrite # type: ignore
from gpxtrackposter import utils
from gpxtrackposter.poster import Poster
from gpxtrackposter.quantity_range import QuantityRange
from gpxtrackposter.xy import XY
class TracksDrawer:
"""Base class that other drawer classes inherit from."""
def __init__(self, the_poster: Poster):
self.poster = the_poster
def create_args(self, args_parser: argparse.ArgumentParser) -> None:
pass
def fetch_args(self, args: argparse.Namespace) -> None:
pass
def draw(self, dr: svgwrite.Drawing, g: svgwrite.container.Group, size: XY, offset: XY) -> None:
pass
def color(self, length_range: QuantityRange, length: pint.Quantity, is_special: bool = False) -> str:
color1 = self.poster.colors["special"] if is_special else self.poster.colors["track"]
color2 = self.poster.colors["special2"] if is_special else self.poster.colors["track2"]
return utils.interpolate_color(color1, color2, length_range.relative_position(length))