1 #!/usr/bin/env python
2 import coloreffect,random,inkex
4 class C(coloreffect.ColorEffect):
5 def __init__(self):
6 coloreffect.ColorEffect.__init__(self)
7 self.OptionParser.add_option("-x", "--hue",
8 action="store", type="inkbool",
9 dest="hue", default=True,
10 help="randomize hue")
11 self.OptionParser.add_option("-s", "--saturation",
12 action="store", type="inkbool",
13 dest="saturation", default=True,
14 help="randomize saturation")
15 self.OptionParser.add_option("-l", "--lightness",
16 action="store", type="inkbool",
17 dest="lightness", default=True,
18 help="randomize lightness")
19 self.OptionParser.add_option("--tab",
20 action="store", type="string",
21 dest="tab",
22 help="The selected UI-tab when OK was pressed")
24 def colmod(self,r,g,b):
25 hsl = self.rgb_to_hsl(r/255.0, g/255.0, b/255.0)
26 if(self.options.hue):
27 hsl[0]=random.random()
28 if(self.options.saturation):
29 hsl[1]=random.random()
30 if(self.options.lightness):
31 hsl[2]=random.random()
32 rgb = self.hsl_to_rgb(hsl[0], hsl[1], hsl[2])
33 return '%02x%02x%02x' % (rgb[0]*255, rgb[1]*255, rgb[2]*255)
35 c = C()
36 c.affect()
39 # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99