ID:264523
 
Code:
OBJ.icon +=rgb(,,,120)
sleep(20)
OBJ.icon +=rgb(,,,255)


Problem description:
for some reason the OBJ wont go back to being opaque can someone help me figure out why?

thanks


When you add two icons the result always has the lower of the two opacities. When you add a color with 120 alpha (about 47%) you're lowering the opacity by 53%, but when you add a color with 255 alpha you're lowering the opacity by 0%. Using the ICON_ADD blend will never increase the alpha of the icon.

Blending with the ICON_OR mode on the other hand gives the higher of the two opacities. However that also means in this case that any totally transparent areas would become totally opaque, so that isn't what you want either.

There are two good solutions here. One is to store the original icon and reuse it instead of trying to add opacity back in. This is actually the better way to go since it doesn't involve any additional icon math. The other approach is to use the IconProcs library or some of the techniques it uses internally. This library was created specifically to deal with the fact that a lot of people don't understand how to use alpha channels.

Lummox JR