LinearGeometryKeyFrame.cs 990 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Windows;
  2. using System.Windows.Media;
  3. using System.Windows.Media.Animation;
  4. using HandyControl.Expression.Drawing;
  5. using HandyControl.Tools;
  6. namespace HandyControl.Media.Animation;
  7. public class LinearGeometryKeyFrame : GeometryKeyFrame
  8. {
  9. public LinearGeometryKeyFrame()
  10. {
  11. }
  12. public LinearGeometryKeyFrame(Geometry value) : base(value)
  13. {
  14. }
  15. public LinearGeometryKeyFrame(Geometry value, KeyTime keyTime) : base(value, keyTime)
  16. {
  17. }
  18. protected override Freezable CreateInstanceCore() => new LinearGeometryKeyFrame();
  19. protected override double[] InterpolateValueCore(double[] baseValue, double keyFrameProgress)
  20. {
  21. if (MathHelper.IsVerySmall(keyFrameProgress))
  22. {
  23. return baseValue;
  24. }
  25. if (MathHelper.AreClose(keyFrameProgress, 1))
  26. {
  27. return Numbers;
  28. }
  29. return AnimationHelper.InterpolateGeometryValue(baseValue, Numbers, keyFrameProgress);
  30. }
  31. }