Пример #1
0
        protected override void Draw(GameTime gameTime)
        {
            _gameDrawPerformance.Begin();
            GraphicsDevice.Clear(Color.CornflowerBlue);

            base.Draw(gameTime);
            _gameDrawPerformance.End();

            // Refresh here as the end-of-frame
            PerformanceTimer.FrameRefresh();
            _gameUpdatePerformance.Refresh();
            _gameDrawPerformance.Refresh();

            // Draw the results onto the screen
            _spriteBatch.Begin();

            _spriteBatch.DrawString(_FPS.SpriteFont,
                                    _FPS & XenString.Temporary(PerformanceTimer.CurrentFramerate, 2) & _space &
                                    XenString.Temporary(PerformanceTimer.MinFramerate, 2) & _space &
                                    XenString.Temporary(PerformanceTimer.MaxFramerate, 2) & _space &
                                    XenString.Temporary(PerformanceTimer.AverageFramerate, 2), Vector2.Zero, Color.White);
            _spriteBatch.DrawString(_update.SpriteFont,
                                    _update & XenString.Temporary(_gameUpdatePerformance.Current, 2) & _space &
                                    XenString.Temporary(_gameUpdatePerformance.Min, 2) & _space &
                                    XenString.Temporary(_gameUpdatePerformance.Max, 2) & _space &
                                    XenString.Temporary(_gameUpdatePerformance.Average, 2), Vector2.UnitY * 20, Color.White);
            _spriteBatch.DrawString(_draw.SpriteFont,
                                    _draw & XenString.Temporary(_gameDrawPerformance.Current, 2) & _suffix & _space &
                                    XenString.Temporary(_gameDrawPerformance.Min, 2) & _suffix & _space &
                                    XenString.Temporary(_gameDrawPerformance.Max, 2) & _suffix & _space &
                                    XenString.Temporary(_gameDrawPerformance.Average, 2) & _suffix, Vector2.UnitY * 40, Color.White);

            //_spriteBatch.DrawString( _font, "CurFPS: " + PerformanceTimer.CurrentFramerate.ToString( "0.00" ), Vector2.Zero, Color.White );
            //_spriteBatch.DrawString( _font, "MinFPS: " + PerformanceTimer.MinFramerate.ToString( "0.00" ), Vector2.UnitY * 20, Color.White );
            //_spriteBatch.DrawString( _font, "MaxFPS: " + PerformanceTimer.MaxFramerate.ToString( "0.00" ), Vector2.UnitY * 40, Color.White );
            //_spriteBatch.DrawString( _font, "AvgFPS: " + PerformanceTimer.AverageFramerate.ToString( "0.00" ), Vector2.UnitY * 60, Color.White );

            //_spriteBatch.DrawString( _font, "CurUpdate: " + _gameUpdatePerformance.Current.ToString( "0.00ms" ), Vector2.UnitY * 100, Color.Blue );
            //_spriteBatch.DrawString( _font, "MinUpdate: " + _gameUpdatePerformance.Min.ToString( "0.00ms" ), Vector2.UnitY * 120, Color.Blue );
            //_spriteBatch.DrawString( _font, "MaxUpdate: " + _gameUpdatePerformance.Max.ToString( "0.00ms" ), Vector2.UnitY * 140, Color.Blue );
            //_spriteBatch.DrawString( _font, "AvgUpdate: " + _gameUpdatePerformance.Average.ToString( "0.00ms" ), Vector2.UnitY * 160, Color.Blue );

            //_spriteBatch.DrawString( _font, "CurDraw: " + _gameDrawPerformance.Current.ToString( "0.00ms" ), Vector2.UnitY * 200, Color.Red );
            //_spriteBatch.DrawString( _font, "MinDraw: " + _gameDrawPerformance.Min.ToString( "0.00ms" ), Vector2.UnitY * 220, Color.Red );
            //_spriteBatch.DrawString( _font, "MaxDraw: " + _gameDrawPerformance.Max.ToString( "0.00ms" ), Vector2.UnitY * 240, Color.Red );
            //_spriteBatch.DrawString( _font, "AvgDraw: " + _gameDrawPerformance.Average.ToString( "0.00ms" ), Vector2.UnitY * 260, Color.Red );
            _spriteBatch.End();

            // Let the next 'frame' begin now because Draw() is throttled internally
            PerformanceTimer.FrameTick();
        }
