修改
This commit is contained in:
148
CleanMachineHMI/Utils/AnimateBase.cs
Normal file
148
CleanMachineHMI/Utils/AnimateBase.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
// LEase.AnimateBase
|
||||
using System;
|
||||
using LEase;
|
||||
|
||||
public class AnimateBase
|
||||
{
|
||||
public static double Back(double x, LEaseMode easeMode)
|
||||
{
|
||||
switch (easeMode)
|
||||
{
|
||||
case LEaseMode.EaseIn:
|
||||
return 2.70158 * x * x * x - 1.70158 * x * x;
|
||||
case LEaseMode.EaseOut:
|
||||
return 1.0 + 2.70158 * Math.Pow(x - 1.0, 3.0) + 1.70158 * Math.Pow(x - 1.0, 2.0);
|
||||
case LEaseMode.EaseInOut:
|
||||
return (x < 0.5) ? (Math.Pow(2.0 * x, 2.0) * (7.189819 * x - 2.5949095) / 2.0) : ((Math.Pow(2.0 * x - 2.0, 2.0) * (7.189819 * x - 4.5949095) + 2.0) / 2.0);
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
private static double BounceOut(double x)
|
||||
{
|
||||
if (x < 0.36363636363636365)
|
||||
{
|
||||
return 7.5625 * x * x;
|
||||
}
|
||||
if (x < 0.72727272727272729)
|
||||
{
|
||||
return 7.5625 * (x -= 0.54545454545454541) * x + 0.75;
|
||||
}
|
||||
if (x < 0.90909090909090906)
|
||||
{
|
||||
return 7.5625 * (x -= 0.81818181818181823) * x + 0.9375;
|
||||
}
|
||||
return 7.5625 * (x -= 21.0 / 22.0) * x + 63.0 / 64.0;
|
||||
}
|
||||
|
||||
public static double Bounce(double x, LEaseMode easeMode)
|
||||
{
|
||||
switch (easeMode)
|
||||
{
|
||||
case LEaseMode.EaseIn:
|
||||
return 1.0 - BounceOut(1.0 - x);
|
||||
case LEaseMode.EaseOut:
|
||||
return BounceOut(x);
|
||||
case LEaseMode.EaseInOut:
|
||||
return (x < 0.5) ? ((1.0 - BounceOut(1.0 - 2.0 * x)) / 2.0) : ((1.0 + BounceOut(2.0 * x - 1.0)) / 2.0);
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
public static double Circle(double x, LEaseMode easeMode)
|
||||
{
|
||||
switch (easeMode)
|
||||
{
|
||||
case LEaseMode.EaseIn:
|
||||
return 1.0 - Math.Sqrt(1.0 - Math.Pow(x, 2.0));
|
||||
case LEaseMode.EaseOut:
|
||||
return Math.Sqrt(1.0 - Math.Pow(x - 1.0, 2.0));
|
||||
case LEaseMode.EaseInOut:
|
||||
return (x < 0.5) ? ((1.0 - Math.Sqrt(1.0 - Math.Pow(2.0 * x, 2.0))) / 2.0) : ((Math.Sqrt(1.0 - Math.Pow(-2.0 * x + 2.0, 2.0)) + 1.0) / 2.0);
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
public static double Power(double x, LEaseMode easeMode, int power)
|
||||
{
|
||||
switch (easeMode)
|
||||
{
|
||||
case LEaseMode.EaseIn:
|
||||
return Math.Pow(x, power);
|
||||
case LEaseMode.EaseOut:
|
||||
return 1.0 - Math.Pow(1.0 - x, power);
|
||||
case LEaseMode.EaseInOut:
|
||||
return (x < 0.5) ? (Math.Pow(2.0, power - 1) * Math.Pow(x, power)) : (1.0 - Math.Pow(-2.0 * x + 2.0, power) / 2.0);
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
public static double Quadratic(double x, LEaseMode easeMode)
|
||||
{
|
||||
return Power(x, easeMode, 2);
|
||||
}
|
||||
|
||||
public static double Cubic(double x, LEaseMode easeMode)
|
||||
{
|
||||
return Power(x, easeMode, 3);
|
||||
}
|
||||
|
||||
public static double Quartic(double x, LEaseMode easeMode)
|
||||
{
|
||||
return Power(x, easeMode, 4);
|
||||
}
|
||||
|
||||
public static double Quintic(double x, LEaseMode easeMode)
|
||||
{
|
||||
return Power(x, easeMode, 5);
|
||||
}
|
||||
|
||||
public static double Elastic(double x, LEaseMode easeMode)
|
||||
{
|
||||
switch (easeMode)
|
||||
{
|
||||
case LEaseMode.EaseIn:
|
||||
return (x == 0.0) ? 0.0 : ((x == 1.0) ? 1.0 : ((0.0 - Math.Pow(2.0, 10.0 * x - 10.0)) * Math.Sin((x * 10.0 - 10.75) * 2.0 * Math.PI / 3.0)));
|
||||
case LEaseMode.EaseOut:
|
||||
return (x == 0.0) ? 0.0 : ((x == 1.0) ? 1.0 : (Math.Pow(2.0, -10.0 * x) * Math.Sin((x * 10.0 - 0.75) * 2.0 * Math.PI / 3.0) + 1.0));
|
||||
case LEaseMode.EaseInOut:
|
||||
return (x == 0.0) ? 0.0 : ((x == 1.0) ? 1.0 : ((x < 0.5) ? ((0.0 - Math.Pow(2.0, 20.0 * x - 10.0) * Math.Sin((x * 20.0 - 11.125) * 2.0 * Math.PI / 4.5)) / 2.0) : (Math.Pow(2.0, -20.0 * x + 10.0) * Math.Sin((x * 20.0 - 11.125) * 2.0 * Math.PI / 4.5) / 2.0 + 1.0)));
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
public static double Exponential(double x, LEaseMode easeMode)
|
||||
{
|
||||
switch (easeMode)
|
||||
{
|
||||
case LEaseMode.EaseIn:
|
||||
return (x == 0.0) ? 0.0 : Math.Pow(2.0, 10.0 * x - 10.0);
|
||||
case LEaseMode.EaseOut:
|
||||
return (x == 1.0) ? 1.0 : (1.0 - Math.Pow(2.0, -10.0 * x));
|
||||
case LEaseMode.EaseInOut:
|
||||
return (x == 0.0) ? 0.0 : ((x == 1.0) ? 1.0 : ((x < 0.5) ? (Math.Pow(2.0, 20.0 * x - 10.0) / 2.0) : ((2.0 - Math.Pow(2.0, -20.0 * x + 10.0)) / 2.0)));
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
public static double Sine(double x, LEaseMode easeMode)
|
||||
{
|
||||
switch (easeMode)
|
||||
{
|
||||
case LEaseMode.EaseIn:
|
||||
return 1.0 - Math.Cos(x * Math.PI / 2.0);
|
||||
case LEaseMode.EaseOut:
|
||||
return Math.Sin(x * Math.PI / 2.0);
|
||||
case LEaseMode.EaseInOut:
|
||||
return (0.0 - (Math.Cos(Math.PI * x) - 1.0)) / 2.0;
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
CleanMachineHMI/Utils/LEaseMode.cs
Normal file
9
CleanMachineHMI/Utils/LEaseMode.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace LEase
|
||||
{
|
||||
public enum LEaseMode
|
||||
{
|
||||
EaseIn,
|
||||
EaseOut,
|
||||
EaseInOut
|
||||
}
|
||||
}
|
||||
16
CleanMachineHMI/Utils/LEaseType.cs
Normal file
16
CleanMachineHMI/Utils/LEaseType.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace LEase
|
||||
{
|
||||
public enum LEaseType
|
||||
{
|
||||
Back,
|
||||
Bounce,
|
||||
Circle,
|
||||
Quadratic,
|
||||
Cubic,
|
||||
Quartic,
|
||||
Quintic,
|
||||
Elastic,
|
||||
Exponential,
|
||||
Sine
|
||||
}
|
||||
}
|
||||
@@ -186,6 +186,8 @@ namespace CleanMachineHMI
|
||||
|
||||
private void TTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
bool b = (_IsOpen?(iNow>=0):(iNow<=iDuration));
|
||||
if (b)
|
||||
{
|
||||
@@ -251,7 +253,7 @@ namespace CleanMachineHMI
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
// e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
||||
Pen penBarBack = new Pen(_CloseColor, _BarHight);
|
||||
Pen penBarFore = new Pen(_OpenColor, _BarHight);
|
||||
|
||||
Reference in New Issue
Block a user