-
Notifications
You must be signed in to change notification settings - Fork 506
[Bug] Unprecise UIColor conversion #1572
Comments
Love it :) |
Am I too picky? 😀 |
I think you are correct, it should output the same numbers, and we should use Math.Round... the question is do you round up or down? |
Not exactly sure what you mean. |
@jamesmontemagno created a PR in case this makes the change more likely to be merged :) |
I guess my question is what Midpoint rounding should we use? https://docs.microsoft.com/en-us/dotnet/api/system.math.round?view=net-5.0#System_Math_Round_System_Double_System_Int32_System_MidpointRounding_ |
In my PR I used the default Math.Round without specifying a Midpoint rounding. I think the default is using |
Description
The precision of the color conversion for UIColor (and perhaps also for NSColor & other platforms) can be improved.
Steps to Reproduce
UIColorPickerViewController
and enterDisplay P3 Hex Color : #663399
UIColorPickerViewController
& callToSystemColor
on itExpected Behavior
#663399
Actual Behavior
#653299
This is because the CGColor has these components:
Red: 101.999986320734
Green: 50.9999969601631
Blue: 153.000021278858
With the current conversion, the values are rounded down:
Essentials/Xamarin.Essentials/Types/PlatformExtensions/ColorExtensions.ios.tvos.watchos.cs
Line 15 in 0dba844
I think this would be a better conversion method:
The text was updated successfully, but these errors were encountered: