import random


def superpixel_colors(
    num_pix:int = 1536,
    schema:str = 'rgb',
    interleave:int = 1,
    stroke:str = '',
    ) -> list:
    """
    Generate color (attribute) list for superpixel SVG paths

    Parameters
    ----------
    num_pix : int
        Number of super pixels to account for (default = 1536)
    schema : str
        Either of 'rgb' or 'random'
    interleave : int
        RGB interleave value (default = 1)
    stroke : str
        String that is inserted into ever attribute at the end, e.g.
        to account for a stroke, such as 'stroke="#808080"'. Please
        note that the entire tag=value (pairs) must be given!
    
    Returns
    -------
    colors : list
        List of attributes suitable for superpixel_outlines (SVG)
    """
    colors = [''] * num_pix
    if not schema in ['random', 'rgb']:
        raise ValueError('invalid schema requested.')
    if schema == 'rgb':
        if stroke:
            for idx in range(num_pix):
                val = interleave * idx
                colors[idx] = 'fill="#{0:02x}{1:02x}{2:02x}" {3:s}'.format(
                    val % 256, (val // 256) % 256, (val // 65536) % 256, stroke)
        else:
            for idx in range(num_pix):
                val = interleave * idx
                colors[idx] = 'fill="#{0:02x}{1:02x}{2:02x}"'.format(
                    val % 256, (val // 256) % 256, (val // 65536) % 256)
    else:

        # IMPORT DONE HERE TO SAVE TIME AT MODULE INIT

        if stroke:
            for idx in range(num_pix):
                colors[idx] = 'fill="#{0:06x} {1:s}"'.format(
                    random.randrange(16777216), stroke)
        else:
            for idx in range(num_pix):
                colors[idx] = 'fill="#{0:06x}"'.format(
                    random.randrange(16777216))
    return colors