示例#1
0
文件: Easing.cs 项目: msiyer/Pinta
		static Easing ()
		{
			BounceOut = new Easing (p => {
				if (p < (1 / 2.75f))
				{
					return 7.5625f * p * p;
				}
				else if (p < (2 / 2.75f))
				{
					p -= (1.5f / 2.75f);
					
					return 7.5625f * p * p + .75f;
				}
				else if (p < (2.5f / 2.75f))
				{
					p -= (2.25f / 2.75f);
					
					return 7.5625f * p * p + .9375f;
				}
				else
				{
					p -= (2.625f / 2.75f);
					
					return 7.5625f * p * p + .984375f;
				}
			});
			
			BounceIn = new Easing (p => 1.0f - BounceOut.Func (p));
		}
示例#2
0
        public Action <double> GetCallback()
        {
            Action <double> result = f => {
                step(easing.Func(f));
                foreach (var animation in children)
                {
                    if (animation.finishedTriggered)
                    {
                        continue;
                    }

                    double val = Math.Max(0.0f, Math.Min(1.0f, (f - animation.beginAt) / (animation.finishAt - animation.beginAt)));

                    if (val <= 0.0f)                     // not ready to process yet
                    {
                        continue;
                    }

                    var callback = animation.GetCallback();
                    callback(val);

                    if (val >= 1.0f)
                    {
                        animation.finishedTriggered = true;
                        if (animation.finished != null)
                        {
                            animation.finished();
                        }
                    }
                }
            };

            return(result);
        }
示例#3
0
文件: Easing.cs 项目: ywscr/Pinta
        static Easing()
        {
            BounceOut = new Easing(p => {
                if (p < (1 / 2.75f))
                {
                    return(7.5625f * p * p);
                }
                else if (p < (2 / 2.75f))
                {
                    p -= (1.5f / 2.75f);

                    return(7.5625f * p * p + .75f);
                }
                else if (p < (2.5f / 2.75f))
                {
                    p -= (2.25f / 2.75f);

                    return(7.5625f * p * p + .9375f);
                }
                else
                {
                    p -= (2.625f / 2.75f);

                    return(7.5625f * p * p + .984375f);
                }
            });

            BounceIn = new Easing(p => 1.0f - BounceOut.Func(p));
        }
示例#4
0
        public void Start()
        {
            Pause();

            lastMilliseconds = 0;
            timer            = Ticker.Default.Insert(step => {
                var ms = step + lastMilliseconds;

                double rawValue = Math.Min(1.0f, ms / (double)Length);
                Value           = Easing.Func(rawValue);

                lastMilliseconds = ms;

                if (ValueUpdated != null)
                {
                    ValueUpdated(this, EventArgs.Empty);
                }

                if (rawValue >= 1.0f)
                {
                    if (Loop)
                    {
                        lastMilliseconds = 0;
                        Value            = 0.0f;
                        return(true);
                    }

                    if (Finished != null)
                    {
                        Finished(this, EventArgs.Empty);
                    }
                    Value = 0.0f;
                    timer = 0;
                    return(false);
                }
                return(true);
            });
        }