Exemple #1
0
def test_complement():
    """Test function complement"""
    cunittest.assert_equals(colormodel.RGB(255 - 250, 255 - 0, 255 - 71), a3.complement_rgb(colormodel.RGB(250, 0, 71)))
    cunittest.assert_equals(colormodel.RGB(255 - 0, 255 - 0, 255 - 0), a3.complement_rgb(colormodel.RGB(0, 0, 0)))
    cunittest.assert_equals(
        colormodel.RGB(255 - 255, 255 - 255, 255 - 255), a3.complement_rgb(colormodel.RGB(255, 255, 255))
    )
def test_complement():
    """Test function complement"""
    cornelltest.assert_equals(
        colormodel.RGB(255 - 250, 255 - 0, 255 - 71), a3.complement_rgb(colormodel.RGB(250, 0, 71))
    )

    # Add another test
    cornelltest.assert_equals(colormodel.RGB(254, 175, 42), a3.complement_rgb(colormodel.RGB(1, 80, 213)))
Exemple #3
0
def test_complement():
    """Test function complement"""
    cornelltest.assert_equals(colormodel.RGB(255 - 250, 255 - 0, 255 - 71),
                              a3.complement_rgb(colormodel.RGB(250, 0, 71)))
    cornelltest.assert_equals(colormodel.RGB(255 - 255, 255 - 255, 255 - 255),
                              a3.complement_rgb(colormodel.RGB(255, 255, 255)))
    cornelltest.assert_equals(colormodel.RGB(255 - 0, 255 - 0, 255 - 0),
                              a3.complement_rgb(colormodel.RGB(0, 0, 0)))
def test_complement():
    """Test function complement"""
    cunittest.assert_equals(colormodel.RGB(5, 255, 184), a3.complement_rgb(\
                                                        colormodel.RGB(250, 0, 71)))
    cunittest.assert_equals(colormodel.RGB(255, 184, 5), a3.complement_rgb(\
                                                        colormodel.RGB(0, 71, 250)))
    cunittest.assert_equals(colormodel.RGB(184, 5, 255), a3.complement_rgb(\
                                                        colormodel.RGB(71, 250, 0)))
    cunittest.assert_equals(colormodel.RGB(0, 0, 0), a3.complement_rgb(\
                                                        colormodel.RGB(255, 255, 255)))
    cunittest.assert_equals(colormodel.RGB(255, 255, 255), a3.complement_rgb(\
                                                        colormodel.RGB(0, 0, 0)))
Exemple #5
0
def test_complement():
    """
    Test function complement
    """
    cornell.assert_equals(cornell.RGB(255 - 250, 255 - 0, 255 - 71),
                          a3.complement_rgb(cornell.RGB(250, 0, 71)))
    cornell.assert_equals(cornell.RGB(255 - 0, 255 - 0, 255 - 0),
                          a3.complement_rgb(cornell.RGB(0, 0, 0)))
    cornell.assert_equals(cornell.RGB(255 - 255, 255 - 255, 255 - 255),
                          a3.complement_rgb(cornell.RGB(255, 255, 255)))
    cornell.assert_equals(cornell.RGB(255 - 173, 255 - 69, 255 - 4),
                          a3.complement_rgb(cornell.RGB(173, 69, 4)))
Exemple #6
0
def test_complement():
    """
    Test function complement
    """
    print('Testing complement')
    # One test is really good enough here
    comp = a3.complement_rgb(introcs.RGB(250, 0, 71))
    introcs.assert_equals(255-250, comp.red)
    introcs.assert_equals(255-0,   comp.green)
    introcs.assert_equals(255-71,  comp.blue)
    # One more for good measure
    comp = a3.complement_rgb(introcs.RGB(128, 64, 255))
    introcs.assert_equals(255-128, comp.red)
    introcs.assert_equals(255-64,  comp.green)
    introcs.assert_equals(255-255, comp.blue)
    print('Test for complement passed')
