HslColor Struct
Definition
Defines a color using the hue/saturation/lightness (HSL) model. This uses a cylindrical-coordinate representation of a color.
public struct HslColor
Constructors
| Name | Description |
|---|---|
| HslColor (2 overloads) | Initializes a new instance of the Avalonia.Media.HslColor struct. |
HslColor overloads
HslColor Constructor
Initializes a new instance of the Avalonia.Media.HslColor struct.
public HslColor(Avalonia.Media.Color color)
Parameters
color Avalonia.Media.Color
The RGB color to convert to HSL.
HslColor Constructor
Initializes a new instance of the Avalonia.Media.HslColor struct.
public HslColor(double alpha, double hue, double saturation, double lightness)
Parameters
alpha double
The Alpha (transparency) component in the range from 0..1.
hue double
The Hue component in the range from 0..360. Note that 360 is equivalent to 0 and will be adjusted automatically.
saturation double
The Saturation component in the range from 0..1.
lightness double
The Lightness component in the range from 0..1.
Methods
| Name | Description |
|---|---|
| Equals (2 overloads) | No summary available. |
| FromAhsl | Creates a new Avalonia.Media.HslColor from individual color component values. |
| FromHsl | Creates a new Avalonia.Media.HslColor from individual color component values. |
| GetHashCode | Gets a hashcode for this object. Hashcode is not guaranteed to be unique. |
| Parse | Parses an HSL color string. |
| ToHsv (2 overloads) | Returns the HSV color model equivalent of this HSL color. |
| ToRgb (2 overloads) | Returns the RGB color model equivalent of this HSL color. |
| ToString | No summary available. |
| TryParse | No summary available. |
Equals overloads
Equals Method
public bool Equals(Avalonia.Media.HslColor other)
Parameters
other Avalonia.Media.HslColor
Returns
bool
Equals Method
public bool Equals(object obj)
Parameters
obj object
Returns
bool
FromAhsl Method
Creates a new Avalonia.Media.HslColor from individual color component values.
public Avalonia.Media.HslColor FromAhsl(double a, double h, double s, double l)
Parameters
a double
The Alpha (transparency) component in the range from 0..1.
h double
The Hue component in the range from 0..360.
s double
The Saturation component in the range from 0..1.
l double
The Lightness component in the range from 0..1.
Returns
A new Avalonia.Media.HslColor built from the individual color component values.
Remarks
This exists for symmetry with the Avalonia.Media.Color struct; however, the appropriate constructor should commonly be used instead.
FromHsl Method
Creates a new Avalonia.Media.HslColor from individual color component values.
public Avalonia.Media.HslColor FromHsl(double h, double s, double l)
Parameters
h double
The Hue component in the range from 0..360.
s double
The Saturation component in the range from 0..1.
l double
The Lightness component in the range from 0..1.
Returns
A new Avalonia.Media.HslColor built from the individual color component values.
Remarks
This exists for symmetry with the Avalonia.Media.Color struct; however, the appropriate constructor should commonly be used instead.
GetHashCode Method
Gets a hashcode for this object. Hashcode is not guaranteed to be unique.
public int GetHashCode()
Returns
int
The hashcode for this object.
Parse Method
Parses an HSL color string.
public Avalonia.Media.HslColor Parse(string s)
Parameters
s string
The HSL color string to parse.
Returns
The parsed Avalonia.Media.HslColor.
ToHsv overloads
ToHsv Method
Returns the HSV color model equivalent of this HSL color.
public Avalonia.Media.HsvColor ToHsv()
Returns
The HSV equivalent color.
ToHsv Method
Converts the given HSLA color component values to their HSV color equivalent.
public Avalonia.Media.HsvColor ToHsv(double hue, double saturation, double lightness, double alpha)
Parameters
hue double
The Hue component in the HSL color model in the range from 0..360.
saturation double
The Saturation component in the HSL color model in the range from 0..1.
lightness double
The Lightness component in the HSL color model in the range from 0..1.
alpha double
The Alpha component in the range from 0..1.
Returns
A new Avalonia.Media.HsvColor equivalent to the given HSLA values.
ToRgb overloads
ToRgb Method
Returns the RGB color model equivalent of this HSL color.
public Avalonia.Media.Color ToRgb()
Returns
The RGB equivalent color.
ToRgb Method
Converts the given HSLA color component values to their RGB color equivalent.
public Avalonia.Media.Color ToRgb(double hue, double saturation, double lightness, double alpha)
Parameters
hue double
The Hue component in the HSL color model in the range from 0..360.
saturation double
The Saturation component in the HSL color model in the range from 0..1.
lightness double
The Lightness component in the HSL color model in the range from 0..1.
alpha double
The Alpha component in the range from 0..1.
Returns
A new RGB Avalonia.Media.Color equivalent to the given HSLA values.
ToString Method
public string ToString()
Returns
string
TryParse Method
public bool TryParse(string s, Avalonia.Media.HslColor& hslColor)
Parameters
s string
hslColor Avalonia.Media.HslColor&
Returns
bool
Properties
| Name | Description |
|---|---|
| A | Gets the Alpha (transparency) component in the range from 0..1 (percentage). |
| H | Gets the Hue component in the range from 0..360 (degrees). This is the color's location, in degrees, on a color wheel/circle from 0 to 360. Note that 360 is equivalent to 0 and will be adjusted automatically. |
| L | Gets the Lightness component in the range from 0..1 (percentage). |
| S | Gets the Saturation component in the range from 0..1 (percentage). |
A Property
Gets the Alpha (transparency) component in the range from 0..1 (percentage).
public double A { get; set; }
Remarks
- 0 is fully transparent.
- 1 is fully opaque.
H Property
Gets the Hue component in the range from 0..360 (degrees). This is the color's location, in degrees, on a color wheel/circle from 0 to 360. Note that 360 is equivalent to 0 and will be adjusted automatically.
public double H { get; set; }
Remarks
- 0/360 degrees is Red.
- 60 degrees is Yellow.
- 120 degrees is Green.
- 180 degrees is Cyan.
- 240 degrees is Blue.
- 300 degrees is Magenta.
L Property
Gets the Lightness component in the range from 0..1 (percentage).
public double L { get; set; }
Remarks
- 0 is fully black.
- 1 is fully white.
S Property
Gets the Saturation component in the range from 0..1 (percentage).
public double S { get; set; }
Remarks
- 0 is fully white (or a shade of gray) and shows no color.
- 1 is the full color.