示例#1
0
 def test_init(self):
     c = bch.HSL(10, 0.2, 0.3)
     assert c
     assert c.a == 1.0
     assert c.h == 10
     assert c.s == 0.2
     assert c.l == 0.3
     c = bch.HSL(10, 0.2, 0.3, 0.3)
     assert c
     assert c.a == 0.3
     assert c.h == 10
     assert c.s == 0.2
     assert c.l == 0.3
示例#2
0
    def test_from_hsl(self):
        c = bch.HSL(10, 0.2, 0.3)
        c2 = bch.HSL.from_hsl(c)
        assert c2 is not c
        assert c2.a == c.a
        assert c2.h == c.h
        assert c2.s == c.s
        assert c2.l == c.l

        c = bch.HSL(10, 0.2, 0.3, 0.1)
        c2 = bch.HSL.from_hsl(c)
        assert c2 is not c
        assert c2.a == c.a
        assert c2.h == c.h
        assert c2.s == c.s
        assert c2.l == c.l
示例#3
0
    def test_to_rgb(self):
        c = bch.HSL(10, 0.2, 0.3)
        c2 = c.to_rgb()
        assert c2 is not c
        assert c2.a == 1.0
        assert c2.r == 92
        assert c2.g == 66
        assert c2.b == 61

        c = bch.HSL(10, 0.2, 0.3, 0.1)
        c2 = c.to_rgb()
        assert c2 is not c
        assert c.a == 0.1
        assert c2.r == 92
        assert c2.g == 66
        assert c2.b == 61
示例#4
0
    def test_to_hsl(self):
        c = bch.HSL(10, 0.2, 0.3)
        c2 = c.to_hsl()
        assert c2 is not c
        assert c2.a == c.a
        assert c2.h == c.h
        assert c2.s == c.s
        assert c2.l == c.l

        c = bch.HSL(10, 0.2, 0.3, 0.1)
        c2 = c.to_hsl()
        assert c2 is not c
        assert c2.a == c.a
        assert c2.h == c.h
        assert c2.s == c.s
        assert c2.l == c.l
示例#5
0
 def test_copy(self):
     c = bch.HSL(10, 0.2, 0.3)
     c2 = c.copy()
     assert c2 is not c
     assert c2.a == c.a
     assert c2.h == c.h
     assert c2.s == c.s
     assert c2.l == c.l
示例#6
0
 def test_repr(self):
     c = bch.HSL(10, 0.2, 0.3)
     assert repr(c) == c.to_css()
     c = bch.HSL(10, 0.2, 0.3, 0.3)
     assert repr(c) == c.to_css()
示例#7
0
 def test_to_css(self):
     c = bch.HSL(10, 0.2, 0.3)
     assert c.to_css() == "hsl(10, 20.0%, 30.0%)"
     c = bch.HSL(10, 0.2, 0.3, 0.3)
     assert c.to_css() == "hsla(10, 20.0%, 30.0%, 0.3)"