コード例 #1
0
ファイル: color.py プロジェクト: sj26/uchroma
    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
ファイル: color.py プロジェクト: burnsed/uchroma
    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)
     ]