Add PixelOffsetMode.Aligned for aligned drawing with sharp lines #1799
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Eto's PixelOffsetMode.None, both Graphics.FillRect(Colors.Blue, 10, 10, 10, 10) and Graphics.DrawRect(Colors.Blue, 10, 10, 10, 10) would draw a sharp-edged rectangle with no antialiasing (sans transforms). In System.Drawing's PixelOffsetMode.None, fills are antialiased unless you offset the rectangle by 0.5 pixels. Unfortunately, if you want to use the same rectangles for both the draws and fills you would have to do extra calculations to account for this such as shrinking the rectangle by one pixel for line drawing. PixelOffsetMode.Half was the usual way to deal with this, however line draws will no longer fall on pixel boundaries unless you offset them by 0.5 pixels yourself.
So, a new mode has been added named PixelOffsetMode.Aligned that makes line draws fall on pixel boundaries, and fills with the same dimensions align with them. So, you can now choose Half when you want fills to be crisp with whole numbers, Aligned if you want lines to be crisp with whole numbers, or None if you want both fills and lines to be crisp with whole numbers.