public ExpoEasingDoubleAnimation(double from, double to, EasingMode easeInMethod, Duration duration)
 {
     FromValue = from;
     ToValue = to;
     Duration = duration;
     EaseFunction = easeInMethod;
 }
示例#2
0
文件: BackEase.cs 项目: GNOME/f-spot
 public BackEase(EasingMode easingMode, double amplitude)
     : base(easingMode)
 {
     if (amplitude < 0)
         throw new ArgumentOutOfRangeException ("amplitude");
     this.amplitude = amplitude;
 }
        public static Storyboard CreateDoubleSB(DependencyObject dpnObj, string property, double secondTime, Double from, Double to, EasingMode em)
        {
        //<Storyboard x:Name="Storyboard1">
        //    <DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="border">
        //        <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
        //    </DoubleAnimationUsingKeyFrames>
        //</Storyboard>
            DoubleAnimationUsingKeyFrames daKeyFrame = new DoubleAnimationUsingKeyFrames();
            EasingDoubleKeyFrame edKeyFrame = new EasingDoubleKeyFrame();
            edKeyFrame.KeyTime = TimeSpan.FromSeconds(secondTime);
            edKeyFrame.Value = to;
            CircleEase ce = new CircleEase();
            ce.EasingMode = em;
            edKeyFrame.EasingFunction = ce;

            daKeyFrame.KeyFrames.Add(edKeyFrame);
            daKeyFrame.EnableDependentAnimation = true;

            Storyboard.SetTarget(daKeyFrame, dpnObj);
            Storyboard.SetTargetProperty(daKeyFrame, property);
            Storyboard sb = new Storyboard();

            sb.Children.Add(daKeyFrame);
            return sb;
        }
示例#4
0
 public RotateEffect(double from, double to, double speed, EasingMode mode, EasingFunctionBase easingFunction)
 {
     this.From = from;
     this.To = to;
     this.Speed = speed;
     this.Mode = mode;
     this.EasingFunction = easingFunction;
 }
示例#5
0
 public MoveEffect(Point from, Point to, double speed,int duration,EasingMode mode,EasingFunctionBase easingFunction)
 {
     this.From = from;
     this.To = to;
     this.Speed = speed;
     this.Duration = duration;
     this.Mode = mode;
     this.EasingFunction = easingFunction;
 }
示例#6
0
 public OpacityEffect(double from, double to, double speed,int duration,EasingMode mode,EasingFunctionBase easingFunction)
 {
     this.From = from;
     this.To = to;
     this.Speed = speed;
     this.Duration = duration;
     this.Mode = mode;
     this.EasingFunction = easingFunction;
 }
        public AnimationBuilder AnchorPoint(
            Vector2 to,
            Vector2?from          = null,
            TimeSpan?delay        = null,
            TimeSpan?duration     = null,
            EasingType easingType = DefaultEasingType,
            EasingMode easingMode = DefaultEasingMode)
        {
            AddCompositionAnimationFactory(nameof(Visual.AnchorPoint), to, from, delay, duration, easingType, easingMode);

            return(this);
        }
示例#8
0
 public AnimationBuilder Offset(
     Axis axis,
     double to,
     double?from           = null,
     TimeSpan?delay        = null,
     TimeSpan?duration     = null,
     RepeatOption?repeat   = null,
     EasingType easingType = DefaultEasingType,
     EasingMode easingMode = DefaultEasingMode)
 {
     return(AddCompositionAnimationFactory(Properties.Composition.Offset(axis), (float)to, (float?)from, delay, duration, repeat, easingType, easingMode));
 }
        public AnimationBuilder Offset(
            Vector2 to,
            Vector2?from          = null,
            TimeSpan?delay        = null,
            TimeSpan?duration     = null,
            EasingType easingType = DefaultEasingType,
            EasingMode easingMode = DefaultEasingMode)
        {
            AddCompositionAnimationFactory(Properties.Composition.OffsetXY(), to, from, delay, duration, easingType, easingMode);

            return(this);
        }
示例#10
0
 /// <summary>
 /// Slerp the specified easingMode, time and duration.
 /// if time is not in the range of 0 to 1, the value will be rounded into 0 or 1.
 /// </summary>
 public static float Slerp(EasingMode easingMode, float time, float duration)
 {
     if (time < 0)
     {
         return(0);
     }
     if (time > duration)
     {
         return(1);
     }
     return(easingMode(time, time, 0, 1, duration));
 }
