def colorHashToRgba( colorHash ):
    """
    Converts the given HTML-style color hash (e.g., '#aabbcc') or
    HTML-with-alpha color hash (e.g. '#aabbccdd') to a quad-color (r,
    g, b, a) tuple and returns the result.

    Examples:

    >>> colorHashToRgba( '#ffffff' )
    (1.0, 1.0, 1.0, 1.0)

    >>> colorHashToRgba( '#ff000000' )
    (1.0, 0.0, 0.0, 0.0)
    """
    
    colorHash = colorHash[1:]
    if len(colorHash) == 6:
        # It's a RGB hash.
        alphaHex = "FF"
    elif len(colorHash) == 8:
        # It's a RGBA hash.
        alphaHex = colorHash[6:8]
    else:
        raise ValueError("Can't parse color hash for '#%s'" % colorHash)

    redHex = colorHash[0:2]
    greenHex = colorHash[2:4]
    blueHex = colorHash[4:6]

    red = float( int(redHex, 16) )
    green = float( int(greenHex, 16) )
    blue = float( int(blueHex, 16) )
    alpha = float( int(alphaHex, 16) )

    return ( red / 255.0, green / 255.0, blue / 255.0, alpha / 255.0 )