def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    # pass # ADD TESTS TO ME
    hsv = colormodel.HSV(1.000, 0.500, 0.500)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(128, rgb.red)
    cornelltest.assert_equals(65, rgb.green)
    cornelltest.assert_equals(64, rgb.blue)

    hsv = colormodel.HSV(200.0, 0.250, 0.250)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(48, rgb.red)
    cornelltest.assert_equals(58, rgb.green)
    cornelltest.assert_equals(64, rgb.blue)

    hsv = colormodel.HSV(312.3, 0.667, 0.913)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(233, rgb.red)
    cornelltest.assert_equals(78, rgb.green)
    cornelltest.assert_equals(201, rgb.blue)

    hsv = colormodel.HSV(87.20, 0.117, 0.699)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(169, rgb.red)
    cornelltest.assert_equals(178, rgb.green)
    cornelltest.assert_equals(157, rgb.blue)

    hsv = colormodel.HSV(0.000, 0.000, 0.000)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(0, rgb.red)
    cornelltest.assert_equals(0, rgb.green)
    cornelltest.assert_equals(0, rgb.blue)
 def on_hsv_press(self,h,s,v):
     """Call back to hsv button"""
     self.hsv = colormodel.HSV(h, s, v)
     temp = a3.hsv_to_rgb(self.hsv)
     assert (temp == None or type(temp) == colormodel.RGB), 'hsv_to_rgb does not return a RGB object'
     self.rgb = self.rgb if temp is None else temp
     self.cmyk = a3.rgb_to_cmyk(self.rgb);
     assert (self.cmyk == None or type(self.cmyk) == colormodel.CMYK), 'rgb_to_cmyk does not return a CMYK object'
     self.update()
Example #3
0
 def on_hsv_press(self,h,s,v):
     """Call back to hsv button"""
     self.bot.clear()
     self.hsv = colormodel.HSV(h, s, v)
     temp = a3.hsv_to_rgb(self.hsv)
     assert (temp == None or type(temp) == colormodel.RGB), 'hsv_to_rgb does not return a RGB object'
     self.rgb = self.rgb if temp is None else temp
     self.cmyk = a3.rgb_to_cmyk(self.rgb);
     assert (self.cmyk == None or type(self.cmyk) == colormodel.CMYK), 'rgb_to_cmyk does not return a CMYK object'
     self.update()
Example #4
0
def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    hsv = colormodel.HSV(0.0, 0.0, 0.0)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals("0.000", a3.round5(rgb.red))
    cunittest.assert_equals("0.000", a3.round5(rgb.green))
    cunittest.assert_equals("0.000", a3.round5(rgb.blue))

    hsv = colormodel.HSV(0.0, 0.0, 1.0)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals("255.0", a3.round5(rgb.red))
    cunittest.assert_equals("255.0", a3.round5(rgb.green))
    cunittest.assert_equals("255.0", a3.round5(rgb.blue))

    hsv = colormodel.HSV(217.9, 0.567, 0.23)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals("25.00", a3.round5(rgb.red))
    cunittest.assert_equals("38.00", a3.round5(rgb.green))
    cunittest.assert_equals("59.00", a3.round5(rgb.blue))
Example #5
0
 def on_hsv_slide(self,h,s,v):
     """Call back to hsv sliders"""
     if not self.active:
         return
     hue = h / 100.0
     sat = s / 100.0
     val = v / 100.0
     self.hsv = colormodel.HSV(hue, sat, val)
     temp = a3.hsv_to_rgb(self.hsv)
     assert (temp == None or type(temp) == colormodel.RGB), 'hsv_to_rgb does not return a RGB object'
     self.rgb = self.rgb if temp is None else temp
     self.cmyk = a3.rgb_to_cmyk(self.rgb);
     assert (self.cmyk == None or type(self.cmyk) == colormodel.CMYK), 'rgb_to_cmyk does not return a CMYK object'
     self.update()
 def on_hsv_slide(self,h,s,v):
     """Call back to hsv sliders"""
     if not self.active:
         return
     hue = h / 100.0
     sat = s / 100.0
     val = v / 100.0
     self.hsv = colormodel.HSV(hue, sat, val)
     temp = a3.hsv_to_rgb(self.hsv)
     assert (temp == None or type(temp) == colormodel.RGB), 'hsv_to_rgb does not return a RGB object'
     self.rgb = self.rgb if temp is None else temp
     self.cmyk = a3.rgb_to_cmyk(self.rgb);
     assert (self.cmyk == None or type(self.cmyk) == colormodel.CMYK), 'rgb_to_cmyk does not return a CMYK object'
     self.update()
