Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PixelOffsetMode.Aligned for aligned drawing with sharp lines #1799

Merged
merged 1 commit into from
Oct 14, 2020

Conversation

cwensley
Copy link
Member

@cwensley cwensley commented Oct 14, 2020

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.

@cwensley cwensley merged commit 750dbc9 into picoe:develop Oct 14, 2020
@cwensley cwensley deleted the curtis/pixeloffset-aligned branch October 14, 2020 20:30
@cwensley cwensley added this to the 2.5.7 milestone Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant