Pergunta

i am writing a game where their is a slider that controls the alpha value of a color. It seems to be working fine except that now i want to invert the alpha value. For example if the value is 0 the value would become 255, and if the value was 255 it would become 0. Unfortunately my google searches turned up no easy way or built in methods for doing this. All help would be appreciated thanks.

Foi útil?

Solução

Do simple math :

int alphaValue = 255 - sliderValue

for example:

when sliderValue = 0, alphaValue = 255 - 0 = 255

when sliderValue = 255, alphaValue = 255 - 255 = 0

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top