示例#11
0
        /// <summary>
        /// Animates the opacity of the UIElement.
        /// </summary>
        /// <param name="animationSet">The animation set.</param>
        /// <param name="value">The fade value, between 0 and 1.</param>
        /// <param name="duration">The duration in milliseconds.</param>
        /// <param name="delay">The delay. (ignored if duration == 0)</param>
        /// <param name="easingType">Used to describe how the animation interpolates between keyframes.</param>
        /// <param name="easingMode">The EasingMode to use to interpolate between keyframes.</param>
        /// <returns>
        /// An AnimationSet.
        /// </returns>
        public static AnimationSet Fade(
            this AnimationSet animationSet,
            float value           = 0f,
            double duration       = 500d,
            double delay          = 0d,
            EasingType easingType = EasingType.Default,
            EasingMode easingMode = EasingMode.EaseOut)
        {
            if (animationSet == null)
            {
                return(null);
            }

            if (!AnimationSet.UseComposition)
            {
                var animation = new DoubleAnimation
                {
                    To             = value,
                    Duration       = TimeSpan.FromMilliseconds(duration),
                    BeginTime      = TimeSpan.FromMilliseconds(delay),
                    EasingFunction = GetEasingFunction(easingType, easingMode)
                };

                animationSet.AddStoryboardAnimation("Opacity", animation);
            }
            else
            {
                if (duration <= 0)
                {
                    animationSet.AddCompositionDirectPropertyChange("Opacity", value);
                    return(animationSet);
                }

                var visual = animationSet.Visual;

                var compositor = visual?.Compositor;

                if (compositor == null)
                {
                    return(null);
                }

                var animation = compositor.CreateScalarKeyFrameAnimation();
                animation.Duration  = TimeSpan.FromMilliseconds(duration);
                animation.DelayTime = TimeSpan.FromMilliseconds(delay);
                animation.InsertKeyFrame(1f, value, GetCompositionEasingFunction(easingType, compositor, easingMode));

                animationSet.AddCompositionAnimation("Opacity", animation);
            }

            return(animationSet);
        }
示例#12
0
        public static Storyboard CreateCanvasMoveStoryboard(
            DependencyObject element,
            double durationSeconds,
            double fromX,
            double toX,
            double fromY,
            double toY,
            EasingMode mode,
            Action onCompleted = null)
        {
            var storyboard = new Storyboard();

            var children = storyboard.Children;

            if (Math.Abs(fromX - toX) > double.Epsilon)
            {
                var anim1 = new DoubleAnimation();
                anim1.From           = fromX;
                anim1.To             = toX;
                anim1.Duration       = new Duration(TimeSpan.FromSeconds(durationSeconds));
                anim1.EasingFunction = new ExponentialEase()
                {
                    EasingMode = mode
                };
                Storyboard.SetTarget(anim1, element);
                Storyboard.SetTargetProperty(anim1, new PropertyPath("(Canvas.Left)"));
                children.Add(anim1);
            }

            if (Math.Abs(fromY - toY) > double.Epsilon)
            {
                var anim2 = new DoubleAnimation();
                anim2                = new DoubleAnimation();
                anim2.From           = fromY;
                anim2.To             = toY;
                anim2.Duration       = new Duration(TimeSpan.FromSeconds(durationSeconds));
                anim2.EasingFunction = new ExponentialEase()
                {
                    EasingMode = mode
                };
                Storyboard.SetTarget(anim2, element);
                Storyboard.SetTargetProperty(anim2, new PropertyPath("(Canvas.Top)"));
                children.Add(anim2);
            }

            if (onCompleted != null)
            {
                storyboard.Completed += delegate { onCompleted(); };
            }

            return(storyboard);
        }
示例#13
0
 public static void TimePulse(double _speed, double _time, EasingMode _easing)
 {
     if (pulsing)
     {
         return;
     }
     speed      = _speed;
     time       = _time;
     easingMode = _easing;
     pulsing    = true;
     progress   = 0;
     oSpeed     = SpeedMultiplier;
 }
            public KeyFrameInfo(
                TimeSpan progress,
                string expression,
                EasingType easingType,
                EasingMode easingMode)
            {
                this.progress   = progress;
                this.value      = default;
                this.expression = expression;

                EasingType = easingType;
                EasingMode = easingMode;
            }
            public KeyFrameInfo(
                TimeSpan progress,
                T value,
                EasingType easingType,
                EasingMode easingMode)
            {
                this.progress   = progress;
                this.value      = value;
                this.expression = null;

                EasingType = easingType;
                EasingMode = easingMode;
            }
示例#16
0
        public AnimationBuilder AnchorPoint(
            Axis axis,
            double to,
            double?from           = null,
            TimeSpan?delay        = null,
            TimeSpan?duration     = null,
            EasingType easingType = DefaultEasingType,
            EasingMode easingMode = DefaultEasingMode)
        {
            AddCompositionAnimationFactory(Properties.Composition.AnchorPoint(axis), (float)to, (float?)from, delay, duration, easingType, easingMode);

            return(this);
        }
