-
-
Notifications
You must be signed in to change notification settings - Fork 855
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
Prevent PathGradientBrush from throwing an error with corner cases #1007
Conversation
There can be such cases where it fails to find intersection points for a given position, especially when the polygon is small. Such an input would result in an error previously, but now it renders correctly.
Not sure why one of the build fails, but I think it's not related to the changes I made? |
Note that this is a breaking change.
Codecov Report
@@ Coverage Diff @@
## master #1007 +/- ##
=======================================
Coverage 89.85% 89.85%
=======================================
Files 1098 1098
Lines 48863 48863
Branches 3433 3433
=======================================
Hits 43908 43908
Misses 4254 4254
Partials 701 701
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #1007 +/- ##
=======================================
Coverage 89.85% 89.85%
=======================================
Files 1098 1098
Lines 48863 48863
Branches 3433 3433
=======================================
Hits 43908 43908
Misses 4254 4254
Partials 701 701
Continue to review full report at Codecov.
|
Also, I changed type of the constructor argument from The reason is, users would normally start with points and their associated colors, so it can be quite cumbersome to construct line segments by hand. The equivalent class in .NET API ( Also, I realized that I'm not sure if I can make a breaking change to the existing API at this stage. So, if it's not allowed, I'll update the PR without the relevant part. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR 👍.
I would agree and think the breaking change is fine in this case.
Thanks for the quick review! :) |
Prevent PathGradientBrush from throwing an error with corner cases
Prerequisites
Description
While testing the initial implementation of
PathGradientBrush
with a more complex scenario, I found that there are such cases where it fails to find intersection points for a given position.The previous code assumed it would be always possible to calculate an intersecting point of a line between the center position and an arbitrary point within the paint area. But it seems that the assumption was wrong for very small polygons, for a reason that I have yet to understand perfectly.
So, I just made a small correction to ignore such corner cases which prevents an error from halting the paint process. And it looks like ignoring them doesn't affect the output image noticeably.
As such, I think we could address this problem with the proposed change without breaking any existing code (that is, if anyone beside me is already using the new gradient brush), although further investigation might be needed in future.