Code

Simple first pass for rough timing
[inkscape.git] / share / extensions / color_replace.py
1 #!/usr/bin/env python
2 import coloreffect
4 import inkex
6 class C(coloreffect.ColorEffect):
7   def __init__(self):
8     coloreffect.ColorEffect.__init__(self)
9     self.OptionParser.add_option("-f", "--from_color", action="store", type="string", dest="from_color", default="000000", help="Replace color")
10     self.OptionParser.add_option("-t", "--to_color", action="store", type="string", dest="to_color", default="000000", help="By color")
12   def colmod(self,r,g,b):
13     this_color = '%02x%02x%02x' % (r, g, b)
15     fr = self.options.from_color.strip('"').replace('#', '').lower()
16     to = self.options.to_color.strip('"').replace('#', '').lower()
17        
18     #inkex.debug(this_color+"|"+fr+"|"+to)
19     if this_color == fr:
20       return to
21     else:
22       return this_color
24 c = C()
25 c.affect()