Пример #1
0
 def __init__(self, name):
     self.name = name
     rgb = Color(*parse_color(name)[:3])
     xyz = rgb.converted(ColorMode.XYZ)
     self.representations = {
         "RGB": rgb,
         "HSV": rgb.converted(ColorMode.HSV),
         "XYZ": xyz,
         "LAB": xyz.converted(ColorMode.LAB),
         "LUV": xyz.converted(ColorMode.LUV),
         "LCH_uv": xyz.converted(ColorMode.LCH_uv),
     }
Пример #2
0
class SimilarColor:
    def __init__(self, name, rgbvec, space):
        self.name = name
        self.rgb = Color(*rgbvec[:3])
        self.vec = self.rgb.converted(ColorMode[space])
        self.space = space

    def dist(self, colorcompare):
        return (self.vec - colorcompare.rep(self.space)).length

    def ansi_str(self, length):
        return color_str(self.rgb, length)