def on_repaint(self, screen): font = fonts.get_font(fonts.FontType.ROBOTO_MEDIUM.value, 36) medication = self.device.selected_prescription.label label = 'Dispensing {} {}'.format(self.device.desired_dose, medication) text = font.render(label, True, Color.RIIT_DARKER_GRAY.value, Color.WHITE.value) centered_rect = ui.common.center(text, *self.bounds()) screen.blit(text, centered_rect)
def get_surface(self): # hacky non-OOP solution to count in interest of time # TODO: implement solution that works for any number of dose options self.number = self.position if not self.device.selected_prescription.show_override: self.number -= 1 font = fonts.get_font(fonts.FontType.ROBOTO_MEDIUM.value, 48) return font.render(str(self.number), True, Color.BLACK.value, self.color)
def render_question(screen, lines, y_start=68): font = fonts.get_font(fonts.FontType.ROBOTO_MEDIUM.value, 36) relative_y = 0 for line in lines: text = font.render(line, True, Color.RIIT_DARKER_GRAY.value, Color.WHITE.value) centered_rect = center(text, 0, y_start + relative_y, screen.get_width()) screen.blit(text, centered_rect) relative_y += 48
def draw_progress_circle(self, screen): x = self.dx(20) y = self.dy(12) pygame.gfxdraw.aacircle(screen, x + 75, y + 75, 75, Color.RIIT_GRAY.value) progress = 1 - self.prescription.get_time_until_next_dose() / self.prescription.dose_window rads = 2 * math.pi * progress end = (1 * math.pi / 2) start = end - rads pygame.draw.arc(screen, self.color, (x - 2, y - 2, 154, 154), start, end, 4) dot_x = round(75 * math.cos(start)) + 75 dot_y = round(75 * -math.sin(start)) + 75 pygame.gfxdraw.aacircle(screen, x + dot_x, y + dot_y, 5, self.color) pygame.gfxdraw.filled_circle(screen, x + dot_x, y + dot_y, 5, self.color) number, unit = self.prescription.format_time_until_next_dose() number_font = fonts.get_font(fonts.FontType.ROBOTO_LIGHT.value, 64) number_text = number_font.render(str(number), True, Color.RIIT_DARK_GRAY.value, Color.WHITE.value) number_centered_rect = ui.common.center(number_text, self.x, y + 29, self.w, 64) screen.blit(number_text, number_centered_rect) unit_font = fonts.get_font(fonts.FontType.ROBOTO_MEDIUM.value, 18) unit_text = unit_font.render(unit, True, Color.RIIT_DARK_GRAY.value, Color.WHITE.value) unit_centered_rect = ui.common.center(unit_text, self.x, y + 100, self.w, 18) screen.blit(unit_text, unit_centered_rect)
def on_repaint(self, screen): pygame.draw.rect(screen, Color.WHITE.value, (self.dx(14), self.dy(6), 162, 188)) # clear pygame.draw.rect(screen, self.border_color, self.bounds(), 1) doses = self.prescription.get_available_doses() if doses == self.prescription.max_dose: if not self.displaying_ready: audio.Sample.READY.play() # only play when changing from not ready to ready self.displaying_ready = True pygame.gfxdraw.aacircle(screen, self.dx(95), self.dy(87), 75, self.color) pygame.gfxdraw.filled_circle(screen, self.dx(95), self.dy(87), 75, self.color) ready_font = fonts.get_font(fonts.FontType.ROBOTO_LIGHT.value, 36) text = ready_font.render("Ready", True, Color.WHITE.value, self.color) centered_rect = ui.common.center(text, self.x, self.dy(12), self.w, 150) screen.blit(text, centered_rect) else: self.displaying_ready = False self.draw_progress_circle(screen) self.draw_dose_dots(screen, doses) label_font = fonts.get_font(fonts.FontType.ROBOTO_MEDIUM.value, 24) text = label_font.render(self.prescription.label.upper(), True, Color.RIIT_DARK_GRAY.value, Color.WHITE.value) centered_rect = ui.common.center(text, self.x, self.dy(194), self.w, 24) screen.blit(text, centered_rect)
def on_repaint(self, screen): font = fonts.get_font(fonts.FontType.ROBOTO_LIGHT.value, 24) text = font.render('Hello.', True, Color.RIIT_DARKER_GRAY.value, Color.WHITE.value) centered_rect = ui.common.center(text, *self.bounds()) screen.blit(text, centered_rect)
def on_repaint(self, screen): pygame.draw.rect(screen, self.color, self.bounds()) font = fonts.get_font(fonts.FontType.ROBOTO_MEDIUM.value, 24) text = font.render(self.label, True, Color.BLACK.value, self.color) centered_rect = ui.common.center(text, *self.bounds()) screen.blit(text, centered_rect)
def get_surface(self): font = fonts.get_font(fonts.FontType.ROBOTO_MEDIUM.value, 36) return font.render(self.option, True, Color.BLACK.value, self.color)