/[gzz]/gzz/gfx/libpaper/colors.py
ViewVC logotype

Diff of /gzz/gfx/libpaper/colors.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by jvk, Tue Sep 24 13:09:24 2002 UTC revision 1.7 by jvk, Wed Sep 25 11:28:11 2002 UTC
# Line 1  Line 1 
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    
# Line 13  class Colors: Line 13  class Colors:
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),
# Line 50  class Colors: Line 61  class Colors:
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):

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26