Table of Contents

Struct HSLA

Namespace
PAC.Colour

A colour in HSL (Hue, Saturation, Lightness) form with an alpha component.

public readonly struct HSLA : IEquatable<HSLA>
Implements
Inherited Members
Extension Methods

Constructors

HSLA(float, float, float, float)

Creates an HSLA with the given components without clamping or wrapping.

public HSLA(float hue, float saturation, float lightness, float alpha)

Parameters

hue float

See h.

saturation float

See s.

lightness float

See l.

alpha float

See a.

Properties

a

Alpha.

public float a { get; init; }

Property Value

float

Remarks

This is intended to be in the inclusive range [0, 1], but can be outside.

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(HSLA)

public bool Equals(HSLA other)

Parameters

other HSLA

Returns

bool

Equals(HSLA, float)

Returns whether each component of other differs from the corresponding component of this by <= tolerance.

public bool Equals(HSLA other, float tolerance)

Parameters

other HSLA
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

Operators

operator ==(HSLA, HSLA)

Component-wise equality.

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

Parameters

x HSLA
y HSLA

Returns

bool

explicit operator HSLA(Color)

Converts from Color to HSLA.

public static explicit operator HSLA(Color rgba)

Parameters

rgba Color

Returns

HSLA

Remarks

Does not do any clamping.

This is independent of colour space.

explicit operator Color(HSLA)

Converts from HSLA to Color.

public static explicit operator Color(HSLA hsla)

Parameters

hsla HSLA

Returns

Color

Remarks

Does not do any clamping.

This is independent of colour space.

explicit operator HSL(HSLA)

Returns an HSL with the same HSL values as the HSLA, but discarding the alpha.

public static explicit operator HSL(HSLA hsla)

Parameters

hsla HSLA

Returns

HSL

explicit operator HSVA(HSLA)

Converts from HSLA to HSVA.

public static explicit operator HSVA(HSLA hsla)

Parameters

hsla HSLA

Returns

HSVA

Remarks

Does not do any clamping.

This is independent of colour space.

operator !=(HSLA, HSLA)

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

Parameters

x HSLA
y HSLA

Returns

bool

See Also

HSL