def son_colores_parecidos(color1, color2): '''Usa la librería colormath para determinar si un par de colores es parecido y devuelve verdadero en ese caso''' from colormath.color_objects import AdobeRGBColor, LabColor, XYZColor from colormath.color_conversions import convert_color from colormath.color_diff import delta_e_cie1976 try: color1 = AdobeRGBColor.new_from_rgb_hex(color1) color2 = AdobeRGBColor.new_from_rgb_hex(color2) delta_e = delta_e_cie1976(convert_color(color1, LabColor), convert_color(color2, LabColor)) print('delta color: ', delta_e) #print(abs(delta_e)<50) return abs(delta_e) < 50 except ValueError: print('Elige un color') return False
def convert_hex_to_xyz(hex_color: str) -> (float, float, float): adobe_rgb_color = AdobeRGBColor.new_from_rgb_hex(hex_color) # clampedRgbColors = AdobeRGBColor(hexx.clamped_rgb_r, hexx.clamped_rgb_g, hexx.clamped_rgb_b) # xyz = convert_color(clampedRgbColors, XYZColor, through_rgb_type=AdobeRGBColor) xyz_color = convert_color(adobe_rgb_color, XYZColor, through_rgb_type=AdobeRGBColor, target_illuminant='d65') return xyz_color.get_value_tuple()