MoinSupport

ViewSupport.py

38:a30675efb1c2
2013-01-19 Paul Boddie Added new module to the setup script.
     1 # -*- coding: iso-8859-1 -*-     2 """     3     MoinMoin - ViewSupport library (derived from EventAggregatorSupport)     4      5     @copyright: 2008, 2009, 2010, 2011, 2012 by Paul Boddie <paul@boddie.org.uk>     6     @license: GNU GPL (v2 or later), see COPYING.txt for details.     7 """     8      9 # Colour-related functions.    10     11 def getColour(s):    12     colour = [0, 0, 0]    13     digit = 0    14     for c in s:    15         colour[digit] += ord(c)    16         colour[digit] = colour[digit] % 256    17         digit += 1    18         digit = digit % 3    19     return tuple(colour)    20     21 def getBlackOrWhite(colour):    22     if sum(colour) / 3.0 > 127:    23         return (0, 0, 0)    24     else:    25         return (255, 255, 255)    26     27 # vim: tabstop=4 expandtab shiftwidth=4