Skip to content

Commit db7f6d8

Browse files
committed
Changed HslColor and HsvColor constructors to use fields. This fixes a breaking change betwen ColorHelper.FromHsv and HsvColor.Create
1 parent 8393fc6 commit db7f6d8

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

components/Helpers/src/ColorHelper/HslColor.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private HslColor(Color color)
5252
// Calculate saturation and lightness
5353
double lightness = 0.5 * (max + min);
5454
double saturation = chroma == 0 ? 0 : chroma / (1 - Math.Abs((2 * lightness) - 1));
55-
55+
5656
// Set hsl properties
5757
Hue = 60 * h1;
5858
Saturation = saturation;
@@ -71,10 +71,12 @@ private HslColor(Color color)
7171
public static HslColor Create(double hue, double saturation, double lightness, double alpha = 1)
7272
{
7373
HslColor color = default;
74-
color.Hue = hue;
75-
color.Saturation = saturation;
76-
color.Lightness = lightness;
77-
color.Alpha = alpha;
74+
#pragma warning disable 0618
75+
color.H = hue;
76+
color.S = saturation;
77+
color.L = lightness;
78+
color.A = alpha;
79+
#pragma warning restore 0618
7880
return color;
7981
}
8082

components/Helpers/src/ColorHelper/HsvColor.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ private HsvColor(Color color)
7171
public static HsvColor Create(double hue, double saturation, double value, double alpha = 1)
7272
{
7373
HsvColor color = default;
74-
color.Hue = hue;
75-
color.Saturation = saturation;
76-
color.Value = value;
77-
color.Alpha = alpha;
74+
#pragma warning disable 0618
75+
color.H = hue;
76+
color.S = saturation;
77+
color.V = value;
78+
color.A = alpha;
79+
#pragma warning restore 0618
7880
return color;
7981
}
8082

0 commit comments

Comments
 (0)