class Thumbnail(): """Thumbnail that has a surface, with a background color set""" def __init__(self, width=64): self.surface_thumb = Rect(0, 0, width, width) self.rect_thumb = Rect(0, 0, width, width) # ex [1] the standard pygame.Color("white") , same as Color("#ffffff") self.color_bg = Color("white") # ex [2] random color with a filter: self.color_bg = random_color('light') self.color_border = random_color('dark') # create empty surface; fill it self.surface_thumb = pygame.Surface([width, width]) self.surface_thumb.fill(self.color_bg) def fill(self): """clear thumb.""" self.surface_thumb.fill(self.color_bg) def move(self, x, y): """move all rects/images together""" self.rect_thumb.move_ip(x, y) def draw(self, screen): screen.blit(self.surface_thumb, self.rect_thumb) def __str__(self): return "<Thumbnail( bg={bg}, rect_thumb={rect_thumb} >".format( bg=self.color_bg, rect_thumb=self.rect_thumb)
class Thumbnail(): """Thumbnail that has a surface, with a background color set""" def __init__(self, width=64): self.surface_thumb = Rect(0,0,width,width) self.rect_thumb = Rect(0,0,width,width) # ex [1] the standard pygame.Color("white") , same as Color("#ffffff") self.color_bg = Color("white") # ex [2] random color with a filter: self.color_bg = random_color('light') self.color_border = random_color('dark') # create empty surface; fill it self.surface_thumb = pygame.Surface([width, width]) self.surface_thumb.fill(self.color_bg) def fill(self): """clear thumb.""" self.surface_thumb.fill(self.color_bg) def move(self, x, y): """move all rects/images together""" self.rect_thumb.move_ip(x,y) def draw(self, screen): screen.blit(self.surface_thumb, self.rect_thumb) def __str__(self): return "<Thumbnail( bg={bg}, rect_thumb={rect_thumb} >".format(bg=self.color_bg, rect_thumb=self.rect_thumb)