80 |
|
|
81 |
return LABclamp(rgb) |
return LABclamp(rgb) |
82 |
|
|
83 |
|
|
84 |
|
def getRandomColor3(minL, maxL, hue_avg, hue_sd, rnd): |
85 |
|
"""Get a random color deterministically with Gaussian hue |
86 |
|
|
87 |
|
minL, maxL: minimum and maximum luminance value |
88 |
|
hue_avg, hue_sd: hue distribution parameters in degerees |
89 |
|
rnd: a random number generator, corresponding to |
90 |
|
java.util.Random for the API. The same color |
91 |
|
is always returned if the PRNG returns the |
92 |
|
same list of values. |
93 |
|
""" |
94 |
|
rgb = [-1] |
95 |
|
L = minL + (maxL - minL) * rnd.nextDouble() |
96 |
|
ang = (hue_avg + rnd.nextGaussian() * hue_sd) / 180 * math.pi |
97 |
|
a = 100 * math.cos(ang) |
98 |
|
b = 100 * math.sin(ang) |
99 |
|
rgb = LABtoRGB([L,a,b]) |
100 |
|
|
101 |
|
return LABclamp(rgb) |
102 |
|
|
103 |
|
|
104 |
def LABclamp(rgb): |
def LABclamp(rgb): |
105 |
"""Clamp a RGB color into [0,1]^3 towards the CIELAB L-axis |
"""Clamp a RGB color into [0,1]^3 towards the CIELAB L-axis |
106 |
|
|