(self, dr: svgwrite.Drawing, g: svgwrite.container.Group, size: XY, offset: XY)
For each track, draw it on the poster.
For each track, draw it on the poster.
For each track draw it on the poster .
def draw(self, dr: svgwrite.Drawing, g: svgwrite.container.Group, size: XY, offset: XY) -> None:
        """For each track, draw it on the poster."""
        if self.poster.tracks is None:
            raise PosterError("No tracks to draw.")
        cell_size, counts = utils.compute_grid(len(self.poster.tracks), size)
        if cell_size is None or counts is None:
            raise PosterError("Unable to compute grid.")
        count_x, count_y = counts[0], counts[1]
        spacing_x = 0 if count_x <= 1 else (size.x - cell_size * count_x) / (count_x - 1)
        spacing_y = 0 if count_y <= 1 else (size.y - cell_size * count_y) / (count_y - 1)
        offset.x += (size.x - count_x * cell_size - (count_x - 1) * spacing_x) / 2
        offset.y += (size.y - count_y * cell_size - (count_y - 1) * spacing_y) / 2
        year_groups: typing.Dict[int, svgwrite.container.Group] = {}
        for (index, tr) in enumerate(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]
            p = XY(index % count_x, index // count_x) * XY(cell_size + spacing_x, cell_size + spacing_y)
            self._draw_track(
                dr,
                g_year,
                tr,
                0.9 * XY(cell_size, cell_size),
                offset + 0.05 * XY(cell_size, cell_size) + p,
            )
def draw ( self , dr : svgwrite . Drawing , g : svgwrite . container . Group , size : XY , offset : XY ) -> None : if self . poster . tracks is None : raise PosterError ( "No tracks to draw." ) cell_size , counts = utils . compute_grid ( len ( self . poster . tracks ) , size ) if cell_size is None or counts is None : raise PosterError ( "Unable to compute grid." ) count_x , count_y = counts [ 0 ] , counts [ 1 ] spacing_x = 0 if count_x <= 1 else ( size . x - cell_size * count_x ) / ( count_x - 1 ) spacing_y = 0 if count_y <= 1 else ( size . y - cell_size * count_y ) / ( count_y - 1 ) offset . x += ( size . x - count_x * cell_size - ( count_x - 1 ) * spacing_x ) / 2 offset . y += ( size . y - count_y * cell_size - ( count_y - 1 ) * spacing_y ) / 2 year_groups : typing . Dict [ int , svgwrite . container . Group ] = { } for ( index , tr ) in enumerate ( 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 ] p = XY ( index % count_x , index // count_x ) * XY ( cell_size + spacing_x , cell_size + spacing_y ) self . _draw_track ( dr , g_year , tr , 0.9 * XY ( cell_size , cell_size ) , offset + 0.05 * XY ( cell_size , cell_size ) + p , )