From: buliabyak Date: Sun, 15 Jul 2007 15:00:23 +0000 (+0000) Subject: simplify X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=29f0dca6a461cca0055b2e7dc2856e963d2d0411;p=inkscape.git simplify --- 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()