Esempio n. 1
0
        private async Task TraceLineAsync(double x, double y)
        {
            if (_lastX is not null && _lastY is not null)
            {
                await _canvas2DContext.SetLineWidthAsync(LineWidth);

                await _canvas2DContext.BeginPathAsync();

                await _canvas2DContext.MoveToAsync(_lastX.Value, _lastY.Value);

                await _canvas2DContext.LineToAsync(x, y);

                await _canvas2DContext.StrokeAsync();
            }

            await _canvas2DContext.BeginPathAsync();

            await _canvas2DContext.ArcAsync(x, y, PointSize, 0, Radius, anticlockwise : true);

            await _canvas2DContext.ClosePathAsync();

            await _canvas2DContext.FillAsync();

            _lastX = x;
            _lastY = y;
        }
Esempio n. 2
0
        public async Task Draw(Canvas2DContext context)
        {
            await Body[currentIndex].Draw(context);
            await Head[currentIndex].Draw(context);

            await context.BeginPathAsync();

            await context.StrokeRectAsync(Head[currentIndex].Position.X - Head[currentIndex].ScaledWidth / 2, Head[currentIndex].Position.Y - Head[currentIndex].ScaledHeight / 2, Head[currentIndex].ScaledWidth, Head[currentIndex].ScaledHeight + Body[currentIndex].SourceRectangle.Height *scale.Y);

            await context.ClosePathAsync();
        }
Esempio n. 3
0
        private async Task DrawEdgeLine(RenderEdge edge)
        {
            await _context.BeginPathAsync();

            await _context.MoveToAsync(edge.From.X, edge.From.Y);

            await _context.LineToAsync(edge.To.X, edge.To.Y);

            await _context.ClosePathAsync();

            await _context.StrokeAsync();
        }
        public static async Task DrawOn(this IDisplayable element, Canvas2DContext context)
        {
            await context.BeginPathAsync();

            await context.ArcAsync(element.Position.X, element.Position.Y, element.Size / 2, 0, Math.PI * 2);

            await context.SetFillStyleAsync(element.Color);

            await context.FillAsync();

            await context.ClosePathAsync();
        }
Esempio n. 5
0
        public async ValueTask DrawLine(int x1, int y1, int x2, int y2, string color)
        {
            await _canvas.SetStrokeStyleAsync(color);

            await _canvas.BeginPathAsync();

            await _canvas.MoveToAsync(x1, y1);

            await _canvas.LineToAsync(x2, y2);

            await _canvas.ClosePathAsync();

            await _canvas.StrokeAsync();

            await _canvas.SetStrokeStyleAsync("");
        }