示例#1
0
    def get_values(self):
        b = [float(x) for x in self.begin.split(',')]
        e = [float(x) for x in self.end.split(',')]

        b_hsv = rgb2hsv(b)
        e_hsv = rgb2hsv(e)

        size_fact = 1.0 / (float(self.size) - 1.0)

        # Ignore the undefined hues
        if b_hsv[0] is None:
            b_hsv[0] = e_hsv[0]
        elif e_hsv[0] is None:
            e_hsv[0] = b_hsv[0]

        if b_hsv[0] is None:
            # There is no hue at all!
            b_hsv[0] = e_hsv[0] = 0.0 # unused value
            hue_step = 0.0
        else:
            # Compute hue
            # Because the hue is an angle, there is two ways to interpolate it;
            # choose the shorter path
            diff1 = e_hsv[0] - b_hsv[0]
            diff2 = e_hsv[0] - b_hsv[0] + 360.0
            if diff2 >= 360.0:
                diff2 -= 360.0
            assert 0.0 <= diff2 < 360.0
            if abs(diff1) < abs(diff2):
                hue_step = diff1
            else:
                hue_step = diff2

        colors = []
        for i in xrange(self.size):
            u = i * size_fact
            hue = b_hsv[0] + u * hue_step
            if hue < 0.0:
                hue += 360.0
            elif hue > 360.0:
                hue -= 360.0
            colors.append(Color.to_string(*hsv2rgb((
                    hue,
                    b_hsv[1] + u * (e_hsv[1] - b_hsv[1]),
                    b_hsv[2] + u * (e_hsv[2] - b_hsv[2])
                ))))

        return colors
示例#2
0
 def get_value(self):
     return Color.to_string(self.qcolor.redF(), self.qcolor.greenF(),
                            self.qcolor.blueF())
示例#3
0
 def get_value(self):
     return Color.to_string(self.qcolor.redF(),
                            self.qcolor.greenF(),
                            self.qcolor.blueF())
示例#4
0
 def fun(b, e, s, i):
     b = [float(x) for x in b.split(',')]
     e = [float(x) for x in e.split(',')]
     u = float(i) / (float(s) - 1.0)
     [r,g,b] = [b[i] + u * (e[i] - b[i]) for i in [0,1,2]]
     return Color.to_string(r, g, b)