Example #7
0
def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    #hi = 0
    hsv = colormodel.HSV(0.0, 0.0, 0.0)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(0, rgb.red)
    cornelltest.assert_equals(0, rgb.green)
    cornelltest.assert_equals(0, rgb.blue)

    hsv = colormodel.HSV(45.5, 0.34, 0.34)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(87, rgb.red)
    cornelltest.assert_equals(80, rgb.green)
    cornelltest.assert_equals(57, rgb.blue)

    #hi = 1
    hsv = colormodel.HSV(80.0, 0.5, 0.123)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(26, rgb.red)
    cornelltest.assert_equals(31, rgb.green)
    cornelltest.assert_equals(16, rgb.blue)

    #hi = 2
    hsv = colormodel.HSV(153.3, 0.9, 0.4)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(10, rgb.red)
    cornelltest.assert_equals(102, rgb.green)
    cornelltest.assert_equals(61, rgb.blue)

    #hi = 3
    hsv = colormodel.HSV(181.1, 0.234, 0.432)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(84, rgb.red)
    cornelltest.assert_equals(110, rgb.green)
    cornelltest.assert_equals(110, rgb.blue)

    #hi = 4
    hsv = colormodel.HSV(275.0, 0.175, 0.275)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(65, rgb.red)
    cornelltest.assert_equals(58, rgb.green)
    cornelltest.assert_equals(70, rgb.blue)

    #hi = 5
    hsv = colormodel.HSV(359.9, 0.76, 0.765)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(195, rgb.red)
    cornelltest.assert_equals(47, rgb.green)
    cornelltest.assert_equals(47, rgb.blue)
Example #8
0
def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    cunittest.assert_equals(colormodel.RGB(128, 122, 64), a3.hsv_to_rgb(\
                                colormodel.HSV(55, .5, .5)))      #math.floor(H/60) = 0
    cunittest.assert_equals(colormodel.RGB(82, 102, 71), a3.hsv_to_rgb(\
                                colormodel.HSV(100, .3, .4)))      #math.floor(H/60) = 1
    cunittest.assert_equals(colormodel.RGB(96, 145, 100), a3.hsv_to_rgb(\
                                colormodel.HSV(125, .34, .57)))   #math.floor(H/60) = 2
    cunittest.assert_equals(colormodel.RGB(102, 204, 255), a3.hsv_to_rgb(\
                                colormodel.HSV(200, .6, 1.0)))   #math.floor(H/60) = 3
    cunittest.assert_equals(colormodel.RGB(30, 30, 227), a3.hsv_to_rgb(\
                                colormodel.HSV(240, .87, .89)))    #math.floor(H/60) = 4
    cunittest.assert_equals(colormodel.RGB(252, 177, 189), a3.hsv_to_rgb(\
                                colormodel.HSV(350, .3, .99)))   #math.floor(H/60) = 5
Example #9
0
def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    #Test hsv_to_rgb() when H is in the interval [0,60):
    hsv = colormodel.HSV(42, .6, .7)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(179, rgb.red)
    cunittest.assert_equals(146, rgb.green)
    cunittest.assert_equals(71, rgb.blue)

    #Test hsv_to_rgb() when H is in the interval [60,120):
    hsv = colormodel.HSV(94, .5, .5)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(91, rgb.red)
    cunittest.assert_equals(128, rgb.green)
    cunittest.assert_equals(64, rgb.blue)

    #Test hsv_to_rgb() when H is in the interval [120,180):
    #Also tests that hsv_to_rgb() properly handles values at the borders of
    #each interval of H
    hsv = colormodel.HSV(120, .5, .5)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(64, rgb.red)
    cunittest.assert_equals(128, rgb.green)
    cunittest.assert_equals(64, rgb.blue)

    #Test hsv_to_rgb() when H is in the interval [180,240):
    hsv = colormodel.HSV(216, .6, .3)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(31, rgb.red)
    cunittest.assert_equals(49, rgb.green)
    cunittest.assert_equals(77, rgb.blue)

    #Test hsv_to_rgb() when H is in the interval [240,300):
    hsv = colormodel.HSV(256, .2, .8)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(174, rgb.red)
    cunittest.assert_equals(163, rgb.green)
    cunittest.assert_equals(204, rgb.blue)

    #Test hsv_to_rgb() when H is in the interval [300,360):
    hsv = colormodel.HSV(343, .7, .3)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(77, rgb.red)
    cunittest.assert_equals(23, rgb.green)
    cunittest.assert_equals(38, rgb.blue)
