26 |
from gfx.libcolor.spaces import getRandomColor,getRandomColor2,YSTtoRGB,clampSat,LtoY |
from gfx.libcolor.spaces import getRandomColor,getRandomColor2,YSTtoRGB,clampSat,LtoY |
27 |
from gfx.libcolor.spaces import RGBtoLAB,LABtoRGB,LABclamp |
from gfx.libcolor.spaces import RGBtoLAB,LABtoRGB,LABclamp |
28 |
|
|
29 |
from math import sin,cos,atan2,pi,log |
from math import sin,cos,atan2,pi,log,sqrt |
30 |
from random import Random,shuffle |
from random import Random,shuffle |
31 |
|
|
32 |
import java |
import java |
69 |
|
|
70 |
# Take one half dark colors and one half light colors |
# Take one half dark colors and one half light colors |
71 |
lumrange = 100 - minlum |
lumrange = 100 - minlum |
72 |
lums = ([minlum + rnd.nextDouble() * lumrange/2 |
if colors == 1: |
73 |
for i in range(0,(colors+1)/2)] + |
# Use the full luminance range for solid color backgrounds |
74 |
[minlum + (1 + rnd.nextDouble()) * lumrange/2 |
x = rnd.nextDouble() |
75 |
for i in range((colors+1)/2,colors)] |
# Weight lower luminances more |
76 |
) |
x = (1 - sqrt(1-x)) |
77 |
|
lums = [minlum + x * lumrange] |
78 |
|
else: |
79 |
|
lums = ([minlum + rnd.nextDouble() * lumrange/2 |
80 |
|
for i in range(0,(colors+1)/2)] + |
81 |
|
[minlum + (1 + rnd.nextDouble()) * lumrange/2 |
82 |
|
for i in range((colors+1)/2,colors)] |
83 |
|
) |
84 |
|
|
85 |
# Sample saturation: |
# Sample saturation: |
86 |
# - take the most saturated color 2/3 of the time |
# - take the most saturated color 2/3 of the time |