ColorTween.cs 794 B

12345678910111213141516171819202122
  1. using Microsoft.Xna.Framework;
  2. namespace MonoGame.Extended.Tweening;
  3. /// <summary>
  4. /// A tween that animates a <see cref="Color"/> value using <see cref="Color.Lerp"/> for interpolation.
  5. /// </summary>
  6. public class ColorTween: Tween<Color>
  7. {
  8. internal ColorTween(object target, float duration, float delay, TweenMember<Color> member, Color endValue) : base(target, duration, delay, member, endValue)
  9. {
  10. }
  11. /// <summary>
  12. /// Interpolates the member's color value between the start and end colors for the given progress.
  13. /// </summary>
  14. /// <param name="n">The interpolation progress in the range [0, 1], after easing has been applied.</param>
  15. protected override void Interpolate(float n)
  16. {
  17. Member.Value = Color.Lerp(_startValue, _endValue, n);
  18. }
  19. }