If flag enabled, it renders all the information regarding the left panel of the visualizer
(self, display)
| 330 | return vehicle_id_surface |
| 331 | |
| 332 | def render(self, display): |
| 333 | """If flag enabled, it renders all the information regarding the left panel of the visualizer""" |
| 334 | if self.show_info: |
| 335 | info_surface = pygame.Surface((240, self.dim[1])) |
| 336 | info_surface.set_alpha(100) |
| 337 | display.blit(info_surface, (0, 0)) |
| 338 | v_offset = 4 |
| 339 | bar_h_offset = 100 |
| 340 | bar_width = 106 |
| 341 | i = 0 |
| 342 | for title, info in self._info_text.items(): |
| 343 | if not info: |
| 344 | continue |
| 345 | surface = self._header_font.render(title, True, COLOR_ALUMINIUM_0).convert_alpha() |
| 346 | display.blit(surface, (8 + bar_width / 2, 18 * i + v_offset)) |
| 347 | v_offset += 12 |
| 348 | i += 1 |
| 349 | for item in info: |
| 350 | if v_offset + 18 > self.dim[1]: |
| 351 | break |
| 352 | if isinstance(item, list): |
| 353 | if len(item) > 1: |
| 354 | points = [(x + 8, v_offset + 8 + (1.0 - y) * 30) for x, y in enumerate(item)] |
| 355 | pygame.draw.lines(display, (255, 136, 0), False, points, 2) |
| 356 | item = None |
| 357 | elif isinstance(item, tuple): |
| 358 | if isinstance(item[1], bool): |
| 359 | rect = pygame.Rect((bar_h_offset, v_offset + 8), (6, 6)) |
| 360 | pygame.draw.rect(display, COLOR_ALUMINIUM_0, rect, 0 if item[1] else 1) |
| 361 | else: |
| 362 | rect_border = pygame.Rect((bar_h_offset, v_offset + 8), (bar_width, 6)) |
| 363 | pygame.draw.rect(display, COLOR_ALUMINIUM_0, rect_border, 1) |
| 364 | f = (item[1] - item[2]) / (item[3] - item[2]) |
| 365 | if item[2] < 0.0: |
| 366 | rect = pygame.Rect((bar_h_offset + f * (bar_width - 6), v_offset + 8), (6, 6)) |
| 367 | else: |
| 368 | rect = pygame.Rect((bar_h_offset, v_offset + 8), (f * bar_width, 6)) |
| 369 | pygame.draw.rect(display, COLOR_ALUMINIUM_0, rect) |
| 370 | item = item[0] |
| 371 | if item: # At this point has to be a str. |
| 372 | surface = self._font_mono.render(item, True, COLOR_ALUMINIUM_0).convert_alpha() |
| 373 | display.blit(surface, (8, 18 * i + v_offset)) |
| 374 | v_offset += 18 |
| 375 | v_offset += 24 |
| 376 | self._notifications.render(display) |
| 377 | self.help.render(display) |
| 378 | |
| 379 | |
| 380 | # ============================================================================== |
no outgoing calls
no test coverage detected