Exemple #7
0
 def update(self, rgb, cmyk, hsv):
     """Refresh the color and text display in the color panels"""
     compRGB = a3.complement_rgb(rgb)
     if (compRGB is None):
         compRGB = rgb
     
     rgb_str = str(rgb)
     cmyk_str = '' if cmyk is None else str(cmyk) 
     hsv_str = '' if hsv is None else str(hsv)
     
     self.main.text = ("Color\nRGB:    " + rgb_str +
                       "\nCMYK: " + cmyk_str +
                       "\nHSV:    " + hsv_str + "\n \n" +
                       "R,G,B sliders in: 0..255\n" +
                       "C,M,Y,K sliders: 0 to 100%\n" +
                       "H slider: 0 <= H < 360 degrees\n" +
                       "S,V sliders: 0 <= S,V <= 1")
     self.main.background = rgb.glColor()
     self.main.foreground = compRGB.glColor()
     self.comp.text = ("Color\nRGB:    " + rgb_str +
                       "\nCMYK: " + cmyk_str +
                       "\nHSV:    " + hsv_str + "\n \n" +
                       "R,G,B sliders in: 0..255\n" +
                       "C,M,Y,K sliders: 0 to 100%\n" +
                       "H slider: 0 <= H < 360 degrees\n" +
                       "S,V sliders: 0 <= S,V <= 1" )
     self.comp.background = compRGB.glColor()
     self.comp.foreground = rgb.glColor()
     
     # set the sliders
     self.rSlider.value = rgb.red*100
     self.gSlider.value = rgb.green*100
     self.bSlider.value = rgb.blue*100
     self.cSlider.value = 0 if cmyk is None else cmyk.cyan*100 
     self.mSlider.value = 0 if cmyk is None else cmyk.magenta*100
     self.ySlider.value = 0 if cmyk is None else cmyk.yellow*100
     self.kSlider.value = 0 if cmyk is None else cmyk.black*100
     self.hSlider.value = 0 if hsv is None else hsv.hue*100
     self.sSlider.value = 0 if hsv is None else hsv.saturation*100
     self.vSlider.value = 0 if hsv is None else hsv.value*100
 def update(self, rgb, cmyk, hsv):
     """Refresh the color and text display in the color panels"""
     compRGB = a3.complement_rgb(rgb)
     if (compRGB is None):
         compRGB = rgb
     
     rgb_str  = rgb_to_str(rgb)
     cmyk_str = '' if cmyk is None else str5_cmyk(cmyk) 
     hsv_str  = '' if hsv is None else str5_hsv(hsv)
     
     self.main.text = ("Color\nRGB:    " + rgb_str +
                       "\nCMYK: " + cmyk_str +
                       "\nHSV:    " + hsv_str + "\n \n" +
                       "R,G,B sliders in: 0..255\n" +
                       "C,M,Y,K sliders: 0 to 100%\n" +
                       "H slider: 0 <= H < 360 degrees\n" +
                       "S,V sliders: 0 <= S,V <= 1")
     self.main.background = rgb.glColor()
     self.main.foreground = compRGB.glColor()
     self.comp.text = ("Color\nRGB:    " + rgb_str +
                       "\nCMYK: " + cmyk_str +
                       "\nHSV:    " + hsv_str + "\n \n" +
                       "R,G,B sliders in: 0..255\n" +
                       "C,M,Y,K sliders: 0 to 100%\n" +
                       "H slider: 0 <= H < 360 degrees\n" +
                       "S,V sliders: 0 <= S,V <= 1" )
     self.comp.background = compRGB.glColor()
     self.comp.foreground = rgb.glColor()
     
     # set the sliders
     self.rSlider.value = rgb.red*100
     self.gSlider.value = rgb.green*100
     self.bSlider.value = rgb.blue*100
     self.cSlider.value = 0 if cmyk is None else cmyk.cyan*100 
     self.mSlider.value = 0 if cmyk is None else cmyk.magenta*100
     self.ySlider.value = 0 if cmyk is None else cmyk.yellow*100
     self.kSlider.value = 0 if cmyk is None else cmyk.black*100
     self.hSlider.value = 0 if hsv is None else hsv.hue*100
     self.sSlider.value = 0 if hsv is None else hsv.saturation*100
     self.vSlider.value = 0 if hsv is None else hsv.value*100
Exemple #9
0
def test_complement():
    """
    Test function complement
    """
    cornell.assert_equals(cornell.RGB(255 - 250, 255 - 0, 255 - 71),
                          a3.complement_rgb(cornell.RGB(250, 0, 71)))
Exemple #10
0
def test_complement():
    """Test function complement"""
    cunittest.assert_equals(colormodel.RGB(255 - 250, 255 - 0, 255 - 71),
                            a3.complement_rgb(colormodel.RGB(250, 0, 71)))