Пример #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)