From c77aac3c8ee0b53e85610e2cf708c3cee7422981 Mon Sep 17 00:00:00 2001 From: JazzyNico Date: Sun, 14 Feb 2010 10:46:42 +0100 Subject: [PATCH] Extensions. New black and white color extension. --- share/extensions/Makefile.am | 2 ++ share/extensions/color_blackandwhite.inx | 17 +++++++++++++++++ share/extensions/color_blackandwhite.py | 17 +++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 share/extensions/color_blackandwhite.inx create mode 100644 share/extensions/color_blackandwhite.py diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am index 110522895..c40ba1c87 100644 --- a/share/extensions/Makefile.am +++ b/share/extensions/Makefile.am @@ -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 index 000000000..8432ab2d3 --- /dev/null +++ b/share/extensions/color_blackandwhite.inx @@ -0,0 +1,17 @@ + + + <_name>Black and White + org.inkscape.color.blackandwhite + coloreffect.py + color_blackandwhite.py + simplestyle.py + + all + + + + + + diff --git a/share/extensions/color_blackandwhite.py b/share/extensions/color_blackandwhite.py new file mode 100644 index 000000000..c11b2a127 --- /dev/null +++ b/share/extensions/color_blackandwhite.py @@ -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() -- 2.30.2