コード例 #1
0
ファイル: grapefruit_test.py プロジェクト: stenson/Grapefruit
 def test_rgb_to_hsl(self):
     assert_items_almost_equal((30.0, 1.0, 0.5),
                               grapefruit.rgb_to_hsl(1, 0.5, 0))
     assert_items_almost_equal((20.0, 1.0, 0.625),
                               grapefruit.rgb_to_hsl(1, 0.5, 0.25))  #ff8040
     assert_items_almost_equal((40.0, 1.0, 0.375),
                               grapefruit.rgb_to_hsl(0.75, 0.5, 0))  #bf8000
コード例 #2
0
ファイル: grapefruit_test.py プロジェクト: stenson/Grapefruit
 def test_set_cmy(self):
     col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
     col.cmy = (0.1, 0.2, 0.3)
     assert_items_almost_equal(col.cmy, (0.1, 0.2, 0.3))
     assert_equal(col.rgb, grapefruit.cmy_to_rgb(0.1, 0.2, 0.3))
     assert_almost_equal(
         col.hsl,
         grapefruit.rgb_to_hsl(grapefruit.cmy_to_rgb(0.1, 0.2, 0.3)))
コード例 #3
0
ファイル: grapefruit_test.py プロジェクト: stenson/Grapefruit
 def test_set_hsv(self):
     col = grapefruit.Color.from_hsv(30, 1, 1)
     col.hsv = (40, 0.5, 0.2)
     assert_items_almost_equal(col.hsv, (40, 0.5, 0.2))
     assert_equal(col.rgb, grapefruit.hsv_to_rgb(40, 0.5, 0.2))
     assert_almost_equal(
         col.hsl, grapefruit.rgb_to_hsl(grapefruit.hsv_to_rgb(40, 0.5,
                                                              0.2)))
コード例 #4
0
ファイル: grapefruit_test.py プロジェクト: stenson/Grapefruit
 def test_set_cmyk(self):
     col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
     col.cmyk = (0, 0.111, 0.222, 0.46)
     assert_items_almost_equal(col.cmyk, (0, 0.111, 0.222, 0.46))
     assert_equal(
         col.rgb,
         grapefruit.cmy_to_rgb(grapefruit.cmyk_to_cmy(
             0, 0.111, 0.222, 0.46)))
     assert_almost_equal(
         col.hsl,
         grapefruit.rgb_to_hsl(
             grapefruit.cmy_to_rgb(
                 grapefruit.cmyk_to_cmy(0, 0.111, 0.222, 0.46))))
コード例 #5
0
ファイル: grapefruit_test.py プロジェクト: xav/Grapefruit
 def test_rgb_to_hsl_tuple(self):
   assert_items_almost_equal((30.0, 1.0, 0.5), grapefruit.rgb_to_hsl((1, 0.5, 0)))
コード例 #6
0
ファイル: grapefruit_test.py プロジェクト: xav/Grapefruit
 def test_set_hsv(self):
   col = grapefruit.Color.from_hsv(30, 1, 1)
   col.hsv = (40, 0.5, 0.2)
   assert_items_almost_equal(col.hsv, (40, 0.5, 0.2))
   assert_equal(col.rgb, grapefruit.hsv_to_rgb(40, 0.5, 0.2))
   assert_almost_equal(col.hsl, grapefruit.rgb_to_hsl(grapefruit.hsv_to_rgb(40, 0.5, 0.2)))
コード例 #7
0
ファイル: grapefruit_test.py プロジェクト: xav/Grapefruit
 def test_set_blue(self):
   col = grapefruit.Color.from_rgb(0.1, 0.2, 0.3)
   col.blue = 0.9
   assert_equal(col.rgb, (0.1, 0.2, 0.9))
   assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.1, 0.2, 0.9))
コード例 #8
0
ファイル: grapefruit_test.py プロジェクト: xav/Grapefruit
 def test_set_green(self):
   col = grapefruit.Color.from_rgb(0.1, 0.2, 0.3)
   col.green = 0.9
   assert_equal(col.rgb, (0.1, 0.9, 0.3))
   assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.1, 0.9, 0.3))
コード例 #9
0
ファイル: grapefruit_test.py プロジェクト: stenson/Grapefruit
 def test_rgb_to_hsl_tuple(self):
     assert_items_almost_equal((30.0, 1.0, 0.5),
                               grapefruit.rgb_to_hsl((1, 0.5, 0)))
コード例 #10
0
ファイル: grapefruit_test.py プロジェクト: xav/Grapefruit
 def test_set_html(self):
   col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
   col.html = '#0080ff'
   assert_equal(col.rgb, (0.0, 128.0/255.0, 1.0))
   assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.0, 128.0/255.0, 1.0))
