def draw_label(label, text_center, obj_center, line_color, background='white'): text = gui.FONT.render(label, True, Color('black'), Color(background)) # offset = Block.patch_text_offset if isinstance(self, Patch) else Block.agent_text_offset # text_center = Pixel_xy((self.rect.x + offset, self.rect.y + offset)) gui.blit(text, text_center) # line_color = Color('white') if isinstance(self, Patch) and self.color == Color('black') else self.color if line_color is not None: gui.draw_line(start_pixel=obj_center, end_pixel=text_center, line_color=line_color)
def draw(self): gui.draw_line(self.agent_1.center_pixel, self.agent_2.center_pixel, line_color=self.color, width=self.width) if (self.label) is not None: # Pass the label to avoid computing it twice. self.draw_label(self.label)
def draw_label(self): text = gui.FONT.render(self.label, True, Color('black'), Color('white')) offset = Block.patch_text_offset if isinstance( self, Patch) else Block.agent_text_offset text_center = Pixel_xy((self.rect.x + offset, self.rect.y + offset)) # gui.SCREEN.blit(text, text_center) gui.blit(text, text_center) line_color = Color('white') if isinstance( self, Patch) and self.color == Color('black') else self.color # self.draw_line(line_color=line_color, start_pixel=self.rect.center, end_pixel=text_center) gui.draw_line(start_pixel=self.rect.center, end_pixel=text_center, line_color=line_color)
def draw(self): gui.draw_line(self.agent_1.rect.center, self.agent_2.rect.center, line_color=self.color)