Example #10
0
def test_hsv_to_rgb():
    """
    Test translation function hsv_to_rgb
    """
    #testing h_i == 0
    hsv = cornell.HSV(50, 0.75, 1)
    rgb = a3.hsv_to_rgb(hsv)
    cornell.assert_equals(255, rgb.red)
    cornell.assert_equals(223, rgb.green)
    cornell.assert_equals(64, rgb.blue)

    #testing h_i == 1
    hsv = cornell.HSV(61.0, 0.234, 0.0)
    rgb = a3.hsv_to_rgb(hsv)
    cornell.assert_equals(0, rgb.red)
    cornell.assert_equals(0, rgb.green)
    cornell.assert_equals(0, rgb.blue)

    #testing h_i == 2
    hsv = cornell.HSV(120.23, 0.762, 0.111)
    rgb = a3.hsv_to_rgb(hsv)
    cornell.assert_equals(7, rgb.red)
    cornell.assert_equals(28, rgb.green)
    cornell.assert_equals(7, rgb.blue)

    #testing h_i == 3
    hsv = cornell.HSV(182.7, 0.632, 0.875)
    rgb = a3.hsv_to_rgb(hsv)
    cornell.assert_equals(82, rgb.red)
    cornell.assert_equals(217, rgb.green)
    cornell.assert_equals(223, rgb.blue)

    #testing h_i == 4
    hsv = cornell.HSV(243.1, 0.132, 0.445)
    rgb = a3.hsv_to_rgb(hsv)
    cornell.assert_equals(99, rgb.red)
    cornell.assert_equals(98, rgb.green)
    cornell.assert_equals(113, rgb.blue)

    #testing h_i == 5
    hsv = cornell.HSV(309.9, 0.785, 0.91)
    rgb = a3.hsv_to_rgb(hsv)
    cornell.assert_equals(232, rgb.red)
    cornell.assert_equals(50, rgb.green)
    cornell.assert_equals(202, rgb.blue)
Example #11
0
def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    #Test hsv_to_rgb() when H is in the interval [0,60):
    hsv = colormodel.HSV(42, .6, .7)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(179, rgb.red)
    cunittest.assert_equals(146, rgb.green)
    cunittest.assert_equals(71, rgb.blue)
    
    #Test hsv_to_rgb() when H is in the interval [60,120):
    hsv = colormodel.HSV(94, .5, .5)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(91, rgb.red)
    cunittest.assert_equals(128, rgb.green)
    cunittest.assert_equals(64, rgb.blue)
    
    #Test hsv_to_rgb() when H is in the interval [120,180):
    #Also tests that hsv_to_rgb() properly handles values at the borders of
    #each interval of H
    hsv = colormodel.HSV(120, .5, .5)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(64, rgb.red)
    cunittest.assert_equals(128, rgb.green)
    cunittest.assert_equals(64, rgb.blue)
    
    #Test hsv_to_rgb() when H is in the interval [180,240):
    hsv = colormodel.HSV(216, .6, .3)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(31, rgb.red)
    cunittest.assert_equals(49, rgb.green)
    cunittest.assert_equals(77, rgb.blue)
    
    #Test hsv_to_rgb() when H is in the interval [240,300):
    hsv = colormodel.HSV(256, .2, .8)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(174, rgb.red)
    cunittest.assert_equals(163, rgb.green)
    cunittest.assert_equals(204, rgb.blue)
    
    #Test hsv_to_rgb() when H is in the interval [300,360):
    hsv = colormodel.HSV(343, .7, .3)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(77, rgb.red)
    cunittest.assert_equals(23, rgb.green)
    cunittest.assert_equals(38, rgb.blue)
