Average the components or various colorchannels (red, green and blue) as stated earlier.

Wille


var    color1:Number = 0xFF0000
var    color2:Number = 0x0000FF

t_iBlend = blendComponents(color1, color2);
showComponents(t_iBlend);

function blendComponents(a_iColor1, a_iColor2){
   t_ar_Color1 = toComponents(a_iColor1);
   t_ar_Color2 = toComponents(a_iColor2);
   tr = (t_ar_Color1[0] + t_ar_Color2[0])/2;
   tg = (t_ar_Color1[1] + t_ar_Color2[1])/2;
   tb = (t_ar_Color1[2] + t_ar_Color2[2])/2;
   return tr << 16 | tg << 8 | tb;
}

function toComponents(a_iColor){
   t_ar_Color = Array();
   t_ar_Color.push(a_iColor>>16 & 0x0000FF); // red
   t_ar_Color.push(a_iColor>>8 & 0x0000FF); // green
   t_ar_Color.push(a_iColor & 0x0000FF); // blue
   return t_ar_Color;
}

function showComponents(a_iColor){
   trace("r:" + (a_iColor>>16 & 0x0000FF) ) ;
   trace("g:" + (a_iColor>>8  & 0x0000FF) ) ;
   trace("b:" + (a_iColor & 0x0000FF) ) ;
}



Joakim Carlgren wrote:
Whats the easiest way to calculate the average of two colors?

var    color1:Number = 0xFF0000

var    color2:Number = 0x0000FF

var    myColor:Color = new Color(my_mc)

        myColor.setRGB((color1 + color2) / 2)

I know its not this simple and probably I need to play with bitwise
operators..

Any easy way to solve this?
Joakim Carlgren



_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to