You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `ColorHelper` package includes methods for manipulating colors in the HSL or HSV color space.
16
37
17
38
```csharp
18
-
Colorcolor="#FFFF0000".ToColor();
19
-
Colorcolor="Red".ToColor();
20
-
stringhex=Colors.Red.ToHex();
21
-
HslColorhsl=Colors.Red.ToHsl();
22
-
HsvColorhsv=Colors.Red.ToHsv();
23
-
inti=Colors.Red.ToInt();
39
+
// Adjust a color's hue (to blue)
40
+
color=color.WithHue(240);
41
+
42
+
// Adjust a color's saturation (to fully saturated)
43
+
color=color.WithSaturation(1);
44
+
```
45
+
46
+
The package also includes models to store the color as either a HSV or HSL color.
47
+
48
+
A `Windows.UI.Color` can be converted to an a `HsvColor` or `HslColor` either by using the `.ToHsv()` and `.ToHsl()` methods, or by using an explicit cast on a color.
49
+
50
+
`HslColor` and `HsvColor` will implicity cast back to a `Windows.UI.Color` when needed.
51
+
52
+
```csharp
53
+
// Convert to hsl
54
+
Colorcolor;
55
+
varhslColor= (HslColor)color;
56
+
57
+
// new SolidColorBrush takes a Color, but the HslColor can be implicitly cast to match
0 commit comments