That make_lines method is horrid. Let’s continue cleaning things up a bit, starting there. The current border-drawing code is this: def draw_border(self, cell, screen): borders: BorderList = self.layout.get_borders(cell) lines = self.make_lines(cell) for border in borders: start, finish = lines[border.side] color = border.select_boundary(self.boundary_colors) pygame.draw.line(screen, color, start, finish) def make_lines(self, cell): cx0 = cell.x * cell_size cy0 = cell.y * cell_size cx1 = cx0 + cell_size cy1 = cy0 + cell_size bottom = ((cx0, cy1), (cx1, cy1)) top = ((cx0, cy0), (cx1, cy0)) left = ((cx0, cy0), (cx0, cy1)) right = ((cx1, cy0), (cx1, cy1)) lines = {(0, 1): bottom, (0, -1): top, (-1, 0): left, (1, 0): right} return lines We’re doing that calculation on every drawing of every cell, and while I’m not really all that concerned about the computation time, that whole method bugs me. I spent some time last night trying to come up with a formula from the sides (1,0) for east, and…
No comments yet. Log in to reply on the Fediverse. Comments will appear here.