def draw_in_widget(self): self.surf.fill(self.back_col) for i in range(len(self.cell_inf)): for j in range(len(self.cell_inf[i])): if self.component_status[i][j] == 0: pygame.draw.rect( self.surf, set_color(self.cell_pass_view), [[ self.w // len(self.cell_inf[i]) * j + self.m_c_x, self.cell_height * i + self.m_c_y ], [(self.w - self.s_b_c * len(self.cell_inf[i]) - self.m_c_x * (len(self.cell_inf[i]))) // len(self.cell_inf[i]), self.cell_height - self.s_b_c]], self.border_radius) elif self.component_status[i][j] == 1: pygame.draw.rect( self.surf, set_color(self.cell_hover_view), [[ self.w // len(self.cell_inf[i]) * j + self.m_c_x, self.cell_height * i + self.m_c_y ], [(self.w - self.s_b_c * len(self.cell_inf[i]) - self.m_c_x * len(self.cell_inf[i])) // len(self.cell_inf[i]), self.cell_height - self.s_b_c] ], self.border_radius)
def draw_cell(screen, width, height, xo, yo, color, border_radius=0): """ Draw isometric cell if you have not texture :param xo: x coordinate of top left angle :param yo: y coordinate of top left angle :param screen: using screen :param border_radius :param color: fill colour for cell (just name, for examlpe: '#FF0000' or 'red) """ pygame.draw.polygon(screen, set_color(color), [[xo, yo], [xo + width, yo], [xo + width, yo + height], [xo, yo + height]])
def __init__(self, x, y, transparency=255, background_color="black", font_color="white", font_style=None): super().__init__(x, y, 42, 24, transparency, background_color) self.font_color = set_color(font_color) self.font_style = font_style self.seconds = 0
def draw_cell(screen, cell_size, xo, yo, color): """ Draw isometric cell if you have not texture :param xo: x coordinate of center :param yo: y coordinate of center :param screen: using screen :param cell_size: size of cell :param color: fill colour for cell (just name, for examlpe: '#FF0000' or 'red) """ pygame.draw.polygon(screen, set_color(color), [[xo - cell_size * 2, yo], [xo, yo - cell_size], [xo + cell_size * 2, yo], [xo, yo + cell_size]])
def __init__(self, x, y, image_list, inform_list, transparency=100, background_color="black", font_color="white", font_style=None): super().__init__(x, y, 100 * len(inform_list) + 10, 30, transparency, background_color) self.font_color = set_color(font_color) self.font_style = font_style self.inform_list = inform_list self.image_list = set_cell_color(image_list)
def draw_place(screen, cell_size, x, y, color): """ Draw, if you haven't a texture :param screen: using screen :param cell_size: size of cell(1/2 of height) :param x: x coordinate of place in top middle :param y: y coordinate of place in top middle :param color: using color """ pygame.draw.polygon(screen, set_color(color), [[x - cell_size * 2, y], [x, y + cell_size], [x + cell_size * 2, y], [x + cell_size * 2, y + cell_size], [x, y + cell_size * 2], [x - cell_size * 2, y + cell_size]]) scr = pygame.Surface((cell_size * 2 + 1, cell_size * 2), pygame.SRCALPHA) pygame.draw.polygon(scr, pygame.Color(0, 0, 0, 100), [[0, cell_size], [cell_size * 2, 0], [cell_size * 2, cell_size], [0, cell_size * 2]]) screen.blit(scr, (x, y))
def render_image(self, scr, x, y): if self.start_pos and self.end_pos and self.rect_pos: pygame.draw.rect(scr, set_color(self.rect_color, "green"), self.rect_pos, 1) if pygame.mouse.get_focused(): scr.blit(self.ob_images[self.using_image], (x, y))
def __init__(self, x, y, width, height, transparency, background_color): self.surf = pygame.Surface((width, height)) self.surf.set_alpha(transparency) self.w, self.h = width, height self.back_col = set_color(background_color) self.x, self.y = x, y