diff options
| author | bulia byak <buliabyak@gmail.com> | 2006-11-15 09:04:37 +0000 |
|---|---|---|
| committer | buliabyak <buliabyak@users.sourceforge.net> | 2006-11-15 09:04:37 +0000 |
| commit | d423a77354d5801305ceede53e3c8a8ac3268db7 (patch) | |
| tree | bb7a39c2d0a74ac6b2ff3b72af233189cbceab50 | |
| parent | removed obsolete -G option from main.cpp and therefore from '--help' output (diff) | |
| download | inkscape-d423a77354d5801305ceede53e3c8a8ac3268db7.tar.gz inkscape-d423a77354d5801305ceede53e3c8a8ac3268db7.zip | |
color effects
(bzr r1953)
28 files changed, 494 insertions, 2 deletions
diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am index 33afbd014..bc0c0b49f 100644 --- a/share/extensions/Makefile.am +++ b/share/extensions/Makefile.am @@ -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 index 000000000..adc34410d --- /dev/null +++ b/share/extensions/color_brighter.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>Brighter</_name>
+ <id>com.kaioa.brighter</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_brighter.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_brighter.py</command>
+ </script>
+</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 index 000000000..d7a52ee70 --- /dev/null +++ b/share/extensions/color_brighter.py @@ -0,0 +1,24 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ FACTOR=0.9 +
+ i=int(1.0/(1.0-FACTOR))
+ if r==0 and g==0 and b==0:
+ return '%02x%02x%02x' % (i,i,i)
+ if r>0 and r<i:
+ r=i
+ if g>0 and g<i:
+ g=i
+ if b>0 and b<i:
+ b=i;
+
+ r=min(int(round((r/FACTOR))), 255)
+ g=min(int(round((g/FACTOR))), 255)
+ b=min(int(round((b/FACTOR))), 255)
+
+ return '%02x%02x%02x' % (r,g,b)
+
+c = C()
+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 index 000000000..8ba2cd520 --- /dev/null +++ b/share/extensions/color_custom.inx @@ -0,0 +1,19 @@ +<inkscape-extension>
+ <_name>Custom</_name>
+ <id>com.kaioa.zcustom</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_custom.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <param name="r" type="string" _gui-text="Red Function">r</param>
+ <param name="g" type="string" _gui-text="Green Function">g</param>
+ <param name="b" type="string" _gui-text="Blue Function">b</param>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_custom.py</command>
+ </script>
+</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 index 000000000..b3daced30 --- /dev/null +++ b/share/extensions/color_custom.py @@ -0,0 +1,31 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def __init__(self):
+ coloreffect.ColorEffect.__init__(self)
+ self.OptionParser.add_option("--r", action="store", type="string", dest="rFunction", default="r",help="red channel function")
+ self.OptionParser.add_option("--g", action="store", type="string", dest="gFunction", default="g",help="green channel function")
+ self.OptionParser.add_option("--b", action="store", type="string", dest="bFunction", default="b",help="blue channel function")
+ def normalize(self, v):
+ if v<0:
+ return 0.0
+ if v>1:
+ return 1.0
+ return v
+ def colmod(self,_r,_g,_b):
+ r=float(_r)/255
+ g=float(_g)/255
+ b=float(_b)/255
+ #coloreffect.debug('I: %f %f %f' % (r,g,b))
+ r=eval(self.options.rFunction)
+ g=eval(self.options.gFunction)
+ b=eval(self.options.bFunction)
+ #coloreffect.debug('E: %f %f %f' % (r,g,b))
+ r=self.normalize(r)
+ g=self.normalize(g)
+ b=self.normalize(b)
+ #coloreffect.debug('N: %f %f %f' % (r,g,b))
+ return '%02x%02x%02x' % (int(round(r*255)),int(round(g*255)),int(round(b*255)))
+
+c = C()
+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 index 000000000..aa937adc1 --- /dev/null +++ b/share/extensions/color_darker.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>Darker</_name>
+ <id>com.kaioa.darker</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_darker.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_darker.py</command>
+ </script>
+</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 index 000000000..ce8899444 --- /dev/null +++ b/share/extensions/color_darker.py @@ -0,0 +1,12 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ FACTOR=0.9 + r=int(round(max(r*FACTOR,0)))
+ g=int(round(max(g*FACTOR,0)))
+ b=int(round(max(b*FACTOR,0)))
+ return '%02x%02x%02x' % (r,g,b)
+
+c = C()
+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 index 000000000..2aa6c0201 --- /dev/null +++ b/share/extensions/color_desaturate.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>Desaturate</_name>
+ <id>com.kaioa.desaturate</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_desaturate.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_desaturate.py</command>
+ </script>
+</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 index 000000000..efdf2658a --- /dev/null +++ b/share/extensions/color_desaturate.py @@ -0,0 +1,10 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ l = (max(r,g,b)+min(r,g,b))/2
+ ig=int(round(l))
+ return '%02x%02x%02x' % (ig,ig,ig)
+
+c = C()
+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 index 000000000..495a3aa18 --- /dev/null +++ b/share/extensions/color_grayscale.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>Grayscale</_name>
+ <id>com.kaioa.grayscale</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_grayscale.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_grayscale.py</command>
+ </script>
+</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 index 000000000..e8c44459a --- /dev/null +++ b/share/extensions/color_grayscale.py @@ -0,0 +1,14 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ #ITU-R Recommendation BT.709
+ #l = 0.2125 * r + 0.7154 * g + 0.0721 * b
+ #NTSC and PAL
+ l = 0.299 * r + 0.587 * g + 0.114 * b
+ ig=int(round(l))
+ #coloreffect.debug('gs '+hex(r)+' '+hex(g)+' '+hex(b)+'%02x%02x%02x' % (ig,ig,ig))
+ return '%02x%02x%02x' % (ig,ig,ig)
+
+c = C()
+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 index 000000000..900f5558b --- /dev/null +++ b/share/extensions/color_keepblue.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>Keep Blue</_name>
+ <id>com.kaioa.keepblue</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_keepblue.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_keepblue.py</command>
+ </script>
+</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 index 000000000..205a87947 --- /dev/null +++ b/share/extensions/color_keepblue.py @@ -0,0 +1,8 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ return '%02x%02x%02x' % (0,0,b)
+
+c = C()
+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 index 000000000..0ee1dddd0 --- /dev/null +++ b/share/extensions/color_keepgreen.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>Keep Green</_name>
+ <id>com.kaioa.keepgreen</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_keepgreen.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_keepgreen.py</command>
+ </script>
+</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 index 000000000..3da5e451b --- /dev/null +++ b/share/extensions/color_keepgreen.py @@ -0,0 +1,8 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ return '%02x%02x%02x' % (0,g,0)
+
+c = C()
+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 index 000000000..824fa2bc4 --- /dev/null +++ b/share/extensions/color_keepred.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>Keep Red</_name>
+ <id>com.kaioa.keepred</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_keepred.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_keepred.py</command>
+ </script>
+</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 index 000000000..662e521e0 --- /dev/null +++ b/share/extensions/color_keepred.py @@ -0,0 +1,8 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ return '%02x%02x%02x' % (r,0,0)
+
+c = C()
+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 index 000000000..7dc73c3cc --- /dev/null +++ b/share/extensions/color_negative.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>Negative</_name>
+ <id>com.kaioa.negative</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_negative.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_negative.py</command>
+ </script>
+</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 index 000000000..0fb2fcecb --- /dev/null +++ b/share/extensions/color_negative.py @@ -0,0 +1,8 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ return '%02x%02x%02x' % (255-r,255-g,255-b)
+
+c = C()
+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 index 000000000..2dadb5a53 --- /dev/null +++ b/share/extensions/color_removeblue.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>Remove Blue</_name>
+ <id>com.kaioa.removeblue</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_removeblue.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_removeblue.py</command>
+ </script>
+</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 index 000000000..90d3fe7c2 --- /dev/null +++ b/share/extensions/color_removeblue.py @@ -0,0 +1,8 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ return '%02x%02x%02x' % (r,g,0)
+
+c = C()
+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 index 000000000..13ea8666b --- /dev/null +++ b/share/extensions/color_removegreen.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>Remove Green</_name>
+ <id>com.kaioa.removegreen</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_removegreen.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_removegreen.py</command>
+ </script>
+</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 index 000000000..87722df54 --- /dev/null +++ b/share/extensions/color_removegreen.py @@ -0,0 +1,8 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ return '%02x%02x%02x' % (r,0,b)
+
+c = C()
+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 index 000000000..ef74410d7 --- /dev/null +++ b/share/extensions/color_removered.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>Remove Red</_name>
+ <id>com.kaioa.removered</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_removered.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_removered.py</command>
+ </script>
+</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 index 000000000..54d071e3f --- /dev/null +++ b/share/extensions/color_removered.py @@ -0,0 +1,8 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ return '%02x%02x%02x' % (0,g,b)
+
+c = C()
+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 index 000000000..a676dae85 --- /dev/null +++ b/share/extensions/color_rgbbarrel.inx @@ -0,0 +1,16 @@ +<inkscape-extension>
+ <_name>RGB Barrel</_name>
+ <id>com.kaioa.rgbbarrel</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_rgbbarrel.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_rgbbarrel.py</command>
+ </script>
+</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 index 000000000..41a0a4e1b --- /dev/null +++ b/share/extensions/color_rgbbarrel.py @@ -0,0 +1,8 @@ +import coloreffect
+
+class C(coloreffect.ColorEffect):
+ def colmod(self,r,g,b):
+ return '%02x%02x%02x' % (b,r,g)
+
+c = C()
+c.affect()
\ No newline at end of file diff --git a/share/extensions/coloreffect.py b/share/extensions/coloreffect.py new file mode 100644 index 000000000..214495502 --- /dev/null +++ b/share/extensions/coloreffect.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python
+'''
+Copyright (C) 2006 Jos Hirth, kaioa.com
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+'''
+import sys, copy, optparse, simplestyle, inkex
+
+import xml.xpath
+
+color_props_fill=('fill:','stop-color:','flood-color:','lighting-color:')
+color_props_stroke=('stroke:',)
+color_props = color_props_fill + color_props_stroke
+
+class ColorEffect(inkex.Effect):
+ def __init__(self):
+ inkex.Effect.__init__(self,use_minidom=True)
+
+ def effect(self):
+ if len(self.selected)==0:
+ self.getAttribs(self.document)
+ else:
+ for id,node in self.selected.iteritems():
+ self.getAttribs(node)
+
+ def getAttribs(self,node):
+ self.changeStyle(node)
+ if node.hasChildNodes():
+ childs=node.childNodes
+ for child in childs:
+ self.getAttribs(child)
+
+ def changeStyle(self,node):
+ if node.hasAttributes():
+ style=node.getAttribute('style') # fixme: this will break for presentation attributes!
+ if style!='':
+ #inkex.debug('old style:'+style)
+ styles=style.split(';')
+ for i in range(len(styles)):
+ for c in range(len(color_props)):
+ if styles[i].startswith(color_props[c]):
+ styles[i]=color_props[c]+self.process_prop(styles[i][len(color_props[c]):])
+ #inkex.debug('new style:'+';'.join(styles))
+ node.setAttribute('style',';'.join(styles))
+ '''
+ def changeStyle(self,node):
+ if node.hasAttributes():
+ sa=node.getAttribute('style')
+ if sa!='':
+ debug(sa)
+ styles=simplestyle.parseStyle(sa)
+ for c in range(len(colortags)):
+ if colortags[c] in styles.keys():
+ styles[colortags[c]]=self.process_prop(styles[colortags[c]])
+ node.setAttribute('style',simplestyle.formatStyle(styles))
+ '''
+ def process_prop(self,col):
+ #debug('got:'+col)
+ if simplestyle.isColor(col):
+ c=simplestyle.parseColor(col)
+ col='#'+self.colmod(c[0],c[1],c[2])
+ #debug('made:'+col)
+ if col.startswith('url(#'):
+ id = col[len('url(#'):col.find(')')]
+ #inkex.debug('ID:' + id )
+ path = '//*[@id="%s"]' % id
+ for node in xml.xpath.Evaluate(path,self.document):
+ self.process_gradient(node)
+ return col
+
+ def process_gradient(self, node):
+ self.changeStyle(node)
+ if node.hasChildNodes():
+ for child in node.childNodes:
+ self.process_gradient(child)
+ if node.hasAttributes():
+ href=node.getAttribute('xlink:href')
+ if href.startswith('#'):
+ id = href[len('#'):len(href)]
+ #inkex.debug('ID:' + id )
+ path = '//*[@id="%s"]' % id
+ for node in xml.xpath.Evaluate(path,self.document):
+ self.process_gradient(node)
+
+ def colmod(self,r,g,b):
+ pass
|
