Something came to mind,
I was writing a convenience function for fading in and fading out a color value ( not a whole color, simply one of it’s values ) and realised that, the value’s fade in and fade out rate was different for everyone and that for one reason, drawing speed ( FrameTime() ).
Here was the actual code I had:
[lua]function FadeInFadeOut( Start, End, Speed )
return math.Clamp( math.abs( Start - End ) * math.sin( CurTime() * Speed ) + ( 255 - Start ), Start, End )
end[/lua]
It has been tested and proved to work smoothly, but unfortunatly, the speed set in will be different for everyone because of their FrameTime(), so I thought, how about I set a ratio using FrameTime(). Ex:
( Speed / FrameTime() ) * 100
That would make it so, people with a slower FrameTime() would get a faster Speed value, as opposite to those with a faster FrameTime(), they would get a slower speed value.
So far all this code and the ratio works perfectly once used in a draw event. The problem is, since I am using math.sin to make my value oscillate from low to high, the FrameTime() part, being inconsistant, comes in and ruins the smoothness of the fade.
Does someone have a way to do what I am trying to accomplish? Or possibly know if there is a work around inconsistant FrameTime()?
Thanks for taking the time.
( ps. If you test this function, Start is assumed to be a lesser value than End. )