コード例 #1
0
        protected override void OnUpdate()
        {
            float progressRatio = Timer.ProgressRatio;

            m_transform.Scale = new Vector2(Interpolator.GetInterpolation(m_startScale.X, m_target.X, progressRatio),
                                            Interpolator.GetInterpolation(m_startScale.Y, m_target.Y, progressRatio));
        }
コード例 #2
0
        protected override void OnUpdate()
        {
            float progressRatio = Timer.ProgressRatio;

            Vector2 targetPos = m_target.PositionGlobal;

            m_transform.Position = new Vector2(Interpolator.GetInterpolation(m_startPos.X, targetPos.X, progressRatio),
                                               Interpolator.GetInterpolation(m_startPos.Y, targetPos.Y, progressRatio));
        }
コード例 #3
0
        protected override void OnUpdate()
        {
            float interpolation = Interpolator.GetInterpolation(m_startFrame, m_endFrame + 1, Timer.ProgressRatio);
            int   currentFrame  = (int)interpolation;

            if (currentFrame <= m_endFrame)
            {
                m_sprite.SetFrame(currentFrame);
            }
        }
コード例 #4
0
        public static void AnimateTo(this Pin self, Position endPosition)
        {
            var startPosition  = new Position(self.Position.Latitude, self.Position.Longitude);
            var startTime      = DateTimeOffset.Now.ToUnixTimeMilliseconds();
            var durationMillis = GetAnimationDuration(startPosition, endPosition);

            Device.StartTimer(TimeSpan.FromMilliseconds(16), () =>
            {
                var elapsed    = DateTimeOffset.Now.ToUnixTimeMilliseconds() - startTime;
                var multiplier = Interpolator.GetInterpolation(elapsed / durationMillis);
                var lng        = multiplier * endPosition.Longitude + (1 - multiplier) * startPosition.Longitude;
                var lat        = multiplier * endPosition.Latitude + (1 - multiplier) * startPosition.Latitude;
                self.Position  = new Position(lat, lng);
                return(elapsed < durationMillis);
            });
        }
コード例 #5
0
        protected override void OnUpdate()
        {
            float progressRatio = Math.Min(Timer.ProgressRatio, 1);

            if (TranslationActive)
            {
                m_transform.Position = new Vector2(Interpolator.GetInterpolation(m_start.PosX, m_end.PosX, progressRatio),
                                                   Interpolator.GetInterpolation(m_start.PosY, m_end.PosY, progressRatio));
            }
            if (ScaleActive)
            {
                m_transform.Scale = new Vector2(Interpolator.GetInterpolation(m_start.SclX, m_end.SclX, progressRatio),
                                                Interpolator.GetInterpolation(m_start.SclY, m_end.SclY, progressRatio));
            }
            if (RotationActive)
            {
                m_transform.Direction = Interpolator.GetInterpolation((float)m_start.Direction, (float)m_end.Direction, progressRatio);
            }
        }
コード例 #6
0
 protected override void OnUpdate()
 {
     m_transform.Direction = Interpolator.GetInterpolation(m_startRot, m_rotationTarget, Timer.ProgressRatio);
 }
コード例 #7
0
 protected override void OnUpdate()
 {
     m_valueToAnimate.Value.X = Interpolator.GetInterpolation(m_startValue.X, m_endValue.X, Timer.ProgressRatio);
     m_valueToAnimate.Value.Y = Interpolator.GetInterpolation(m_startValue.Y, m_endValue.Y, Timer.ProgressRatio);
 }
