@@ -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 ( max == red ) {
15+ else if ( foundation_ . FloatEqual ( max , red ) ) {
1616 hue = 60.0f * ( ( ( green - blue ) / delta ) % 6 ) ;
1717 }
18- else if ( max == green ) {
18+ else if ( foundation_ . FloatEqual ( max , green ) ) {
1919 hue = 60.0f * ( ( ( blue - red ) / delta ) + 2 ) ;
2020 }
21- else if ( max == blue ) {
21+ else if ( foundation_ . FloatEqual ( max , blue ) ) {
2222 hue = 60.0f * ( ( ( red - green ) / delta ) + 4 ) ;
2323 }
2424
@@ -92,14 +92,14 @@ public static HSVColor fromAHSV(float alpha, float hue, float saturation, float
9292 }
9393
9494 public static HSVColor fromColor ( Color color ) {
95- float red = color . red / 0xFF ;
96- float green = color . green / 0xFF ;
97- float blue = color . blue / 0xFF ;
95+ float red = ( float ) color . red / 0xFF ;
96+ float green = ( float ) color . green / 0xFF ;
97+ float blue = ( float ) color . blue / 0xFF ;
9898
9999 float max = Mathf . Max ( red , Mathf . Max ( green , blue ) ) ;
100100 float min = Mathf . Min ( red , Mathf . Min ( green , blue ) ) ;
101101 float delta = max - min ;
102- float alpha = color . alpha / 0xFF ;
102+ float alpha = ( float ) color . alpha / 0xFF ;
103103 float hue = painting_ . _getHue ( red , green , blue , max , delta ) ;
104104 float saturation = max == 0.0f ? 0.0f : delta / max ;
105105
@@ -164,18 +164,18 @@ public static HSLColor fromAHSL(float alpha, float hue, float saturation, float
164164 }
165165
166166 public static HSLColor fromColor ( Color color ) {
167- float red = color . red / 0xFF ;
168- float green = color . green / 0xFF ;
169- float blue = color . blue / 0xFF ;
167+ float red = ( float ) color . red / 0xFF ;
168+ float green = ( float ) color . green / 0xFF ;
169+ float blue = ( float ) color . blue / 0xFF ;
170170
171171 float max = Mathf . Max ( red , Mathf . Max ( green , blue ) ) ;
172172 float min = Mathf . Min ( red , Mathf . Min ( green , blue ) ) ;
173173 float delta = max - min ;
174174
175- float alpha = color . alpha / 0xFF ;
175+ 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 = lightness == 1.0f
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