ColorHSL

References
public struct ColorHSL : IEquatable<ColorHSL>
Color representation in the HSL color model
Remarks: This allows you to manage a color in the HSL cylindrical model. This is a helper class to handle HSL colors. Whenever a color is used it must be converted to a Color struct first, either by using ToColor() or the implicit conversion.

Constructors

ColorHSL

#
public ColorHSL(Color color)
Initializes a new instance of the ColorHSL class with converted HSL values from a Color

ColorHSL

#
public ColorHSL(float hue, float saturation, float luminance, float alpha = 1)
Initializes a new instance of the ColorHSL class
hue (float)Hue component (0-360)
saturation (float)Saturation component (0-1)
luminance (float)Luminace component (0-1)
alpha (float = 1)Alpha component (0-1)

Properties

Methods

Distance

#
public static float Distance(ColorHSL value1, ColorHSL value2)
Calculates the 'distance' of two HSL colors
Remarks: This is useful for comparing two different color values to determine if they are similar. The HSL comparison algorithm, while not essentially accurate, gives a good representation of like-colours to the human eye. This method of calculating distance is preferred over the other methods (RGB, CMYK, HSB)
value1 (ColorHSL)First color to compare
value2 (ColorHSL)Second color to compare
The overall distance/difference between the two colours. A lower value indicates a closer match

Equals

#
public bool Equals(ColorHSL other)
Compares the given object for equality with this object
other (ColorHSL)Object to compare with
True if the object is equal to this instance, false otherwise

Equals

#
public override bool Equals(object obj)
Compares the given object for equality with this object
obj (object)Object to compare with
True if the object is equal to this instance, false otherwise
ValueType.Equals

GetHashCode

#
public override int GetHashCode()
Gets the hash code for this object

ToColor

#
public Color ToColor()
Converts this HSL color to a RGB Color value

Operators

OperationResultDescription
ColorHSL==ColorHSLboolCompares two ColorHSL objects for equality
ColorHSL!=ColorHSLboolCompares two ColorHSL objects for equality

Convertors

OperationResultDescription
implicitColorHSLColorImplicitly converts a ColorHSL to an RGB Color
implicitColorColorHSLImplicitly converts from a Color to a ColorHSL