1 import coloreffect\r
2 \r
3 class C(coloreffect.ColorEffect):\r
4 def __init__(self):\r
5 coloreffect.ColorEffect.__init__(self)\r
6 self.OptionParser.add_option("--r", action="store", type="string", dest="rFunction", default="r",help="red channel function")\r
7 self.OptionParser.add_option("--g", action="store", type="string", dest="gFunction", default="g",help="green channel function")\r
8 self.OptionParser.add_option("--b", action="store", type="string", dest="bFunction", default="b",help="blue channel function")\r
9 def normalize(self, v):\r
10 if v<0:\r
11 return 0.0\r
12 if v>1:\r
13 return 1.0\r
14 return v\r
15 def colmod(self,_r,_g,_b):\r
16 r=float(_r)/255\r
17 g=float(_g)/255\r
18 b=float(_b)/255\r
19 r2=self.normalize(eval(self.options.rFunction))\r
20 g2=self.normalize(eval(self.options.gFunction))\r
21 b2=self.normalize(eval(self.options.bFunction))\r
22 return '%02x%02x%02x' % (int(round(r2*255)),int(round(g2*255)),int(round(b2*255)))\r
23 \r
24 c = C()\r
25 c.affect()