Exemplo n.º 1
0
 def draw(self, dr: svgwrite.Drawing, g: svgwrite.container.Group, size: XY,
          offset: XY) -> None:
     """Draw the heatmap based on tracks."""
     bbox = self._determine_bbox()
     year_groups: typing.Dict[int, svgwrite.container.Group] = {}
     for tr in self.poster.tracks:
         year = tr.start_time().year
         if year not in year_groups:
             g_year = dr.g(id=f"year{year}")
             g.add(g_year)
             year_groups[year] = g_year
         else:
             g_year = year_groups[year]
         color = self.color(self.poster.length_range, tr.length(),
                            tr.special)
         for line in utils.project(bbox, size, offset, tr.polylines):
             for opacity, width in [(0.1, 5.0), (0.2, 2.0), (1.0, 0.3)]:
                 g_year.add(
                     dr.polyline(
                         points=line,
                         stroke=color,
                         stroke_opacity=opacity,
                         fill="none",
                         stroke_width=width,
                         stroke_linejoin="round",
                         stroke_linecap="round",
                     ))
Exemplo n.º 2
0
 def _draw_track(self, dr: svgwrite.Drawing, tr: Track, size: XY,
                 offset: XY) -> None:
     color = self.color(self.poster.length_range, tr.length(), tr.special)
     for line in utils.project(tr.bbox(), size, offset, tr.polylines):
         dr.add(
             dr.polyline(
                 points=line,
                 stroke=color,
                 fill="none",
                 stroke_width=0.5,
                 stroke_linejoin="round",
                 stroke_linecap="round",
             ))
Exemplo n.º 3
0
    def _draw_track(self, dr: svgwrite.Drawing, g: svgwrite.container.Group, tr: Track, size: XY, offset: XY) -> None:
        color = self.color(self.poster.length_range, tr.length(), tr.special)
        str_length = utils.format_float(self.poster.m2u(tr.length()))

        date_title = str(tr.start_time.date()) if tr.start_time else "Unknown Date"
        for line in utils.project(tr.bbox(), size, offset, tr.polylines):
            polyline = dr.polyline(
                points=line,
                stroke=color,
                fill="none",
                stroke_width=0.5,
                stroke_linejoin="round",
                stroke_linecap="round",
            )
            polyline.set_desc(title=f"{date_title} {str_length} {self.poster.u()}")
            g.add(polyline)
 def draw(self, dr: svgwrite.Drawing, size: XY, offset: XY):
     """Draw the heatmap based on tracks."""
     bbox = self._determine_bbox()
     for tr in self.poster.tracks:
         color = self.color(self.poster.length_range, tr.length, tr.special)
         for line in utils.project(bbox, size, offset, tr.polylines):
             for opacity, width in [(0.1, 5.0), (0.2, 2.0), (1.0, 0.3)]:
                 dr.add(
                     dr.polyline(
                         points=line,
                         stroke=color,
                         stroke_opacity=opacity,
                         fill="none",
                         stroke_width=width,
                         stroke_linejoin="round",
                         stroke_linecap="round",
                     ))