Example #12
0
def test_hsv_to_rgb():
    """
    Test translation function hsv_to_rgb
    """
    print('Testing hsv_to_rgb')
    # ADD TESTS TO ME
    #Hi == 0
    hsv = introcs.HSV(0.0, 0.0, 0.0);
    rgb = a3.hsv_to_rgb(hsv);
    introcs.assert_equals(0.0,round(rgb.red,3))
    introcs.assert_equals(0.0,round(rgb.green,3))
    introcs.assert_equals(0.0,round(rgb.blue,3))
    #Hi == 1
    hsv = introcs.HSV(70.0, 0.5, 1.0);
    rgb = a3.hsv_to_rgb(hsv);
    introcs.assert_equals(234,round(rgb.red,3))
    introcs.assert_equals(255,round(rgb.green,3))
    introcs.assert_equals(128,round(rgb.blue,3))
    #Hi == 2
    hsv = introcs.HSV(130.0, 0.5, 1.0);
    rgb = a3.hsv_to_rgb(hsv);
    introcs.assert_equals(128,round(rgb.red,3))
    introcs.assert_equals(255,round(rgb.green,3))
    introcs.assert_equals(149,round(rgb.blue,3))
    #Hi == 3
    hsv = introcs.HSV(190.0, 0.5, 1.0);
    rgb = a3.hsv_to_rgb(hsv);
    introcs.assert_equals(128,round(rgb.red,3))
    introcs.assert_equals(234,round(rgb.green,3))
    introcs.assert_equals(255,round(rgb.blue,3))
    #Hi == 4
    hsv = introcs.HSV(250.0, 0.5, 1.0);
    rgb = a3.hsv_to_rgb(hsv);
    introcs.assert_equals(149,round(rgb.red,3))
    introcs.assert_equals(128,round(rgb.green,3))
    introcs.assert_equals(255,round(rgb.blue,3))
    #Hi == 5
    hsv = introcs.HSV(310.0, 0.5, 1.0);
    rgb = a3.hsv_to_rgb(hsv);
    introcs.assert_equals(255,round(rgb.red,3))
    introcs.assert_equals(128,round(rgb.green,3))
    introcs.assert_equals(234,round(rgb.blue,3))
    print('Tests for hsv_to_rgb passed')
def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    
    hsv= colormodel.HSV(20.00,1.000,1.000)
    rgb= a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals( 255, rgb.red)
    cornelltest.assert_equals(84, rgb.green)
    cornelltest.assert_equals(0, rgb.blue)
    
    hsv= colormodel.HSV(60.00,1.000,1.000)
    rgb= a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals( 255, rgb.red)
    cornelltest.assert_equals(255, rgb.green)
    cornelltest.assert_equals(0, rgb.blue)
    
    hsv= colormodel.HSV(120.00,1.000,1.000)
    rgb= a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals( 0, rgb.red)
    cornelltest.assert_equals(255, rgb.green)
    cornelltest.assert_equals(0, rgb.blue)
    
    hsv= colormodel.HSV(180.00,1.000,1.000)
    rgb= a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals( 0, rgb.red)
    cornelltest.assert_equals(255, rgb.green)
    cornelltest.assert_equals(255, rgb.blue)
    
    hsv= colormodel.HSV(240.00,1.000,1.000)
    rgb= a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals( 0, rgb.red)
    cornelltest.assert_equals(0, rgb.green)
    cornelltest.assert_equals(255, rgb.blue)
    
    hsv= colormodel.HSV(300.00,1.000,1.000)
    rgb= a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals( 255, rgb.red)
    cornelltest.assert_equals(0, rgb.green)
    cornelltest.assert_equals(255, rgb.blue)
