1 |
# Choosing colors and 3-dotproduct factors for papers. |
# Choosing colors and 3-dotproduct factors for papers. |
2 |
|
|
3 |
from gfx.libcolor.spaces import getRandomColor2 |
from gfx.libcolor.spaces import getRandomColor,getRandomColor2,RGBtoLAB |
4 |
|
|
5 |
from math import atan2,pi |
from math import atan2,pi |
6 |
|
|
13 |
rnd = self.rnd = java.util.Random(seed) |
rnd = self.rnd = java.util.Random(seed) |
14 |
# currently, 4 colors |
# currently, 4 colors |
15 |
minlum = 80 |
minlum = 80 |
16 |
|
|
17 |
|
# Just take alternating dark and light colors |
18 |
while 1: |
while 1: |
19 |
|
t = (100 - minlum)/2 |
20 |
|
col = [ getRandomColor(minlum + t - t * (i & 1), |
21 |
|
100 - t * (i & 1), rnd) |
22 |
|
for i in range(0,4) ] |
23 |
|
#if 180 - self._AB_angle(col) > 135 * rnd.nextFloat(): break |
24 |
|
if self._AB_angle(col) < 180: break |
25 |
|
print self._AB_angle(col) |
26 |
|
|
27 |
|
while 0: |
28 |
col = [ |
col = [ |
29 |
getRandomColor2(minlum,100, rnd), |
getRandomColor2(minlum,100, rnd), |
30 |
getRandomColor2(minlum,minlum + (100-minlum)*0.7, rnd), |
getRandomColor2(minlum,minlum + (100-minlum)*0.7, rnd), |
61 |
return self._js(self.randvecs[ind % len(self.randvecs)])+" 1" |
return self._js(self.randvecs[ind % len(self.randvecs)])+" 1" |
62 |
|
|
63 |
def _AB_angle(self, cols): |
def _AB_angle(self, cols): |
64 |
print cols |
#print cols |
65 |
getangle = lambda lab: 180 / pi * atan2(lab[2], lab[1]) |
getangle = lambda lab: 180 / pi * atan2(lab[2], lab[1]) |
66 |
angles = [ getangle(RGBtoLAB(col)) for col in cols ] |
angles = [ getangle(RGBtoLAB(col)) for col in cols ] |
67 |
print angles |
#print angles |
68 |
angles.sort() |
angles.sort() |
69 |
print angles |
#print angles |
70 |
n = len(angles) |
n = len(angles) |
71 |
maxd = 0 |
maxd = 0 |
72 |
for i in range(0, n): |
for i in range(0, n): |