rds1983 / Myra

UI Library for MonoGame, FNA and Stride
MIT License
742 stars 93 forks source link

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

Closed Gohan closed 1 year ago

Gohan commented 1 year 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