// colour levels demo // draw level curves for each channel // author: info@toxi.co.uk int[] rLevels,gLevels,bLevels; char currChannel='r'; BImage img; void setup() { size(256,256); noStroke(); img=(loadImage("milan_rubbish.jpg")).copy(width,height); // setup conversion tables for each channel rLevels=new int[256]; gLevels=new int[256]; bLevels=new int[256]; // initially linear progression for(int i=0; i<256; i++) rLevels[i]=gLevels[i]=bLevels[i]=i; } void loop() { // display image according to current level setting for(int i=0; i>16&0xff]<<16 | gLevels[col>>8&0xff]<<8 | bLevels[col&0xff]; } // adjust curve if mouse is pressed // to avoid gaps in the table when mouse is moved too fast // all values from the previous position will be updated if (mousePressed) { // limit mouse position to window int cx=min(max(mouseX,0),width-1); int cy=min(max(mouseY,0),width-1); int px=min(max(pmouseX,0),width-1); int dir=(px