rds1983 / Myra

UI Library for MonoGame, FNA and Stride
MIT License
704 stars 94 forks source link

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

Closed Gohan closed 8 months ago

Gohan commented 9 months ago

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