示例#17
0
        public static AnimationClock AnimateEasingEquation(
            DependencyObject element,
            DependencyProperty prop,
            EasingFunction function,
            EasingMode mode,            
            double to,
            int durationMS)
        {
            double from = double.IsNaN((double)element.GetValue(prop)) ?
                                0 :
                                (double)element.GetValue(prop);

            AnimationTimeline timeline = GetEasingAnimation(function, mode, from, to, durationMS);
            return Animate(element, prop, timeline, durationMS, null, null, null);
        }
        private static CAMediaTimingFunction GetQuarticTimingFunction(EasingMode easingMode)
        {
            switch (easingMode)
            {
            case EasingMode.EaseIn:
                return(CAMediaTimingFunction.FromControlPoints(0.895f, 0.03f, 0.685f, 0.22f));

            case EasingMode.EaseOut:
                return(CAMediaTimingFunction.FromControlPoints(0.165f, 0.84f, 0.44f, 1.0f));

            case EasingMode.EaseInOut:
                return(CAMediaTimingFunction.FromControlPoints(0.77f, 0.0f, 0.175f, 1.0f));
            }

            return(GetDefaultTimingFunction());
        }
        private static CAMediaTimingFunction GetCubicTimingFunction(EasingMode easingMode)
        {
            switch (easingMode)
            {
            case EasingMode.EaseIn:
                return(CAMediaTimingFunction.FromControlPoints(0.55f, 0.055f, 0.675f, 0.19f));

            case EasingMode.EaseOut:
                return(CAMediaTimingFunction.FromControlPoints(0.215f, 0.61f, 0.355f, 1.0f));

            case EasingMode.EaseInOut:
                return(CAMediaTimingFunction.FromControlPoints(0.645f, 0.045f, 0.355f, 1.0f));
            }

            return(GetDefaultTimingFunction());
        }
        private static CAMediaTimingFunction GetQuadraticTimingFunction(EasingMode easingMode)
        {
            switch (easingMode)
            {
            case EasingMode.EaseIn:
                return(CAMediaTimingFunction.FromControlPoints(0.55f, 0.085f, 0.68f, 0.53f));

            case EasingMode.EaseOut:
                return(CAMediaTimingFunction.FromControlPoints(0.25f, 0.46f, 0.45f, 0.94f));

            case EasingMode.EaseInOut:
                return(CAMediaTimingFunction.FromControlPoints(0.455f, 0.03f, 0.515f, 0.955f));
            }

            return(GetDefaultTimingFunction());
        }
        private static CAMediaTimingFunction GetBackTimingFunction(EasingMode easingMode)
        {
            switch (easingMode)
            {
            case EasingMode.EaseIn:
                return(CAMediaTimingFunction.FromControlPoints(0.6f, -0.28f, 0.735f, 0.045f));

            case EasingMode.EaseOut:
                return(CAMediaTimingFunction.FromControlPoints(0.175f, 0.885f, 0.320f, 1.275f));

            case EasingMode.EaseInOut:
                return(CAMediaTimingFunction.FromControlPoints(0.68f, -0.55f, 0.265f, 1.55f));
            }

            return(GetDefaultTimingFunction());
        }
        private static CAMediaTimingFunction GetSineTimingFunction(EasingMode easingMode)
        {
            switch (easingMode)
            {
            case EasingMode.EaseIn:
                return(CAMediaTimingFunction.FromControlPoints(0.47f, 0.0f, 0.745f, 0.715f));

            case EasingMode.EaseOut:
                return(CAMediaTimingFunction.FromControlPoints(0.39f, 0.575f, 0.565f, 1.0f));

            case EasingMode.EaseInOut:
                return(CAMediaTimingFunction.FromControlPoints(0.445f, 0.05f, 0.55f, 0.95f));
            }

            return(GetDefaultTimingFunction());
        }
        private static CAMediaTimingFunction GetQuinticTimingFunction(EasingMode easingMode)
        {
            switch (easingMode)
            {
            case EasingMode.EaseIn:
                return(CAMediaTimingFunction.FromControlPoints(0.755f, 0.05f, 0.855f, 0.06f));

            case EasingMode.EaseOut:
                return(CAMediaTimingFunction.FromControlPoints(0.23f, 1.0f, 0.320f, 1.0f));

            case EasingMode.EaseInOut:
                return(CAMediaTimingFunction.FromControlPoints(0.86f, 0.0f, 0.07f, 1.0f));
            }

            return(GetDefaultTimingFunction());
        }