コード例 #11
0
ファイル: grapefruit_test.py プロジェクト: xav/Grapefruit
 def test_set_cmyk(self):
   col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
   col.cmyk = (0, 0.111, 0.222, 0.46)
   assert_items_almost_equal(col.cmyk, (0, 0.111, 0.222, 0.46))
   assert_equal(col.rgb, grapefruit.cmy_to_rgb(grapefruit.cmyk_to_cmy(0, 0.111, 0.222, 0.46)))
   assert_almost_equal(col.hsl, grapefruit.rgb_to_hsl(grapefruit.cmy_to_rgb(grapefruit.cmyk_to_cmy(0, 0.111, 0.222, 0.46))))
コード例 #12
0
ファイル: grapefruit_test.py プロジェクト: stenson/Grapefruit
 def test_set_ints(self):
     col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
     col.ints = (0, 128, 255)
     assert_equal(col.rgb, (0.0, 128.0 / 255.0, 1.0))
     assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.0, 128.0 / 255.0, 1.0))
コード例 #13
0
ファイル: grapefruit_test.py プロジェクト: stenson/Grapefruit
 def test_set_blue(self):
     col = grapefruit.Color.from_rgb(0.1, 0.2, 0.3)
     col.blue = 0.9
     assert_equal(col.rgb, (0.1, 0.2, 0.9))
     assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.1, 0.2, 0.9))
コード例 #14
0
ファイル: grapefruit_test.py プロジェクト: stenson/Grapefruit
 def test_set_green(self):
     col = grapefruit.Color.from_rgb(0.1, 0.2, 0.3)
     col.green = 0.9
     assert_equal(col.rgb, (0.1, 0.9, 0.3))
     assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.1, 0.9, 0.3))
コード例 #15
0
ファイル: grapefruit_test.py プロジェクト: xav/Grapefruit
 def test_rgb_to_hsl(self):
   assert_items_almost_equal((30.0, 1.0, 0.5), grapefruit.rgb_to_hsl(1, 0.5, 0))
   assert_items_almost_equal((20.0, 1.0, 0.625), grapefruit.rgb_to_hsl(1, 0.5, 0.25)) #ff8040
   assert_items_almost_equal((40.0, 1.0, 0.375), grapefruit.rgb_to_hsl(0.75, 0.5, 0)) #bf8000
コード例 #16
0
ファイル: grapefruit_test.py プロジェクト: stenson/Grapefruit
 def test_set_html(self):
     col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
     col.html = '#0080ff'
     assert_equal(col.rgb, (0.0, 128.0 / 255.0, 1.0))
     assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.0, 128.0 / 255.0, 1.0))
コード例 #17
0
ファイル: grapefruit_test.py プロジェクト: xav/Grapefruit
 def test_set_cmy(self):
   col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
   col.cmy = (0.1, 0.2, 0.3)
   assert_items_almost_equal(col.cmy, (0.1, 0.2, 0.3))
   assert_equal(col.rgb, grapefruit.cmy_to_rgb(0.1, 0.2, 0.3))
   assert_almost_equal(col.hsl, grapefruit.rgb_to_hsl(grapefruit.cmy_to_rgb(0.1, 0.2, 0.3)))
コード例 #18
0
ファイル: grapefruit_test.py プロジェクト: stenson/Grapefruit
 def test_set_pil(self):
     col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
     col.pil = 0xff8000
     assert_equal(col.rgb, (0.0, 128.0 / 255.0, 1.0))
     assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.0, 128.0 / 255.0, 1.0))
コード例 #19
0
ファイル: grapefruit_test.py プロジェクト: xav/Grapefruit
 def test_set_ints(self):
   col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
   col.ints = (0, 128, 255)
   assert_equal(col.rgb, (0.0, 128.0/255.0, 1.0))
   assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.0, 128.0/255.0, 1.0))
コード例 #20
0
ファイル: grapefruit_test.py プロジェクト: xav/Grapefruit
 def test_set_rgba(self):
   col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
   col.rgba = (0.1, 0.2, 0.3, 0.5)
   assert_equal(col.rgb, (0.1, 0.2, 0.3))
   assert_equal(col.alpha, 0.5)
   assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.1, 0.2, 0.3))
コード例 #21
0
ファイル: grapefruit_test.py プロジェクト: xav/Grapefruit
 def test_set_pil(self):
   col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
   col.pil = 0xff8000
   assert_equal(col.rgb, (0.0, 128.0/255.0, 1.0))
   assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.0, 128.0/255.0, 1.0))
コード例 #22
0
ファイル: grapefruit_test.py プロジェクト: stenson/Grapefruit
 def test_set_rgba(self):
     col = grapefruit.Color.from_rgb(1.0, 0.5, 0.0)
     col.rgba = (0.1, 0.2, 0.3, 0.5)
     assert_equal(col.rgb, (0.1, 0.2, 0.3))
     assert_equal(col.alpha, 0.5)
     assert_equal(col.hsl, grapefruit.rgb_to_hsl(0.1, 0.2, 0.3))