color_replace.py revision 86af00f265ba75e1bdf51e6984bddd6351bb9fdf
3303f085664c9d7add74753b1b1541871cd31498joelholdsworthimport coloreffect
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth
3303f085664c9d7add74753b1b1541871cd31498joelholdsworthimport inkex
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth
3303f085664c9d7add74753b1b1541871cd31498joelholdsworthclass C(coloreffect.ColorEffect):
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth def __init__(self):
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth coloreffect.ColorEffect.__init__(self)
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth self.OptionParser.add_option("-f", "--from_color", action="store", type="string", dest="from_color", default="000000", help="Replace color")
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth self.OptionParser.add_option("-t", "--to_color", action="store", type="string", dest="to_color", default="000000", help="By color")
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth def colmod(self,r,g,b):
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth this_color = '%02x%02x%02x' % (r, g, b)
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth if self.options.from_color[0] == '"':
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth self.options.from_color = self.options.from_color[1:]
3303f085664c9d7add74753b1b1541871cd31498joelholdsworth 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:
return this_color
c = C()
c.affect()