Showing posts with label hue. Show all posts
Showing posts with label hue. Show all posts

15 September 2008

compiz-fusion color filter for hue inversion

The negative plug-in for compiz fusion can be used to reduce eye straining while reading from screen: it switches black-text-on-white-background to white-text-on-black-background. But such inversion involves also color channels: red appears cyan, green appears magenta, blue appears yellow and so on. Therefore if you want that in your application, for example, your green buttons (which mean "good", "on", "ok"...) will remain green, and for example your red buttons (which mean "alert", "off", "cancel"...) will remain red, you have to resort to an additional hue switching transformation.
The Color Filter plug-in could be used for such a color transformation, but the already available filters do not include such option. Moreover, I couldn't find a similar trasformation through google, so I write it for you. You can find it just below here, it is merely a dozen of lines of OpenGL fragment program: simply copy those lines in a file (to be placed, for example, among the other filters in /usr/share/compiz/filters/) and then select as filter files both the negative filter and my filter (the order is irrelevant).
Enjoy! :)

!!ARBfp1.0
TEMP output, tmp, YPbPr;
TEX output, fragment.texcoord[0], texture[0], RECT;

MOV tmp, output;

DP3 YPbPr.x, tmp, {0.333, 0.333, 0.333, 1};
SUB YPbPr.y, YPbPr.x, tmp.b;
SUB YPbPr.z, YPbPr.x, tmp.r;

ADD tmp.r, YPbPr.x, YPbPr.z; 
ADD tmp.b, YPbPr.x, YPbPr.y;
SUB tmp.g, YPbPr.x, YPbPr.z; 
SUB tmp.g, tmp.g, YPbPr.y;

MOV result.color, tmp;
END