Code

Following this thread: http://www.nabble.com/Extension-parameters-td9064285.html...
[inkscape.git] / share / extensions / color_grayscale.py
1 import coloreffect
3 class C(coloreffect.ColorEffect):
4   def colmod(self,r,g,b):
5     #ITU-R Recommendation BT.709
6     #l = 0.2125 * r + 0.7154 * g + 0.0721 * b
7     #NTSC and PAL
8     l = 0.299 * r + 0.587 * g + 0.114 * b
9     ig=int(round(l))
10     #coloreffect.debug('gs '+hex(r)+' '+hex(g)+' '+hex(b)+'%02x%02x%02x' % (ig,ig,ig))
11     return '%02x%02x%02x' % (ig,ig,ig)
13 c = C()
14 c.affect()