def test_color_conversion(): print('\n') rgb_red = RGB(255, 0, 0) rgb_blue = RGB(0, 0, 255) hsv_red = rgb_red.to(HSV) assert rgb_red.to(HEX).to(RGB) is not None assert hsv_red.get_dimensions(normalise=True) == [0.0, 1.0, 1.0] assert hsv_red.get_dimensions(normalise=False) == [0, 100, 100] hsv_red = HSV(0, 100, 100) assert hsv_red.get_dimensions(normalise=True) == [0.0, 1.0, 1.0] assert hsv_red.to(RGB) == rgb_red sum = rgb_red + hsv_red
def test_inter_color_sum(): print('\n') rgb_blue = RGB(0, 0, 255) rgb_red = RGB(255, 0, 0) hsv_red = rgb_red.to(HSV) hsv_blue = rgb_blue.to(HSV) print(hsv_red) print('+') print(rgb_blue) print('_' * 15) sum1 = hsv_red + rgb_blue assert 0 <= max(sum1.get_dimensions()) <= 255 sum2 = rgb_red + hsv_blue assert sum1 == sum2
def test_truediv_and_mul(): print('\n') print('/ and *') red = RGB(255, 0, 0) faded_red = red / 3 assert faded_red == RGB(85, 0, 0) assert faded_red * 3 == red hsv_red = red.to(HSV) assert hsv_red / 3 == faded_red