#NEWLINE# def apply_alpha( self , background = '#000000FF' ) : #NEWLINE# #INDENT# '\n        Apply the given transparency with the given background.\n\n        This gives a color that represents what the eye sees with\n        the transparent color against the given background.\n        ' #NEWLINE# def tx_alpha( cf , af , cb , ab ) : #NEWLINE# #INDENT# 'Translate the color channel with the alpha channel and background channel color.' #NEWLINE# return ( round_int ( abs ( ( ( cf * ( af * RGB_CHANNEL_SCALE ) ) + ( ( cb * ( ab * RGB_CHANNEL_SCALE ) ) * ( 1 - ( af * RGB_CHANNEL_SCALE ) ) ) ) ) ) & 255 ) #NEWLINE# #UNINDENT# if ( self . a < 255 ) : #NEWLINE# #INDENT# ( r , g , b , a ) = self . _split_channels ( background ) #NEWLINE# self . r = tx_alpha ( self . r , self . a , r , a ) #NEWLINE# self . g = tx_alpha ( self . g , self . a , g , a ) #NEWLINE# self . b = tx_alpha ( self . b , self . a , b , a ) #NEWLINE# #UNINDENT# return self . get_rgb ( )