sincerely
Singaporean
If you have not done so, read this full tutorial on how to use SGEXTN to build an application.
class SGXColourRGBA;
part of SGEXTN module SG_Core
8bit RGBA colour
list of all including inherited members
preprocessor file inclusion directive: #include ‹SGXColourRGBA.h›
CMake target for BuildLah: SGEXTN::SG_Core
see this link for more information about BuildLah
parent class: (none)
children classes: (none)
SGXColourRGBA(int r, int g, int b, int a);
SGXColourRGBA(int r, int g, int b);
SGXColourRGBA(float r, float g, float b);
SGXColourRGBA(float r, float g, float b, float a);
SGXColourRGBA& applyTint(SGXColourRGBA x);
SGXColourRGBA& applyTintNoGammaCorrection(SGXColourRGBA x);
SGXColourRGBA& applyTintNoGammaCorrectionSeparateTransparency(SGXColourRGBA x, int a);
SGXColourRGBA& applyTintNoGammaCorrectionSeparateTransparencyUsingFloat(SGXColourRGBA x, float a);
SGXColourRGBA& applyTintSeparateTransparency(SGXColourRGBA x, int a);
SGXColourRGBA& applyTintSeparateTransparencyUsingFloat(SGXColourRGBA x, float a);
void gammaCorrectBegin(float& r, float& g, float& b) const;
void gammaCorrectEnd(float r, float g, float b);
[[nodiscard]] int getBlue() const;
[[nodiscard]] float getBlueAsFloat() const;
[[nodiscard]] int getGreen() const;
[[nodiscard]] float getGreenAsFloat() const;
[[nodiscard]] int getRed() const;
[[nodiscard]] float getRedAsFloat() const;
[[nodiscard]] SGXString getStringForPrintingRGBAFloatHTML() const;
[[nodiscard]] SGXString getStringForPrintingRGBAHTML() const;
[[nodiscard]] SGXString getStringForPrintingRGBAHex() const;
[[nodiscard]] SGXString getStringForPrintingRGBFloatHTML() const;
[[nodiscard]] SGXString getStringForPrintingRGBHTML() const;
[[nodiscard]] SGXString getStringForPrintingRGBHex() const;
[[nodiscard]] int getTransparency() const;
[[nodiscard]] float getTransparencyAsFloat() const;
[[nodiscard]] int hash() const;
[[nodiscard]] SGXColourRGBA linearInterpolate(SGXColourRGBA x, float f) const;
[[nodiscard]] SGXColourRGBA linearInterpolateGammaCorrection(SGXColourRGBA x, float f) const;
SGXColourRGBA& linearTransformBlue(float m, float c);
SGXColourRGBA& linearTransformBlueWithGamma(float m, float c);
SGXColourRGBA& linearTransformGreen(float m, float c);
SGXColourRGBA& linearTransformGreenWithGamma(float m, float c);
SGXColourRGBA& linearTransformRed(float m, float c);
SGXColourRGBA& linearTransformRedWithGamma(float m, float c);
SGXColourRGBA& linearTransformTransparency(float m, float c);
[[nodiscard]] bool operator!=(SGXColourRGBA x) const;
[[nodiscard]] bool operator‹(SGXColourRGBA x) const;
[[nodiscard]] bool operator==(SGXColourRGBA x) const;
[[nodiscard]] bool operator›(SGXColourRGBA x) const;
[[nodiscard]] float relativeContrast() const;
SGXColourRGBA& setBlue(int b);
SGXColourRGBA& setBlueUsingFloat(float b);
SGXColourRGBA& setGreen(int g);
SGXColourRGBA& setGreenUsingFloat(float g);
SGXColourRGBA& setRed(int r);
SGXColourRGBA& setRedUsingFloat(float r);
SGXColourRGBA& setTransparency(int a);
SGXColourRGBA& setTransparencyUsingFloat(float a);
SGXColourRGBA& toComplementColour();
SGXColourRGBA represents a colour in RGBA format with 8 bits per channel. Each of the red, green, blue, and transparency channels can range between 0 to 255 inclusive. Features such as colour transformation and gamma correction are included also.
SGXColourRGBA packs all 4 channels into 1 unsigned int.
Creates a SGXColourRGBA from its components (red r, green g, blue b, transparency a).
Each channel should range from 0 to 255 inclusive. Out of bounds channels are corrected automatically.
Ensure that all arguments passed have a type of int, otherwise it may trigger the wrong constructor.
Creates a SGXColourRGBA from its components (red r, green g, blue b) with transparency assumed to be 255.
Each channel should range from 0 to 255 inclusive. Out of bounds channels are corrected automatically.
Ensure that all arguments passed have a type of int, otherwise it may trigger the wrong constructor.
Creates a SGXColourRGBA from its components (red r, green g, blue b) with transparency assumed to be 1.
Each channel should range from 0 to 1 inclusive. Out of bounds channels are corrected automatically.
Ensure that all arguments passed have a type of float, otherwise it may trigger the wrong constructor.
Creates a SGXColourRGBA from its components (red r, green g, blue b, transparency a).
Each channel should range from 0 to 1 inclusive. Out of bounds channels are corrected automatically.
Ensure that all arguments passed have a type of float, otherwise it may trigger the wrong constructor.
Sets this SGXColourRGBA to the resulting colour if this SGXColourRGBA is viewed behind a screen with colour x, with computation done in linear colour space and returns a reference to this SGXColourRGBA to allow operation chaining.
This does not change the transparency of this SGXColourRGBA.
Sets this SGXColourRGBA to the resulting colour if this SGXColourRGBA is viewed behind a screen with colour x and returns a reference to this SGXColourRGBA to allow operation chaining.
This does not change the transparency of this SGXColourRGBA.
Sets this SGXColourRGBA to the resulting colour if this SGXColourRGBA is viewed behind a screen with colour c, where c has equal RGB channels as x but a transparency of a between 0 and 255 inclusive and returns a reference to this SGXColourRGBA to allow operation chaining.
The computation proceeds anyways if a is out of bounds. This can be useful for effects that remove a certain colour.
This does not change the transparency of this SGXColourRGBA.
Sets this SGXColourRGBA to the resulting colour if this SGXColourRGBA is viewed behind a screen with colour c, where c has equal RGB channels as x but a transparency of a between 0 and 1 inclusive and returns a reference to this SGXColourRGBA to allow operation chaining.
The computation proceeds anyways if a is out of bounds. This can be useful for effects that remove a certain colour.
This does not change the transparency of this SGXColourRGBA.
Sets this SGXColourRGBA to the resulting colour if this SGXColourRGBA is viewed behind a screen with colour c, where c has equal RGB channels as x but a transparency of a between 0 and 255 inclusive, with computation done in linear colour space and returns a reference to this SGXColourRGBA to allow operation chaining.
The computation proceeds anyways if a is out of bounds. This can be useful for effects that remove a certain colour.
This does not change the transparency of this SGXColourRGBA.
Sets this SGXColourRGBA to the resulting colour if this SGXColourRGBA is viewed behind a screen with colour c, where c has equal RGB channels as x but a transparency of a between 0 and 1 inclusive, with computation done in linear colour space and returns a reference to this SGXColourRGBA to allow operation chaining.
The computation proceeds anyways if a is out of bounds. This can be useful for effects that remove a certain colour.
This does not change the transparency of this SGXColourRGBA.
Converts the SGXColourRGBA to linear colour space for physically accurate colour mixing. The linear colour space RGB values are output in r, g, and b as floating point numbers between 0 and 1 inclusive.
Putting linear colour space values into a SGXColourRGBA is not recommended, instead use SGXColourRGBA::gammaCorrectEnd to convert it back.
Converts the RGB values r, g, b in linear colour space back into the SGXColourRGBA colour space and apply them to this SGXColourRGBA.
If the any component is out of bounds, it is corrected automatically.
Returns the blue component of this SGXColourRGBA as a int between 0 and 255 inclusive.
Returns the blue component of this SGXColourRGBA as a float between 0 and 1 inclusive.
Returns the green component of this SGXColourRGBA as a int between 0 and 255 inclusive.
Returns the green component of this SGXColourRGBA as a float between 0 and 1 inclusive.
Returns the red component of this SGXColourRGBA as a int between 0 and 255 inclusive.
Returns the red component of this SGXColourRGBA as a float between 0 and 1 inclusive.
Returns the HTML style string representation of this SGXColourRGBA with colour between 0 and 1 inclusive, this is something like rgb(1.0, 0.0, 0.8, 1.0).
Returns the HTML style string representation of this SGXColourRGBA with colour between 0 and 255 inclusive, this is something like rgb(255, 0, 200, 255).
Returns the hex code string representation of this SGXColourRGBA, this is something like #FF00C8FF.
Returns the HTML style string representation of this SGXColourRGBA with colour between 0 and 1 inclusive, this is something like rgb(1.0, 0.0, 0.8).
Returns the HTML style string representation of this SGXColourRGBA with colour between 0 and 255 inclusive, this is something like rgb(255, 0, 200).
Returns the hex code string representation of this SGXColourRGBA, this is something like #FF00C8.
Returns the transparency component of this SGXColourRGBA as a int between 0 and 255 inclusive.
Returns the transparency component of this SGXColourRGBA as a float between 0 and 1 inclusive.
Hash function defined for SGLHash.
Returns the resulting colour if f of this SGXColourRGBA is mixed with (1 - f) of x, where f is between 0 and 1 inclusive.
The computation proceeds anyways if f is out of bounds. This can be useful for effects that remove a certain colour.
The returned colour has the same transparency as this SGXColourRGBA.
Returns the resulting colour if f of this SGXColourRGBA is mixed with (1 - f) of x, where f is between 0 and 1 inclusive, computation done in linear colour space.
The computation proceeds anyways if f is out of bounds. This can be useful for effects that remove a certain colour.
The returned colour has the same transparency as this SGXColourRGBA.
Replaces the blue component of this SGXColourRGBA with m * blue + c and returns a reference to this SGXColourRGBA to allow operation chaining.
If the new blue component is out of bounds, it is corrected automatically.
Replaces the blue component of this SGXColourRGBA with m * blue + c, with computation done in linear colour space and returns a reference to this SGXColourRGBA to allow operation chaining.
If the new blue component is out of bounds, it is corrected automatically.
Replaces the green component of this SGXColourRGBA with m * green + c and returns a reference to this SGXColourRGBA to allow operation chaining.
If the new green component is out of bounds, it is corrected automatically.
Replaces the green component of this SGXColourRGBA with m * green + c, with computation done in linear colour space and returns a reference to this SGXColourRGBA to allow operation chaining.
If the new green component is out of bounds, it is corrected automatically.
Replaces the red component of this SGXColourRGBA with m * red + c and returns a reference to this SGXColourRGBA to allow operation chaining.
If the new red component is out of bounds, it is corrected automatically.
Replaces the red component of this SGXColourRGBA with m * red + c, with computation done in linear colour space and returns a reference to this SGXColourRGBA to allow operation chaining.
If the new red component is out of bounds, it is corrected automatically.
Replaces the transparency component of this SGXColourRGBA with m * transparency + c and returns a reference to this SGXColourRGBA to allow operation chaining.
If the new transparency component is out of bounds, it is corrected automatically.
Inequality check with x defined for SGLEqualsTo.
Lesser than operator with x defined for SGLLesserThan and SGLMoreThan.
Equality check with x defined for SGLEqualsTo.
More than operator with x defined for SGLLesserThan and SGLMoreThan.
Returns the contrast value of this SGXColourRGBA. Text and background in any UI element must have a contrast difference of at least 1 to be compatible with WCAG AA.
This is not the WCAG contrast ratio.
For WCAG AAA compatibility, a contrast difference of 1.3 is required
Sets the blue component of this SGXColourRGBA to b and returns a reference to this SGXColourRGBA to allow operation chaining.
b should be between 0 and 255 inclusive. If it is out of bounds, it is corrected automatically.
Sets the blue component of this SGXColourRGBA to b and returns a reference to this SGXColourRGBA to allow operation chaining.
b should be between 0 and 1 inclusive. If it is out of bounds, it is corrected automatically.
Sets the green component of this SGXColourRGBA to g and returns a reference to this SGXColourRGBA to allow operation chaining.
g should be between 0 and 255 inclusive. If it is out of bounds, it is corrected automatically.
Sets the green component of this SGXColourRGBA to g and returns a reference to this SGXColourRGBA to allow operation chaining.
g should be between 0 and 1 inclusive. If it is out of bounds, it is corrected automatically.
Sets the red component of this SGXColourRGBA to r and returns a reference to this SGXColourRGBA to allow operation chaining.
r should be between 0 and 255 inclusive. If it is out of bounds, it is corrected automatically.
Sets the red component of this SGXColourRGBA to r and returns a reference to this SGXColourRGBA to allow operation chaining.
r should be between 0 and 1 inclusive. If it is out of bounds, it is corrected automatically.
Sets the transparency component of this SGXColourRGBA to a and returns a reference to this SGXColourRGBA to allow operation chaining.
a should be between 0 and 255 inclusive. If it is out of bounds, it is corrected automatically.
Sets the transparency component of this SGXColourRGBA to a and returns a reference to this SGXColourRGBA to allow operation chaining.
a should be between 0 and 1 inclusive. If it is out of bounds, it is corrected automatically.
Sets this SGXColourRGBA to its complementary colour, with RGB channels inverted and returns a reference to this SGXColourRGBA to allow operation chaining.
©2025 05524F.sg (Singapore)