Fade

by Foomer
[Share] [Zip]
ID:124385
 
(Thanks to AJX for providing the alpha gradient icon.)

This library makes it easy to fade the text parameter on interface controls from one color to another over a short period of time. This can be used to fade text into and out of view. If the text starts as black on a black background, it can be faded into white, and then faded back into black to blend in with the background again when the user is done viewing the text.

You can also use this library to fade various level of black over the map view. You can control the black's alpha levels, so anywhere between clear and black can be displayed, and you can cause it to fade to various levels of twilight and the pace you want.

TEXT FADING:
Fading text is easy, you just need to have a client, a control, and a desired color to fade into. When this library is included, there is a datum created when the world starts up called 'fade'. All you need to do is use this datum's Text() proc and you're in business:

If you want to fade your text from one color to another, just do this:

fade.Text(client, control, color, increments)

client is the client or mob (with a client) that the control belongs to.

control is the name of the control that the text which is going to be faded belongs to.

color is the color of the text to fade into.

increments is the number of steps that it takes to fade from the original color to the new color.

time is the amount of time (in ticks) that it takes to complete the entire transition. A transition should not have more increments than it has time to transition.

Take a look at the example to see it in action!

MAP FADING:
Whenever a new client is created while this library is included, the new client will have a /map_text screen object inserted into their screen list. This object will be displayed over the client's entire map view, from NORTHWEST to SOUTHEAST. The map fade object is actually black, but you can alter the alpha transparency level.

NOTE: If a map fade in progress detects that the map's alpha transparency is changing through some other means, it will cancel the fade. So you should be able to safely alter the alpha levels while a fade is in progress.

FADING CONTROLS:
If you want to have the map fade from one transparency level to another, you can do it like this:

fade.Map(client, alpha, increments, time)

client is the client or mob (with a client) that is viewing the map.

alpha is the level of transparency that you want to fade to.

increments is the number of steps that it takes to fade from the original alpha to the specified alpha. Too many increments may slow down your game, so unless you're using it while the player isn't doing anything, it might be good to cut back.

time is the amount of time (in ticks) that it takes to complete the entire transition. A transition should not have more increments than it has time to transition.

SET FADE LEVEL:
If you don't want the fade effects, you just want to set the alpha transparency directly, you can do it like this:

fade.MapSet(client, alpha)

client is the client or mob (with a client) that is viewing the map.

alpha is the level of transparency that you want to set the map to.

SET FADE LAYER:
If needed, you can also use this function to set which layer the alpha layer is displayed on, just in case this interferes with your HUD or other map displays..

fade.SetLayer(client, new_layer)

client is the client or mob (with a client) that is viewing the map.

new_layer is the layer to put the alpha layer on.