def draw_lab_l_cylinder(image, l): width, height = image.size pixels = image.load() for x in range(width): hue = interpolate(0, 360, x / width) for y in range(height): chroma = interpolate(1.4, 0.0, y / height) a, b = chroma_hue_to_ab(chroma, hue) color = Color.NewFromLab(l, a, b) pixels[x,y] = color_to_ints(color)
def draw_lab_hue_spoke(image, hue): width, height = image.size pixels = image.load() for x in range(width): chroma = interpolate(-1.5, 1.5, x / width) for y in range(height): l = interpolate(99.9, 0.0, y / height) a, b = chroma_hue_to_ab(chroma, hue) color = Color.NewFromLab(l, a, b) pixels[x,y] = color_to_ints(color)
def peak_chroma_color(): """ What is the color with the highest chroma value? """ best_chroma = 0 best_color = None for lightness in range(0, 100): for hue in range(0, 360): chroma = max_chroma(hue, lightness) if chroma > best_chroma: best_chroma = chroma a, b = chroma_hue_to_ab(chroma, hue) best_color = Color.NewFromLab(lightness, a, b) return best_color, best_chroma
def draw_cylinder_surface(image): from limits import max_chroma width, height = image.size pixels = image.load() for x in range(width): hue = interpolate(0, 360, x / width) for y in range(height): l = interpolate(99.9, 0.0, y / height) chroma = max_chroma(hue, l) if chroma: a, b = chroma_hue_to_ab(chroma, hue) color = Color.NewFromLab(l, a, b) else: color = gray pixels[x,y] = color_to_ints(color)
def valid_for_chroma(chroma): a, b = chroma_hue_to_ab(chroma, hue) color = Color.NewFromLab(lightness, a, b) return color.isLegal