def mix(self, color1, color2, weight=<NUM_LIT:50>, *args):
if color1 and color2:<EOL><INDENT>if isinstance(weight, string_types):<EOL><INDENT>weight = float(weight.strip('<STR_LIT:%>'))<EOL><DEDENT>weight = ((weight / <NUM_LIT>) * <NUM_LIT:2>) - <NUM_LIT:1><EOL>rgb1 = self._hextorgb(color1)<EOL>rgb2 = self._hextorgb(color2)<EOL>alpha = <NUM_LIT:0><EOL>w1 = (((weight if weight * alpha == -<NUM_LIT:1> else weight + alpha) /<EOL>(<NUM_LIT:1> + weight * alpha)) + <NUM_LIT:1>)<EOL>w1 = w1 / <NUM_LIT><EOL>w2 = <NUM_LIT:1> - w1<EOL>rgb = [<EOL>rgb1[<NUM_LIT:0>] * w1 + rgb2[<NUM_LIT:0>] * w2,<EOL>rgb1[<NUM_LIT:1>] * w1 + rgb2[<NUM_LIT:1>] * w2,<EOL>rgb1[<NUM_LIT:2>] * w1 + rgb2[<NUM_LIT:2>] * w2,<EOL>]<EOL>return self._rgbatohex(rgb)<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>
This algorithm factors in both the user-provided weight
        and the difference between the alpha values of the two colors
        to decide how to perform the weighted average of the two RGB values.

        It works by first normalizing both parameters to be within [-1, 1],
        where 1 indicates "only use color1", -1 indicates "only use color 0",
        and all values in between indicated a proportionately weighted average.

        Once we have the normalized variables w and a,
        we apply the formula (w + a)/(1 + w*a)
        to get the combined weight (in [-1, 1]) of color1.
        This formula has two especially nice properties:

         * When either w or a are -1 or 1, the combined weight is also that number
           (cases where w * a == -1 are undefined, and handled as a special case).

         * When a is 0, the combined weight is w, and vice versa

        Finally, the weight of color1 is renormalized to be within [0, 1]
        and the weight of color2 is given by 1 minus the weight of color1.

        Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
        http://sass-lang.com
        args:
            color1 (str): first color
            color2 (str): second color
            weight (int/str): weight
        raises:
            ValueError
        returns:
            str