示例#1
0
        protected void RenderFps(IDrawingContextImpl context, Rect clientRect, bool incrementFrameCount)
        {
            var now     = _stopwatch.Elapsed;
            var elapsed = now - _lastFpsUpdate;

            if (incrementFrameCount)
            {
                ++_framesThisSecond;
            }

            if (elapsed.TotalSeconds > 1)
            {
                _fps = (int)(_framesThisSecond / elapsed.TotalSeconds);
                _framesThisSecond = 0;
                _lastFpsUpdate    = now;
            }

            _fpsText.Text = string.Format("FPS: {0:000}", _fps);
            var size = _fpsText.Measure();
            var rect = new Rect(clientRect.Right - size.Width, 0, size.Width, size.Height);

            context.Transform = Matrix.Identity;
            context.FillRectangle(Brushes.Black, rect);
            context.DrawText(Brushes.White, rect.TopLeft, _fpsText.PlatformImpl);
        }
示例#2
0
        protected void RenderFps(IDrawingContextImpl context, Rect clientRect, int?layerCount)
        {
            var now     = _stopwatch.Elapsed;
            var elapsed = now - _lastFpsUpdate;

            ++_framesThisSecond;

            if (elapsed.TotalSeconds > 1)
            {
                _fps = (int)(_framesThisSecond / elapsed.TotalSeconds);
                _framesThisSecond = 0;
                _lastFpsUpdate    = now;
            }

            if (layerCount.HasValue)
            {
                _fpsText.Text = string.Format("Layers: {0} FPS: {1:000}", layerCount, _fps);
            }
            else
            {
                _fpsText.Text = string.Format("FPS: {0:000}", _fps);
            }

            var size = _fpsText.Bounds.Size;
            var rect = new Rect(clientRect.Right - size.Width, 0, size.Width, size.Height);

            context.Transform = Matrix.Identity;
            context.FillRectangle(Brushes.Black, rect);
            context.DrawText(Brushes.White, rect.TopLeft, _fpsText.PlatformImpl);
        }
示例#3
0
 private void RenderDirtyRects(IDrawingContextImpl context)
 {
     foreach (var r in _dirtyRectsDisplay)
     {
         var brush = new ImmutableSolidColorBrush(Colors.Magenta, r.Opacity);
         context.FillRectangle(brush, r.Rect);
     }
 }
示例#4
0
        /// <inheritdoc/>
        public override void Render(IDrawingContextImpl context)
        {
            context.Transform = Transform;

            if (Brush != null)
            {
                context.FillRectangle(Brush, Rect, CornerRadius);
            }

            if (Pen != null)
            {
                context.DrawRectangle(Pen, Rect, CornerRadius);
            }
        }
            public void Render(IDrawingContextImpl context)
            {
                try
                {
                    context.FillRectangle(BackgroundColor, Bounds);

                    Data = Frontend.GetNextGeneration();

                    DrawCells(CellColor, context);
                    DrawGrid(GridColor, context);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
            private void DrawPixel(IBrush brush, Point point, IDrawingContextImpl context)
            {
                var pixel = new Rect(new Point(point.X * Resolution, point.Y * Resolution), new Size(Resolution, Resolution));

                context.FillRectangle(brush, pixel);
            }
示例#7
0
 /// <summary>
 /// Draws a filled rectangle.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="rect">The rectangle bounds.</param>
 /// <param name="cornerRadius">The corner radius.</param>
 public void FillRectangle(Brush brush, Rect rect, float cornerRadius = 0.0f)
 => _impl.FillRectangle(brush, rect, cornerRadius);