示例#24
0
        public static AnimationClock AnimateEasingEquation(
            DependencyObject element,
            DependencyProperty prop,
            EasingFunction function,
            EasingMode mode,
            double to,
            int durationMS)
        {
            double from = double.IsNaN((double)element.GetValue(prop)) ?
                          0 :
                          (double)element.GetValue(prop);

            AnimationTimeline timeline = GetEasingAnimation(function, mode, from, to, durationMS);

            return(Animate(element, prop, timeline, durationMS, null, null, null));
        }
        public AnimationBuilder Clip(
            Thickness to,
            Thickness?from        = null,
            TimeSpan?delay        = null,
            TimeSpan?duration     = null,
            EasingType easingType = DefaultEasingType,
            EasingMode easingMode = DefaultEasingMode)
        {
            this.compositionAnimationFactories.Add(new CompositionClipScalarAnimation(
                                                       nameof(InsetClip.LeftInset),
                                                       (float)to.Left,
                                                       (float?)from?.Left,
                                                       delay ?? DefaultDelay,
                                                       duration ?? DefaultDuration,
                                                       easingType,
                                                       easingMode));

            this.compositionAnimationFactories.Add(new CompositionClipScalarAnimation(
                                                       nameof(InsetClip.TopInset),
                                                       (float)to.Top,
                                                       (float?)from?.Top,
                                                       delay ?? DefaultDelay,
                                                       duration ?? DefaultDuration,
                                                       easingType,
                                                       easingMode));

            this.compositionAnimationFactories.Add(new CompositionClipScalarAnimation(
                                                       nameof(InsetClip.RightInset),
                                                       (float)to.Right,
                                                       (float?)from?.Right,
                                                       delay ?? DefaultDelay,
                                                       duration ?? DefaultDuration,
                                                       easingType,
                                                       easingMode));

            this.compositionAnimationFactories.Add(new CompositionClipScalarAnimation(
                                                       nameof(InsetClip.BottomInset),
                                                       (float)to.Bottom,
                                                       (float?)from?.Bottom,
                                                       delay ?? DefaultDelay,
                                                       duration ?? DefaultDuration,
                                                       easingType,
                                                       easingMode));

            return(this);
        }
示例#26
0
        /// <summary>
        /// Animates the Gaussian blur of the UIElement.
        /// </summary>
        /// <param name="associatedObject">The associated object.</param>
        /// <param name="value">The blur amount.</param>
        /// <param name="duration">The duration in milliseconds.</param>
        /// <param name="delay">The delay. (ignored if duration == 0)</param>
        /// <param name="easingType">The easing function</param>
        /// <param name="easingMode">The easing mode</param>
        /// <returns>
        /// An Animation Set.
        /// </returns>
        public static AnimationSet Blur(
            this FrameworkElement associatedObject,
            double value          = 0d,
            double duration       = 500d,
            double delay          = 0d,
            EasingType easingType = EasingType.Default,
            EasingMode easingMode = EasingMode.EaseOut)
        {
            if (associatedObject == null)
            {
                return(null);
            }

            var animationSet = new AnimationSet(associatedObject);

            return(animationSet.Blur(value, duration, delay, easingType, easingMode));
        }
示例#27
0
 public static double CircleEase(EasingMode mode, double percent)
 {
     switch (mode)
     {
         case EasingMode.EaseOut:
             return Math.Sqrt(1 - (1 - percent) * (1 - percent));
         case EasingMode.EaseIn:
             return 1 - Math.Sqrt(1 - percent * percent);
         case EasingMode.EaseInOut:
             if (percent <= 0.5)
             {
                 return 0.5 - Math.Sqrt(0.25 - percent * percent);
             }
             return 0.5 + Math.Sqrt(0.25 - (percent - 1) * (percent - 1));
         default: return 0;
     }
 }
示例#28
0
        public static Storyboard CreateColorSB(DependencyObject dpnObj, string property, double secondTime, Color to, EasingMode em)
        {
            ColorAnimation ca = new ColorAnimation();
            ca.Duration = TimeSpan.FromSeconds(secondTime);
            ca.To = to;

            CircleEase ce = new CircleEase();
            ce.EasingMode = em;
            ca.EasingFunction = ce;

            Storyboard.SetTarget(ca, dpnObj);
            Storyboard.SetTargetProperty(ca, property);
            Storyboard sb = new Storyboard();

            sb.Children.Add(ca);
            return sb;
        }
示例#29
0
 public static double QuinticEase(EasingMode mode, double percent)
 {
     switch (mode)
     {
         case EasingMode.EaseOut:
             return Math.Pow((percent - 1), 5) + 1;
         case EasingMode.EaseIn:
             return Math.Pow(percent, 5);
         case EasingMode.EaseInOut:
             if (percent <= 0.5)
             {
                 return Math.Pow(percent * 2, 5) / 2;
             }
             return Math.Pow((percent - 1) * 2, 5) / 2 + 1;
         default: return 0;
     }
 }
示例#30
0
        /// <summary>
        /// Animates the opacity of the UIElement.
        /// </summary>
        /// <param name="associatedObject">The UI Element to change the opacity of.</param>
        /// <param name="value">The fade value, between 0 and 1.</param>
        /// <param name="duration">The duration in milliseconds.</param>
        /// <param name="delay">The delay. (ignored if duration == 0)</param>
        /// <param name="easingType">Used to describe how the animation interpolates between keyframes.</param>
        /// <param name="easingMode">The easing mode to use to interpolate between keyframes.</param>
        /// <returns>
        /// An AnimationSet.
        /// </returns>
        public static AnimationSet Fade(
            this UIElement associatedObject,
            float value           = 0f,
            double duration       = 500d,
            double delay          = 0d,
            EasingType easingType = EasingType.Default,
            EasingMode easingMode = EasingMode.EaseOut)
        {
            if (associatedObject == null)
            {
                return(null);
            }

            var animationSet = new AnimationSet(associatedObject);

            return(animationSet.Fade(value, duration, delay, easingType, easingMode));
        }
