From 29f0dca6a461cca0055b2e7dc2856e963d2d0411 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Sun, 15 Jul 2007 15:00:23 +0000 Subject: [PATCH] simplify --- share/extensions/color_replace.py | 42 ++++++++++++------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/share/extensions/color_replace.py b/share/extensions/color_replace.py index adf6823c0..8db10e0b9 100644 --- a/share/extensions/color_replace.py +++ b/share/extensions/color_replace.py @@ -1,34 +1,24 @@ import coloreffect - -import inkex + +import inkex class C(coloreffect.ColorEffect): - def __init__(self): - coloreffect.ColorEffect.__init__(self) - self.OptionParser.add_option("-f", "--from_color", action="store", type="string", dest="from_color", default="000000", help="Replace color") - self.OptionParser.add_option("-t", "--to_color", action="store", type="string", dest="to_color", default="000000", help="By color") - + def __init__(self): + coloreffect.ColorEffect.__init__(self) + self.OptionParser.add_option("-f", "--from_color", action="store", type="string", dest="from_color", default="000000", help="Replace color") + self.OptionParser.add_option("-t", "--to_color", action="store", type="string", dest="to_color", default="000000", help="By color") + def colmod(self,r,g,b): this_color = '%02x%02x%02x' % (r, g, b) - - if self.options.from_color[0] == '"': - self.options.from_color = self.options.from_color[1:] - if self.options.from_color[0] == '#': - self.options.from_color = self.options.from_color[1:] - if self.options.from_color[-1] == '"': - self.options.from_color = self.options.from_color[:-1] - if self.options.to_color[0] == '"': - self.options.to_color = self.options.to_color[1:] - if self.options.to_color[0] == '#': - self.options.to_color = self.options.to_color[1:] - if self.options.to_color[-1] == '"': - self.options.to_color = self.options.to_color[:-1] - - #inkex.debug(this_color+"|"+self.options.from_color) - if this_color == self.options.from_color: - return self.options.to_color - else: + + fr = self.options.from_color.strip('"').replace('#', '') + to = self.options.to_color.strip('"').replace('#', '') + + #inkex.debug(this_color+"|"+fr+"|"+to) + if this_color == fr: + return to + else: return this_color c = C() -c.affect() \ No newline at end of file +c.affect() -- 2.30.2