Microsoft.Maui.Graphics icon indicating copy to clipboard operation
Microsoft.Maui.Graphics copied to clipboard

Define pixel center

Open rick-palmsens opened this issue 3 years ago • 2 comments

Currently when I draw a single width black line on an integer pixel coordinate (e.g. [100, 100]) in Microsoft.Maui.Graphics.Win2D.WinUI I get a grey 2 pixel width line instead. Is there some definition for all backends where the pixel center should be? I honestly don't care if it is in a corner or in the center, as long as it is consistent on all backends.

image

rick-palmsens avatar Jan 18 '22 09:01 rick-palmsens

The same things happens with rectangles. A filled rectangle is placed nicely within the bounds, while a stroked rectangle needs offsets to make sure it is a single line wide. I'm considering just using rectangles instead of lines for all horizontal or vertical lines.

rick-palmsens avatar Jan 18 '22 11:01 rick-palmsens

@rick-palmsens This is the expected behavior, and it's consistent across all implementations. If you want a 1 pixel line to draw on pixel boundaries, you should translate your canvas by .5, .5f before issuing drawing commands.

jonlipsky avatar Jan 25 '22 04:01 jonlipsky