def hue_gradient(start: float=0.0, length: int=360) -> list: """ Generate a gradient which spans all hues :param start: starting hue :param length: number of colors which should be produced :return: list of colors """ step = 360 / length return [Color.NewFromHsv((start + (step * x)) % 360, 1, 1) for x in range(0, length)]
def random_generator(rgb: bool = False): """ Generate random colors using the golden ratio conjugate :param rgb: True if RGB tuples should be generated :return: generator: """ golden_ratio_conjugate = (1 + math.sqrt(5)) / 2 hue = random.random() c0 = Color.NewFromHsv(0, 1.0, 1.0) while True: hue += golden_ratio_conjugate hue %= 1 value = c0.ColorWithHue(hue * 360) if rgb: yield to_rgb(value) else: yield value
def _hue_gradient(start, length): step = 360 / length return [ Color.NewFromHsv((start + (step * x)) % 360, 1, 1) for x in range(0, length) ]