Skip to content

Monogame CustomWidget drawline with (thickness > 1), the line is not drawing from center. #403

Closed
@Gohan

Description

@Gohan

Monogame Packages: monogame.framework.desktopgl\3.8.1.303

public class DrawLineUi : Widget
{
    public override void InternalRender(RenderContext context)
    {
        base.InternalRender(context);
        var bounds = ActualBounds;
        var start = new Vector2(0, bounds.Center.Y);
        var end = new Vector2(bounds.Width, bounds.Center.Y);
        context.DrawRectangle(bounds, Color.Black);
        context.DrawLine(start, end, Color.Brown, thickness: 100);
        context.DrawLine(start, end, Color.White, thickness: 1);
    }
}

the render result is like this below:
image

because RenderContext::Drawline use SpriteBatch::Draw internel, and use default "origin: (0,0)" which should be use (0, 0.5) for drawing lines?

expect result should be this below I suppose:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions