From cff2ed46f059b845cc6b03a2b086a1d7556af158 Mon Sep 17 00:00:00 2001 From: amphi Date: Mon, 13 Aug 2007 20:07:36 +0000 Subject: [PATCH] color_randomize added --- share/extensions/Makefile.am | 2 ++ share/extensions/color_randomize.inx | 19 +++++++++++++++++ share/extensions/color_randomize.py | 31 ++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 share/extensions/color_randomize.inx create mode 100644 share/extensions/color_randomize.py diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am index af31e6777..b1cda326b 100644 --- a/share/extensions/Makefile.am +++ b/share/extensions/Makefile.am @@ -26,6 +26,7 @@ extensions = \ color_morelight.py\ color_moresaturation.py\ color_negative.py\ + color_randomize.py\ color_removeblue.py\ color_removegreen.py\ color_removered.py\ @@ -118,6 +119,7 @@ modules = \ color_morelight.inx\ color_moresaturation.inx\ color_negative.inx\ + color_randomize.py\ color_removeblue.inx\ color_removegreen.inx\ color_removered.inx\ diff --git a/share/extensions/color_randomize.inx b/share/extensions/color_randomize.inx new file mode 100644 index 000000000..c92bef4f2 --- /dev/null +++ b/share/extensions/color_randomize.inx @@ -0,0 +1,19 @@ + + <_name>Randomize + org.inkscape.color.randomize + coloreffect.py + color_randomize.py + simplestyle.py + true + true + true + + all + + + + + + \ No newline at end of file diff --git a/share/extensions/color_randomize.py b/share/extensions/color_randomize.py new file mode 100644 index 000000000..4591675b5 --- /dev/null +++ b/share/extensions/color_randomize.py @@ -0,0 +1,31 @@ +import coloreffect,random,inkex + +class C(coloreffect.ColorEffect): + def __init__(self): + coloreffect.ColorEffect.__init__(self) + self.OptionParser.add_option("-x", "--hue", + action="store", type="inkbool", + dest="hue", default=True, + help="randomize hue") + self.OptionParser.add_option("-s", "--saturation", + action="store", type="inkbool", + dest="saturation", default=True, + help="randomize saturation") + self.OptionParser.add_option("-l", "--lightness", + action="store", type="inkbool", + dest="lightness", default=True, + help="randomize lightness") + + def colmod(self,r,g,b): + hsl = self.rgb_to_hsl(r/255.0, g/255.0, b/255.0) + if(self.options.hue): + hsl[0]=random.random() + if(self.options.saturation): + hsl[1]=random.random() + if(self.options.lightness): + hsl[2]=random.random() + rgb = self.hsl_to_rgb(hsl[0], hsl[1], hsl[2]) + return '%02x%02x%02x' % (rgb[0]*255, rgb[1]*255, rgb[2]*255) + +c = C() +c.affect() \ No newline at end of file -- 2.30.2