summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2007-07-10 15:53:35 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2007-07-10 15:53:35 +0000
commitc9731678f87ec6307bd7ba9f6764265ec9098a0f (patch)
treef5665f641f9d6fdd2bb7825d885b80c7304b5aa7 /share
parentDifferent default styles for non-parallel 3D box faces (diff)
downloadinkscape-c9731678f87ec6307bd7ba9f6764265ec9098a0f.tar.gz
inkscape-c9731678f87ec6307bd7ba9f6764265ec9098a0f.zip
add color replacer
(bzr r3214)
Diffstat (limited to 'share')
-rw-r--r--share/extensions/Makefile.am2
-rw-r--r--share/extensions/color_replace.inx18
-rw-r--r--share/extensions/color_replace.py34
3 files changed, 54 insertions, 0 deletions
diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am
index 7d3a00bb2..e15df2f38 100644
--- a/share/extensions/Makefile.am
+++ b/share/extensions/Makefile.am
@@ -30,6 +30,7 @@ extensions = \
color_removegreen.py\
color_removered.py\
color_rgbbarrel.py\
+ color_replace.py\
cspsubdiv.py \
cubicsuperpath.py \
dia2svg.sh \
@@ -120,6 +121,7 @@ modules = \
color_removegreen.inx\
color_removered.inx\
color_rgbbarrel.inx\
+ color_replace.inx\
dia.inx \
dots.inx \
dxf_input.inx \
diff --git a/share/extensions/color_replace.inx b/share/extensions/color_replace.inx
new file mode 100644
index 000000000..d305ec329
--- /dev/null
+++ b/share/extensions/color_replace.inx
@@ -0,0 +1,18 @@
+<inkscape-extension>
+ <_name>Replace color...</_name>
+ <id>org.inkscape.color.replacecolor</id>
+ <dependency type="executable" location="extensions">coloreffect.py</dependency>
+ <dependency type="executable" location="extensions">color_replace.py</dependency>
+ <dependency type="executable" location="extensions">simplestyle.py</dependency>
+ <param name="from_color" type="string" gui-text="Replace color (RRGGBB hex):">000000</param>
+ <param name="to_color" type="string" gui-text="By color (RRGGBB hex):">000000</param>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Color"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">color_replace.py</command>
+ </script>
+</inkscape-extension> \ No newline at end of file
diff --git a/share/extensions/color_replace.py b/share/extensions/color_replace.py
new file mode 100644
index 000000000..adf6823c0
--- /dev/null
+++ b/share/extensions/color_replace.py
@@ -0,0 +1,34 @@
+import coloreffect
+
+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 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:
+ return this_color
+
+c = C()
+c.affect() \ No newline at end of file