Omg. I should start to math all over again.
"RGB(clamp(lerp(GetRed(particle('fadetoColor')), GetRed(particle('fadefromColor')), particle('currentcolortime') / particle('colorfadetime')), 0, 255), clamp(lerp(GetGreen(particle('fadetoColor')), GetGreen(particle('fadefromColor')), particle('currentcolortime') / particle('colorfadetime')), 0, 255), clamp(lerp(GetBlue(particle('fadetoColor')), GetBlue(particle('fadefromColor')), particle('currentcolortime') / particle('colorfadetime')), 0, 255))"
What are you talking about. How did you calculate it :). lerp inside of clamp. Sin, cos, tan. I wish I had listened my math teacher on my collage years.
Thank you for sharing.
You're welcome :)
But don't get too afraid just of long phrases. It really is simple, as soon as you follow the logic behind it.
The values of the three color channels are linearily interpolated, so that all three change in the same amount of time. This is what lerp is for. The t-value of lerp ist calculated as a ratio of the total time given to interpolate and the actual time.
Clamp just serves one purpose: timedelta is constantly substracted from currentcolortime, and so can get negative, which would make the t-value negative also, and the color would continue to change (but in an unwanted way). Something was needed to prevent that the color value will get negative and clamp is one way of doing so. You could also just use max(formula, 0).
The fun of sin and cos is that they are so easy to use. Just give it an angle and it tells you a position, I love it ;)
And when used to animate something it also has some kind of built-in deceleration/acceleration. I did go into detail somewhere else, so I won't repeat it, but if you could only learn and use two functions, I'd say go with sin and cos. What you can realize with only those is so versatile.