Ejemplo n.º 1
0
        private async Task DrawNode(RenderNode node)
        {
            await _context.StrokeRectAsync(node.Position.X, node.Position.Y,
                                           node.Dimensions.Width, node.Dimensions.Height);

            await DrawNodeComponents(node);
        }
Ejemplo 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();
        }
Ejemplo n.º 3
0
        internal async Task DrawRectangleAsync(Color fillColor, Color borderColor, float borderWidth, Rectangle rectangle)
        {
            if (fillColor != null)
            {
                await this.SetFillColor(fillColor);

                await ctx.FillRectAsync(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
            }

            if (borderColor != null)
            {
                await this.SetStrokeColor(borderColor);

                await this.SetLineWidth(borderWidth);

                await ctx.StrokeRectAsync(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
            }
        }
Ejemplo n.º 4
0
        public async ValueTask Render(Canvas2DContext context)
        {
            await context.DrawImageAsync(Sprite.SpriteSheet, _transform.Position.X, _transform.Position.Y,
                                         Sprite.Size.Width, Sprite.Size.Height);

            if (DrawBoundingBox)
            {
                await context.BeginPathAsync();

                await context.SetStrokeStyleAsync($"rgb(255,255,0)");

                await context.SetLineWidthAsync(3);

                await context.StrokeRectAsync(_transform.BoundingBox.X, _transform.BoundingBox.Y,
                                              _transform.BoundingBox.Width,
                                              _transform.BoundingBox.Height);
            }
        }
        public async ValueTask Render(GameContext game, Canvas2DContext context)
        {
            var tmpW = context.LineWidth;
            var tmpS = context.StrokeStyle;

            await context.BeginPathAsync();

            await context.SetStrokeStyleAsync("rgb(255,255,0)");

            await context.SetLineWidthAsync(3);

            await context.StrokeRectAsync(_bounds.X, _bounds.Y,
                                          _bounds.Width,
                                          _bounds.Height);

            await context.SetStrokeStyleAsync(tmpS);

            await context.SetLineWidthAsync(tmpW);
        }
Ejemplo n.º 6
0
        public async ValueTask DrawRectangle(int left, int top, int width, int height, string color = "", string fillColor = "")
        {
            await _canvas.SetStrokeStyleAsync(color);

            if (color != "")
            {
                await _canvas.StrokeRectAsync(left, top, width, height);

                await _canvas.SetStrokeStyleAsync("");
            }

            await _canvas.SetFillStyleAsync(fillColor);

            if (fillColor != "")
            {
                await _canvas.FillRectAsync(left, top, width, height);

                await _canvas.SetFillStyleAsync("");
            }
        }