Ejemplo n.º 1
0
 def test_round_trip_maximum(self):
     """ Test to assert stability of values through round-trips """
     for value in range(65536):
         with self.subTest(int=value):
             result = channels_to_ints(
                 ints_to_channels(
                     [value],
                     maximum=65535,
                 ),
                 maximum=65535,
             )
             self.assertEqual(result, (value, ))
Ejemplo n.º 2
0
def rgba_to_toolkit_color(rgba):
    """ Convert an RGBA tuple to a hex tuple.

    Parameters
    ----------
    color : tuple
        A tuple of integer values from 0 to 255 inclusive.

    Returns
    -------
    rgba : tuple
        A tuple of 4 floating point values between 0.0 and 1.0 inclusive.
    """
    return channels_to_ints(rgba)
Ejemplo n.º 3
0
def rgba_to_toolkit_color(rgba):
    """ Convert an RGBA tuple to a wx.Colour.

    Parameters
    ----------
    rgba : tuple
        A tuple of 4 floating point values between 0.0 and 1.0 inclusive.

    Returns
    -------
    wx_color : wx.Colour
        A wx.Colour object.
    """
    values = channels_to_ints(rgba)
    return wx.Colour(*values)
Ejemplo n.º 4
0
def rgba_to_toolkit_color(rgba):
    """ Convert an RGBA tuple to a QColor.

    Parameters
    ----------
    rgba_tuple : tuple
        A tuple of 4 floating point values between 0.0 and 1.0 inclusive.

    Returns
    -------
    qcolor : QColor
        A QColor object.
    """
    values = channels_to_ints(rgba)
    return QColor(*values)
Ejemplo n.º 5
0
 def test_channels_to_ints_maximum(self):
     channels = (0.4, 0.4, 0.0, 1.0)
     values = channels_to_ints(channels, maximum=15)
     self.assertEqual(values, (6, 6, 0, 15))
Ejemplo n.º 6
0
 def test_channels_to_ints(self):
     channels = (0.4, 0.4, 0.0, 1.0)
     values = channels_to_ints(channels)
     self.assertEqual(values, (102, 102, 0, 255))