(cls, hexcode)
return cls(*[int(''.join(x), 16) for x in zip(hexcode[::2], hexcode[1::2])])
Convert hexcode to RGB/RGBA.
Convert hexcode to RGB/RGBA.
Convert hexcode to RGB / RGBA .
def from_hexcode(cls, hexcode):
        """
        Convert hexcode to RGB/RGBA.
        """
        hexcode = hexcode.strip('#')
        assert len(hexcode) in (3,4,6,8), "Hex codes must be 3, 4, 6 or 8 characters long"
        if len(hexcode) in (3,4):
            hexcode = ''.join(x*2 for x in hexcode)
        return cls(*[int(''.join(x), 16) for x in zip(hexcode[::2], hexcode[1::2])])
def from_hexcode ( cls , hexcode ) : hexcode = hexcode . strip ( '#' ) assert len ( hexcode ) in ( 3 , 4 , 6 , 8 ) , "Hex codes must be 3, 4, 6 or 8 characters long" if len ( hexcode ) in ( 3 , 4 ) : hexcode = '' . join ( x * 2 for x in hexcode ) return cls ( * [ int ( '' . join ( x ) , 16 ) for x in zip ( hexcode [ : : 2 ] , hexcode [ 1 : : 2 ] ) ] )