Code

color_randomize added
authoramphi <amphi@users.sourceforge.net>
Mon, 13 Aug 2007 20:07:36 +0000 (20:07 +0000)
committeramphi <amphi@users.sourceforge.net>
Mon, 13 Aug 2007 20:07:36 +0000 (20:07 +0000)
share/extensions/Makefile.am
share/extensions/color_randomize.inx [new file with mode: 0644]
share/extensions/color_randomize.py [new file with mode: 0644]

index af31e67779cb518edc266cb4f0adeb757db8cd2e..b1cda326b90cd7e2d0439d0255adaef4c55ffaed 100644 (file)
@@ -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 (file)
index 0000000..c92bef4
--- /dev/null
@@ -0,0 +1,19 @@
+<inkscape-extension>\r
+       <_name>Randomize</_name>\r
+       <id>org.inkscape.color.randomize</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_randomize.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\r
+       <param name="hue" type="boolean" _gui-text="Hue">true</param>\r
+       <param name="saturation" type="boolean" _gui-text="Saturation">true</param>\r
+       <param name="lightness" type="boolean" _gui-text="Lightness">true</param>\r
+       <effect>\r
+               <object-type>all</object-type>\r
+               <effects-menu>\r
+                       <submenu _name="Color"/>\r
+               </effects-menu>\r
+       </effect>\r
+       <script>\r
+               <command reldir="extensions" interpreter="python">color_randomize.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_randomize.py b/share/extensions/color_randomize.py
new file mode 100644 (file)
index 0000000..4591675
--- /dev/null
@@ -0,0 +1,31 @@
+import coloreffect,random,inkex\r
+\r
+class C(coloreffect.ColorEffect):\r
+    def __init__(self):\r
+        coloreffect.ColorEffect.__init__(self)\r
+        self.OptionParser.add_option("-x", "--hue",\r
+            action="store", type="inkbool", \r
+            dest="hue", default=True,\r
+            help="randomize hue")\r
+        self.OptionParser.add_option("-s", "--saturation",\r
+            action="store", type="inkbool", \r
+            dest="saturation", default=True,\r
+            help="randomize saturation")\r
+        self.OptionParser.add_option("-l", "--lightness",\r
+            action="store", type="inkbool", \r
+            dest="lightness", default=True,\r
+            help="randomize lightness")\r
+\r
+    def colmod(self,r,g,b):\r
+        hsl = self.rgb_to_hsl(r/255.0, g/255.0, b/255.0)\r
+        if(self.options.hue):\r
+            hsl[0]=random.random()\r
+        if(self.options.saturation):\r
+            hsl[1]=random.random()\r
+        if(self.options.lightness):\r
+            hsl[2]=random.random()\r
+        rgb = self.hsl_to_rgb(hsl[0], hsl[1], hsl[2])\r
+        return '%02x%02x%02x' % (rgb[0]*255, rgb[1]*255, rgb[2]*255)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file