示例#31
0
	    private EasingMode ObterModoDaAnimacao()
	    {
	        var modoDaAnimacao = new EasingMode();
	        switch (ModoDaAnimacao.SelectedValue.ToString())
	        {
	            case "EaseIn":
	                modoDaAnimacao = EasingMode.EaseIn;
	                break;
                case "EaseOut":
	                modoDaAnimacao = EasingMode.EaseOut;
	                break;
                case "EaseInOut":
	                modoDaAnimacao = EasingMode.EaseInOut;
	                break;
	        }

	        return modoDaAnimacao;
	    }
示例#32
0
        public static AnimationClock AnimateEasingEquation(
            DependencyObject element,
            DependencyProperty prop,
            EasingFunction function,
            EasingMode mode,
            double?from,
            double to,
            int durationMS,
            EventHandler callbackFunc)
        {
            double defaultFrom = double.IsNaN((double)element.GetValue(prop)) ?
                                 0 :
                                 (double)element.GetValue(prop);

            AnimationTimeline timeline = GetEasingAnimation(function, mode, from.GetValueOrDefault(defaultFrom), to, durationMS);

            return(Animate(element, prop, timeline, durationMS, null, null, callbackFunc));
        }
        /// <summary>
        /// Animates the offset of the UIElement.
        /// </summary>
        /// <param name="associatedObject">The specified UI Element.</param>
        /// <param name="offsetX">The offset on the x axis.</param>
        /// <param name="offsetY">The offset on the y axis.</param>
        /// <param name="duration">The duration in milliseconds.</param>
        /// <param name="delay">The delay in milliseconds. (ignored if duration == 0)</param>
        /// <param name="easingType">Used to describe how the animation interpolates between keyframes.</param>
        /// <param name="easingMode">The EasingMode to use to interpolate between keyframes.</param>
        /// <returns>
        /// An AnimationSet.
        /// </returns>
        public static AnimationSet Offset(
            this UIElement associatedObject,
            float offsetX         = 0f,
            float offsetY         = 0f,
            double duration       = 500d,
            double delay          = 0d,
            EasingType easingType = EasingType.Default,
            EasingMode easingMode = EasingMode.EaseOut)
        {
            if (associatedObject == null)
            {
                return(null);
            }

            var animationSet = new AnimationSet(associatedObject);

            return(animationSet.Offset(offsetX, offsetY, duration, delay, easingType, easingMode));
        }
示例#34
0
        public static AnimationSet Light(
            this FrameworkElement associatedObject,
            double distance       = 0d,
            double duration       = 500d,
            double delay          = 0d,
            Color?color           = null,
            EasingType easingType = EasingType.Default,
            EasingMode easingMode = EasingMode.EaseOut)
        {
            if (associatedObject == null)
            {
                return(null);
            }

            var animationSet = new AnimationSet(associatedObject);

            return(animationSet.Light(distance, duration, delay, color, easingType, easingMode));
        }
示例#35
0
        internal static ITimeInterpolator GetPowerTimeInterpolator(float power, EasingMode mode)
        {
            switch (mode)
            {
            case EasingMode.EaseIn:
                return(new AccelerateInterpolator(power * 0.5f));

            case EasingMode.EaseOut:
                return(new DecelerateInterpolator(power * 0.5f));

            case EasingMode.EaseInOut:
                //We cannot set the power for AccelerateDecelerateInterpolator therefore we use the default one.
                return(new AccelerateDecelerateInterpolator());

            default:
                throw new NotSupportedException("This easing mode is not supported.");
            }
        }
        private void BringElementToView(FrameworkElement element, EasingMode easeMode)
        {
            if (element == null)
            {
                return;
            }
            ScrollViewer scrollViewer = element.FindAncestorByType <ScrollViewer>();

            if (scrollViewer != null)
            {
                Point relativePoint = element.TransformToAncestor(scrollViewer).Transform(new Point(0, 0));
                ScrollToPosition(scrollViewer, relativePoint.X, relativePoint.Y, easeMode);
            }
            else
            {
                element.BringIntoView();
            }
        }
