def cmyk_component_changed(self, *arg): c = self.C_value.get() / 100.0 m = self.M_value.get() / 100.0 y = self.Y_value.get() / 100.0 k = self.K_value.get() / 100.0 a = self.A_value.get() / 100.0 self.callback(CreateCMYKAColor(c, m, y, k, a))
def reset_color(self, color): r, g, b = color if self.color.model == 'RGB': self.callback(CreateRGBAColor(r, g, b, self.color.alpha)) elif self.color.model == 'CMYK': rgb = CreateRGBColor(r, g, b) c, m, y, k = rgb.getCMYK() self.callback(CreateCMYKAColor(c, m, y, k, self.color.alpha)) else: pass
def convert_color(self, color, cs_name): if cs_name is None: return color elif cs_name == 'CMYK': c, m, y, k = color.getCMYK() return CreateCMYKAColor(c, m, y, k, color.alpha) elif cs_name == 'RGB': r, g, b = color.getRGB() return CreateRGBAColor(r, g, b, color.alpha)
def set_cs(self): if self.check_changes(): if self.cs_name.get() == RGB: if self.current_cs == EMPTY: self.callback(CreateRGBColor(0, 0, 0)) else: r, g, b = self.color.getRGB() self.callback(CreateRGBAColor(r, g, b, self.color.alpha)) elif self.cs_name.get() == CMYK: if self.current_cs == EMPTY: self.callback(CreateCMYKColor(0, 0, 0, 1)) else: c, m, y, k = self.color.getCMYK() self.callback( CreateCMYKAColor(c, m, y, k, self.color.alpha)) elif self.cs_name.get() == REGISTRATION: self.callback(Registration_Black()) elif self.cs_name.get() == SPOT: self.cs_name.set(self.current_cs) else: self.callback(None)
def convert_color(self, color_spec): try: c = self.color_cache.get(color_spec) if c: return c if color_spec[0] == 'RGB' and len(color_spec) == 4: c = CreateRGBColor(color_spec[1], color_spec[2], color_spec[3]) elif color_spec[0] == 'RGB' and len(color_spec) == 5: c = CreateRGBAColor(color_spec[1], color_spec[2], color_spec[3], color_spec[4]) elif color_spec[0] == 'CMYK' and len(color_spec) == 5: c = CreateCMYKColor(color_spec[1], color_spec[2], color_spec[3], color_spec[4]) elif color_spec[0] == 'CMYK' and len(color_spec) == 6: c = CreateCMYKAColor(color_spec[1], color_spec[2], color_spec[3], color_spec[4], color_spec[5]) elif color_spec[0] == 'SPOT' and len(color_spec) == 10: c = CreateSPOTColor(color_spec[3], color_spec[4], color_spec[5], color_spec[6], color_spec[7], color_spec[8], color_spec[9], color_spec[2], color_spec[1]) elif color_spec[0] == 'SPOT' and len(color_spec) == 11: c = CreateSPOTAColor(color_spec[3], color_spec[4], color_spec[5], color_spec[6], color_spec[7], color_spec[8], color_spec[9], color_spec[10], color_spec[2], color_spec[1]) else: c = apply(ParseSketchColor, color_spec) self.color_cache[color_spec] = c except: # This should only happen if the color_spec is invalid type, value = sys.exc_info()[:2] warn(INTERNAL, 'Color allocation failed: %s: %s', type, value) c = StandardColors.black return c