Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know I can take a color and multiply it by a float to reduce its alpha like that:

Color color = Color.Green * 0.15f;

But how do I return the color's alpha to it's original value?

I tried doing this:

color.A = 255;

But it seems like I get a different color. (The RGB are different then those of the original color).

Also, just changing the alpha of the original color (directly, not by multiplying) doesn't make it transparent..

share|improve this question
Divide by the same amount. – Vaughan Hilts Aug 14 '13 at 13:47
It isn't possible to divide for some reason.. – Ofir Aug 14 '13 at 14:18
@Ofir See how… has an op_Multiply function? This is why color * float works. There is no op_Division but this should work color = color * (1 / .15). – ClassicThunder Aug 14 '13 at 14:32
How silly - but yes, just use inverted mulitplication. Thanks @ClassicThunder – Vaughan Hilts Aug 14 '13 at 14:38
It works but It's not 100% accurate. Thanks anyway, I'll just do it in another way. – Ofir Aug 14 '13 at 14:41

You are multiplying all color components, not only the alpha channel (Color.Green * 0.15f;) To only change the alpha:

Color color = Color.Green;
color.A *= 0.15f;
share|improve this answer
This is wrong because it is not taking into account the fact that he is using XNA and thus premultiplied alpha. – ClassicThunder Aug 14 '13 at 12:28
Like I wrote in my post, directly changing the alpha doesn't make the object transparent. – Ofir Aug 14 '13 at 12:40
-1 because Xna uses premultiplied alpha – Blau Aug 14 '13 at 13:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.