/[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.10 by jvk, Fri Sep 27 14:05:08 2002 UTC revision 1.11 by jvk, Sun Sep 29 08:33:37 2002 UTC
# Line 2  Line 2 
2    
3  from gfx.libcolor.spaces import getRandomColor,getRandomColor2,RGBtoLAB,LABtoRGB,LABclamp  from gfx.libcolor.spaces import getRandomColor,getRandomColor2,RGBtoLAB,LABtoRGB,LABclamp
4    
5  from math import sin,cos,atan2,pi  from math import sin,cos,atan2,pi,log
6  from random import shuffle  from random import Random,shuffle
7    
8    
 import java;  
9    
10  dbg=0  dbg=0
11    
# Line 13  class Colors: Line 13  class Colors:
13      def _js(self, arg):      def _js(self, arg):
14          return " ".join([str(a) for a in arg])          return " ".join([str(a) for a in arg])
15      def __init__(self, seed):      def __init__(self, seed):
16          rnd = self.rnd = java.util.Random(seed)          rnd = self.rnd = Random(seed)
17            rnd.nextDouble = rnd.random
18    
19          # currently, 4 colors          colors = 8
         colors = 4  
20          minlum = 80          minlum = 80
21          huerange = (45 + rnd.nextGaussian() * 45) * (pi / 180)          #huerange = (45 + rnd.nextGaussian() * 45)
22            huerange = rnd.lognormvariate(log(60), .3)
23    
24            # gnuplot code for plotting huerange distribution:
25            # sigma=.4; mu=log(60); plot [0:360] 1 / (x * sqrt(2 * pi * sigma**2)) * exp(-(log(x)-mu)**2 / (2 * sigma**2))
26    
27          # Note: This color sampling scheme only produces          # Note: This color sampling scheme only produces
28          # palettes with similar colors.          # palettes with similar colors.
# Line 27  class Colors: Line 31  class Colors:
31          # (Note: color complementing should be done in RGB space)          # (Note: color complementing should be done in RGB space)
32    
33          # Sample hues uniformly from the range shifted to a random angle          # Sample hues uniformly from the range shifted to a random angle
34            huerange *= pi / 180
35          hue0 = rnd.nextDouble() * 2*pi          hue0 = rnd.nextDouble() * 2*pi
36          hues = [hue0 + rnd.nextDouble() * huerange for i in range(0,colors)]          hues = ([hue0, hue0 + huerange] +
37                    [hue0 + rnd.nextDouble() * huerange for i in range(2,colors)])
38            shuffle(hues, rnd.nextDouble)
39    
40          # Take one half dark colors and one half light colors          # Take one half dark colors and one half light colors
41          lumrange = 100 - minlum          lumrange = 100 - minlum

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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