def _repr_pretty_(self, p, cycle): # IS NOT TESTED!! if cycle: p.text("Color(...)") else: with p.group(1, "Color(", ")"): p.breakable() p.text("id=%s %s," % (self.color_space_id, ColorSpaceID.name_of(self.color_space_id))) p.breakable() p.pretty(self.color_data)
def read(cls, fp, **kwargs): id = read_fmt('H', fp)[0] try: id = ColorSpaceID(id) except ValueError: logger.info('Custom color space found: %d' % (id)) if id == ColorSpaceID.LAB: values = read_fmt('4h', fp) else: values = read_fmt('4H', fp) return cls(id, list(values))
def decode_color(fp): color_space_id = read_fmt("H", fp)[0] if not ColorSpaceID.is_known(color_space_id): warnings.warn("Unknown color space (%s)" % color_space_id) if color_space_id == ColorSpaceID.LAB: color_data = read_fmt("4h", fp) else: color_data = read_fmt("4H", fp) return Color(color_space_id, color_data)
def _repr_pretty_(self, p, cycle): # IS NOT TESTED!! if cycle: p.text('Color(...)') else: with p.group(1, 'Color(', ')'): p.breakable() p.text("id=%s %s," % (self.color_space_id, ColorSpaceID.name_of(self.color_space_id))) p.breakable() p.pretty(self.color_data)
def decode_color(fp): color_space_id = read_fmt("H", fp)[0] if not ColorSpaceID.is_known(color_space_id): warnings.warn("Unknown color space (%s)" % color_space_id) if color_space_id in (ColorSpaceID.RGB, ColorSpaceID.HSB): color_data = read_fmt("3H 2x", fp) elif color_space_id == ColorSpaceID.LAB: color_data = read_fmt("Hhh 2x", fp) elif color_space_id == ColorSpaceID.GRAYSCALE: color_data = read_fmt("H 6x", fp) else: color_data = read_fmt("4H", fp) return Color(color_space_id, color_data)
def __repr__(self): return "Color(id=%s %s, %s)" % (self.color_space_id, ColorSpaceID.name_of(self.color_space_id), self.color_data)
def __repr__(self): return "Color(id=%s %s, %s)" % ( self.color_space_id, ColorSpaceID.name_of( self.color_space_id), self.color_data)