-
-
Notifications
You must be signed in to change notification settings - Fork 850
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
Fix incorrect gradient color-stop calculation #864
Fix incorrect gradient color-stop calculation #864
Conversation
Hi there, thanks for this! Could you please upload some demo images to demonstrate before/after? Cheers! |
Quick example: Top old, bottom new. Gradient in question: new ColorStop<Rgba32>(0, Rgba32.Black),
new ColorStop<Rgba32>(1 / 4f, Rgba32.Blue),
new ColorStop<Rgba32>(2 / 4f, Rgba32.Red),
new ColorStop<Rgba32>(3 / 4f, Rgba32.White),
new ColorStop<Rgba32>(1, Rgba32.Lime) The first four quadrants, instead of being sampled as
are sampled as
because the lerp math failed to subtract the local gradient start from the local gradient end. |
@jongleur1983 as the original author, do you have some time to check this? 😄 |
@antonfirsov I hope to find the time tomorrow. |
@Poyo-SSB code looks good so far, thanks for spotting that bug. See FillLinearGradientBrushTests.cs for other tests on that. Somehow my setup still fails to compile ImageSharp here, no idea what's wrong, but the code looks correct and the output is definitly far more correct than before. Thanks |
@jongleur1983 You're probably missing the new standards submodule. If you rerun the command from the readme it'll most likely work. |
thanks @JimBobSquarePants - I did initialize the submodules, the init/update command didn't give any output anymore, but compilation is fine now. @Poyo-SSB code looks good, but we'd have to adapt the tests accordingly. So we have to replace the reference images there. |
@jongleur1983 thanks a lot for your help with the tests! @Poyo-SSB so what still needs to be pushed in order to merge this:
PS: |
Plan B. I like how strict our reference tests are. The only problem is the centralized repo. If I update a reference image after fixing a bug and my PR is blocked then that can potentially break any other builds. |
@JimBobSquarePants cool! Looks like this is something we need to deal with! Opened #868. |
Codecov Report
@@ Coverage Diff @@
## master #864 +/- ##
==========================================
+ Coverage 88.97% 88.97% +<.01%
==========================================
Files 1017 1017
Lines 44436 44438 +2
Branches 3227 3228 +1
==========================================
+ Hits 39538 39540 +2
Misses 4176 4176
Partials 722 722
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #864 +/- ##
==========================================
+ Coverage 88.97% 88.98% +<.01%
==========================================
Files 1017 1017
Lines 44436 44466 +30
Branches 3227 3228 +1
==========================================
+ Hits 39538 39568 +30
Misses 4176 4176
Partials 722 722
Continue to review full report at Codecov.
|
I'll have a look at this later on to see why builds are failing and fix accordingly. |
* Fix incorrect gradient color-stop calculation * Update submodule * Add multi-stop gradient test * Add missing reference image
Gradients with more than two color stops were being incorrectly calculated, leading to bizarre cutoffs.