コード例 #8
0
ファイル: Animation.cs プロジェクト: bravesoftdz/krento
        /// <summary>
        /// Gets the transformation to apply at a specified point in time. Implementations of this
        /// method should always replace the specified Transformation or document they are doing
        /// otherwise.
        /// </summary>
        /// <param name="currentTime">Where we are in the animation. This is wall clock time.</param>
        /// <param name="outTransformation">A tranformation object that is provided by the
        /// caller and will be filled in by the animation.</param>
        /// <returns>True if the animation is still running</returns>
        public bool GetTransformation(int currentTime, Transformation outTransformation)
        {
            if (startTime == -1)
            {
                startTime = currentTime;
            }

            int   currentStartOffset = startOffset;
            int   currentDuration    = duration;
            float normalizedTime;

            if (currentDuration != 0)
            {
                normalizedTime = ((float)(currentTime - (startTime + currentStartOffset))) /
                                 (float)currentDuration;
            }
            else
            {
                // time is a step-change with a zero duration
                normalizedTime = currentTime < startTime ? 0.0f : 1.0f;
            }

            bool expired = normalizedTime >= 1.0f;

            more = !expired;

            if (!fillEnabled)
            {
                normalizedTime = Math.Max(Math.Min(normalizedTime, 1.0f), 0.0f);
            }

            if ((normalizedTime >= 0.0f || fillBefore) && (normalizedTime <= 1.0f || fillAfter))
            {
                if (!started)
                {
                    if (listener != null)
                    {
                        listener.OnAnimationStart(this);
                    }
                    started = true;
                }

                if (fillEnabled)
                {
                    normalizedTime = Math.Max(Math.Min(normalizedTime, 1.0f), 0.0f);
                }

                if (cycleFlip)
                {
                    normalizedTime = 1.0f - normalizedTime;
                }

                float interpolatedTime = interpolator.GetInterpolation(normalizedTime);
                ApplyTransformation(interpolatedTime, outTransformation);
            }

            if (expired)
            {
                if (repeatCount == repeated)
                {
                    if (!ended)
                    {
                        ended = true;
                        if (listener != null)
                        {
                            listener.OnAnimationEnd(this);
                        }
                    }
                }
                else
                {
                    if (repeatCount > 0)
                    {
                        repeated++;
                    }

                    if (mRepeatMode == RepeatMode.Reverse)
                    {
                        cycleFlip = !cycleFlip;
                    }

                    startTime = -1;
                    more      = true;
                    if (listener != null)
                    {
                        listener.OnAnimationRepeat(this);
                    }
                }
            }

            if (!more && oneMoreTime)
            {
                oneMoreTime = false;
                return(true);
            }

            return(more);
        }
コード例 #9
0
ファイル: EdgeGlow.cs プロジェクト: bravesoftdz/krento
        private void Update()
        {
            long  time = SystemClock.UptimeMillis();
            float t    = Math.Min((time - mStartTime) / mDuration, 1.0f);

            float interp = mInterpolator.GetInterpolation(t);

            mEdgeAlpha  = mEdgeAlphaStart + (mEdgeAlphaFinish - mEdgeAlphaStart) * interp;
            mEdgeScaleY = mEdgeScaleYStart + (mEdgeScaleYFinish - mEdgeScaleYStart) * interp;
            mGlowAlpha  = mGlowAlphaStart + (mGlowAlphaFinish - mGlowAlphaStart) * interp;
            mGlowScaleY = mGlowScaleYStart + (mGlowScaleYFinish - mGlowScaleYStart) * interp;

            if (t >= 1.0f - EPSILON)
            {
                switch (mState)
                {
                case STATE_ABSORB:
                    mState     = STATE_RECEDE;
                    mStartTime = SystemClock.UptimeMillis();
                    mDuration  = RECEDE_TIME;

                    mEdgeAlphaStart  = mEdgeAlpha;
                    mEdgeScaleYStart = mEdgeScaleY;
                    mGlowAlphaStart  = mGlowAlpha;
                    mGlowScaleYStart = mGlowScaleY;

                    // After absorb, the glow and edge should fade to nothing.
                    mEdgeAlphaFinish  = 0.0f;
                    mEdgeScaleYFinish = 0.0f;
                    mGlowAlphaFinish  = 0.0f;
                    mGlowScaleYFinish = 0.0f;
                    break;

                case STATE_PULL:
                    mState     = STATE_PULL_DECAY;
                    mStartTime = SystemClock.UptimeMillis();
                    mDuration  = PULL_DECAY_TIME;

                    mEdgeAlphaStart  = mEdgeAlpha;
                    mEdgeScaleYStart = mEdgeScaleY;
                    mGlowAlphaStart  = mGlowAlpha;
                    mGlowScaleYStart = mGlowScaleY;

                    // After pull, the glow and edge should fade to nothing.
                    mEdgeAlphaFinish  = 0.0f;
                    mEdgeScaleYFinish = 0.0f;
                    mGlowAlphaFinish  = 0.0f;
                    mGlowScaleYFinish = 0.0f;
                    break;

                case STATE_PULL_DECAY:
                    // When receding, we want edge to decrease more slowly
                    // than the glow.
                    float factor = mGlowScaleYFinish != 0 ? 1
                                   / (mGlowScaleYFinish * mGlowScaleYFinish)
                                : float.MaxValue;
                    mEdgeScaleY = mEdgeScaleYStart +
                                  (mEdgeScaleYFinish - mEdgeScaleYStart) *
                                  interp * factor;
                    break;

                case STATE_RECEDE:
                    mState = STATE_IDLE;
                    break;
                }
            }
        }