def test_parse_success() -> None: assert Color.parse("default") == Color("default", ColorType.DEFAULT, None, None) assert Color.parse("red") == Color("red", ColorType.STANDARD, 1, None) assert Color.parse("bright_red") == Color("bright_red", ColorType.STANDARD, 9, None) assert Color.parse("yellow4") == Color("yellow4", ColorType.EIGHT_BIT, 106, None) assert Color.parse("color(100)") == Color( "color(100)", ColorType.EIGHT_BIT, 100, None ) assert Color.parse("#112233") == Color( "#112233", ColorType.TRUECOLOR, None, ColorTriplet(0x11, 0x22, 0x33) ) assert Color.parse("rgb(90,100,110)") == Color( "rgb(90,100,110)", ColorType.TRUECOLOR, None, ColorTriplet(90, 100, 110) )
def test_truecolor() -> None: assert Color.parse("#ff0000").get_truecolor() == ColorTriplet(255, 0, 0) assert Color.parse("red").get_truecolor() == ColorTriplet(128, 0, 0) assert Color.parse("1").get_truecolor() == ColorTriplet(128, 0, 0) assert Color.parse("17").get_truecolor() == ColorTriplet(0, 0, 95) assert Color.parse("default").get_truecolor() == ColorTriplet(0, 0, 0) assert Color.parse("default").get_truecolor( foreground=False) == ColorTriplet(255, 255, 255) assert Color("red", ColorType.WINDOWS, number=1).get_truecolor() == ColorTriplet(255, 0, 0)
def test_truecolor() -> None: assert Color.parse("#ff0000").get_truecolor( themes.DEFAULT) == ColorTriplet(255, 0, 0) assert Color.parse("red").get_truecolor(themes.DEFAULT) == ColorTriplet( 128, 0, 0) assert Color.parse("1").get_truecolor(themes.DEFAULT) == ColorTriplet( 128, 0, 0) assert Color.parse("17").get_truecolor(themes.DEFAULT) == ColorTriplet( 0, 0, 95) assert Color.parse("default").get_truecolor( themes.DEFAULT) == ColorTriplet(0, 0, 0) assert Color.parse("default").get_truecolor( themes.DEFAULT, foreground=False) == ColorTriplet(255, 255, 255)
def test_from_triplet() -> None: assert Color.from_triplet(ColorTriplet(0x10, 0x20, 0x30)) == Color( "#102030", ColorType.TRUECOLOR, None, ColorTriplet(0x10, 0x20, 0x30))
def test_blend_rgb() -> None: assert blend_rgb(ColorTriplet(10, 20, 30), ColorTriplet(30, 40, 50)) == ColorTriplet(20, 30, 40)
def test_parse_rgb_hex() -> None: assert parse_rgb_hex("aabbcc") == ColorTriplet(0xAA, 0xBB, 0xCC)