sincerely Singaporean

If you have not done so, read this full tutorial on how to use SGEXTN to build an application.

SGXColourHSLA

see header file

see source file

class SGXColourHSLA;

part of SGEXTN module SG_Core

HSLA (hue saturation lightness) colour

detailed description

list of all including inherited members

implementation details

preprocessor file inclusion directive: #include ‹SGXColourHSLA.h›

CMake target for BuildLah: SGEXTN::SG_Core

see this link for more information about BuildLah

parent class: (none)

children classes: (none)

instance member variables

float a;

float h;

float l;

float s;

instance member functions

SGXColourHSLA(SGXColourRGBA x);

SGXColourHSLA(float h, float s, float l, float a);

[[nodiscard]] SGXColourRGBA getColourWithContrast(float c) const;

[[nodiscard]] int hash() const;

SGXColourHSLA& invertHue();

SGXColourHSLA& invertLightness();

SGXColourHSLA& invertSaturation();

SGXColourHSLA& linearTransformLightness(float m, float c);

SGXColourHSLA& linearTransformSaturation(float m, float c);

SGXColourHSLA& linearTransformTransparency(float m, float c);

SGXColourHSLA& offsetHue(float c);

[[nodiscard]] bool operator!=(SGXColourHSLA x) const;

[[nodiscard]] bool operator‹(SGXColourHSLA x) const;

[[nodiscard]] bool operator==(SGXColourHSLA x) const;

[[nodiscard]] bool operator›(SGXColourHSLA x) const;

SGXColourHSLA& setHue(float h);

SGXColourHSLA& setLightness(float l);

SGXColourHSLA& setSaturation(float s);

SGXColourHSLA& setTransparency(float a);

[[nodiscard]] SGXColourRGBA toRGBA() const;

Detailed Description

SGXColourHSLA represents a colour in HSLA format with effectively infinite precision as it uses floating point numbers internally. The hue can range from 0 to 360 inclusive and the saturation, lightness, and transparency can range from 0 to 100 inclusive. SGXColourHSLA is only intended for precise colour mixing, it must be convert to SGXColourRGBA for output. Note that a colour with full lightness is always white, HSL is NOT the same as HSV.

Implementation Details

SGXColourHSLA stores the hue, saturation, lightness, and transparency channels in 4 floating point numbers.

float a;

Transparency of the SGXColourHSLA.

Setting this to a value below 0 or above 100 is undefined behaviour.

float h;

Hue of the SGXColourHSLA.

Setting this to a value below 0 or above 360 is undefined behaviour.

float l;

Lightness of the SGXColourHSLA.

Setting this to a value below 0 or above 100 is undefined behaviour.

float s;

Saturation of the SGXColourHSLA

Setting this to a value below 0 or above 100 is undefined behaviour.

SGXColourHSLA(SGXColourRGBA x);

Creates a SGXColourHSLA from the SGXColourRGBA x.

SGXColourHSLA(float h, float s, float l, float a);

Creates a SGXColourHSLA with hue h, saturation s, lightness l, and transparency a.

If any argument is out of bounds, the constructor corrects it automatically.

[[nodiscard]] SGXColourRGBA getColourWithContrast(float c) const;

Returns a SGXColourRGBA with the same hue and saturation as this SGXColourHSLA and its SGXColourRGBA::relativeContrast being c.

[[nodiscard]] int hash() const;

Hash function defined for SGLLesserThan and SGLMoreThan.

SGXColourHSLA& invertHue();

Inverts the hue of this SGXColourHSLA and returns a reference to this SGXColourHSLA to allow operation chaining.

SGXColourHSLA& invertLightness();

Inverts the lightness of this SGXColourHSLA and returns a reference to this SGXColourHSLA to allow operation chaining.

This can be used to change between light mode and dark mode for custom UI.

SGXColourHSLA& invertSaturation();

Inverts the saturation of this SGXColourHSLA and returns a reference to this SGXColourHSLA to allow operation chaining.

SGXColourHSLA& linearTransformLightness(float m, float c);

Replaces the lightness of this SGXColourHSLA with m * lightness + c and returns a reference to this SGXColourHSLA to allow operation chaining.

If the new lightness is out of bounds, it is corrected automatically.

SGXColourHSLA& linearTransformSaturation(float m, float c);

Replaces the saturation of this SGXColourHSLA with m * saturation + c and returns a reference to this SGXColourHSLA to allow operation chaining.

If the new saturation is out of bounds, it is corrected automatically.

SGXColourHSLA& linearTransformTransparency(float m, float c);

Replaces the transparency of this SGXColourHSLA with m * transparency + c and returns a reference to this SGXColourHSLA to allow operation chaining.

If the new transparency is out of bounds, it is corrected automatically.

SGXColourHSLA& offsetHue(float c);

Replaces the hue of this SGXColourHSLA with hue + c and returns a reference to this SGXColourHSLA to allow operation chaining.

If the new hue is out of bounds, it is corrected automatically.

[[nodiscard]] bool operator!=(SGXColourHSLA x) const;

Inequality check with x defined for SGLEqualsTo.

[[nodiscard]] bool operator‹(SGXColourHSLA x) const;

Lesser than operator with x defined for SGLLesserThan and SGLMoreThan.

[[nodiscard]] bool operator==(SGXColourHSLA x) const;

Equality check with x defined for SGLEqualsTo.

[[nodiscard]] bool operator›(SGXColourHSLA x) const;

More than operator with x defined for SGLLesserThan and SGLMoreThan.

SGXColourHSLA& setHue(float h);

Sets the hue of this SGXColourHSLA to h and returns a reference to this SGXColourHSLA to allow operation chaining.

If h is out of bounds, it is corrected automatically.

SGXColourHSLA& setLightness(float l);

Sets the lightness of this SGXColourHSLA to l and returns a reference to this SGXColourHSLA to allow operation chaining.

If l is out of bounds, it is corrected automatically.

SGXColourHSLA& setSaturation(float s);

Sets the saturation of this SGXColourHSLA to s and returns a reference to this SGXColourHSLA to allow operation chaining.

If s is out of bounds, it is corrected automatically.

SGXColourHSLA& setTransparency(float a);

Sets the transparency of this SGXColourHSLA to a and returns a reference to this SGXColourHSLA to allow operation chaining.

If a is out of bounds, it is corrected automatically.

[[nodiscard]] SGXColourRGBA toRGBA() const;

Returns this SGXColourHSLA converted to a SGXColourRGBA.

This is necessary to use the colour for display.

©2025 05524F.sg (Singapore)

contact 05524F / report a bug / make a suggestion

about 05524F SINGAPORE values

list of 05524F projects