Table of Contents

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

hue float
saturation float
lightness float

Returns

(int R, int G, int B)

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

hue float
saturation float
brightness float

Returns

(int R, int G, int B)

GetBrightness(Color)

Gets Color brightness based on HSV space.

public static double GetBrightness(this Color color)

Parameters

color Color

Input color.

Returns

double

GetHue(Color)

Gets Color hue based on HSV space.

public static double GetHue(this Color color)

Parameters

color Color

Input color.

Returns

double

GetLuminance(Color)

Gets Color luminance based on HSL space.

public static double GetLuminance(this Color color)

Parameters

color Color

Input color.

Returns

double

GetSaturation(Color)

Gets Color saturation based on HSV space.

public static double GetSaturation(this Color color)

Parameters

color Color

Input color.

Returns

double

ToBrush(Color)

Creates a SolidColorBrush from a Color.

public static SolidColorBrush ToBrush(this Color color)

Parameters

color Color

Input 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

color Color

Input color.

opacity double

Degree of opacity.

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

(float Hue, float Saturation, float Lightness)

float hue, float saturation, float lightness

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

(float Hue, float Saturation, float Lightness)

float hue, float saturation, float brightness

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 Color

Color to convert.

brightnessFactor float

The value of the brightness change factor from 100 to -100.

saturationFactor float

The value of the saturation change factor from 100 to -100.

luminanceFactor float

The value of the luminance change factor from 100 to -100.

Returns

Color

Updated Color.

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

color Color

Input color.

factor float

The value of the brightness change factor from 100 to -100.

Returns

Color

Updated Color.

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

color Color

Input color.

factor float

The value of the luminance change factor from 100 to -100.

Returns

Color

Updated Color.

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)

Parameters

color Color

Input color.

factor float

The value of the saturation change factor from 100 to -100.

Returns

Color

Updated Color.