Re: [Flashcoders] Get the average of 2 colors

2006-03-10 Thread Helen Triolo
Probably the best thing would be to get the average for each channel 
individually and then combine them.  I have an example of separate color 
channel manipulation (the old Color class way) at the bottom of this 
page http://flash-creations.com/notes/asclass_color.php if that helps.


Helen

--
http://flash-creations.com
http://i-technica.com



Joakim Carlgren wrote:


Whats the easiest way to calculate the average of two colors?





varcolor1:Number = 0xFF

varcolor2:Number = 0xFF



varmyColor: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


Re: [Flashcoders] Get the average of 2 colors

2006-03-10 Thread Danny Kodicek

Whats the easiest way to calculate the average of two colors?


Your answer sounds fine, given that there's not really a precise definition 
of the 'average of two colours'. But certainly if you were interpolating 
between colours, that's what you'd do.


There are two main ways to combine colours: additively, as you did, or 
multiplicatively (how's that for a word?), otherwise called 'modulating'. We 
use multiplicative combinations of colours for things like reflections, 
where the colour of one object affects the light coming off it. Additive 
blending is used when we have two sources of colour shining on the same 
spot. In your case, I'm pretty sure additive is what you're looking for.


Danny 


___
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


Re: [Flashcoders] Get the average of 2 colors

2006-03-10 Thread Janis Radins
Get my ColorTween class at www.mediaverk.lv/asd/com/jR/Math/ColorTween.as
Then do the simple thing:
import com.jR.Math.ColorTween;
var midColor:Number = new ColorTween([0xFF, 0xFF]).getPoint(255/2);
trace(0x+midColor.toString(16))

2006/3/10, Joakim Carlgren [EMAIL PROTECTED]:

 Whats the easiest way to calculate the average of two colors?





 varcolor1:Number = 0xFF

 varcolor2:Number = 0xFF



 varmyColor: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


Re: [Flashcoders] Get the average of 2 colors

2006-03-10 Thread Wille Frankenhaeuser
Average the components or various colorchannels (red, green and blue) as 
stated earlier.


Wille


varcolor1:Number = 0xFF
varcolor2:Number = 0xFF

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_iColor16  0xFF); // red
   t_ar_Color.push(a_iColor8  0xFF); // green
   t_ar_Color.push(a_iColor  0xFF); // blue
   return t_ar_Color;
}

function showComponents(a_iColor){
   trace(r: + (a_iColor16  0xFF) ) ;
   trace(g: + (a_iColor8   0xFF) ) ;
   trace(b: + (a_iColor  0xFF) ) ;
}



Joakim Carlgren wrote:

Whats the easiest way to calculate the average of two colors?

 

 


varcolor1:Number = 0xFF

varcolor2:Number = 0xFF

 


varmyColor: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


Re: [Flashcoders] Get the average of 2 colors

2006-03-10 Thread Danny Kodicek


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


Crap. That's what I meant, obviously.

Writing without thinking. Got to stop doing that.

Danny
___
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


RE: [Flashcoders] Get the average of 2 colors

2006-03-10 Thread Joakim Carlgren
Thanks Janis...works great. Will take a closer look later.

Kindly
Joakim Carlgren

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Janis
Radins
Sent: den 10 mars 2006 15:17
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Get the average of 2 colors

Get my ColorTween class at
www.mediaverk.lv/asd/com/jR/Math/ColorTween.as
Then do the simple thing:
import com.jR.Math.ColorTween;
var midColor:Number = new ColorTween([0xFF,
0xFF]).getPoint(255/2);
trace(0x+midColor.toString(16))

2006/3/10, Joakim Carlgren [EMAIL PROTECTED]:

 Whats the easiest way to calculate the average of two colors?





 varcolor1:Number = 0xFF

 varcolor2:Number = 0xFF



 varmyColor: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
___
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


Re: [Flashcoders] Get the average of 2 colors

2006-03-10 Thread Janis Radins
you're wellcome

2006/3/10, Joakim Carlgren [EMAIL PROTECTED]:

 Thanks Janis...works great. Will take a closer look later.

 Kindly
 Joakim Carlgren

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Janis
 Radins
 Sent: den 10 mars 2006 15:17
 To: Flashcoders mailing list
 Subject: Re: [Flashcoders] Get the average of 2 colors

 Get my ColorTween class at
 www.mediaverk.lv/asd/com/jR/Math/ColorTween.as
 Then do the simple thing:
 import com.jR.Math.ColorTween;
 var midColor:Number = new ColorTween([0xFF,
 0xFF]).getPoint(255/2);
 trace(0x+midColor.toString(16))

 2006/3/10, Joakim Carlgren [EMAIL PROTECTED]:
 
  Whats the easiest way to calculate the average of two colors?
 
 
 
 
 
  varcolor1:Number = 0xFF
 
  varcolor2:Number = 0xFF
 
 
 
  varmyColor: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
 ___
 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