def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    hsv = colormodel.HSV(30.54, 1.0, 0.54321)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(139, rgb.red)
    cornelltest.assert_equals(71, rgb.green)
    cornelltest.assert_equals(0, rgb.blue)

    hsv = colormodel.HSV(78.93, 0.33, 0.02)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(5, rgb.red)
    cornelltest.assert_equals(5, rgb.green)
    cornelltest.assert_equals(3, rgb.blue)

    hsv = colormodel.HSV(125.666, 0.666, 1.00)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(85, rgb.red)
    cornelltest.assert_equals(255, rgb.green)
    cornelltest.assert_equals(101, rgb.blue)

    hsv = colormodel.HSV(188.808, 0.001, .115)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(29, rgb.red)
    cornelltest.assert_equals(29, rgb.green)
    cornelltest.assert_equals(29, rgb.blue)

    hsv = colormodel.HSV(255.22812234, .5532354326, .834098765432)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(125, rgb.red)
    cornelltest.assert_equals(95, rgb.green)
    cornelltest.assert_equals(213, rgb.blue)

    hsv = colormodel.HSV(341.0928346, .4088, 0.9234)
    rgb = a3.hsv_to_rgb(hsv)
    cornelltest.assert_equals(235, rgb.red)
    cornelltest.assert_equals(139, rgb.green)
    cornelltest.assert_equals(170, rgb.blue)
Example #15
0
def test_hsv_to_rgb():
    """
    Test translation function hsv_to_rgb
    """
    hsv = cornell.HSV(0.000, 0.000, 0.000);
    rgb = a3.hsv_to_rgb(hsv);
    cornell.assert_equals(0, (rgb.red))
    cornell.assert_equals(0, (rgb.green))
    cornell.assert_equals(0, (rgb.blue))
    
    hsv = cornell.HSV(82.50, 0.302, 0.999);
    rgb = a3.hsv_to_rgb(hsv);
    cornell.assert_equals(226, (rgb.red))
    cornell.assert_equals(255, (rgb.green))
    cornell.assert_equals(178, (rgb.blue))
    
    hsv = cornell.HSV(130.0, 0.302, 1.000);
    rgb = a3.hsv_to_rgb(hsv);
    cornell.assert_equals(178, (rgb.red))
    cornell.assert_equals(255, (rgb.green))
    cornell.assert_equals(191, (rgb.blue))
    
    hsv = cornell.HSV(200.0, 1.000, 0.453);
    rgb = a3.hsv_to_rgb(hsv);
    cornell.assert_equals(0, (rgb.red))
    cornell.assert_equals(77, (rgb.green))
    cornell.assert_equals(116, (rgb.blue))

    hsv = cornell.HSV(280.4, 1.000, 0.455);
    rgb = a3.hsv_to_rgb(hsv);
    cornell.assert_equals(78, (rgb.red))
    cornell.assert_equals(0, (rgb.green))
    cornell.assert_equals(116, (rgb.blue))
    
    hsv = cornell.HSV(300.5, 1.000, 1.000);
    rgb = a3.hsv_to_rgb(hsv);
    cornell.assert_equals(255, (rgb.red))
    cornell.assert_equals(0, (rgb.green))
    cornell.assert_equals(253, (rgb.blue))
    
    hsv = cornell.HSV(359.9, 0.000, 1.000);
    rgb = a3.hsv_to_rgb(hsv);
    cornell.assert_equals(255, (rgb.red))
    cornell.assert_equals(255, (rgb.green))
    cornell.assert_equals(255, (rgb.blue))
    
    hsv = cornell.HSV(359.9, 0.000, 0.000);
    rgb = a3.hsv_to_rgb(hsv);
    cornell.assert_equals(0, (rgb.red))
    cornell.assert_equals(0, (rgb.green))
    cornell.assert_equals(0, (rgb.blue))
    
    hsv = cornell.HSV(0.000, 1.000, 0.000);
    rgb = a3.hsv_to_rgb(hsv);
    cornell.assert_equals(0, (rgb.red))
    cornell.assert_equals(0, (rgb.green))
    cornell.assert_equals(0, (rgb.blue))
    
    hsv = cornell.HSV(0.000, 0.000, 1.000);
    rgb = a3.hsv_to_rgb(hsv);
    cornell.assert_equals(255, (rgb.red))
    cornell.assert_equals(255, (rgb.green))
    cornell.assert_equals(255, (rgb.blue))