Exemplo n.º 1
0
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)
Exemplo n.º 2
0
 def draw(self, shape_name=None):
     if self.label:
         self.draw_label()
     if isinstance(self, Patch) or shape_name in SHAPES:
         self.rect.center = self.center_pixel
         # self.rect = Rect(center=self.rect.center)
         gui.blit(self.image, self.rect)
     else:
         gui.draw(self, shape_name=shape_name)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 def draw(self):
     if self.label:
         self.draw_label()
     gui.blit(self.image, self.rect)