diff options
| author | bulia byak <buliabyak@gmail.com> | 2007-07-15 15:00:23 +0000 |
|---|---|---|
| committer | buliabyak <buliabyak@users.sourceforge.net> | 2007-07-15 15:00:23 +0000 |
| commit | aed58de79296d8ed588b33047b632ea22a2807f2 (patch) | |
| tree | 6615a6daf6171c38fbbdd539575e59b04731e2ae | |
| parent | fix crash with empty parameter string (diff) | |
| download | inkscape-aed58de79296d8ed588b33047b632ea22a2807f2.tar.gz inkscape-aed58de79296d8ed588b33047b632ea22a2807f2.zip | |
simplify
(bzr r3252)
| -rw-r--r-- | share/extensions/color_replace.py | 42 |
1 files 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()
|
