<s> import pygame <EOL> from pygame . locals import * <EOL> from pygame . sprite import DirtySprite , LayeredDirty <EOL> pygame . init ( ) <EOL> screenSurface = pygame . display . set_mode ( ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> class PpuiImage ( DirtySprite ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , imagepath ) : <EOL> pygame . sprite . DirtySprite . __init__ ( self ) <EOL> self . image = pygame . image . load ( imagepath ) . convert ( ) <EOL> self . rect = self . image . get_rect ( ) <EOL> def update ( self , screen ) : <EOL> screen . blit ( self . image , self . rect ) <EOL> def applyColour ( self , colour ) : <EOL> """<STR_LIT>""" <EOL> for x in range ( <NUM_LIT:0> , self . rect . width ) : <EOL> for y in range ( <NUM_LIT:0> , self . rect . height ) : <EOL> pixel = self . image . get_at ( ( x , y ) ) . r <EOL> if ( pixel > <NUM_LIT:50> ) : <EOL> self . image . set_at ( ( x , y ) , colour ) <EOL> bg = PpuiImage ( "<STR_LIT>" ) <EOL> button = PpuiImage ( "<STR_LIT>" ) <EOL> button . applyColour ( ( <NUM_LIT:255> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> sprites = LayeredDirty ( ) <EOL> sprites . add ( bg ) <EOL> sprites . add ( button ) <EOL> while pygame . display . get_init ( ) : <EOL> sprites . draw ( screenSurface ) <EOL> pygame . display . update ( ) <EOL> for event in pygame . event . get ( ) : <EOL> if event . type == KEYUP : <EOL> pygame . quit ( ) <EOL> break <EOL> if ( event . type == MOUSEMOTION ) : <EOL> button . rect . left = event . pos [ <NUM_LIT:0> ] <EOL> button . rect . top = event . pos [ <NUM_LIT:1> ] <EOL> button . dirty = <NUM_LIT:1> </s>
