summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1ee1b50)
raw | patch | inline | side by side (parent: 1ee1b50)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 15 Jul 2007 15:00:23 +0000 (15:00 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 15 Jul 2007 15:00:23 +0000 (15:00 +0000) |
share/extensions/color_replace.py | patch | blob | history |
index adf6823c0108373f8a8a441c3abdff856d7191d0..8db10e0b958be43d5c3fb198133b0d547761a9f2 100644 (file)
import coloreffect\r
-
-import inkex
+\r
+import inkex\r
\r
class C(coloreffect.ColorEffect):\r
- 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):\r
+ coloreffect.ColorEffect.__init__(self)\r
+ self.OptionParser.add_option("-f", "--from_color", action="store", type="string", dest="from_color", default="000000", help="Replace color")\r
+ self.OptionParser.add_option("-t", "--to_color", action="store", type="string", dest="to_color", default="000000", help="By color")\r
+\r
def colmod(self,r,g,b):\r
this_color = '%02x%02x%02x' % (r, g, b)\r
-
- 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\r
- else:
+\r
+ fr = self.options.from_color.strip('"').replace('#', '')\r
+ to = self.options.to_color.strip('"').replace('#', '')\r
+ \r
+ #inkex.debug(this_color+"|"+fr+"|"+to)\r
+ if this_color == fr:\r
+ return to\r
+ else:\r
return this_color\r
\r
c = C()\r
-c.affect()
\ No newline at end of file
+c.affect()\r