Code

Extensions. New black and white color extension.
authorJazzyNico <nicoduf@yahoo.fr>
Sun, 14 Feb 2010 09:46:42 +0000 (10:46 +0100)
committerJazzyNico <nicoduf@yahoo.fr>
Sun, 14 Feb 2010 09:46:42 +0000 (10:46 +0100)
share/extensions/Makefile.am
share/extensions/color_blackandwhite.inx [new file with mode: 0644]
share/extensions/color_blackandwhite.py [new file with mode: 0644]

index 1105228954c9ad62f0dd67b4d0275fec7e0786fb..c40ba1c873ea27b6b2640504c69c3375272b49e8 100644 (file)
@@ -18,6 +18,7 @@ extensions = \
        addnodes.py \
        bezmisc.py \
        chardataeffect.py\
+       color_blackandwhite.py\
        color_brighter.py\
        color_custom.py\
        color_darker.py\
@@ -154,6 +155,7 @@ modules = \
        cdt_input.inx \
        cgm_input.inx \
        cmx_input.inx \
+       color_blackandwhite.inx\
        color_brighter.inx\
        color_custom.inx \
        color_darker.inx\
diff --git a/share/extensions/color_blackandwhite.inx b/share/extensions/color_blackandwhite.inx
new file mode 100644 (file)
index 0000000..8432ab2
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+       <_name>Black and White</_name>
+       <id>org.inkscape.color.blackandwhite</id>
+       <dependency type="executable" location="extensions">coloreffect.py</dependency>
+       <dependency type="executable" location="extensions">color_blackandwhite.py</dependency>
+       <dependency type="executable" location="extensions">simplestyle.py</dependency>
+       <effect>
+               <object-type>all</object-type>
+               <effects-menu>
+                       <submenu _name="Color"/>
+               </effects-menu>
+       </effect>
+       <script>
+               <command reldir="extensions" interpreter="python">color_blackandwhite.py</command>
+       </script>
+</inkscape-extension>
diff --git a/share/extensions/color_blackandwhite.py b/share/extensions/color_blackandwhite.py
new file mode 100644 (file)
index 0000000..c11b2a1
--- /dev/null
@@ -0,0 +1,17 @@
+import coloreffect,sys
+
+class C(coloreffect.ColorEffect):
+  def colmod(self,r,g,b):
+    #ITU-R Recommendation BT.709
+    #l = 0.2125 * r + 0.7154 * g + 0.0721 * b
+    #NTSC and PAL
+    l = 0.299 * r + 0.587 * g + 0.114 * b
+    if l > 127:
+       ig = 255
+    else:
+       ig = 0
+    #coloreffect.debug('gs '+hex(r)+' '+hex(g)+' '+hex(b)+'%02x%02x%02x' % (ig,ig,ig))
+    return '%02x%02x%02x' % (ig,ig,ig)
+
+c = C()
+c.affect()