Changeset 78 for trunk/src/color.py

Show
Ignore:
Timestamp:
03/20/08 13:24:03 (4 years ago)
Author:
lgs
Message:

Automatically adjust the light of the color scheme based on the number of keys. Patch based on the patch by jae_AT_zhar.net. Fixes #8

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/color.py

    r45 r78  
    4949            clamp(0.0, 1.0, b + amount)) 
    5050     
    51 def generateColorscheme(masterColor, keys, light=0.098): 
     51def generateColorscheme(masterColor, keys): 
    5252    """Generates a dictionary where the keys match the keys argument and 
    5353    the values are colors derivated from the masterColor. 
    5454 
    55     Each color is a lighter version of masterColor separated by a difference 
    56     given by the light argument. 
     55    Each color is a lighter version of masterColor. This difference is 
     56    computed based on the number of keys. 
    5757 
    5858    The masterColor is given in a hex string format. 
    5959    """ 
    6060    r, g, b = hex2rgb(masterColor) 
     61    light = 1.0 / (len(keys)*2) 
    6162    return dict([(key, lighten(r, g, b, light * i)) 
    6263                 for i, key in enumerate(keys)])