Exemplo n.º 1
0
 /// <summary>
 /// Tweens the value to the new value.
 /// </summary>
 public void TweenTo(Rectangle newValue, TweenEaseType easeType, double duration = 1.0f)
 {
     _x.TweenTo(newValue.X, easeType, duration);
     _y.TweenTo(newValue.Y, easeType, duration);
     _w.TweenTo(newValue.Width, easeType, duration);
     _h.TweenTo(newValue.Height, easeType, duration);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Eases with the specified ease type.
 /// </summary>
 public static Rectangle EaseWithType(TweenEaseType easeType, double amount, Rectangle startValue, Rectangle change)
 {
     return(new Rectangle(
                (int)TweenedDouble.EaseWithType(easeType, amount, startValue.X, change.X),
                (int)TweenedDouble.EaseWithType(easeType, amount, startValue.Y, change.Y),
                (int)TweenedDouble.EaseWithType(easeType, amount, startValue.Width, change.Height),
                (int)TweenedDouble.EaseWithType(easeType, amount, startValue.Height, change.Height)));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Tweens the value to the new value.
        /// </summary>
        public void TweenTo(double newValue, TweenEaseType easeType, double duration = 1.0f)
        {
            _sourceValue = Value;
            TargetValue  = newValue;

            CompletionTime = _game.Time + duration;

            _duration = duration;
            EaseType  = easeType;
        }
 /// <summary>
 /// Eases with the specified ease type.
 /// </summary>
 public static Vector2 EaseWithType(TweenEaseType easeType, double amount, Vector2 startValue, Vector2 change)
 {
     return(new Vector2((float)TweenedDouble.EaseWithType(easeType, amount, startValue.X, change.X), (float)TweenedDouble.EaseWithType(easeType, amount, startValue.Y, change.Y)));
 }
 /// <summary>
 /// Tweens the value to the new value.
 /// </summary>
 public void TweenTo(Vector2 newValue, TweenEaseType easeType, double duration = 1.0f)
 {
     _x.TweenTo(newValue.X, easeType, duration);
     _y.TweenTo(newValue.Y, easeType, duration);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Eases with the specified ease type.
        /// </summary>
        public static double EaseWithType(TweenEaseType easeType, double amount, double startValue, double change)
        {
            switch (easeType)
            {
            case TweenEaseType.Linear:
                return(MathHelper.Lerp((float)startValue, (float)startValue + (float)change, (float)amount));

            // t: current time, b: begInnIng value, c: change In value, d: duration

            case TweenEaseType.EaseInQuad:
                return(change * amount * amount + startValue);

            case TweenEaseType.EaseOutQuad:
                return(-change * amount * (amount - 2) + startValue);

            case TweenEaseType.EaseInOutQuad:
                if ((amount *= 2) < 1)
                {
                    return(change / 2 * amount * amount + startValue);
                }
                return(-change / 2 * --amount * (amount - 2 - 1) + amount);

            case TweenEaseType.EaseInCubic:
                return(change * amount * amount * amount + startValue);

            case TweenEaseType.EaseOutCubic:
                return(change * ((amount = amount - 1) * amount * amount + 1) + startValue);

            case TweenEaseType.EaseInOutCubic:
                if ((amount *= 2) < 1)
                {
                    return(change / 2 * amount * amount * amount + startValue);
                }
                return(change / 2 * ((amount -= 2) * amount * amount + 2) + startValue);

            case TweenEaseType.EaseInQuart:
                return(change * amount * amount * amount * amount + startValue);

            case TweenEaseType.EaseOutQuart:
                return(-change * (amount = amount - 1) * amount * amount * amount + startValue);

            case TweenEaseType.EaseInOutQuart:
                if ((amount * 2) < 1)
                {
                    return(change / 2 * amount * amount * amount * amount + startValue);
                }
                return(-change / 2 * (amount -= 2 * amount * amount * amount - 2) + startValue);

            case TweenEaseType.EaseInSine:
                return(-change *Math.Cos(amount *(Math.PI / 2)) + change + startValue);

            case TweenEaseType.EaseOutSine:
                return(change * Math.Sin(amount * (Math.PI / 2)) + startValue);

            case TweenEaseType.EaseInOutSine:
                return(-change / 2 * (Math.Cos(Math.PI * amount) - 1) + startValue);

            case TweenEaseType.EaseInExpo:
                return(amount == 0 ? startValue : change *Math.Pow(2, 10 *(amount - 1)) + startValue);

            case TweenEaseType.EaseOutExpo:
                return(amount == 1 ? startValue + change : change *(-Math.Pow(2, -10 * amount) + 1) + startValue);

            case TweenEaseType.EaseInOutExpo:
                if (amount == 0)
                {
                    return(startValue);
                }
                if (amount == 1)
                {
                    return(startValue + change);
                }
                if ((amount *= 2) < 1)
                {
                    return(change / 2 * Math.Pow(2, 10 * (amount - 1)) + startValue);
                }
                return(change / 2 * (-Math.Pow(2, -10 * --amount) + 2) + startValue);

            case TweenEaseType.EaseInCirc:
                return(-change * (Math.Sqrt(1 - amount * amount) - 1) + startValue);

            case TweenEaseType.EaseOutCirc:
                return(change * (Math.Sqrt(1 - (amount -= 1) * amount) - 1) + startValue);

            case TweenEaseType.EaseInOutCirc:
                if ((amount *= 2) < 1)
                {
                    return(-change / 2 * (Math.Sqrt(1 - amount * amount) - 1) + startValue);
                }
                return(change / 2 * (Math.Sqrt(1 - (amount -= 2) * amount) + 1) + startValue);
            }
            return(startValue + change);
        }