-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
DrawPolygon with a thickness of less that 0.5 fills produces a filled polygon instead of a outline #323
Comments
this is an issue introduced when we upgraded to In the 1.0.0 time frame we where working with an There is 2nd issues that exacerbates this problem. In cases where the outlining returns no paths (because the clipper has decided it was such a small outline that it would skip it) we currently just return the original (unmodified) path back... which I think is also wrong as no shape is better in this case than a filled polygon. I think the way to tackle this edge case is, in cases where the thickness is less that 0.5 we scale the path (and thickness) until its above the thickness would be above 0.5, outline as normal, then scale back down after the fact by the same amount. Secondly we should stop returning the original outline in cases where end up with an empty path. I feel the combination of both those should fix this edge case and mitigate any other related cases we have yet to find. |
this is the offending line https://github.com/SixLabors/ImageSharp.Drawing/blob/2a9ee515/src/ImageSharp.Drawing/Shapes/PolygonClipper/PolygonOffsetter.cs#L121 in the third party code |
I have been searching and testing all afternoon to find out what triggered it, and it triggered between 0.49 and 0.5, so it didn't seem a coincidence. Nice to see I was onto something indeed, it seems a hairy issue. It would also be nice to have some guidelines for the limitations of the polygon drawing, like until what thickness do you want to quasi guarantee correct output? At some point no output would probably be better than a full fill, e.g. a thickness of 0.001 would be acceptable as not displayed at all in a bitmap. |
issue kicks in on thicknesses less than
0.5f
.Expected output
Actual output
Discussed in #322
Originally posted by woutware March 8, 2024
Edit: after further investigations this seems to be a bug, I've edited the text below.
When argument thickness is less than 0.5 (e.g. 0.4), method DrawPolygon now fills the polygon, while it used to only stroke the outline, how to get the old behavior? Tested on ImageSharp 3.1.3, ImageSharp.Drawing 2.1.2. When the thickness is equal to 0.5 or greater, the behavior is like it used to be (I think the expected/correct behavior).
I've narrowed it down to the change having happened in ImageSharp.Drawing 2.0.0. It was OK in 1.0.0.
The call that used to not fill the polygon (from DrawPolygonExtensions):
The text was updated successfully, but these errors were encountered: