I’m making a matrix effect thing using AS3. Everything is going good except for color transitions.
Basically i have two bitmap images, one is where the leading white letters are falling, another is where the letters are printed on to, and i use a color matrix filter to slowly fade the letters away and tint its color.
And this tinting of color is what im having problems with right now. My method works for colors like 0x00FF00, 0xFF0000, or any colors with only 0s and Fs. Other colors with hex values between F and 0 will inevitably turn into a color of 0s and Fs or jus turn black, due to …
var cmf:ColorMatrixFilter =new ColorMatrixFilter(hexToMatrix(0x00FF00,90));
function hexToMatrix ( rgb, alpha )
{
var matrix:Array = [];
matrix = matrix.concat([1, 0, 0, 0, (-255+col[0])/3]); // red
matrix = matrix.concat([0, 1, 0, 0, (-255+col[1])/3]); // green
matrix = matrix.concat([0, 0, 1, 0, (-255+col[2])/3]); // blue
matrix = matrix.concat([0, 0, 0, alpha/100, 0]); // alpha
return matrix;
}
//inside my enterframe loop
trailBitMap.applyFilter(trailBitMap,trailBitMap.rect,new Point(0,0),cmf);
The problem im facing right now, is that it keeps incrementing the bitmap with the cmf till each component (Red, Green and Blue) reaches over 255, and well at that point it basically turns black. And im out of ideas as how to make it stop adding each red green blue component when it reaches the designated value for each component.
To show you what i mean
color : RED 0, GREEN 255, BLUE 0
color : RED 50, GREEN 140, BLUE 50
my idea right now is to scan through each pixel and add its RGB component individually checking if it has reached the designated value or not, but ive no idea how to go about doing this and i think it might cause lagg.
Help plz