by using blend()
http://as.processing.org/reference/blend_.html
You can screen copy to a PImage buffer and then use this function, changing the alpha as you go.
The fade is another issue to do with bits left over when fading. This can be resolved by implementing a dedicated fade routine. I pulled this one from the Alpha board and it tackles precisely this problem. It may need some changing to run on Beta - PImage instead of BImage etc., but should get you what you need
Code:
int shift = 4;
int currentR, currentG, currentB;
int diffR, diffG, diffB;
int changeR, changeG, changeB;
int newR, newG, newB;
int targetR, targetG, targetB;
void fadescr(BImage source, color targetCol) {
targetR = (int)red(targetCol);
targetG = (int)green(targetCol);
targetB = (int)blue(targetCol);
int mindiff = int(pow(2,shift));
for (int i = 0; i < source.pixels.length; i++) {
// 1. Get colour compnents
// (same as calling red()/green()/blue(),
// but faster if in colorMode(RGB,255), and using ints)
currentR = (source.pixels[i] >> 16) & 0x000000ff;
currentG = (source.pixels[i] >> 8) & 0x000000ff;
currentB = source.pixels[i] & 0x000000ff;
// 2. Get difference between current and target
diffR = abs(targetR - currentR);
diffG = abs(targetG - currentG);
diffB = abs(targetB - currentB);
// 3. Calculate change as a fraction of the difference (using the shift value from above)
changeR = abs(diffR) >= mindiff ? diffR >> shift : diffR > 0 ? 1 : diffR < 0 ? -1 : 0;
changeG = abs(diffG) >= mindiff ? diffG >> shift : diffG > 0 ? 1 : diffG < 0 ? -1 : 0;
changeB = abs(diffB) >= mindiff ? diffB >> shift : diffB > 0 ? 1 : diffB < 0 ? -1 : 0;
// 4. Calculate the new colour
newR = currentR + changeR;
newG = currentG + changeG;
newB = currentB + changeB;
// 5. Put the components back together again
// (same as color(newR,newG,newB) in colorMode(RGB,255), but faster with ints
source.pixels[i] = (newR << 16) | (newG << 8) | newB;
}
}