def draw_frame(title, name, perc): return global last_draw if time.time() < last_draw + timeout: return frame = graphics.get_surface() w, h = frame.get_size() ui.fill(frame, (0, 0)) text = ui.mediumfont.render(name, 1, (0, 0, 0)) titletext = ui.mediumfont.render(title, 1, (0, 0, 0)) frame.blit(text, ((w - text.get_width()) / 2, h - 60)) frame.blit(titletext, ((w - titletext.get_width()) / 2, h - 120)) barheight = 20 barwidth = w * 0.6 barpos = (w * 0.2, 100) round = 8 ui.round_rect(frame, (200, 255, 200, 200), (0, 0, 0, 0), barpos + (barwidth, barheight), round) if perc > 0: ui.round_rect(frame, (0, 255, 0, 200), (0, 0, 0, 0), barpos + (int(barwidth * perc), barheight), round) # .draw.rect(frame, (200, 255, 200), barpos + (barwidth, barheight)) # .draw.rect(frame, (0, 255, 0), barpos + (int(barwidth * perc), barheight)) graphics.flip() last_draw = time.time()
def draw_frame(title, name, perc): global last_draw if time.time() < last_draw + timeout: return frame = pygame.display.get_surface() w, h = frame.get_size() ui.fill(frame, (0, 0)) text = ui.mediumfont.render(name, 1, (0, 0, 0)) titletext = ui.mediumfont.render(title, 1, (0, 0, 0)) frame.blit(text, ((w - text.get_width()) / 2, h - 60)) frame.blit(titletext, ((w - titletext.get_width()) / 2, h - 120)) barheight = 20 barwidth = w * 0.6 barpos = (w * 0.2, 100) round = 8 ui.round_rect(frame, (200, 255, 200, 200), (0, 0, 0, 0), barpos + (barwidth, barheight), round) if perc > 0: ui.round_rect(frame, (0, 255, 0, 200), (0, 0, 0, 0), barpos + (int(barwidth * perc), barheight), round) #pygame.draw.rect(frame, (200, 255, 200), barpos + (barwidth, barheight)) #pygame.draw.rect(frame, (0, 255, 0), barpos + (int(barwidth * perc), barheight)) pygame.display.flip() last_draw = time.time()
def draw_frame(title, name, perc): frame = pygame.display.get_surface() w, h = frame.get_size() ui.fill(frame, (0, 0)) text = ui.mediumfont.render(name, 1, (0, 0, 0)) titletext = ui.mediumfont.render(title, 1, (0, 0, 0)) frame.blit(text, ((w - text.get_width())/2, h - 60)) frame.blit(titletext, ((w - titletext.get_width())/2, h - 120)) barheight = 20 barwidth = w * 0.6 barpos = (w * 0.2, 100) round = 8 ui.round_rect(frame, (200, 255, 200, 200), (0,0,0,0), barpos + (barwidth, barheight), round) if perc > 0: ui.round_rect(frame, (0, 255, 0, 200), (0,0,0,0), barpos + (int(barwidth * perc), barheight), round) #pygame.draw.rect(frame, (200, 255, 200), barpos + (barwidth, barheight)) #pygame.draw.rect(frame, (0, 255, 0), barpos + (int(barwidth * perc), barheight)) pygame.display.flip()
def draw(self, surf, pos): width = ui.screen_width * (self.spacing + 1) x, y = pos time = float(self.frame) / self.duration if self.dir == 1: a = self.src b = self.dest at = -time else: a = self.dest b = self.src at = time - 1 a_x = int(at * width) b_x = int((at+1) * width) if not self.samebg: ui.fill(surf, (b_x + x, y), b) else: ui.fill(surf, (0, 0), b) b.draw(surf, (b_x + x, y)) if not self.samebg: ui.fill(surf, (a_x + x, y), a) a.draw(surf, (a_x + x, y))
def draw(self, surf, pos): width = ui.screen_width * (self.spacing + 1) x, y = pos time = float(self.frame) / self.duration if self.dir == 1: a = self.src b = self.dest at = -time else: a = self.dest b = self.src at = time - 1 a_x = int(at * width) b_x = int((at + 1) * width) if not self.samebg: ui.fill(surf, (b_x + x, y), b) else: ui.fill(surf, (0, 0), b) b.draw(surf, (b_x + x, y)) if not self.samebg: ui.fill(surf, (a_x + x, y), a) a.draw(surf, (a_x + x, y))