本文整理汇总了C#中EasingType类的典型用法代码示例。如果您正苦于以下问题:C# EasingType类的具体用法?C# EasingType怎么用?C# EasingType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EasingType类属于命名空间,在下文中一共展示了EasingType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FunctionFromType
private static Func<decimal, decimal> FunctionFromType(EasingType easing)
{
switch (easing)
{
case EasingType.Constant:
return x => 1;
case EasingType.Linear:
return x => x;
case EasingType.Quadratic:
return x => DMath.Pow(x, 2);
case EasingType.Cubic:
return x => DMath.Pow(x, 3);
case EasingType.Quartic:
return x => DMath.Pow(x, 4);
case EasingType.Quintic:
return x => DMath.Pow(x, 5);
case EasingType.Sinusoidal:
return x => 1 - DMath.Cos(x * DMath.PI / 2); // Wait... That's not Sine!
case EasingType.Exponential:
return x => DMath.Pow(x, 5);
case EasingType.Circular:
return x => 1 - DMath.Sqrt(1 - x * x);
default:
throw new ArgumentOutOfRangeException();
}
}
示例2: Ease
public Ease(EasingType type, float duration, object toEase, string mask)
{
_type = type;
_startTime = Time.time;
_value = toEase;
_mask = mask;
}
示例3: Ease
// Adapted from source : http://www.robertpenner.com/easing/
public static float Ease(double linearStep, float acceleration, EasingType type) {
float easedStep = acceleration > 0 ? EaseIn(linearStep, type) :
acceleration < 0 ? EaseOut(linearStep, type) :
(float) linearStep;
return MathHelper.Lerp(linearStep, easedStep, Math.Abs(acceleration));
}
示例4: Interp
public static Vector3 Interp(Spline.Path pts, float t, EasingType ease, bool easeIn, bool easeOut)
{
t = Spline.Ease(t, ease, easeIn, easeOut);
if (pts.Length == 0)
{
return Vector3.zero;
}
if (pts.Length == 1)
{
return pts[0];
}
if (pts.Length == 2)
{
return Vector3.Lerp(pts[0], pts[1], t);
}
if (pts.Length == 3)
{
return QuadBez.Interp(pts[0], pts[2], pts[1], t);
}
if (pts.Length == 4)
{
return CubicBez.Interp(pts[0], pts[3], pts[1], pts[2], t);
}
return CRSpline.Interp(Spline.Wrap(pts), t);
}
示例5: EaseOut
public static float EaseOut(double linearStep, EasingType type)
{
switch (type)
{
case EasingType.None:
return 1f;
case EasingType.Linear:
return (float) linearStep;
case EasingType.Sine:
return Easing.Sine.EaseOut(linearStep);
case EasingType.Quadratic:
return Easing.Power.EaseOut(linearStep, 2);
case EasingType.Cubic:
return Easing.Power.EaseOut(linearStep, 3);
case EasingType.Quartic:
return Easing.Power.EaseOut(linearStep, 4);
case EasingType.Quintic:
return Easing.Power.EaseOut(linearStep, 5);
case EasingType.Sextic:
return Easing.Power.EaseOut(linearStep, 6);
case EasingType.Septic:
return Easing.Power.EaseOut(linearStep, 7);
case EasingType.Octic:
return Easing.Power.EaseOut(linearStep, 8);
case EasingType.Nonic:
return Easing.Power.EaseOut(linearStep, 9);
case EasingType.Decic:
return Easing.Power.EaseOut(linearStep, 10);
case EasingType.Circular:
return Easing.Circular.EaseOut(linearStep);
default:
throw new NotImplementedException();
}
}
示例6: EaseOut
public static float EaseOut(double linearStep, EasingType type)
{
switch (type)
{
case EasingType.Step: return linearStep < 0.5 ? 0 : 1;
case EasingType.Linear: return (float)linearStep;
case EasingType.Sine: return Sine.EaseOut(linearStep);
case EasingType.Quadratic: return Power.EaseOut(linearStep, 2);
case EasingType.Circular: return Circular.EaseOut(linearStep);
}
throw new NotImplementedException();
}
示例7: EaseInOut
public static float EaseInOut(double linearStep, EasingType type) {
linearStep = Mathf.Clamp01((float)linearStep);
switch (type) {
case EasingType.Step: return linearStep < 0.5 ? 0 : 1;
case EasingType.Linear: return (float)linearStep;
case EasingType.Sine: return Sine.EaseInOut(linearStep);
case EasingType.Quadratic: return Power.EaseInOut(linearStep, 2);
case EasingType.Cubic: return Power.EaseInOut(linearStep, 3);
case EasingType.Quartic: return Power.EaseInOut(linearStep, 4);
case EasingType.Quintic: return Power.EaseInOut(linearStep, 5);
}
throw new NotImplementedException();
}
示例8: GizmoDraw
public static void GizmoDraw(Vector3[] pts, float t, EasingType ease, bool easeIn, bool easeOut)
{
Gizmos.color = Color.white;
Vector3 to = Spline.Interp(pts, 0f);
for (int i = 1; i <= 20; i++)
{
float t2 = (float)i / 20f;
Vector3 vector = Spline.Interp(pts, t2, ease, easeIn, easeOut);
Gizmos.DrawLine(vector, to);
to = vector;
}
Gizmos.color = Color.blue;
Vector3 vector2 = Spline.Interp(pts, t, ease, easeIn, easeOut);
Gizmos.DrawLine(vector2, vector2 + Spline.Velocity(pts, t, ease, easeIn, easeOut));
}
示例9: MakeInvisible
// Set this object up to fade-out
public void MakeInvisible(float t = -1.0f, float alpha = 0.0f, EasingType easingType=EasingType.Linear, bool force = false)
{
alphaEaseType = easingType;
alpha = Mathf.Max(0.0f, alpha);
alpha = Mathf.Min(1.0f, alpha);
if( t == 0.0f ) {
if (transform.renderer.material.HasProperty("_Color") ) {
if (GetComponent<DynamicText>() != null) {
DynamicText dt = GetComponent<DynamicText>();
transitionStartColor = dt.color;
transitionEndColor = new Color(transparantColor.r, transparantColor.g, transparantColor.b, alpha);
oldAlpha = dt.color.a;
dt.color = transitionEndColor;
} else {
transitionStartColor = renderer.material.color;
transitionEndColor = new Color(transparantColor.r, transparantColor.g, transparantColor.b, alpha);
oldAlpha = renderer.material.color.a;
renderer.material.color = transitionEndColor;
}
} else {
oldAlpha = transform.renderer.material.GetFloat("_alpha_blend");
transform.renderer.material.SetFloat("_alpha_blend", alpha);
}
m_isVisible = alpha > 0.0f;
// return;
}
duration = (t >= 0.0f ? t : defaultDuration);
stage = 0F;
if (transform.renderer.material.HasProperty("_Color") ) {
if (GetComponent<DynamicText>() != null) {
transitionStartColor = GetComponent<DynamicText>().color;
oldAlpha = transitionStartColor.a;
} else {
transitionStartColor = renderer.material.color;
oldAlpha = renderer.material.color.a;
}
transitionEndColor = new Color(transparantColor.r, transparantColor.g, transparantColor.b, alpha);
} else {
oldAlpha = transform.renderer.material.GetFloat("_alpha_blend");
}
targetAlpha = alpha;
m_isTransitioning = true;
}
示例10: Ease
/// <summary>
/// Returns the output of an easing function for a specific time.
/// </summary>
/// <param name="t">The normalized time</param>
/// <param name="easingType">The easing function to use</param>
/// <returns>The eased output</returns>
public static float Ease(float t, EasingType easingType)
{
switch (easingType)
{
case EasingType.ExponentialIn: return Functions.ExponentialIn(t);
case EasingType.ExponentialOut: return Functions.ExponentialOut(t);
case EasingType.ExponentialInOut: return Functions.ExponentialInOut(t);
case EasingType.ExponentialOutIn: return Functions.ExponentialOutIn(t);
case EasingType.SineIn: return Functions.SineIn(t);
case EasingType.SineOut: return Functions.SineOut(t);
case EasingType.SineInOut: return Functions.SineInOut(t);
case EasingType.SineOutIn: return Functions.SineOutIn(t);
case EasingType.CubicIn: return Functions.CubicIn(t);
case EasingType.CubicOut: return Functions.CubicOut(t);
case EasingType.CubicInOut: return Functions.CubicInOut(t);
case EasingType.CubicOutIn: return Functions.CubicOutIn(t);
case EasingType.QuinticIn: return Functions.QuinticIn(t);
case EasingType.QuinticOut: return Functions.QuinticOut(t);
case EasingType.QuinticInOut: return Functions.QuinticInOut(t);
case EasingType.QuinticOutIn: return Functions.QuinticOutIn(t);
case EasingType.CircularIn: return Functions.CircularIn(t);
case EasingType.CircularOut: return Functions.CircularOut(t);
case EasingType.CircularInOut: return Functions.CircularInOut(t);
case EasingType.CircularOutIn: return Functions.CircularOutIn(t);
case EasingType.ElasticIn: return Functions.ElasticIn(t);
case EasingType.ElasticOut: return Functions.ElasticOut(t);
case EasingType.ElasticInOut: return Functions.ElasticInOut(t);
case EasingType.ElasticOutIn: return Functions.ElasticOutIn(t);
case EasingType.QuadraticIn: return Functions.QuadraticIn(t);
case EasingType.QuadraticOut: return Functions.QuadraticOut(t);
case EasingType.QuadraticInOut: return Functions.QuadraticInOut(t);
case EasingType.QuadraticOutIn: return Functions.QuadraticOutIn(t);
case EasingType.QuarticIn: return Functions.QuarticIn(t);
case EasingType.QuarticOut: return Functions.QuarticOut(t);
case EasingType.QuarticInOut: return Functions.QuarticInOut(t);
case EasingType.QuarticOutIn: return Functions.QuarticOutIn(t);
case EasingType.BackIn: return Functions.BackIn(t);
case EasingType.BackOut: return Functions.BackOut(t);
case EasingType.BackInOut: return Functions.BackInOut(t);
case EasingType.BackOutIn: return Functions.BackOutIn(t);
case EasingType.BounceIn: return Functions.BounceIn(t);
case EasingType.BounceOut: return Functions.BounceOut(t);
case EasingType.BounceInOut: return Functions.BounceInOut(t);
case EasingType.BounceOutIn: return Functions.BounceOutIn(t);
default: return Functions.Linear(t);
}
}
示例11: Animation
public Animation(object obj, string propName, float startValue, float endValue, EaseFunctionDelegate easeFunc,
EasingType easeType)
{
if(propName != null)
{
_property = obj.GetType().GetProperty(propName);
}
else
{
_property = null;
}
PropertyName = propName;
_obj = obj;
_startValue = startValue;
_endValue = endValue;
_easeFunc = easeFunc;
_easeType = easeType;
}
示例12: Vibrate
public override void Vibrate(VibrationMotor motor, double amount, float duration, EasingType easingType)
{
throw new NotSupportedException();
}
示例13: EaseInOut
public static float EaseInOut(double linearStep, EasingType easeInType, EasingType easeOutType)
{
linearStep = Mathf.Clamp01((float)linearStep);
return linearStep < 0.5 ? EaseInOut(linearStep, easeInType) : EaseInOut(linearStep, easeOutType);
}
示例14: EaseWithReturn
public static float EaseWithReturn(double linearStep, EasingType ease)
{
linearStep = (double)Mathf.Clamp01((float)linearStep);
var amount = linearStep > 0.5 ? 1+((0.5-linearStep)*2) : (linearStep * 2);
return EaseOut(amount, ease);
}
示例15: EaseInOut
public static float EaseInOut ( double linearStep, EasingType easeInType, EasingType easeOutType )
{
return linearStep < 0.5 ? EaseInOut ( linearStep, easeInType ) : EaseInOut ( linearStep, easeOutType );
}