~ubuntu-branches/debian/squeeze/inkscape/squeeze

« back to all changes in this revision

Viewing changes to share/extensions/color_randomize.py

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import coloreffect,random,inkex
 
2
 
 
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")
 
18
 
 
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)
 
29
 
 
30
c = C()
 
31
c.affect()
 
 
b'\\ No newline at end of file'