public override void Draw(GameTime gameTime)
        {
            sampleFrames++;

            // FPS 表示の周りに半透明の黒い矩形のサイズ計算と配置
            var size = Font.MeasureString("X");
            var rect = new Rectangle(0, 0, (int) (size.X * 14f), (int) (size.Y * 1.3f));

            var vp = GraphicsDevice.Viewport;
            var layout = new Layout(new Rectangle(vp.X, vp.Y, vp.Width, vp.Height), vp.TitleSafeArea);
            rect = layout.Place(rect, 0.01f, 0.01f, LayoutAlignment.TopLeft);

            // FPS 表示を矩形の中で配置
            size = Font.MeasureString(stringBuilder);
            layout.ClientArea = rect;
            var position = layout.Place(size, 0.0f, 0.1f, LayoutAlignment.Center);

            var fColor = !gameTime.IsRunningSlowly ? fontColor : runningSlowlyFontColor;

            SpriteBatch.Begin();
            SpriteBatch.Draw(FillTexture, rect, windowColor);
            SpriteBatch.DrawString(Font, stringBuilder, position, fColor);
            SpriteBatch.End();
        }
예제 #2
0
        protected override void LoadContent()
        {
            logs = new FrameLog[2];
            for (int i = 0; i < logs.Length; ++i)
            {
                logs[i] = new FrameLog();
            }

            sampleFrames = targetSampleFrames = 1;

            var vp = GraphicsDevice.Viewport;
            var layout = new Layout(new Rectangle(vp.X, vp.Y, vp.Width, vp.Height), vp.TitleSafeArea);

            width = (int) (layout.ClientArea.Width * 0.8f);

            position = layout.Place(
                new Vector2(width, BarHeight),
                0.0f,
                0.01f,
                LayoutAlignment.BottomCenter);

            base.LoadContent();
        }