Exemplo n.º 1
0
        /// <summary>
        /// Smoothly moves a GUI to a new UDim2 position in the specified time using the specified EasingDirection and EasingStyle.
        /// </summary>
        /// <returns></returns>
        public bool TweenPosition(UDim2 endPos, EasingDirection easingDirection = EasingDirection.Out, EasingStyle easingStyle = EasingStyle.Quad, float time = 1f, bool oride = false)
        {
            if (oride && _beingTweened)
            {
                _interrupt = true;
            }

            // TODO: add an actual tween in render loop

            return(false);
        }
Exemplo n.º 2
0
 public static float GetEasing(EasingStyle style, EasingDirection direction, float percent)
 {
     if (style == EasingStyle.Bounce)
     {
         if (direction == EasingDirection.Out)
         {
             return(1 - easeOut(percent, bounce));
         }
         else if (direction == EasingDirection.In)
         {
             return(1 - bounce(percent));
         }
         else
         {
             return(1 - easeInOut(percent, bounce));
         }
     }
     else if (style == EasingStyle.Elastic)
     {
         double result;
         if (direction == EasingDirection.InOut)
         {
             double t = ((double)percent * 2) - 1;
             result = Math.Pow(2, 10 * t) * Math.Sin((t - 0.1125) * tau / 0.45);
             if (t < 0)
             {
                 result = 1 - (-.5 * result);
             }
             else
             {
                 result = 1 - (1 + .5 * result);
             }
         }
         else
         {
             double t = (double)percent;
             result = (1 + Math.Pow(2, -10 * t) * Math.Sin((t - 0.925) * tau / 0.3));
             if (direction == EasingDirection.In)
             {
                 result = 1 - result;
             }
         }
         return((float)result);
     }
     else if (style == EasingStyle.Cubic)
     {
         if (direction == EasingDirection.Out)
         {
             return(1 - easeOut(percent, cubic));
         }
         else if (direction == EasingDirection.In)
         {
             return(1 - cubic(percent));
         }
         else
         {
             return(1 - easeInOut(percent, cubic));
         }
     }
     else if (style == EasingStyle.Linear)
     {
         return(1 - percent);
     }
     else // Constant
     {
         if (direction == EasingDirection.Out)
         {
             return(1);
         }
         else if (direction == EasingDirection.In)
         {
             return(0);
         }
         else
         {
             return(0.5f);
         }
     }
 }
Exemplo n.º 3
0
        public static float GetEasing(EasingStyle style, EasingDirection direction, float percent)
        {
            if (style == EasingStyle.Bounce)
            {
                float result;

                if (direction == EasingDirection.Out)
                {
                    result = 1 - easeOut(percent, bounce);
                }
                else if (direction == EasingDirection.In)
                {
                    result = 1 - bounce(percent);
                }
                else
                {
                    result = 1 - easeInOut(percent, bounce);
                }

                return(result);
            }
            else if (style == EasingStyle.Elastic)
            {
                double result;

                if (direction == EasingDirection.InOut)
                {
                    double t     = ((double)percent * 2) - 1;
                    double inOut = Math.Pow(2, 10 * t) * Math.Sin((t - 0.1125) * tau / 0.45);

                    if (t < 0)
                    {
                        inOut = 1 - (-.5 * inOut);
                    }
                    else
                    {
                        inOut = 1 - (1 + .5 * inOut);
                    }

                    result = inOut;
                }
                else
                {
                    double t     = percent;
                    double value = (1 + Math.Pow(2, -10 * t) * Math.Sin((t - 0.925) * tau / 0.3));

                    if (direction == EasingDirection.In)
                    {
                        value = 1 - value;
                    }

                    result = value;
                }

                return((float)result);
            }
            else if (style == EasingStyle.Cubic)
            {
                float result;

                if (direction == EasingDirection.Out)
                {
                    result = 1 - easeOut(percent, cubic);
                }
                else if (direction == EasingDirection.In)
                {
                    result = 1 - cubic(percent);
                }
                else
                {
                    result = 1 - easeInOut(percent, cubic);
                }

                return(result);
            }
            else if (style == EasingStyle.Linear)
            {
                return(1 - percent);
            }
            else // Constant
            {
                float result;

                if (direction == EasingDirection.Out)
                {
                    result = 1;
                }
                else if (direction == EasingDirection.In)
                {
                    result = 0;
                }
                else
                {
                    result = 0.5f;
                }

                return(result);
            }
        }