Code

color effects
authorbuliabyak <buliabyak@users.sourceforge.net>
Wed, 15 Nov 2006 09:04:37 +0000 (09:04 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Wed, 15 Nov 2006 09:04:37 +0000 (09:04 +0000)
28 files changed:
share/extensions/Makefile.am
share/extensions/color_brighter.inx [new file with mode: 0644]
share/extensions/color_brighter.py [new file with mode: 0644]
share/extensions/color_custom.inx [new file with mode: 0644]
share/extensions/color_custom.py [new file with mode: 0644]
share/extensions/color_darker.inx [new file with mode: 0644]
share/extensions/color_darker.py [new file with mode: 0644]
share/extensions/color_desaturate.inx [new file with mode: 0644]
share/extensions/color_desaturate.py [new file with mode: 0644]
share/extensions/color_grayscale.inx [new file with mode: 0644]
share/extensions/color_grayscale.py [new file with mode: 0644]
share/extensions/color_keepblue.inx [new file with mode: 0644]
share/extensions/color_keepblue.py [new file with mode: 0644]
share/extensions/color_keepgreen.inx [new file with mode: 0644]
share/extensions/color_keepgreen.py [new file with mode: 0644]
share/extensions/color_keepred.inx [new file with mode: 0644]
share/extensions/color_keepred.py [new file with mode: 0644]
share/extensions/color_negative.inx [new file with mode: 0644]
share/extensions/color_negative.py [new file with mode: 0644]
share/extensions/color_removeblue.inx [new file with mode: 0644]
share/extensions/color_removeblue.py [new file with mode: 0644]
share/extensions/color_removegreen.inx [new file with mode: 0644]
share/extensions/color_removegreen.py [new file with mode: 0644]
share/extensions/color_removered.inx [new file with mode: 0644]
share/extensions/color_removered.py [new file with mode: 0644]
share/extensions/color_rgbbarrel.inx [new file with mode: 0644]
share/extensions/color_rgbbarrel.py [new file with mode: 0644]
share/extensions/coloreffect.py [new file with mode: 0644]

index 33afbd014d738bdc17ee160b8bc30236657bdc19..bc0c0b49f9ef0d3d064a22dbde891499fc2a3fa4 100644 (file)
@@ -63,7 +63,22 @@ extensions = \
        webbrowser_reportabug.py \
        webbrowser_svgspec.py \
        webbrowser_commandline.py \
-       webbrowser_faq.py
+       webbrowser_faq.py\
+       color_custom.py\
+       color_desaturate.py\
+       coloreffect.py\
+       color_grayscale.py\
+       color_brighter.py\
+       color_darker.py\
+       color_keepblue.py\
+       color_keepgreen.py\
+       color_keepred.py\
+       color_negative.py\
+       color_removeblue.py\
+       color_removegreen.py\
+       color_removered.py\
+       color_rgbbarrel.py
+
 
 otherstuff = \
     aisvg.xslt
@@ -124,7 +139,20 @@ modules = \
        inkscape_help_reportabug.inx \
        inkscape_help_svgspec.inx \
        inkscape_help_commandline.inx \
-       inkscape_help_faq.inx
+       inkscape_help_faq.inx\
+       color_brighter.inx\
+       color_darker.inx\
+       color_desaturate.inx\
+       color_grayscale.inx\
+       color_negative.inx\
+       color_keepblue.inx\
+       color_keepgreen.inx\
+       color_keepred.inx\
+       color_removeblue.inx\
+       color_removegreen.inx\
+       color_removered.inx\
+       color_rgbbarrel.inx\
+       color_custom.inx 
 
 
 extension_SCRIPTS = \
diff --git a/share/extensions/color_brighter.inx b/share/extensions/color_brighter.inx
new file mode 100644 (file)
index 0000000..adc3441
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>Brighter</_name>\r
+       <id>com.kaioa.brighter</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_brighter.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_brighter.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_brighter.py b/share/extensions/color_brighter.py
new file mode 100644 (file)
index 0000000..d7a52ee
--- /dev/null
@@ -0,0 +1,24 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    FACTOR=0.9
+   \r
+    i=int(1.0/(1.0-FACTOR))\r
+    if r==0 and g==0 and b==0:\r
+      return '%02x%02x%02x' % (i,i,i)\r
+    if r>0 and r<i:\r
+      r=i\r
+    if g>0 and g<i:\r
+      g=i\r
+    if b>0 and b<i:\r
+      b=i;\r
+\r
+    r=min(int(round((r/FACTOR))), 255)\r
+    g=min(int(round((g/FACTOR))), 255)\r
+    b=min(int(round((b/FACTOR))), 255)\r
+   \r
+    return '%02x%02x%02x' % (r,g,b)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_custom.inx b/share/extensions/color_custom.inx
new file mode 100644 (file)
index 0000000..8ba2cd5
--- /dev/null
@@ -0,0 +1,19 @@
+<inkscape-extension>\r
+       <_name>Custom</_name>\r
+       <id>com.kaioa.zcustom</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_custom.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\r
+       <param name="r" type="string" _gui-text="Red Function">r</param>\r
+       <param name="g" type="string" _gui-text="Green Function">g</param>\r
+       <param name="b" type="string" _gui-text="Blue Function">b</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_custom.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_custom.py b/share/extensions/color_custom.py
new file mode 100644 (file)
index 0000000..b3daced
--- /dev/null
@@ -0,0 +1,31 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def __init__(self):\r
+    coloreffect.ColorEffect.__init__(self)\r
+    self.OptionParser.add_option("--r", action="store", type="string", dest="rFunction", default="r",help="red channel function")\r
+    self.OptionParser.add_option("--g", action="store", type="string", dest="gFunction", default="g",help="green channel function")\r
+    self.OptionParser.add_option("--b", action="store", type="string", dest="bFunction", default="b",help="blue channel function")\r
+  def normalize(self, v):\r
+    if v<0:\r
+      return 0.0\r
+    if v>1:\r
+      return 1.0\r
+    return v\r
+  def colmod(self,_r,_g,_b):\r
+    r=float(_r)/255\r
+    g=float(_g)/255\r
+    b=float(_b)/255\r
+    #coloreffect.debug('I: %f %f %f' % (r,g,b))\r
+    r=eval(self.options.rFunction)\r
+    g=eval(self.options.gFunction)\r
+    b=eval(self.options.bFunction)\r
+    #coloreffect.debug('E: %f %f %f' % (r,g,b))\r
+    r=self.normalize(r)\r
+    g=self.normalize(g)\r
+    b=self.normalize(b)\r
+    #coloreffect.debug('N: %f %f %f' % (r,g,b))\r
+    return '%02x%02x%02x' % (int(round(r*255)),int(round(g*255)),int(round(b*255)))\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_darker.inx b/share/extensions/color_darker.inx
new file mode 100644 (file)
index 0000000..aa937ad
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>Darker</_name>\r
+       <id>com.kaioa.darker</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_darker.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_darker.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_darker.py b/share/extensions/color_darker.py
new file mode 100644 (file)
index 0000000..ce88994
--- /dev/null
@@ -0,0 +1,12 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    FACTOR=0.9
+    r=int(round(max(r*FACTOR,0)))\r
+    g=int(round(max(g*FACTOR,0)))\r
+    b=int(round(max(b*FACTOR,0)))\r
+    return '%02x%02x%02x' % (r,g,b)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_desaturate.inx b/share/extensions/color_desaturate.inx
new file mode 100644 (file)
index 0000000..2aa6c02
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>Desaturate</_name>\r
+       <id>com.kaioa.desaturate</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_desaturate.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_desaturate.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_desaturate.py b/share/extensions/color_desaturate.py
new file mode 100644 (file)
index 0000000..efdf265
--- /dev/null
@@ -0,0 +1,10 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    l = (max(r,g,b)+min(r,g,b))/2\r
+    ig=int(round(l))\r
+    return '%02x%02x%02x' % (ig,ig,ig)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_grayscale.inx b/share/extensions/color_grayscale.inx
new file mode 100644 (file)
index 0000000..495a3aa
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>Grayscale</_name>\r
+       <id>com.kaioa.grayscale</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_grayscale.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_grayscale.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_grayscale.py b/share/extensions/color_grayscale.py
new file mode 100644 (file)
index 0000000..e8c4445
--- /dev/null
@@ -0,0 +1,14 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    #ITU-R Recommendation BT.709\r
+    #l = 0.2125 * r + 0.7154 * g + 0.0721 * b\r
+    #NTSC and PAL\r
+    l = 0.299 * r + 0.587 * g + 0.114 * b\r
+    ig=int(round(l))\r
+    #coloreffect.debug('gs '+hex(r)+' '+hex(g)+' '+hex(b)+'%02x%02x%02x' % (ig,ig,ig))\r
+    return '%02x%02x%02x' % (ig,ig,ig)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_keepblue.inx b/share/extensions/color_keepblue.inx
new file mode 100644 (file)
index 0000000..900f555
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>Keep Blue</_name>\r
+       <id>com.kaioa.keepblue</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_keepblue.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_keepblue.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_keepblue.py b/share/extensions/color_keepblue.py
new file mode 100644 (file)
index 0000000..205a879
--- /dev/null
@@ -0,0 +1,8 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    return '%02x%02x%02x' % (0,0,b)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_keepgreen.inx b/share/extensions/color_keepgreen.inx
new file mode 100644 (file)
index 0000000..0ee1ddd
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>Keep Green</_name>\r
+       <id>com.kaioa.keepgreen</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_keepgreen.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_keepgreen.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_keepgreen.py b/share/extensions/color_keepgreen.py
new file mode 100644 (file)
index 0000000..3da5e45
--- /dev/null
@@ -0,0 +1,8 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    return '%02x%02x%02x' % (0,g,0)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_keepred.inx b/share/extensions/color_keepred.inx
new file mode 100644 (file)
index 0000000..824fa2b
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>Keep Red</_name>\r
+       <id>com.kaioa.keepred</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_keepred.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_keepred.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_keepred.py b/share/extensions/color_keepred.py
new file mode 100644 (file)
index 0000000..662e521
--- /dev/null
@@ -0,0 +1,8 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    return '%02x%02x%02x' % (r,0,0)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_negative.inx b/share/extensions/color_negative.inx
new file mode 100644 (file)
index 0000000..7dc73c3
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>Negative</_name>\r
+       <id>com.kaioa.negative</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_negative.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_negative.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_negative.py b/share/extensions/color_negative.py
new file mode 100644 (file)
index 0000000..0fb2fce
--- /dev/null
@@ -0,0 +1,8 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    return '%02x%02x%02x' % (255-r,255-g,255-b)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_removeblue.inx b/share/extensions/color_removeblue.inx
new file mode 100644 (file)
index 0000000..2dadb5a
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>Remove Blue</_name>\r
+       <id>com.kaioa.removeblue</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_removeblue.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_removeblue.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_removeblue.py b/share/extensions/color_removeblue.py
new file mode 100644 (file)
index 0000000..90d3fe7
--- /dev/null
@@ -0,0 +1,8 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    return '%02x%02x%02x' % (r,g,0)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_removegreen.inx b/share/extensions/color_removegreen.inx
new file mode 100644 (file)
index 0000000..13ea866
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>Remove Green</_name>\r
+       <id>com.kaioa.removegreen</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_removegreen.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_removegreen.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_removegreen.py b/share/extensions/color_removegreen.py
new file mode 100644 (file)
index 0000000..87722df
--- /dev/null
@@ -0,0 +1,8 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    return '%02x%02x%02x' % (r,0,b)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_removered.inx b/share/extensions/color_removered.inx
new file mode 100644 (file)
index 0000000..ef74410
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>Remove Red</_name>\r
+       <id>com.kaioa.removered</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_removered.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_removered.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_removered.py b/share/extensions/color_removered.py
new file mode 100644 (file)
index 0000000..54d071e
--- /dev/null
@@ -0,0 +1,8 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    return '%02x%02x%02x' % (0,g,b)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/color_rgbbarrel.inx b/share/extensions/color_rgbbarrel.inx
new file mode 100644 (file)
index 0000000..a676dae
--- /dev/null
@@ -0,0 +1,16 @@
+<inkscape-extension>\r
+       <_name>RGB Barrel</_name>\r
+       <id>com.kaioa.rgbbarrel</id>\r
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>\r
+       <dependency type="executable" location="extensions">color_rgbbarrel.py</dependency>\r
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>\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_rgbbarrel.py</command>\r
+       </script>\r
+</inkscape-extension>
\ No newline at end of file
diff --git a/share/extensions/color_rgbbarrel.py b/share/extensions/color_rgbbarrel.py
new file mode 100644 (file)
index 0000000..41a0a4e
--- /dev/null
@@ -0,0 +1,8 @@
+import coloreffect\r
+\r
+class C(coloreffect.ColorEffect):\r
+  def colmod(self,r,g,b):\r
+    return '%02x%02x%02x' % (b,r,g)\r
+\r
+c = C()\r
+c.affect()
\ No newline at end of file
diff --git a/share/extensions/coloreffect.py b/share/extensions/coloreffect.py
new file mode 100644 (file)
index 0000000..2144955
--- /dev/null
@@ -0,0 +1,98 @@
+#!/usr/bin/env python \r
+'''\r
+Copyright (C) 2006 Jos Hirth, kaioa.com\r
+\r
+This program is free software; you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation; either version 2 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program; if not, write to the Free Software\r
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+'''\r
+import sys, copy, optparse, simplestyle, inkex\r
+\r
+import xml.xpath\r
+\r
+color_props_fill=('fill:','stop-color:','flood-color:','lighting-color:')\r
+color_props_stroke=('stroke:',)\r
+color_props = color_props_fill + color_props_stroke\r
+\r
+class ColorEffect(inkex.Effect):\r
+  def __init__(self):\r
+    inkex.Effect.__init__(self,use_minidom=True)\r
+\r
+  def effect(self):\r
+    if len(self.selected)==0:\r
+      self.getAttribs(self.document)\r
+    else:\r
+      for id,node in self.selected.iteritems():\r
+        self.getAttribs(node)\r
+\r
+  def getAttribs(self,node):\r
+    self.changeStyle(node)\r
+    if node.hasChildNodes():\r
+      childs=node.childNodes\r
+      for child in childs:\r
+        self.getAttribs(child)\r
+  \r
+  def changeStyle(self,node):\r
+    if node.hasAttributes():\r
+      style=node.getAttribute('style') # fixme: this will break for presentation attributes!\r
+      if style!='':\r
+        #inkex.debug('old style:'+style)\r
+        styles=style.split(';')\r
+        for i in range(len(styles)):\r
+          for c in range(len(color_props)):\r
+            if styles[i].startswith(color_props[c]):\r
+              styles[i]=color_props[c]+self.process_prop(styles[i][len(color_props[c]):])\r
+        #inkex.debug('new style:'+';'.join(styles))\r
+        node.setAttribute('style',';'.join(styles))\r
+  '''\r
+  def changeStyle(self,node):\r
+    if node.hasAttributes():\r
+      sa=node.getAttribute('style')\r
+      if sa!='':\r
+        debug(sa)\r
+        styles=simplestyle.parseStyle(sa)\r
+        for c in range(len(colortags)):\r
+          if colortags[c] in styles.keys():\r
+            styles[colortags[c]]=self.process_prop(styles[colortags[c]])\r
+        node.setAttribute('style',simplestyle.formatStyle(styles))\r
+  '''        \r
+  def process_prop(self,col):\r
+    #debug('got:'+col)\r
+    if simplestyle.isColor(col):\r
+      c=simplestyle.parseColor(col)\r
+      col='#'+self.colmod(c[0],c[1],c[2])\r
+      #debug('made:'+col)\r
+    if col.startswith('url(#'):\r
+       id = col[len('url(#'):col.find(')')]\r
+       #inkex.debug('ID:' + id )\r
+       path = '//*[@id="%s"]' % id\r
+       for node in xml.xpath.Evaluate(path,self.document):\r
+         self.process_gradient(node)\r
+    return col\r
+\r
+  def process_gradient(self, node):\r
+    self.changeStyle(node)\r
+    if node.hasChildNodes():\r
+      for child in node.childNodes:\r
+        self.process_gradient(child)\r
+    if node.hasAttributes():                           \r
+      href=node.getAttribute('xlink:href')\r
+      if href.startswith('#'):\r
+        id = href[len('#'):len(href)]\r
+        #inkex.debug('ID:' + id )\r
+        path = '//*[@id="%s"]' % id\r
+        for node in xml.xpath.Evaluate(path,self.document):\r
+          self.process_gradient(node)\r
\r
+  def colmod(self,r,g,b):\r
+    pass\r