# XNA changing color alpha

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..

• 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 msdn.microsoft.com/en-us/library/… 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;