def draw(self, dr: svgwrite.Drawing, g: svgwrite.container.Group, size: XY, offset: XY) -> None: """Iterate through the Poster's years, creating a calendar for each.""" if self.poster.tracks is None: raise PosterError("No tracks to draw.") years = self.poster.years.count() _, counts = utils.compute_grid(years, size) if counts is None: raise PosterError("Unable to compute grid.") count_x, count_y = counts[0], counts[1] x, y = 0, 0 cell_size = size * XY(1 / count_x, 1 / count_y) margin = XY(4, 8) if count_x <= 1: margin.x = 0 if count_y <= 1: margin.y = 0 sub_size = cell_size - 2 * margin for year in self.poster.years.iter(): g_year = dr.g(id=f"year{year}") g.add(g_year) self._draw(dr, g_year, sub_size, offset + margin + cell_size * XY(x, y), year) x += 1 if x >= count_x: x = 0 y += 1
def draw(self, dr: svgwrite.Drawing, g: svgwrite.container.Group, size: XY, offset: XY) -> None: """Draw the circular Poster using distances broken down by time""" if self.poster.tracks is None: raise PosterError("No tracks to draw.") if self.poster.length_range_by_date is None: return years = self.poster.years.count() _, counts = utils.compute_grid(years, size) if counts is None: raise PosterError("Unable to compute grid.") count_x, count_y = counts[0], counts[1] x, y = 0, 0 cell_size = size * XY(1 / count_x, 1 / count_y) margin = XY(4, 4) if count_x <= 1: margin.x = 0 if count_y <= 1: margin.y = 0 sub_size = cell_size - 2 * margin for year in self.poster.years.iter(): g_year = dr.g(id=f"year{year}") g.add(g_year) self._draw_year(dr, g_year, sub_size, offset + margin + cell_size * XY(x, y), year) x += 1 if x >= count_x: x = 0 y += 1
def draw(self, dr: svgwrite.Drawing, size: XY, offset: XY): """Iterate through the Poster's years, creating a calendar for each.""" if self.poster.tracks is None: raise PosterError("No tracks to draw.") years = self.poster.years.count() _, counts = utils.compute_grid(years, size) if counts is None: raise PosterError("Unable to compute grid.") count_x, count_y = counts[0], counts[1] x, y = 0, 0 cell_size = size * XY(1 / count_x, 1 / count_y) margin = XY(4, 8) if count_x <= 1: margin.x = 0 if count_y <= 1: margin.y = 0 sub_size = cell_size - 2 * margin for year in range(self.poster.years.from_year, self.poster.years.to_year + 1): self._draw(dr, sub_size, offset + margin + cell_size * XY(x, y), year) x += 1 if x >= count_x: x = 0 y += 1