示例#37
0
        public static Storyboard CreateDoubleSB(DependencyObject dpnObj, string property, double secondTime, Double to, EasingMode em, EventHandler<object> complete)
        {
            DoubleAnimation ca = new DoubleAnimation();
            ca.EnableDependentAnimation = true;
            ca.Duration = TimeSpan.FromSeconds(secondTime);
            ca.To = to;

            CircleEase ce = new CircleEase();
            ce.EasingMode = em;
            ca.EasingFunction = ce;

            Storyboard.SetTarget(ca, dpnObj);
            Storyboard.SetTargetProperty(ca, property);
            Storyboard sb = new Storyboard();
            if (complete != null)
                sb.Completed += complete;
            sb.Children.Add(ca);
            return sb;
        }
示例#38
0
        public AnimationBuilder Opacity(
            double to,
            double?from           = null,
            TimeSpan?delay        = null,
            TimeSpan?duration     = null,
            EasingType easingType = DefaultEasingType,
            EasingMode easingMode = DefaultEasingMode,
            FrameworkLayer layer  = FrameworkLayer.Composition)
        {
            if (layer == FrameworkLayer.Composition)
            {
                AddCompositionAnimationFactory(nameof(Visual.Opacity), (float)to, (float?)from, delay, duration, easingType, easingMode);
            }
            else
            {
                AddXamlAnimationFactory(nameof(UIElement.Opacity), to, from, delay, duration, easingType, easingMode);
            }

            return(this);
        }
示例#39
0
        public AnimationBuilder RotationInDegrees(
            double to,
            double?from           = null,
            TimeSpan?delay        = null,
            TimeSpan?duration     = null,
            EasingType easingType = DefaultEasingType,
            EasingMode easingMode = DefaultEasingMode,
            FrameworkLayer layer  = FrameworkLayer.Composition)
        {
            if (layer == FrameworkLayer.Composition)
            {
                AddCompositionAnimationFactory(nameof(Visual.RotationAngleInDegrees), (float)to, (float?)from, delay, duration, easingType, easingMode);
            }
            else
            {
                AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.Rotation), to, from, delay, duration, easingType, easingMode);
            }

            return(this);
        }
示例#40
0
        public static double CircleEase(EasingMode mode, double percent)
        {
            switch (mode)
            {
            case EasingMode.EaseOut:
                return(Math.Sqrt(1 - (1 - percent) * (1 - percent)));

            case EasingMode.EaseIn:
                return(1 - Math.Sqrt(1 - percent * percent));

            case EasingMode.EaseInOut:
                if (percent <= 0.5)
                {
                    return(0.5 - Math.Sqrt(0.25 - percent * percent));
                }
                return(0.5 + Math.Sqrt(0.25 - (percent - 1) * (percent - 1)));

            default: return(0);
            }
        }
示例#41
0
        public static double QuinticEase(EasingMode mode, double percent)
        {
            switch (mode)
            {
            case EasingMode.EaseOut:
                return(Math.Pow((percent - 1), 5) + 1);

            case EasingMode.EaseIn:
                return(Math.Pow(percent, 5));

            case EasingMode.EaseInOut:
                if (percent <= 0.5)
                {
                    return(Math.Pow(percent * 2, 5) / 2);
                }
                return(Math.Pow((percent - 1) * 2, 5) / 2 + 1);

            default: return(0);
            }
        }
示例#42
0
        /// <summary>
        /// Animates the scale of the specified UIElement.
        /// </summary>
        /// <param name="associatedObject">The associated UIElement.</param>
        /// <param name="scaleX">The scale on the x axis.</param>
        /// <param name="scaleY">The scale on the y axis.</param>
        /// <param name="centerX">The center x in pixels.</param>
        /// <param name="centerY">The center y in pixels.</param>
        /// <param name="duration">The duration in millisecond.</param>
        /// <param name="delay">The delay in milliseconds. (ignored if duration == 0)</param>
        /// <param name="easingType">Used to describe how the animation interpolates between keyframes.</param>
        /// <param name="easingMode">The EasingMode to use to interpolate between keyframes.</param>
        /// <returns>
        /// An AnimationSet.
        /// </returns>
        public static AnimationSet Scale(
            this UIElement associatedObject,
            float scaleX          = 1f,
            float scaleY          = 1f,
            float centerX         = 0f,
            float centerY         = 0f,
            double duration       = 500d,
            double delay          = 0d,
            EasingType easingType = EasingType.Default,
            EasingMode easingMode = EasingMode.EaseOut)
        {
            if (associatedObject == null)
            {
                return(null);
            }

            var animationSet = new AnimationSet(associatedObject);

            return(animationSet.Scale(scaleX, scaleY, centerX, centerY, duration, delay, easingType, easingMode));
        }
