Exemplo n.º 1
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.DrawRectangle(Brushes.Black, null, rect);
            context.DrawText(Brushes.White, rect.TopLeft, _fpsText.PlatformImpl);
        }
Exemplo n.º 2
0
 private void RenderDirtyRects(IDrawingContextImpl context)
 {
     foreach (var r in _dirtyRectsDisplay)
     {
         var brush = new ImmutableSolidColorBrush(Colors.Magenta, r.Opacity);
         context.DrawRectangle(brush, null, r.Rect);
     }
 }
        /// <inheritdoc/>
        public override void Render(IDrawingContextImpl context)
        {
            context.Transform = Transform;

            if (context is IDrawingContextWithAcrylicLikeSupport idc)
            {
                idc.DrawRectangle(Material, Rect);
            }
            else
            {
                context.DrawRectangle(new ImmutableSolidColorBrush(Material.FallbackColor), null, Rect);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 5
0
    public void RenderFps(IDrawingContextImpl context, string aux)
    {
        var now     = _stopwatch.Elapsed;
        var elapsed = now - _lastFpsUpdate;

        ++_framesThisSecond;
        ++_totalFrames;

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

        var    fpsLine = $"Frame #{_totalFrames:00000000} FPS: {_fps:000} " + aux;
        double width   = 0;
        double height  = 0;

        foreach (var ch in fpsLine)
        {
            var run = _runs[ch - FirstChar];
            width += run.Size.Width;
            height = Math.Max(height, run.Size.Height);
        }

        var rect = new Rect(0, 0, width + 3, height + 3);

        context.DrawRectangle(Brushes.Black, null, rect);

        double offset = 0;

        foreach (var ch in fpsLine)
        {
            var run = _runs[ch - FirstChar];
            context.Transform = Matrix.CreateTranslation(offset, 0);
            context.DrawGlyphRun(Brushes.White, run);
            offset += run.Size.Width;
        }
    }
Exemplo n.º 6
0
 /// <summary>
 /// Draws the outline of a rectangle.
 /// </summary>
 /// <param name="pen">The pen.</param>
 /// <param name="rect">The rectangle bounds.</param>
 /// <param name="cornerRadius">The corner radius.</param>
 public void DrawRectangle(Pen pen, Rect rect, float cornerRadius = 0.0f)
 => _impl.DrawRectangle(pen, rect, cornerRadius);
Exemplo n.º 7
0
        /// <inheritdoc/>
        public override void Render(IDrawingContextImpl context)
        {
            context.Transform = Transform;

            context.DrawRectangle(Brush, Pen, Rect, BoxShadows);
        }
Exemplo n.º 8
0
        /// <inheritdoc/>
        public override void Render(IDrawingContextImpl context)
        {
            context.Transform = Transform;

            context.DrawRectangle(Brush, Pen, Rect, RadiusX, RadiusY);
        }