Represents a colour, also including a transparency value. More...
Public Member Functions | |
| Colour () noexcept | |
| Creates a transparent black colour. | |
| Colour (const Colour &other) noexcept | |
| Creates a copy of another Colour object. | |
| Colour (uint32 argb) noexcept | |
| Creates a colour from a 32-bit ARGB value. | |
| Colour (uint8 red, uint8 green, uint8 blue) noexcept | |
| Creates an opaque colour using 8-bit red, green and blue values. | |
| Colour (uint8 red, uint8 green, uint8 blue, uint8 alpha) noexcept | |
| Creates a colour using 8-bit red, green, blue and alpha values. | |
| Colour (uint8 red, uint8 green, uint8 blue, float alpha) noexcept | |
| Creates a colour from 8-bit red, green, and blue values, and a floating-point alpha. | |
| Colour (float hue, float saturation, float brightness, uint8 alpha) noexcept | |
| Creates a colour using floating point hue, saturation and brightness values, and an 8-bit alpha. | |
| Colour (float hue, float saturation, float brightness, float alpha) noexcept | |
| Creates a colour using floating point hue, saturation, brightness and alpha values. | |
| ~Colour () noexcept | |
| Destructor. | |
| Colour & | operator= (const Colour &other) noexcept |
| Copies another Colour object. | |
| bool | operator== (const Colour &other) const noexcept |
| Compares two colours. | |
| bool | operator!= (const Colour &other) const noexcept |
| Compares two colours. | |
| uint8 | getRed () const noexcept |
| Returns the red component of this colour. | |
| uint8 | getGreen () const noexcept |
| Returns the green component of this colour. | |
| uint8 | getBlue () const noexcept |
| Returns the blue component of this colour. | |
| float | getFloatRed () const noexcept |
| Returns the red component of this colour as a floating point value. | |
| float | getFloatGreen () const noexcept |
| Returns the green component of this colour as a floating point value. | |
| float | getFloatBlue () const noexcept |
| Returns the blue component of this colour as a floating point value. | |
| const PixelARGB | getPixelARGB () const noexcept |
| Returns a premultiplied ARGB pixel object that represents this colour. | |
| uint32 | getARGB () const noexcept |
| Returns a 32-bit integer that represents this colour. | |
| uint8 | getAlpha () const noexcept |
| Returns the colour's alpha (opacity). | |
| float | getFloatAlpha () const noexcept |
| Returns the colour's alpha (opacity) as a floating point value. | |
| bool | isOpaque () const noexcept |
| Returns true if this colour is completely opaque. | |
| bool | isTransparent () const noexcept |
| Returns true if this colour is completely transparent. | |
| Colour | withAlpha (uint8 newAlpha) const noexcept |
| Returns a colour that's the same colour as this one, but with a new alpha value. | |
| Colour | withAlpha (float newAlpha) const noexcept |
| Returns a colour that's the same colour as this one, but with a new alpha value. | |
| Colour | withMultipliedAlpha (float alphaMultiplier) const noexcept |
| Returns a colour that's the same colour as this one, but with a modified alpha value. | |
| Colour | overlaidWith (const Colour &foregroundColour) const noexcept |
| Returns a colour that is the result of alpha-compositing a new colour over this one. | |
| Colour | interpolatedWith (const Colour &other, float proportionOfOther) const noexcept |
| Returns a colour that lies somewhere between this one and another. | |
| float | getHue () const noexcept |
| Returns the colour's hue component. | |
| float | getSaturation () const noexcept |
| Returns the colour's saturation component. | |
| float | getBrightness () const noexcept |
| Returns the colour's brightness component. | |
| void | getHSB (float &hue, float &saturation, float &brightness) const noexcept |
| Returns the colour's hue, saturation and brightness components all at once. | |
| Colour | withHue (float newHue) const noexcept |
| Returns a copy of this colour with a different hue. | |
| Colour | withSaturation (float newSaturation) const noexcept |
| Returns a copy of this colour with a different saturation. | |
| Colour | withBrightness (float newBrightness) const noexcept |
| Returns a copy of this colour with a different brightness. | |
| Colour | withRotatedHue (float amountToRotate) const noexcept |
| Returns a copy of this colour with it hue rotated. | |
| Colour | withMultipliedSaturation (float multiplier) const noexcept |
| Returns a copy of this colour with its saturation multiplied by the given value. | |
| Colour | withMultipliedBrightness (float amount) const noexcept |
| Returns a copy of this colour with its brightness multiplied by the given value. | |
| Colour | brighter (float amountBrighter=0.4f) const noexcept |
| Returns a brighter version of this colour. | |
| Colour | darker (float amountDarker=0.4f) const noexcept |
| Returns a darker version of this colour. | |
| Colour | contrasting (float amount=1.0f) const noexcept |
| Returns a colour that will be clearly visible against this colour. | |
| String | toString () const |
| Returns a stringified version of this colour. | |
| String | toDisplayString (bool includeAlphaValue) const |
| Returns the colour as a hex string in the form RRGGBB or AARRGGBB. | |
Static Public Member Functions | |
| static Colour | fromRGB (uint8 red, uint8 green, uint8 blue) noexcept |
| Creates an opaque colour using 8-bit red, green and blue values. | |
| static Colour | fromRGBA (uint8 red, uint8 green, uint8 blue, uint8 alpha) noexcept |
| Creates a colour using 8-bit red, green, blue and alpha values. | |
| static Colour | fromRGBAFloat (uint8 red, uint8 green, uint8 blue, float alpha) noexcept |
| Creates a colour using 8-bit red, green, blue and float alpha values. | |
| static Colour | fromHSV (float hue, float saturation, float brightness, float alpha) noexcept |
| Creates a colour using floating point hue, saturation and brightness values, and an 8-bit alpha. | |
| static Colour | contrasting (const Colour &colour1, const Colour &colour2) noexcept |
| Returns a colour that contrasts against two colours. | |
| static Colour | greyLevel (float brightness) noexcept |
| Returns an opaque shade of grey. | |
| static Colour | fromString (const String &encodedColourString) |
| Reads the colour from a string that was created with toString(). | |
Represents a colour, also including a transparency value.
The colour is stored internally as unsigned 8-bit red, green, blue and alpha values.
| Colour::Colour | ( | ) |
Creates a transparent black colour.
| Colour::Colour | ( | uint32 | argb ) | [explicit] |
Creates a colour from a 32-bit ARGB value.
The format of this number is: ((alpha << 24) | (red << 16) | (green << 8) | blue).
All components in the range 0x00 to 0xff. An alpha of 0x00 is completely transparent, alpha of 0xff is opaque.
Creates an opaque colour using 8-bit red, green and blue values.
Creates a colour using 8-bit red, green, blue and alpha values.
Creates a colour from 8-bit red, green, and blue values, and a floating-point alpha.
Alpha of 0.0 is transparent, alpha of 1.0f is opaque. Values outside the valid range will be clipped.
| Colour::Colour | ( | float | hue, |
| float | saturation, | ||
| float | brightness, | ||
| uint8 | alpha | ||
| ) |
Creates a colour using floating point hue, saturation and brightness values, and an 8-bit alpha.
The floating point values must be between 0.0 and 1.0. An alpha of 0x00 is completely transparent, alpha of 0xff is opaque. Values outside the valid range will be clipped.
| Colour::Colour | ( | float | hue, |
| float | saturation, | ||
| float | brightness, | ||
| float | alpha | ||
| ) |
Creates a colour using floating point hue, saturation, brightness and alpha values.
All values must be between 0.0 and 1.0. Numbers outside the valid range will be clipped.
| Colour::~Colour | ( | ) |
Destructor.
Creates an opaque colour using 8-bit red, green and blue values.
Creates a colour using 8-bit red, green, blue and alpha values.
Creates a colour using 8-bit red, green, blue and float alpha values.
| static Colour Colour::fromHSV | ( | float | hue, |
| float | saturation, | ||
| float | brightness, | ||
| float | alpha | ||
| ) | [static] |
Creates a colour using floating point hue, saturation and brightness values, and an 8-bit alpha.
The floating point values must be between 0.0 and 1.0. An alpha of 0x00 is completely transparent, alpha of 0xff is opaque. Values outside the valid range will be clipped.
| bool Colour::operator== | ( | const Colour & | other ) | const |
Compares two colours.
| bool Colour::operator!= | ( | const Colour & | other ) | const |
Compares two colours.
| uint8 Colour::getRed | ( | ) | const |
Returns the red component of this colour.
| uint8 Colour::getGreen | ( | ) | const |
Returns the green component of this colour.
| uint8 Colour::getBlue | ( | ) | const |
Returns the blue component of this colour.
| float Colour::getFloatRed | ( | ) | const |
Returns the red component of this colour as a floating point value.
| float Colour::getFloatGreen | ( | ) | const |
Returns the green component of this colour as a floating point value.
| float Colour::getFloatBlue | ( | ) | const |
Returns the blue component of this colour as a floating point value.
| const PixelARGB Colour::getPixelARGB | ( | ) | const |
Returns a premultiplied ARGB pixel object that represents this colour.
| uint32 Colour::getARGB | ( | ) | const |
Returns a 32-bit integer that represents this colour.
The format of this number is: ((alpha << 24) | (red << 16) | (green << 16) | blue).
| uint8 Colour::getAlpha | ( | ) | const |
Returns the colour's alpha (opacity).
Alpha of 0x00 is completely transparent, 0xff is completely opaque.
References PixelARGB::getAlpha().
| float Colour::getFloatAlpha | ( | ) | const |
Returns the colour's alpha (opacity) as a floating point value.
Alpha of 0.0 is completely transparent, 1.0 is completely opaque.
Referenced by FillType::getOpacity().
| bool Colour::isOpaque | ( | ) | const |
Returns true if this colour is completely opaque.
Equivalent to (getAlpha() == 0xff).
| bool Colour::isTransparent | ( | ) | const |
Returns true if this colour is completely transparent.
Equivalent to (getAlpha() == 0x00).
Returns a colour that's the same colour as this one, but with a new alpha value.
| Colour Colour::withAlpha | ( | float | newAlpha ) | const |
Returns a colour that's the same colour as this one, but with a new alpha value.
| Colour Colour::withMultipliedAlpha | ( | float | alphaMultiplier ) | const |
Returns a colour that's the same colour as this one, but with a modified alpha value.
The new colour's alpha will be this object's alpha multiplied by the value passed-in.
Returns a colour that is the result of alpha-compositing a new colour over this one.
If the foreground colour is semi-transparent, it is blended onto this colour accordingly.
Returns a colour that lies somewhere between this one and another.
If amountOfOther is zero, the result is 100% this colour, if amountOfOther is 1.0, the result is 100% of the other colour.
| float Colour::getHue | ( | ) | const |
Returns the colour's hue component.
The value returned is in the range 0.0 to 1.0
| float Colour::getSaturation | ( | ) | const |
Returns the colour's saturation component.
The value returned is in the range 0.0 to 1.0
| float Colour::getBrightness | ( | ) | const |
Returns the colour's brightness component.
The value returned is in the range 0.0 to 1.0
| void Colour::getHSB | ( | float & | hue, |
| float & | saturation, | ||
| float & | brightness | ||
| ) | const |
Returns the colour's hue, saturation and brightness components all at once.
The values returned are in the range 0.0 to 1.0
| Colour Colour::withHue | ( | float | newHue ) | const |
Returns a copy of this colour with a different hue.
| Colour Colour::withSaturation | ( | float | newSaturation ) | const |
Returns a copy of this colour with a different saturation.
| Colour Colour::withBrightness | ( | float | newBrightness ) | const |
Returns a copy of this colour with a different brightness.
| Colour Colour::withRotatedHue | ( | float | amountToRotate ) | const |
Returns a copy of this colour with it hue rotated.
The new colour's hue is ((this->getHue() + amountToRotate) % 1.0)
| Colour Colour::withMultipliedSaturation | ( | float | multiplier ) | const |
Returns a copy of this colour with its saturation multiplied by the given value.
The new colour's saturation is (this->getSaturation() * multiplier) (the result is clipped to legal limits).
| Colour Colour::withMultipliedBrightness | ( | float | amount ) | const |
Returns a copy of this colour with its brightness multiplied by the given value.
The new colour's saturation is (this->getBrightness() * multiplier) (the result is clipped to legal limits).
| Colour Colour::brighter | ( | float | amountBrighter = 0.4f ) |
const |
Returns a brighter version of this colour.
| amountBrighter | how much brighter to make it - a value from 0 to 1.0 where 0 is unchanged, and higher values make it brighter |
| Colour Colour::darker | ( | float | amountDarker = 0.4f ) |
const |
Returns a darker version of this colour.
| amountDarker | how much darker to make it - a value from 0 to 1.0 where 0 is unchanged, and higher values make it darker |
| Colour Colour::contrasting | ( | float | amount = 1.0f ) |
const |
Returns a colour that will be clearly visible against this colour.
The amount parameter indicates how contrasting the new colour should be, so e.g. Colours::black.contrasting (0.1f) will return a colour that's just a little bit lighter; Colours::black.contrasting (1.0f) will return white; Colours::white.contrasting (1.0f) will return black, etc.
Returns a colour that contrasts against two colours.
Looks for a colour that contrasts with both of the colours passed-in.
Handy for things like choosing a highlight colour in text editors, etc.
| static Colour Colour::greyLevel | ( | float | brightness ) | [static] |
Returns an opaque shade of grey.
| brightness | the level of grey to return - 0 is black, 1.0 is white |
| String Colour::toString | ( | ) | const |
Returns a stringified version of this colour.
The string can be turned back into a colour using the fromString() method.
Reads the colour from a string that was created with toString().
| String Colour::toDisplayString | ( | bool | includeAlphaValue ) | const |
Returns the colour as a hex string in the form RRGGBB or AARRGGBB.