示例#43
0
        public static Storyboard CreateDoubleSB(DependencyObject dpnObj, string property, double secondTime, Double from, Double to, EasingMode em, EventHandler<object> complete)
        {
            DoubleAnimation ca = new DoubleAnimation();
            ca.EnableDependentAnimation = true;
            ca.Duration = TimeSpan.FromSeconds(secondTime);
            ca.From = from;
            ca.To = to;

            CircleEase ce = new CircleEase();
            ce.EasingMode = em;
            ca.EasingFunction = ce;

            Storyboard.SetTarget(ca, dpnObj);
            Storyboard.SetTargetProperty(ca, property);
            Storyboard sb = new Storyboard();
            sb.Completed += complete;
            sb.Children.Add(ca);
            return sb;


            //DoubleAnimationUsingKeyFrames daKeyFrame = new DoubleAnimationUsingKeyFrames();
            //EasingDoubleKeyFrame edKeyFrame = new EasingDoubleKeyFrame();
            //edKeyFrame.KeyTime = TimeSpan.FromSeconds(secondTime);
            //edKeyFrame.Value = to;
            //CircleEase ce = new CircleEase();
            //ce.EasingMode = em;
            //edKeyFrame.EasingFunction = ce;

            //daKeyFrame.KeyFrames.Add(edKeyFrame);
            //daKeyFrame.EnableDependentAnimation = true;

            //Storyboard.SetTarget(daKeyFrame, dpnObj);
            //Storyboard.SetTargetProperty(daKeyFrame, property);
            //Storyboard sb = new Storyboard();
            //sb.Completed += complete;

            //sb.Children.Add(daKeyFrame);
            //return sb;
        }
示例#44
0
        public override void Update(GameTime gameTime)
        {
            // <UP> key --> Select previous easing function.
              if (InputService.IsPressed(Keys.Up, true))
              {
            _selectedEasingFunctionIndex--;

            if (_selectedEasingFunctionIndex < 0)
              _selectedEasingFunctionIndex = _easingFunctions.Length - 1;
              }

              // <DOWN> key --> Select next easing function.
              if (InputService.IsPressed(Keys.Down, true))
              {
            _selectedEasingFunctionIndex++;
            if (_selectedEasingFunctionIndex >= _easingFunctions.Length)
              _selectedEasingFunctionIndex = 0;
              }

              // <1>, <2>, <3> --> Select easing mode.
              if (InputService.IsPressed(Keys.D1, false))
              {
            _selectedEasingMode = EasingMode.EaseIn;
              }
              else if (InputService.IsPressed(Keys.D2, false))
              {
            _selectedEasingMode = EasingMode.EaseOut;
              }
              else if (InputService.IsPressed(Keys.D3, false))
              {
            _selectedEasingMode = EasingMode.EaseInOut;
              }

              if (_animationController.State == AnimationState.Filling)
              {
            // The current animation has finished - it is now holding the last animation
            // value because the fill behavior is set to 'Hold' by default.
            // (_fromToAnimation.FillBehavior == FillBehavior.Hold).

            // Stop the animation.
            _animationController.Stop();

            // Switch the From and To values of the horizontal animation to move the sprite back
            // to the other screen side.
            Rectangle bounds = GraphicsDevice.Viewport.TitleSafeArea;
            if (_animatableFloat.Value < bounds.Center.X)
            {
              _fromToAnimation.From = bounds.Left + 200;
              _fromToAnimation.To = bounds.Right - 200;
            }
            else
            {
              _fromToAnimation.From = bounds.Right - 200;
              _fromToAnimation.To = bounds.Left + 200;
            }

            // Set easing funciton.
            _fromToAnimation.EasingFunction = _easingFunctions[_selectedEasingFunctionIndex];

            // Set easing mode.
            EasingFunction currentEasingFunction = _fromToAnimation.EasingFunction as EasingFunction;
            if (currentEasingFunction != null)
              currentEasingFunction.Mode = _selectedEasingMode;

            // Start the new animation.
            _animationController.Start();
              }

              base.Update(gameTime);
        }
示例#45
0
 protected QuinticEase(EasingMode easingMode)
     : base(easingMode)
 {
 }
示例#46
0
        public static MethodInfo GetFunction(EaseFuncType type, EasingMode mode)
        {
            string methodName = type.ToString();
            if (type != EaseFuncType.Linear)
                methodName += mode.ToString();

            MethodInfo method = typeof(EaseFuncMath).GetMethod(methodName);
            return method;
        }
示例#47
0
 protected BackEase(EasingMode easingMode)
     : this(easingMode, 1.0)
 {
 }
        private DoubleAnimation CreateWaitAnimation(DependencyObject obj, DependencyProperty prop, double value, double from, double duration, EasingMode easingMode = EasingMode.EaseOut)
        {
            CubicEase easingFunction = new CubicEase() { EasingMode = easingMode };
            DoubleAnimation animation = new DoubleAnimation()
            {
                Duration = new Duration(TimeSpan.FromMilliseconds(duration)),
                From = from,
                To = value,
                FillBehavior = FillBehavior.HoldEnd,
                EasingFunction = easingFunction
            };

            Storyboard.SetTarget(animation, obj);
            Storyboard.SetTargetProperty(animation, new PropertyPath(prop));

            return animation;
        }
