资源简介
winform 自定义温度计控件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace AnimationLibrary
{
/// <summary>
/// 线性动画函数(算法基本由Silverlight提取出来)
/// </summary>
[Description("线性动画函数(算法基本由Silverlight提取出来)")]
public static class AnimationCore
{
#region UniformMotion
/// <summary>
/// 匀速
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <returns></returns>
public static double UniformMotion(double origin, double transform, double usedTime, double allTime)
{
return origin transform * UniformMotionCore(usedTime, allTime);
}
/// <summary>
/// 匀速
/// </summary>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <returns></returns>
public static double UniformMotionCore(double usedTime, double allTime)
{
return usedTime / allTime;
}
#endregion
#region Ease
/// <summary>
/// 变速
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseIn(double origin, double transform, double usedTime, double allTime, double power)
{
return origin transform * EaseInCore(usedTime / allTime, power);
}
/// <summary>
/// 变速
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseInCore(double progressTime, double power)
{
power = Math.Max(0.0, power);
return Math.Pow(progressTime, power);
}
/// <summary>
/// 变速
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseOut(double origin, double transform, double usedTime, double allTime, double power)
{
return origin transform * (EaseOutCore(usedTime / allTime, power));
}
/// <summary>
/// 变速
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseOutCore(double progressTime, double power)
{
return 1.0 - EaseInCore(1.0 - progressTime, power);
}
/// <summary>
/// 变速
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseBoth(double origin, double transform, double usedTime, double allTime, double power)
{
return origin transform * EaseBothCore(usedTime / allTime, power);
}
/// <summary>
/// 变速
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseBothCore(double progressTime, double power)
{
if (progressTime >= 0.5)
return (1.0 - EaseInCore((1.0 - progressTime) * 2.0, power)) * 0.5 0.5;
return EaseInCore(progressTime * 2.0, power) * 0.5;
}
#endregion
#region Back
/// <summary>
/// 收缩
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackIn(double origin, double transform, double usedTime, double allTime, double power, double amplitude)
{
return origin transform * BackInCore((usedTime / allTime), power, amplitude);
}
/// <summary>
/// 收缩
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackInCore(double progressTime, double power, double amplitude)
{
amplitude = Math.Max(0.0, amplitude);
return Math.Pow(progressTime, power) - progressTime * amplitude * Math.Sin(Math.PI * progressTime);
}
/// <summary>
/// 收缩
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackOut(double origin, double transform, double usedTime, double allTime, double power, double amplitude)
{
return origin transform * BackOutCore((usedTime / allTime), power, amplitude);
}
/// <summary>
/// 收缩
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackOutCore(double progressTime, double power, double amplitude)
{
return 1.0 - BackInCore(1.0 - progressTime, power, amplitude);
}
/// <summary>
/// 收缩
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackBoth(double origin, double transform, double usedTime, double allTime, double power, double amplitude)
{
return origin transform * BackBothCore(usedTime / allTime, power, amplitude);
}
/// <summary>
/// 收缩
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackBothCore(double progressTime, double power, double amplitude)
{
if (progressTime >= 0.5)
return (1.0 - BackInCore((1.0 - progressTime) * 2.0, power, amplitude)) * 0.5 0.5;
return BackInCore(progressTime * 2.0, power, amplitude) * 0.5;
}
#endregion
#region Bounce
/// <summary>
/// 弹球减振 加速
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceIn(double origin, double transform, double usedTime, double allTime, int bounces, double bounciness)
{
return origin transform * BounceInCore((usedTime / allTime), bounces, bounciness);
}
/// <summary>
/// 弹球减振 加速
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceInCore(double progressTime, int bounces, double bounciness)
{
double y1 = Math.Max(0.0, (double)bounces);
double num1 = bounciness;
if (num1 < 1.0 || Math.Abs(num1 - 1.0) < 2.22044604925031E-15)
num1 = 1001.0 / 1000.0;
double num2 = Math.Pow(num1, y1);
double num3 = 1.0 - num1;
double num4 = (1.0 - num2) / num3 num2 * 0.5;
double y2 = Math.Floor(Math.Log(-(progressTime * num4) * (1.0 - num1) 1.0, num1));
double y3 = y2 1.0;
double num5 = (1.0 - Math.Pow(num1, y2)) / (num3 * num4);
double num6 = (1.0 - Math.Pow(num1, y3)) / (num3 * num4);
double num7 = (num5 num6) * 0.5;
double num8 = progressTime - num7;
double num9 = num7 - num5;
return -Math.Pow(1.0 / num1, y1 - y2) / (num9 * num9) * (num8 - num9) * (num8 num9);
}
/// <summary>
/// 加速 弹球减振
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceOut(double origin, double transform, double usedTime, double allTime, int bounces, double bounciness)
{
return origin transform * BounceOutCore((usedTime / allTime), bounces, bounciness);
}
/// <summary>
/// 加速 弹球减振
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceOutCore(double progressTime, int bounces, double bounciness)
{
return 1.0 - BounceInCore(1.0 - progressTime, bounces, bounciness);
}
/// <summary>
/// 弹球减振 加速 弹球减振
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceBoth(double origin, double transform, double usedTime, double allTime, int bounces, double bounciness)
{
return origin transform * BounceBothCore(usedTime / allTime, bounces, bounciness);
}
/// <summary>
/// 弹球减振 加速 弹球减振
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceBothCore(double progressTime, int bounces, double bounciness)
{
if (progressTime >= 0.5)
return (1.0 - BounceInCore((1.0 - progressTime) * 2.0, bounces, bounciness)) * 0.5 0.5;
return BounceInCore(progressTime * 2.0, bounces, bounciness) * 0.5;
}
#endregion
#region Elastic
/// <summary>
/// Elastic
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticIn(double origin, double transform, double usedTime, double allTime, int oscillations, double springiness)
{
return origin transform * ElasticInCore((usedTime / allTime), oscillations, springiness);
}
/// <summary>
/// Elastic
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticInCore(double progressTime, int oscillations, double springiness)
{
oscillations = Math.Max(0, oscillations);
springiness = Math.Max(0.0, springiness);
return (!(Math.Abs(springiness) < 2.22044604925031E-15) ? (Math.Exp(springiness * progressTime) - 1.0) / (Math.Exp(springiness) - 1.0) : progressTime) * Math.Sin((2.0 * Math.PI * oscillations Math.PI / 2.0) * progressTime);
}
/// <summary>
/// Elastic
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticOut(double origin, double transform, double usedTime, double allTime, int oscillations, double springiness)
{
return origin transform * ElasticOutCore((usedTime / allTime), oscillations, springiness);
}
/// <summary>
/// Elastic
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticOutCore(double progressTime, int oscillations, double springiness)
{
return 1.0 - ElasticInCore(1.0 - progressTime, oscillations, springiness);
}
/// <summary>
/// Elastic
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticBoth(double origin, double transform, double usedTime, double allTime, int oscillations, double springiness)
{
return origin transform * ElasticBothCore(usedTime / allTime, oscillations, springiness);
}
/// <summary>
/// Elastic
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticBothCore(double progressTime, int oscillations, double springiness)
{
if (progressTime >= 0.5)
return (1.0 - ElasticInCore((1.0 - progressTime) * 2.0, oscillations, springiness)) * 0.5 0.5;
return ElasticInCore(progressTime * 2.0, oscillations, springiness) * 0.5;
}
#endregion
#region Quadratic
/// <summary>
/// 二次
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <returns></returns>
public static double QuadraticIn(double origin, double transform, double usedTime, double allTime)
{
return origin transform * QuadraticInCore(usedTime / allTime);
}
/// <summary>
/// 二次
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <returns></returns>
public static double QuadraticInCore(double progressTime)
{
return -4 * Math.Pow((progressTime - 0.5), 2.0) 1.0;
}
/// <summary>
/// 二次
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <returns></returns>
public static double QuadraticOut(double origin, double transform, double usedTime, double allTime)
{
return origin transform * QuadraticOutCore(usedTime / allTime);
}
/// <summary>
/// 二次
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <returns></returns>
public static double QuadraticOutCore(double progressTime)
{
if (progressTime >= 0.5)
{
return 4 * Math.Pow((progressTime - 0.5 - 0.5), 2.0);
}
return 4 * Math.Pow((progressTime), 2.0);
}
#endregion
}
/// <summary>
/// 动画类型
/// </summary>
[Description("动画类型")]
public enum AnimationTypes
{
UniformMotion,
EaseIn,
EaseOut,
EaseBoth,
BackIn,
BackOut,
BackBoth,
BounceIn,
BounceOut,
BounceBoth,
ElasticIn,
ElasticOut,
ElasticBoth,
QuadraticIn,
QuadraticOut
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace AnimationLibrary
{
/// <summary>
/// 线性动画函数(算法基本由Silverlight提取出来)
/// </summary>
[Description("线性动画函数(算法基本由Silverlight提取出来)")]
public static class AnimationCore
{
#region UniformMotion
/// <summary>
/// 匀速
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <returns></returns>
public static double UniformMotion(double origin, double transform, double usedTime, double allTime)
{
return origin transform * UniformMotionCore(usedTime, allTime);
}
/// <summary>
/// 匀速
/// </summary>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <returns></returns>
public static double UniformMotionCore(double usedTime, double allTime)
{
return usedTime / allTime;
}
#endregion
#region Ease
/// <summary>
/// 变速
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseIn(double origin, double transform, double usedTime, double allTime, double power)
{
return origin transform * EaseInCore(usedTime / allTime, power);
}
/// <summary>
/// 变速
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseInCore(double progressTime, double power)
{
power = Math.Max(0.0, power);
return Math.Pow(progressTime, power);
}
/// <summary>
/// 变速
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseOut(double origin, double transform, double usedTime, double allTime, double power)
{
return origin transform * (EaseOutCore(usedTime / allTime, power));
}
/// <summary>
/// 变速
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseOutCore(double progressTime, double power)
{
return 1.0 - EaseInCore(1.0 - progressTime, power);
}
/// <summary>
/// 变速
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseBoth(double origin, double transform, double usedTime, double allTime, double power)
{
return origin transform * EaseBothCore(usedTime / allTime, power);
}
/// <summary>
/// 变速
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值2)</param>
/// <returns></returns>
public static double EaseBothCore(double progressTime, double power)
{
if (progressTime >= 0.5)
return (1.0 - EaseInCore((1.0 - progressTime) * 2.0, power)) * 0.5 0.5;
return EaseInCore(progressTime * 2.0, power) * 0.5;
}
#endregion
#region Back
/// <summary>
/// 收缩
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackIn(double origin, double transform, double usedTime, double allTime, double power, double amplitude)
{
return origin transform * BackInCore((usedTime / allTime), power, amplitude);
}
/// <summary>
/// 收缩
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackInCore(double progressTime, double power, double amplitude)
{
amplitude = Math.Max(0.0, amplitude);
return Math.Pow(progressTime, power) - progressTime * amplitude * Math.Sin(Math.PI * progressTime);
}
/// <summary>
/// 收缩
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackOut(double origin, double transform, double usedTime, double allTime, double power, double amplitude)
{
return origin transform * BackOutCore((usedTime / allTime), power, amplitude);
}
/// <summary>
/// 收缩
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackOutCore(double progressTime, double power, double amplitude)
{
return 1.0 - BackInCore(1.0 - progressTime, power, amplitude);
}
/// <summary>
/// 收缩
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackBoth(double origin, double transform, double usedTime, double allTime, double power, double amplitude)
{
return origin transform * BackBothCore(usedTime / allTime, power, amplitude);
}
/// <summary>
/// 收缩
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="power">动画曲线幂(默认值3)</param>
/// <param name="amplitude">收缩与相关联的幅度动画。此值必须大于或等于 0。 默认值为 1。</param>
/// <returns></returns>
public static double BackBothCore(double progressTime, double power, double amplitude)
{
if (progressTime >= 0.5)
return (1.0 - BackInCore((1.0 - progressTime) * 2.0, power, amplitude)) * 0.5 0.5;
return BackInCore(progressTime * 2.0, power, amplitude) * 0.5;
}
#endregion
#region Bounce
/// <summary>
/// 弹球减振 加速
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceIn(double origin, double transform, double usedTime, double allTime, int bounces, double bounciness)
{
return origin transform * BounceInCore((usedTime / allTime), bounces, bounciness);
}
/// <summary>
/// 弹球减振 加速
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceInCore(double progressTime, int bounces, double bounciness)
{
double y1 = Math.Max(0.0, (double)bounces);
double num1 = bounciness;
if (num1 < 1.0 || Math.Abs(num1 - 1.0) < 2.22044604925031E-15)
num1 = 1001.0 / 1000.0;
double num2 = Math.Pow(num1, y1);
double num3 = 1.0 - num1;
double num4 = (1.0 - num2) / num3 num2 * 0.5;
double y2 = Math.Floor(Math.Log(-(progressTime * num4) * (1.0 - num1) 1.0, num1));
double y3 = y2 1.0;
double num5 = (1.0 - Math.Pow(num1, y2)) / (num3 * num4);
double num6 = (1.0 - Math.Pow(num1, y3)) / (num3 * num4);
double num7 = (num5 num6) * 0.5;
double num8 = progressTime - num7;
double num9 = num7 - num5;
return -Math.Pow(1.0 / num1, y1 - y2) / (num9 * num9) * (num8 - num9) * (num8 num9);
}
/// <summary>
/// 加速 弹球减振
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceOut(double origin, double transform, double usedTime, double allTime, int bounces, double bounciness)
{
return origin transform * BounceOutCore((usedTime / allTime), bounces, bounciness);
}
/// <summary>
/// 加速 弹球减振
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceOutCore(double progressTime, int bounces, double bounciness)
{
return 1.0 - BounceInCore(1.0 - progressTime, bounces, bounciness);
}
/// <summary>
/// 弹球减振 加速 弹球减振
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceBoth(double origin, double transform, double usedTime, double allTime, int bounces, double bounciness)
{
return origin transform * BounceBothCore(usedTime / allTime, bounces, bounciness);
}
/// <summary>
/// 弹球减振 加速 弹球减振
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="bounces">反弹次数。值必须大于或等于零(默认值为3)</param>
/// <param name="bounciness">指定反弹动画的弹性大小。虽然较高的值都会导致反弹 (弹性较小),此属性中的结果很少或者反弹低值会丢失反弹 (弹性较大) 之间的高度。此值必须是正数(默认值为 2)</param>
/// <returns></returns>
public static double BounceBothCore(double progressTime, int bounces, double bounciness)
{
if (progressTime >= 0.5)
return (1.0 - BounceInCore((1.0 - progressTime) * 2.0, bounces, bounciness)) * 0.5 0.5;
return BounceInCore(progressTime * 2.0, bounces, bounciness) * 0.5;
}
#endregion
#region Elastic
/// <summary>
/// Elastic
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticIn(double origin, double transform, double usedTime, double allTime, int oscillations, double springiness)
{
return origin transform * ElasticInCore((usedTime / allTime), oscillations, springiness);
}
/// <summary>
/// Elastic
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticInCore(double progressTime, int oscillations, double springiness)
{
oscillations = Math.Max(0, oscillations);
springiness = Math.Max(0.0, springiness);
return (!(Math.Abs(springiness) < 2.22044604925031E-15) ? (Math.Exp(springiness * progressTime) - 1.0) / (Math.Exp(springiness) - 1.0) : progressTime) * Math.Sin((2.0 * Math.PI * oscillations Math.PI / 2.0) * progressTime);
}
/// <summary>
/// Elastic
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticOut(double origin, double transform, double usedTime, double allTime, int oscillations, double springiness)
{
return origin transform * ElasticOutCore((usedTime / allTime), oscillations, springiness);
}
/// <summary>
/// Elastic
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticOutCore(double progressTime, int oscillations, double springiness)
{
return 1.0 - ElasticInCore(1.0 - progressTime, oscillations, springiness);
}
/// <summary>
/// Elastic
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticBoth(double origin, double transform, double usedTime, double allTime, int oscillations, double springiness)
{
return origin transform * ElasticBothCore(usedTime / allTime, oscillations, springiness);
}
/// <summary>
/// Elastic
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <param name="oscillations">目标来回滑过动画目标的次数。此值必须大于或等于0 (默认值为3)</param>
/// <param name="springiness">弹簧铡度。 越小的 Springiness 值为,严格 spring,通过每个振动的强度减小的速度越快弹性。一个正数(默认值为3)</param>
/// <returns></returns>
public static double ElasticBothCore(double progressTime, int oscillations, double springiness)
{
if (progressTime >= 0.5)
return (1.0 - ElasticInCore((1.0 - progressTime) * 2.0, oscillations, springiness)) * 0.5 0.5;
return ElasticInCore(progressTime * 2.0, oscillations, springiness) * 0.5;
}
#endregion
#region Quadratic
/// <summary>
/// 二次
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <returns></returns>
public static double QuadraticIn(double origin, double transform, double usedTime, double allTime)
{
return origin transform * QuadraticInCore(usedTime / allTime);
}
/// <summary>
/// 二次
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <returns></returns>
public static double QuadraticInCore(double progressTime)
{
return -4 * Math.Pow((progressTime - 0.5), 2.0) 1.0;
}
/// <summary>
/// 二次
/// </summary>
/// <param name="origin">要变换的起始值</param>
/// <param name="transform">要变换的总值</param>
/// <param name="usedTime">已进行动画时间</param>
/// <param name="allTime">总动画时间</param>
/// <returns></returns>
public static double QuadraticOut(double origin, double transform, double usedTime, double allTime)
{
return origin transform * QuadraticOutCore(usedTime / allTime);
}
/// <summary>
/// 二次
/// </summary>
/// <param name="progressTime">已进行动画时间/总动画时间</param>
/// <returns></returns>
public static double QuadraticOutCore(double progressTime)
{
if (progressTime >= 0.5)
{
return 4 * Math.Pow((progressTime - 0.5 - 0.5), 2.0);
}
return 4 * Math.Pow((progressTime), 2.0);
}
#endregion
}
/// <summary>
/// 动画类型
/// </summary>
[Description("动画类型")]
public enum AnimationTypes
{
UniformMotion,
EaseIn,
EaseOut,
EaseBoth,
BackIn,
BackOut,
BackBoth,
BounceIn,
BounceOut,
BounceBoth,
ElasticIn,
ElasticOut,
ElasticBoth,
QuadraticIn,
QuadraticOut
}
}
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace AnimationLibrary
{
///
/// 线性动画函数(算法基本由Silverlight提取出来)
///
[Description(“线性动画函数(算法基本由Silverlight提取出来)“)]
public static class AnimationCore
{
#region UniformMotion
///
/// 匀速
///
/// 要变换的起始值
/// 要变换的总值
/// 已进行动画时间
/// 总动画时间
///
public static double UniformMotion(double origin double transform double usedTime double allTime)
{
return origin + transform * UniformMotionCore(usedTime allTime);
}
///
/// 匀速
///
/// 已进行动画时间
/// 总动画时间
///
public static doub
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-06-22 13:30 温度计控件\
目录 0 2020-06-22 13:30 温度计控件\AnimationLibrary\
文件 21704 2020-06-19 21:10 温度计控件\AnimationLibrary\AnimationCore.cs
文件 2652 2020-06-22 11:49 温度计控件\AnimationLibrary\AnimationLibrary.csproj
文件 21699 2020-06-19 21:10 温度计控件\AnimationLibrary\AnimationTimer.cs
目录 0 2020-06-22 13:30 温度计控件\AnimationLibrary\bin\
目录 0 2020-06-22 13:31 温度计控件\AnimationLibrary\bin\Debug\
文件 19968 2020-06-22 13:31 温度计控件\AnimationLibrary\bin\Debug\AnimationLibrary.dll
文件 44544 2020-06-22 13:31 温度计控件\AnimationLibrary\bin\Debug\AnimationLibrary.pdb
目录 0 2020-06-22 13:30 温度计控件\AnimationLibrary\Design\
文件 1005 2020-06-19 21:10 温度计控件\AnimationLibrary\Design\EmptyExpandableob
目录 0 2020-06-22 13:30 温度计控件\AnimationLibrary\obj\
目录 0 2020-06-22 13:31 温度计控件\AnimationLibrary\obj\Debug\
文件 452 2020-06-22 13:31 温度计控件\AnimationLibrary\obj\Debug\AnimationLibrary.csproj.FileListAbsolute.txt
文件 19968 2020-06-22 13:31 温度计控件\AnimationLibrary\obj\Debug\AnimationLibrary.dll
文件 44544 2020-06-22 13:31 温度计控件\AnimationLibrary\obj\Debug\AnimationLibrary.pdb
文件 5880 2020-06-22 13:31 温度计控件\AnimationLibrary\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2020-06-22 12:43 温度计控件\AnimationLibrary\obj\Debug\TempPE\
目录 0 2020-06-22 13:30 温度计控件\AnimationLibrary\Properties\
文件 1410 2020-06-22 01:55 温度计控件\AnimationLibrary\Properties\AssemblyInfo.cs
目录 0 2020-06-22 13:30 温度计控件\ControlLibraryExt\
目录 0 2020-06-22 13:30 温度计控件\ControlLibraryExt\bin\
目录 0 2020-06-22 13:31 温度计控件\ControlLibraryExt\bin\Debug\
文件 19968 2020-06-22 13:31 温度计控件\ControlLibraryExt\bin\Debug\AnimationLibrary.dll
文件 44544 2020-06-22 13:31 温度计控件\ControlLibraryExt\bin\Debug\AnimationLibrary.pdb
文件 28672 2020-06-27 23:16 温度计控件\ControlLibraryExt\bin\Debug\ControlLibraryExt.dll
文件 46592 2020-06-27 23:16 温度计控件\ControlLibraryExt\bin\Debug\ControlLibraryExt.pdb
目录 0 2020-06-22 12:43 温度计控件\ControlLibraryExt\bin\Release\
文件 3768 2020-06-22 13:31 温度计控件\ControlLibraryExt\ControlLibraryExt.csproj
目录 0 2020-06-22 13:31 温度计控件\ControlLibraryExt\Design\
文件 1244 2020-06-22 13:31 温度计控件\ControlLibraryExt\Design\ImaginaryLineBorderExtDesigner.cs
............此处省略61个文件信息
- 上一篇:C# 一元线性回归
- 下一篇:Linq to SQL 入门级教程
相关资源
- winform 鼠标聚焦 焦点时变色
- winform仿qq停靠屏幕边缘
- winform手动改变自定义窗口大小
- winform鼠标穿透(新)
- C#winform打印指定区域 -控件拖动 -设置
- winform 垂直交错效果显示图像
- winform 浮雕效果的图像
- WPF 自定义标题的winform窗体实现源码
- 仿苹果Safari 自定义控件(tab切换控件
- C# WinForm取命令行参数
- Winform中鼠标穿透效果,类似桌面壁纸
- winform 利用image实现变脸小动画
- winform中set文件的写入
- winform操作webform后台
- winform程序默认以管理员身份运行 (
- 自定义Winform窗体例子(入门级)122
- js调用winform类中的方法
- winform收银机客显器LED测试软件demo
- winform 窗体换肤技巧
- winform富文本编辑器(kwig)
- C# 小软件:WINFORM 浏览器
- WinForm实现文件的压缩和解压,并思考
- winform右下角最小化
- WinForm联合halcon加载一张图片
- winform调用webservice
- WinForm实现win7 Aero磨砂效果
- c# winform FTP连接服务器对文件进行操作
- WinformHTMLEditor winform 富文本编辑器
- 1252056375_ddvip_2352 C#下基于WCF的聊天程
- 50847002C C# WinForm实践开发教程
评论
共有 条评论