Пример #1
0
    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)]
Пример #2
0
    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
Пример #3
0
 def _hue_gradient(start, length):
     step = 360 / length
     return [
         Color.NewFromHsv((start + (step * x)) % 360, 1, 1)
         for x in range(0, length)
     ]