Table of Contents

Struct HSL

Namespace
PAC.Colour

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

hue float

See h.

saturation float

See s.

lightness float

See l.

Properties

h

Hue.

public float h { get; init; }

Property Value

float

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

float

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

float

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

other HSL

Returns

bool

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

other HSL
tolerance float

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

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

format string

Returns

string

WithAlpha(float)

Returns an HSLA with the same HSL values and with the given alpha.

public HSLA WithAlpha(float alpha)

Parameters

alpha float

Returns

HSLA

Operators

operator ==(HSL, HSL)

Component-wise equality.

public static bool operator ==(HSL x, HSL y)

Parameters

x HSL
y HSL

Returns

bool

explicit operator HSV(HSL)

Converts from HSL to HSV.

public static explicit operator HSV(HSL hsl)

Parameters

hsl HSL

Returns

HSV

Remarks

Does not do any clamping.

This is independent of colour space.

explicit operator RGB(HSL)

Converts from HSL to RGB.

public static explicit operator RGB(HSL hsl)

Parameters

hsl HSL

Returns

RGB

Remarks

Does not do any clamping.

This is independent of colour space.

operator !=(HSL, HSL)

public static bool operator !=(HSL x, HSL y)

Parameters

x HSL
y HSL

Returns

bool

See Also