Пример #2
0
        protected override void Draw(GameTime gameTime)
        {
            _gameDrawPerformance.Begin();
            GraphicsDevice.Clear(Color.CornflowerBlue);

            _spriteBatch.Begin();

            for (float i = 0.0f; i < 1.0f; i += StepInterval)
            {
                _tweenPerformance.Begin();
                float   x1 = i, x2 = i + StepInterval;
                Vector2 start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.Step(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                Vector2 end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.Step(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Blue, start, end, 3);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.Linear(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.Linear(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Yellow, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.Sine(_pStart.Y, _pEnd.Y, x1, 0.25f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.Sine(_pStart.Y, _pEnd.Y, x2, 0.25f, true));
                _spriteBatch.DrawLine(Color.Pink, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.SineIn(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.SineIn(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Green, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.SineOut(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.SineOut(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Red, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.SineInOut(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.SineInOut(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Purple, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.Quadratic(_pStart.Y, _pEnd.Y, x1, 0.25f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.Quadratic(_pStart.Y, _pEnd.Y, x2, 0.25f, true));
                _spriteBatch.DrawLine(Color.Pink, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.QuadraticIn(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.QuadraticIn(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Green, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.QuadraticOut(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.QuadraticOut(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Red, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.QuadraticInOut(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.QuadraticInOut(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Purple, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.Cubic(_pStart.Y, _pEnd.Y, x1, 0.25f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.Cubic(_pStart.Y, _pEnd.Y, x2, 0.25f, true));
                _spriteBatch.DrawLine(Color.Pink, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.CubicIn(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.CubicIn(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Green, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.CubicOut(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.CubicOut(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Red, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.CubicInOut(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.CubicInOut(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Purple, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.Exponential(_pStart.Y, _pEnd.Y, x1, MathHelper.E, 0.25f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.Exponential(_pStart.Y, _pEnd.Y, x2, MathHelper.E, 0.25f, true));
                _spriteBatch.DrawLine(Color.Pink, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.ExponentialIn(_pStart.Y, _pEnd.Y, x1, MathHelper.E, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.ExponentialIn(_pStart.Y, _pEnd.Y, x2, MathHelper.E, 0.5f, true));
                _spriteBatch.DrawLine(Color.Green, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.ExponentialOut(_pStart.Y, _pEnd.Y, x1, MathHelper.E, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.ExponentialOut(_pStart.Y, _pEnd.Y, x2, MathHelper.E, 0.5f, true));
                _spriteBatch.DrawLine(Color.Red, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.ExponentialInOut(_pStart.Y, _pEnd.Y, x1, MathHelper.E, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.ExponentialInOut(_pStart.Y, _pEnd.Y, x2, MathHelper.E, 0.5f, true));
                _spriteBatch.DrawLine(Color.Purple, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.Logarithmic(_pStart.Y, _pEnd.Y, x1, MathHelper.E, 0.25f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.Logarithmic(_pStart.Y, _pEnd.Y, x2, MathHelper.E, 0.25f, true));
                _spriteBatch.DrawLine(Color.Pink, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.LogarithmicIn(_pStart.Y, _pEnd.Y, x1, MathHelper.E, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.LogarithmicIn(_pStart.Y, _pEnd.Y, x2, MathHelper.E, 0.5f, true));
                _spriteBatch.DrawLine(Color.Green, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.LogarithmicOut(_pStart.Y, _pEnd.Y, x1, MathHelper.E, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.LogarithmicOut(_pStart.Y, _pEnd.Y, x2, MathHelper.E, 0.5f, true));
                _spriteBatch.DrawLine(Color.Red, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.LogarithmicInOut(_pStart.Y, _pEnd.Y, x1, MathHelper.E, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.LogarithmicInOut(_pStart.Y, _pEnd.Y, x2, MathHelper.E, 0.5f, true));
                _spriteBatch.DrawLine(Color.Purple, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.Circular(_pStart.Y, _pEnd.Y, x1, 0.25f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.Circular(_pStart.Y, _pEnd.Y, x2, 0.25f, true));
                _spriteBatch.DrawLine(Color.Pink, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.CircularIn(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.CircularIn(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Green, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.CircularOut(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.CircularOut(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Red, start, end, 2);

                start = new Vector2(x1 * GraphicsDevice.Viewport.Width, Interpolator.CircularInOut(_pStart.Y, _pEnd.Y, x1, 0.5f, true));
                end   = new Vector2(x2 * GraphicsDevice.Viewport.Width, Interpolator.CircularInOut(_pStart.Y, _pEnd.Y, x2, 0.5f, true));
                _spriteBatch.DrawLine(Color.Purple, start, end, 2);
                _tweenPerformance.End();
            }

            _spriteBatch.End();

            base.Draw(gameTime);
            _gameDrawPerformance.End();

            // Refresh here as the end-of-frame
            PerformanceTimer.FrameRefresh();
            _gameDrawPerformance.Refresh();
            _tweenPerformance.Refresh();

            // Draw the results onto the screen
            _spriteBatch.Begin();
            _spriteBatch.DrawString(_font, "CurFPS: " + PerformanceTimer.CurrentFramerate.ToString("0.00"), Vector2.Zero, Color.White);
            _spriteBatch.DrawString(_font, "MinFPS: " + PerformanceTimer.MinFramerate.ToString("0.00"), Vector2.UnitY * 20, Color.White);
            _spriteBatch.DrawString(_font, "MaxFPS: " + PerformanceTimer.MaxFramerate.ToString("0.00"), Vector2.UnitY * 40, Color.White);
            _spriteBatch.DrawString(_font, "AvgFPS: " + PerformanceTimer.AverageFramerate.ToString("0.00"), Vector2.UnitY * 60, Color.White);

            _spriteBatch.DrawString(_font, "CurDraw: " + _gameDrawPerformance.Current.ToString("0.00ms"), Vector2.UnitY * 100, Color.Black);
            _spriteBatch.DrawString(_font, "MinDraw: " + _gameDrawPerformance.Min.ToString("0.00ms"), Vector2.UnitY * 120, Color.Black);
            _spriteBatch.DrawString(_font, "MaxDraw: " + _gameDrawPerformance.Max.ToString("0.00ms"), Vector2.UnitY * 140, Color.Black);
            _spriteBatch.DrawString(_font, "AvgDraw: " + _gameDrawPerformance.Average.ToString("0.00ms"), Vector2.UnitY * 160, Color.Black);

            _spriteBatch.DrawString(_font, "CurTween: " + _tweenPerformance.Current.ToString("0.00ms"), Vector2.UnitY * 200, Color.Black);
            _spriteBatch.DrawString(_font, "MinTween: " + _tweenPerformance.Min.ToString("0.00ms"), Vector2.UnitY * 220, Color.Black);
            _spriteBatch.DrawString(_font, "MaxTween: " + _tweenPerformance.Max.ToString("0.00ms"), Vector2.UnitY * 240, Color.Black);
            _spriteBatch.DrawString(_font, "AvgTween: " + _tweenPerformance.Average.ToString("0.00ms"), Vector2.UnitY * 260, Color.Black);
            _spriteBatch.DrawDecimal(_font, _tweenPerformance.Average, 2, Vector2.UnitY * 280, Color.Black);
            _spriteBatch.DrawDecimal(_font, PerformanceTimer.CurrentFramerate, 2, Vector2.UnitY * 300, Color.Black);
            _spriteBatch.End();

            // Let the next 'frame' begin now because Draw() is throttled internally
            PerformanceTimer.FrameTick();
        }