MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / render

Method render

PythonAPI/examples/automatic_control.py:288–324  ·  view source on GitHub ↗
(self, display)

Source from the content-addressed store, hash-verified

286 self._notifications.set_text('Error: %s' % text, (255, 0, 0))
287
288 def render(self, display):
289 if self._show_info:
290 info_surface = pygame.Surface((220, self.dim[1]))
291 info_surface.set_alpha(100)
292 display.blit(info_surface, (0, 0))
293 v_offset = 4
294 bar_h_offset = 100
295 bar_width = 106
296 for item in self._info_text:
297 if v_offset + 18 > self.dim[1]:
298 break
299 if isinstance(item, list):
300 if len(item) > 1:
301 points = [(x + 8, v_offset + 8 + (1.0 - y) * 30) for x, y in enumerate(item)]
302 pygame.draw.lines(display, (255, 136, 0), False, points, 2)
303 item = None
304 v_offset += 18
305 elif isinstance(item, tuple):
306 if isinstance(item[1], bool):
307 rect = pygame.Rect((bar_h_offset, v_offset + 8), (6, 6))
308 pygame.draw.rect(display, (255, 255, 255), rect, 0 if item[1] else 1)
309 else:
310 rect_border = pygame.Rect((bar_h_offset, v_offset + 8), (bar_width, 6))
311 pygame.draw.rect(display, (255, 255, 255), rect_border, 1)
312 f = (item[1] - item[2]) / (item[3] - item[2])
313 if item[2] < 0.0:
314 rect = pygame.Rect((bar_h_offset + f * (bar_width - 6), v_offset + 8), (6, 6))
315 else:
316 rect = pygame.Rect((bar_h_offset, v_offset + 8), (f * bar_width, 6))
317 pygame.draw.rect(display, (255, 255, 255), rect)
318 item = item[0]
319 if item: # At this point has to be a str.
320 surface = self._font_mono.render(item, True, (255, 255, 255))
321 display.blit(surface, (8, v_offset))
322 v_offset += 18
323 self._notifications.render(display)
324 self.help.render(display)
325
326# ==============================================================================
327# -- FadingText ----------------------------------------------------------------

Callers 3

renderMethod · 0.45
set_textMethod · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected