Class ColorExtensions
- Namespace
- Wpf.Ui.Extensions
- Assembly
- Wpf.Ui.dll
Adds an extension for Color that allows manipulation with HSL and HSV color spaces.
public static class ColorExtensions
- Inheritance
-
ColorExtensions
- Inherited Members
Methods
FromHslToRgb(float, float, float)
Converts the color values stored as HSL to RGB.
public static (int R, int G, int B) FromHslToRgb(float hue, float saturation, float lightness)
Parameters
Returns
FromHsvToRgb(float, float, float)
Converts the color values stored as HSV (HSB) to RGB.
public static (int R, int G, int B) FromHsvToRgb(float hue, float saturation, float brightness)
Parameters
Returns
GetBrightness(Color)
Gets Color brightness based on HSV space.
public static double GetBrightness(this Color color)
Parameters
color
ColorInput color.
Returns
GetHue(Color)
Gets Color hue based on HSV space.
public static double GetHue(this Color color)
Parameters
color
ColorInput color.
Returns
GetLuminance(Color)
Gets Color luminance based on HSL space.
public static double GetLuminance(this Color color)
Parameters
color
ColorInput color.
Returns
GetSaturation(Color)
Gets Color saturation based on HSV space.
public static double GetSaturation(this Color color)
Parameters
color
ColorInput color.
Returns
ToBrush(Color)
Creates a SolidColorBrush from a Color.
public static SolidColorBrush ToBrush(this Color color)
Parameters
color
ColorInput color.
Returns
- SolidColorBrush
Brush converted to color.
ToBrush(Color, double)
Creates a SolidColorBrush from a Color with defined brush opacity.
public static SolidColorBrush ToBrush(this Color color, double opacity)
Parameters
Returns
- SolidColorBrush
Brush converted to color with modified opacity.
ToHsl(Color)
HSL representation models the way different paints mix together to create colour in the real world, with the lightness dimension resembling the varying amounts of black or white paint in the mixture.
public static (float Hue, float Saturation, float Lightness) ToHsl(this Color color)
Parameters
color
Color
Returns
ToHsv(Color)
HSV representation models how colors appear under light.
public static (float Hue, float Saturation, float Value) ToHsv(this Color color)
Parameters
color
Color
Returns
Update(Color, float, float, float)
Allows to change the brightness, saturation and luminance by a factors based on the HSL and HSV color space.
public static Color Update(this Color color, float brightnessFactor, float saturationFactor = 0, float luminanceFactor = 0)
Parameters
color
ColorColor to convert.
brightnessFactor
floatThe value of the brightness change factor from
100
to-100
.saturationFactor
floatThe value of the saturation change factor from
100
to-100
.luminanceFactor
floatThe value of the luminance change factor from
100
to-100
.
Returns
UpdateBrightness(Color, float)
Allows to change the brightness by a factor based on the HSV color space.
public static Color UpdateBrightness(this Color color, float factor)
Parameters
Returns
UpdateLuminance(Color, float)
Allows to change the luminance by a factor based on the HSL color space.
public static Color UpdateLuminance(this Color color, float factor)
Parameters
Returns
UpdateSaturation(Color, float)
Allows to change the saturation by a factor based on the HSL color space.
public static Color UpdateSaturation(this Color color, float factor)