예제 #1
0
 def test_valid_percentages_hsl(self):
     """Test 0% and 100% in the HSL colorspace."""
     white = utils.interpolate_color(self.white, self.black, 0, QColor.Hsl)
     black = utils.interpolate_color(self.white, self.black, 100,
                                     QColor.Hsl)
     assert Color(white) == self.white
     assert Color(black) == self.black
예제 #2
0
 def test_valid_percentages_hsv(self, colors):
     """Test 0% and 100% in the HSV colorspace."""
     white = utils.interpolate_color(colors.white, colors.black, 0,
                                     QColor.Hsv)
     black = utils.interpolate_color(colors.white, colors.black, 100,
                                     QColor.Hsv)
     assert Color(white) == colors.white
     assert Color(black) == colors.black
예제 #3
0
 def test_0_100(self, colors, colorspace):
     """Test 0% and 100% in different colorspaces."""
     white = utils.interpolate_color(colors.white, colors.black, 0,
                                     colorspace)
     black = utils.interpolate_color(colors.white, colors.black, 100,
                                     colorspace)
     assert Color(white) == colors.white
     assert Color(black) == colors.black
예제 #4
0
 def test_valid_percentages_hsv(self, colors):
     """Test 0% and 100% in the HSV colorspace."""
     white = utils.interpolate_color(colors.white, colors.black, 0,
                                     QColor.Hsv)
     black = utils.interpolate_color(colors.white, colors.black, 100,
                                     QColor.Hsv)
     assert Color(white) == colors.white
     assert Color(black) == colors.black
예제 #5
0
 def test_0_100(self, colors, colorspace):
     """Test 0% and 100% in different colorspaces."""
     white = utils.interpolate_color(colors.white, colors.black, 0,
                                     colorspace)
     black = utils.interpolate_color(colors.white, colors.black, 100,
                                     colorspace)
     assert Color(white) == colors.white
     assert Color(black) == colors.black
예제 #6
0
 def test_interpolation_hsl(self):
     """Test an interpolation in the HSL colorspace."""
     start = Color()
     stop = Color()
     start.setHsl(0, 40, 100)
     stop.setHsl(0, 20, 200)
     color = utils.interpolate_color(start, stop, 50, QColor.Hsl)
     expected = Color()
     expected.setHsl(0, 30, 150)
     assert Color(color) == expected
예제 #7
0
 def test_interpolation_hsl(self):
     """Test an interpolation in the HSL colorspace."""
     start = Color()
     stop = Color()
     start.setHsl(0, 40, 100)
     stop.setHsl(0, 20, 200)
     color = utils.interpolate_color(start, stop, 50, QColor.Hsl)
     expected = Color()
     expected.setHsl(0, 30, 150)
     assert Color(color) == expected
예제 #8
0
 def test_interpolation_rgb(self):
     """Test an interpolation in the RGB colorspace."""
     color = utils.interpolate_color(Color(0, 40, 100), Color(0, 20, 200),
                                     50, QColor.Rgb)
     assert Color(color) == Color(0, 30, 150)
예제 #9
0
 def test_invalid_colorspace(self, colors):
     """Test an invalid colorspace."""
     with pytest.raises(ValueError):
         utils.interpolate_color(colors.white, colors.black, 10,
                                 QColor.Cmyk)
예제 #10
0
 def test_invalid_percentage(self, colors, perc):
     """Test an invalid percentage."""
     with pytest.raises(ValueError):
         utils.interpolate_color(colors.white, colors.white, perc)
예제 #11
0
 def test_invalid_end(self, colors):
     """Test an invalid end color."""
     with pytest.raises(qtutils.QtValueError):
         utils.interpolate_color(colors.white, Color(), 0)
예제 #12
0
 def test_invalid_start(self, colors):
     """Test an invalid start color."""
     with pytest.raises(qtutils.QtValueError):
         utils.interpolate_color(Color(), colors.white, 0)
예제 #13
0
 def test_interpolation_none(self, percentage, expected):
     """Test an interpolation with a gradient turned off."""
     color = utils.interpolate_color(Color(0, 0, 0), Color(255, 255, 255),
                                     percentage, None)
     assert isinstance(color, QColor)
     assert Color(color) == Color(*expected)
예제 #14
0
 def test_invalid_percentage(self):
     """Test an invalid percentage."""
     with pytest.raises(ValueError):
         utils.interpolate_color(self.white, self.white, -1)
     with pytest.raises(ValueError):
         utils.interpolate_color(self.white, self.white, 101)
예제 #15
0
 def test_invalid_colorspace(self, colors):
     """Test an invalid colorspace."""
     with pytest.raises(ValueError):
         utils.interpolate_color(colors.white, colors.black, 10,
                                 QColor.Cmyk)
예제 #16
0
 def test_invalid_percentage(self, colors, perc):
     """Test an invalid percentage."""
     with pytest.raises(ValueError):
         utils.interpolate_color(colors.white, colors.white, perc)
예제 #17
0
 def test_invalid_end(self, colors):
     """Test an invalid end color."""
     with pytest.raises(qtutils.QtValueError):
         utils.interpolate_color(colors.white, Color(), 0)
예제 #18
0
 def test_invalid_start(self, colors):
     """Test an invalid start color."""
     with pytest.raises(qtutils.QtValueError):
         utils.interpolate_color(Color(), colors.white, 0)
예제 #19
0
 def test_invalid_percentage(self):
     """Test an invalid percentage."""
     with pytest.raises(ValueError):
         utils.interpolate_color(self.white, self.white, -1)
     with pytest.raises(ValueError):
         utils.interpolate_color(self.white, self.white, 101)
예제 #20
0
 def test_interpolation_none(self, percentage, expected):
     """Test an interpolation with a gradient turned off."""
     color = utils.interpolate_color(Color(0, 0, 0), Color(255, 255, 255),
                                     percentage, None)
     assert isinstance(color, QColor)
     assert Color(color) == Color(*expected)
예제 #21
0
 def test_interpolation_rgb(self):
     """Test an interpolation in the RGB colorspace."""
     color = utils.interpolate_color(Color(0, 40, 100), Color(0, 20, 200),
                                     50, QColor.Rgb)
     assert Color(color) == Color(0, 30, 150)