Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Commit be4d6f6

Browse files
committed
refine code
1 parent 5b7ee99 commit be4d6f6

File tree

1 file changed

+4
-4
lines changed
  • com.unity.uiwidgets/Runtime/painting

1 file changed

+4
-4
lines changed

com.unity.uiwidgets/Runtime/painting/colors.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ internal static float _getHue(float red, float green, float blue, float max, flo
1212
if (max == 0.0f || delta == 0.0f) {
1313
hue = 0.0f;
1414
}
15-
else if (Math.Abs(max - red) < foundation_.precisionErrorTolerance) {
15+
else if (foundation_.FloatEqual(max,red)) {
1616
hue = 60.0f * (((green - blue) / delta) % 6);
1717
}
18-
else if (Math.Abs(max - green) < foundation_.precisionErrorTolerance) {
18+
else if (foundation_.FloatEqual(max,green)) {
1919
hue = 60.0f * (((blue - red) / delta) + 2);
2020
}
21-
else if (Math.Abs(max - blue) < foundation_.precisionErrorTolerance) {
21+
else if (foundation_.FloatEqual(max,blue)) {
2222
hue = 60.0f * (((red - green) / delta) + 4);
2323
}
2424

@@ -175,7 +175,7 @@ public static HSLColor fromColor(Color color) {
175175
float alpha = (float)color.alpha / 0xFF;
176176
float hue = painting_._getHue(red, green, blue, max, delta);
177177
float lightness = (max + min) / 2.0f;
178-
float saturation = Math.Abs(lightness - 1.0f) < foundation_.precisionErrorTolerance
178+
float saturation = foundation_.FloatEqual(lightness, 1.0f)
179179
? 0.0f
180180
: ((delta / (1.0f - Mathf.Abs(2.0f * lightness - 1.0f))).clamp(0.0f, 1.0f));
181181
return HSLColor.fromAHSL(alpha, hue, saturation, lightness);

0 commit comments

Comments
 (0)