77 |
a = 100 * math.cos(ang) |
a = 100 * math.cos(ang) |
78 |
b = 100 * math.sin(ang) |
b = 100 * math.sin(ang) |
79 |
rgb = LABtoRGB([L,a,b]) |
rgb = LABtoRGB([L,a,b]) |
80 |
|
|
81 |
|
return LABclamp(rgb) |
82 |
|
|
83 |
|
def LABclamp(rgb): |
84 |
|
"""Clamp a RGB color into [0,1]^3 towards the CIELAB L-axis |
85 |
|
|
86 |
|
rgb: the color in RGB709 |
87 |
|
returns: the clamped color in RGB709 |
88 |
|
""" |
89 |
if len(filter((lambda x: x<0 or x>1), rgb)) == 0: |
if len(filter((lambda x: x<0 or x>1), rgb)) == 0: |
90 |
return rgb |
return rgb |
91 |
|
|
92 |
|
(L,a,b) = RGBtoLAB(rgb) |
93 |
|
|
94 |
r = 0 |
r = 0 |
95 |
bit = .5 |
bit = .5 |
96 |
for iter in range(0,10): |
for iter in range(0,10): |
99 |
r = r + bit |
r = r + bit |
100 |
bit = bit * .5 |
bit = bit * .5 |
101 |
return LABtoRGB([L,r*a,r*b]) |
return LABtoRGB([L,r*a,r*b]) |
102 |
|
|
|
|
|