示例#49
0
 public QuinticEase(EasingMode easingMode)
     : base(easingMode)
 {
 }
        public static DoubleAnimation CreateOpacityAnimation(DependencyObject obj, double from, double value, double milliseconds, double beginTime, EasingMode easing = EasingMode.EaseIn)
        {
            CubicEase ease = new CubicEase() { EasingMode = easing };
            DoubleAnimation animation = new DoubleAnimation();

            PropertyPath propPath = new PropertyPath("(UIElement.Opacity)");

            //PropertyPath propPath = new PropertyPath(UIElement.OpacityProperty);
            animation.BeginTime = TimeSpan.FromMilliseconds(beginTime);
            animation.Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds));
            animation.From = from;
            animation.To = Convert.ToDouble(value);
            animation.FillBehavior = FillBehavior.HoldEnd;
            animation.EasingFunction = ease;

            Storyboard.SetTarget(animation, obj);
            Storyboard.SetTargetProperty(animation, propPath);


            return animation;
        }
示例#51
0
        public static AnimationClock AnimateEasingEquation(
            DependencyObject element,
            DependencyProperty prop,
            EasingFunction function,
            EasingMode mode,
            double? from,
            double to,
            int durationMS,
            EventHandler callbackFunc)
        {
            double defaultFrom = double.IsNaN((double)element.GetValue(prop)) ?
                                0 :
                                (double)element.GetValue(prop);

            AnimationTimeline timeline = GetEasingAnimation(function, mode, from.GetValueOrDefault(defaultFrom), to, durationMS);
            return Animate(element, prop, timeline, durationMS, null, null, callbackFunc);
        }
示例#52
0
 public EasingBase() { Mode = EasingMode.None; }
示例#53
0
 protected EasingFunction(EasingMode easingMode)
 {
     EasingMode = easingMode;
 }
示例#54
0
        public DoubleAnimation CreateAnimation(DependencyObject obj, DependencyProperty prop, double value, double milliseconds, EasingMode easing = EasingMode.EaseOut)
        {
            CubicEase ease = new CubicEase() { EasingMode = easing };
            DoubleAnimation animation = new DoubleAnimation
            {
                Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds)),
                From = Convert.ToDouble(obj.GetValue(prop)),
                To = Convert.ToDouble(value),
                FillBehavior = FillBehavior.HoldEnd,
                EasingFunction = ease
            };
            Storyboard.SetTarget(animation, obj);
            Storyboard.SetTargetProperty(animation, new PropertyPath(prop));

            return animation;
        }
示例#55
0
        private static AnimationTimeline GetEasingAnimation(EasingFunction function, EasingMode mode, double from, double to, int durationMS)
        {
            AnimationTimeline returnTimeline = null;
            switch (function)
            {
                case EasingFunction.Quad:
                    returnTimeline = new QuadEasingDoubleAnimation(from, to, mode, new Duration(new TimeSpan(0, 0, 0, 0, durationMS)));
                    break;
                case EasingFunction.Linear:
                    returnTimeline = new LinearEasingDoubleAnimation(from, to, mode, new Duration(new TimeSpan(0, 0, 0, 0, durationMS)));
                    break;
                case EasingFunction.Back:
                    returnTimeline = new BackEasingDoubleAnimation(from, to, mode, new Duration(new TimeSpan(0, 0, 0, 0, durationMS)));
                    break;
                case EasingFunction.Expo:
                    returnTimeline = new ExpoEasingDoubleAnimation(from, to, mode, new Duration(new TimeSpan(0, 0, 0, 0, durationMS)));
                    break;
                case EasingFunction.Elastic:
                    returnTimeline = new ElasticEasingDoubleAnimation(from, to, mode, new Duration(new TimeSpan(0, 0, 0, 0, durationMS)));
                    break;
                case EasingFunction.Sine:
                    returnTimeline = new SineEasingDoubleAnimation(from, to, mode, new Duration(new TimeSpan(0, 0, 0, 0, durationMS)));
                    break;
                default:
                    break;
            }

            return returnTimeline;
        }
 private DoubleAnimation CreateWaitAnimation(DependencyObject obj, DependencyProperty prop, double value, double duration, EasingMode easingMode = EasingMode.EaseOut)
 {
     var from = Convert.ToDouble(obj.GetValue(prop));
     return CreateWaitAnimation(obj, prop, value, from, duration, easingMode);
 }
示例#57
0
 public EasingFunction(EasingMode easingMode)
 {
     this.easingMode = easingMode;
 }
示例#58
0
 public CubicEase(EasingMode easingMode)
     : base(easingMode)
 {
 }
示例#59
0
 public EasingFunction(EasingMode easingMode)
 {
     EasingMode = easingMode;
 }
示例#60
0
文件: BackEase.cs 项目: GNOME/f-spot
 public BackEase(EasingMode easingMode)
     : this(easingMode, 1.0)
 {
 }