Struct HSL
A colour in HSL (Hue, Saturation, Lightness) form with no alpha component.
public readonly struct HSL : IEquatable<HSL>
- Implements
- Inherited Members
- Extension Methods
Constructors
HSL(float, float, float)
Creates an HSL with the given components without clamping or wrapping.
public HSL(float hue, float saturation, float lightness)
Parameters
Properties
h
Hue.
public float h { get; init; }
Property Value
Remarks
This is intended to be in the inclusive-exclusive range [0, 1), but can be outside.
l
Lightness.
public float l { get; init; }
Property Value
Remarks
This is intended to be in the inclusive range [0, 1], but can be outside.
s
Saturation.
public float s { get; init; }
Property Value
Remarks
This is intended to be in the inclusive range [0, 1], but can be outside.
Methods
Equals(HSL)
public bool Equals(HSL other)
Parameters
otherHSL
Returns
Equals(HSL, float)
Returns whether each component of other differs from the corresponding component of this by <= tolerance.
public bool Equals(HSL other, float tolerance)
Parameters
Returns
Equals(object)
See Equals(HSL).
public override bool Equals(object obj)
Parameters
objobject
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
ToString(string)
Applies format to each component.
public string ToString(string format)
Parameters
formatstring
Returns
WithAlpha(float)
Returns an HSLA with the same HSL values and with the given alpha.
public HSLA WithAlpha(float alpha)
Parameters
alphafloat
Returns
Operators
operator ==(HSL, HSL)
Component-wise equality.
public static bool operator ==(HSL x, HSL y)
Parameters
Returns
explicit operator HSV(HSL)
public static explicit operator HSV(HSL hsl)
Parameters
hslHSL
Returns
Remarks
Does not do any clamping.
This is independent of colour space.
explicit operator RGB(HSL)
public static explicit operator RGB(HSL hsl)
Parameters
hslHSL
Returns
Remarks
Does not do any clamping.
This is independent of colour space.
operator !=(HSL, HSL)
public static bool operator !=(HSL x, HSL y)