(self, cover_color)
return Color(red, green, blue, alpha)
Mix the two colors respecting their alpha value.

        Puts cover_color over itself compositing the colors using the alpha
        values.
Mix the two colors respecting their alpha value.
Mix the two colors respecting their alpha value .
def cover_with(self, cover_color):
        """
        Mix the two colors respecting their alpha value.

        Puts cover_color over itself compositing the colors using the alpha
        values.
        """
        # fastpath for solid colors
        if cover_color.alpha == 255:
            return Color(cover_color.red, cover_color.green, cover_color.blue, cover_color.alpha)

        srca = cover_color.alpha / 255
        dsta = self.alpha / 255
        outa = srca + dsta * (1 - srca)

        srcr, srcg, srcb = cover_color.red, cover_color.green, cover_color.blue
        dstr, dstg, dstb = self.red, self.green, self.blue

        outr = (srcr * srca + dstr * dsta * (1 - srca)) / outa
        outg = (srcg * srca + dstg * dsta * (1 - srca)) / outa
        outb = (srcb * srca + dstb * dsta * (1 - srca)) / outa

        red = int(round(outr))
        green = int(round(outg))
        blue = int(round(outb))
        alpha = int(round(outa * 255))

        return Color(red, green, blue, alpha)
def cover_with ( self , cover_color ) : # fastpath for solid colors if cover_color . alpha == 255 : return Color ( cover_color . red , cover_color . green , cover_color . blue , cover_color . alpha ) srca = cover_color . alpha / 255 dsta = self . alpha / 255 outa = srca + dsta * ( 1 - srca ) srcr , srcg , srcb = cover_color . red , cover_color . green , cover_color . blue dstr , dstg , dstb = self . red , self . green , self . blue outr = ( srcr * srca + dstr * dsta * ( 1 - srca ) ) / outa outg = ( srcg * srca + dstg * dsta * ( 1 - srca ) ) / outa outb = ( srcb * srca + dstb * dsta * ( 1 - srca ) ) / outa red = int ( round ( outr ) ) green = int ( round ( outg ) ) blue = int ( round ( outb ) ) alpha = int ( round ( outa * 255 ) ) return Color ( red , green , blue , alpha )