Code

fix reading style from prefs for tools
[inkscape.git] / share / extensions / color_randomize.py
1 import coloreffect,random,inkex
3 class C(coloreffect.ColorEffect):
4     def __init__(self):
5         coloreffect.ColorEffect.__init__(self)
6         self.OptionParser.add_option("-x", "--hue",
7             action="store", type="inkbool", 
8             dest="hue", default=True,
9             help="randomize hue")
10         self.OptionParser.add_option("-s", "--saturation",
11             action="store", type="inkbool", 
12             dest="saturation", default=True,
13             help="randomize saturation")
14         self.OptionParser.add_option("-l", "--lightness",
15             action="store", type="inkbool", 
16             dest="lightness", default=True,
17             help="randomize lightness")
19     def colmod(self,r,g,b):
20         hsl = self.rgb_to_hsl(r/255.0, g/255.0, b/255.0)
21         if(self.options.hue):
22             hsl[0]=random.random()
23         if(self.options.saturation):
24             hsl[1]=random.random()
25         if(self.options.lightness):
26             hsl[2]=random.random()
27         rgb = self.hsl_to_rgb(hsl[0], hsl[1], hsl[2])
28         return '%02x%02x%02x' % (rgb[0]*255, rgb[1]*255, rgb[2]*255)
30 c = C()
31 c.affect()
34 # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99