(self, css, factor)
return css
Apply a fake transparency to color.

        Fake transparency is preformed on top of the background color.
Apply a fake transparency to color.
Apply a fake transparency to color .
def fade(self, css, factor):
        """
        Apply a fake transparency to color.

        Fake transparency is preformed on top of the background color.
        """
        try:
            parts = [c.strip('; ') for c in css.split(':')]
            if len(parts) == 2 and parts[0] in ('background-color', 'color'):
                bgcolor = self.colors.get('.background').get('background-color')
                bgparts = [c.strip('; ') for c in bgcolor.split(':')]
                rgba = RGBA(parts[1] + "%02f" % int(255.0 * max(min(float(factor), 1.0), 0.0)))
                rgba.apply_alpha(bgparts[1])
                return '%s: %s; ' % (parts[0], rgba.get_rgb())
        except Exception:
            pass
        return css
def fade ( self , css , factor ) : try : parts = [ c . strip ( '; ' ) for c in css . split ( ':' ) ] if len ( parts ) == 2 and parts [ 0 ] in ( 'background-color' , 'color' ) : bgcolor = self . colors . get ( '.background' ) . get ( 'background-color' ) bgparts = [ c . strip ( '; ' ) for c in bgcolor . split ( ':' ) ] rgba = RGBA ( parts [ 1 ] + "%02f" % int ( 255.0 * max ( min ( float ( factor ) , 1.0 ) , 0.0 ) ) ) rgba . apply_alpha ( bgparts [ 1 ] ) return '%s: %s; ' % ( parts [ 0 ] , rgba . get_rgb ( ) ) except Exception : pass return css