Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)