@@ -47,11 +47,11 @@ public struct HsvColor
4747 private HsvColor ( Color color )
4848 {
4949 // Calculate hue, chroma, and supplementary values
50- ( double h1 , double chroma ) = ColorHelper . CalculateHueAndChroma ( color , out var _ , out var max , out var alpha ) ;
50+ ( float h1 , float chroma ) = ColorHelper . CalculateHueAndChroma ( color , out var _ , out var max , out var alpha ) ;
5151
5252 // Calculate saturation and value
53- double saturation = chroma == 0 ? 0 : chroma / max ;
54- double value = max ;
53+ float saturation = chroma == 0 ? 0 : chroma / max ;
54+ float value = max ;
5555
5656 // Set hsv properties
5757 Hue = 60 * h1 ;
@@ -68,7 +68,7 @@ private HsvColor(Color color)
6868 /// <param name="value">The color's value.</param>
6969 /// <param name="alpha">The alpha/opacity.</param>
7070 /// <returns>The new <see cref="HsvColor"/>.</returns>
71- public static HsvColor Create ( double hue , double saturation , double value , double alpha = 1 )
71+ public static HsvColor Create ( float hue , float saturation , float value , float alpha = 1 )
7272 {
7373 HsvColor color = default ;
7474#pragma warning disable 0618
@@ -80,7 +80,6 @@ public static HsvColor Create(double hue, double saturation, double value, doubl
8080 return color ;
8181 }
8282
83-
8483 // This class contains deprecated public backing fields to be removed in a future version.
8584 // Suppress the warnings from using them in their new wrapping properties.
8685#pragma warning disable 0618
@@ -91,9 +90,9 @@ public static HsvColor Create(double hue, double saturation, double value, doubl
9190 /// <remarks>
9291 /// This value is clamped between 0 and 360.
9392 /// </remarks>
94- public double Hue
93+ public float Hue
9594 {
96- readonly get => Math . Clamp ( H , 0 , 360 ) ;
95+ readonly get => ( float ) H ;
9796 set => H = Math . Clamp ( value , 0 , 360 ) ;
9897 }
9998
@@ -103,9 +102,9 @@ public double Hue
103102 /// <remarks>
104103 /// This value is clamped between 0 and 1.
105104 /// </remarks>
106- public double Saturation
105+ public float Saturation
107106 {
108- readonly get => Math . Clamp ( S , 0 , 1 ) ;
107+ readonly get => ( float ) S ;
109108 set => S = Math . Clamp ( value , 0 , 1 ) ;
110109 }
111110
@@ -115,9 +114,9 @@ public double Saturation
115114 /// <remarks>
116115 /// This value is clamped between 0 and 1.
117116 /// </remarks>
118- public double Value
117+ public float Value
119118 {
120- readonly get => Math . Clamp ( V , 0 , 1 ) ;
119+ readonly get => ( float ) V ;
121120 set => V = Math . Clamp ( value , 0 , 1 ) ;
122121 }
123122
@@ -127,9 +126,9 @@ public double Value
127126 /// <remarks>
128127 /// This value is clamped between 0 and 1.
129128 /// </remarks>
130- public double Alpha
129+ public float Alpha
131130 {
132- readonly get => Math . Clamp ( A , 0 , 1 ) ;
131+ readonly get => ( float ) A ;
133132 set => A = Math . Clamp ( value , 0 , 1 ) ;
134133 }
135134
@@ -142,10 +141,10 @@ public double Alpha
142141 /// <returns>The <see cref="HsvColor"/> as a <see cref="Color"/>.</returns>
143142 public readonly Color ToColor ( )
144143 {
145- double chroma = Value * Saturation ;
146- double h1 = Hue / 60 ;
147- double x = chroma * ( 1 - Math . Abs ( ( h1 % 2 ) - 1 ) ) ;
148- double m = Value - chroma ;
144+ float chroma = Value * Saturation ;
145+ float h1 = Hue / 60 ;
146+ float x = chroma * ( 1 - Math . Abs ( ( h1 % 2 ) - 1 ) ) ;
147+ float m = Value - chroma ;
149148
150149 return ColorHelper . FromHueChroma ( h1 , chroma , x , m , Alpha ) ;
151150 }
0 commit comments