1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/ViewSupport.py Sat Aug 18 20:33:04 2012 +0200
1.3 @@ -0,0 +1,27 @@
1.4 +# -*- coding: iso-8859-1 -*-
1.5 +"""
1.6 + MoinMoin - ViewSupport library (derived from EventAggregatorSupport)
1.7 +
1.8 + @copyright: 2008, 2009, 2010, 2011, 2012 by Paul Boddie <paul@boddie.org.uk>
1.9 + @license: GNU GPL (v2 or later), see COPYING.txt for details.
1.10 +"""
1.11 +
1.12 +# Colour-related functions.
1.13 +
1.14 +def getColour(s):
1.15 + colour = [0, 0, 0]
1.16 + digit = 0
1.17 + for c in s:
1.18 + colour[digit] += ord(c)
1.19 + colour[digit] = colour[digit] % 256
1.20 + digit += 1
1.21 + digit = digit % 3
1.22 + return tuple(colour)
1.23 +
1.24 +def getBlackOrWhite(colour):
1.25 + if sum(colour) / 3.0 > 127:
1.26 + return (0, 0, 0)
1.27 + else:
1.28 + return (255, 255, 255)
1.29 +
1.30 +# vim: tabstop=4 expandtab shiftwidth=4