Describes the layout and colours that should be used to paint a colour gradient. More...
Public Member Functions | |
ColourGradient () noexcept | |
Creates an uninitialised gradient. | |
ColourGradient (const ColourGradient &) | |
ColourGradient (ColourGradient &&) noexcept | |
ColourGradient & | operator= (const ColourGradient &) |
ColourGradient & | operator= (ColourGradient &&) noexcept |
ColourGradient (Colour colour1, float x1, float y1, Colour colour2, float x2, float y2, bool isRadial) | |
Creates a gradient object. | |
ColourGradient (Colour colour1, Point< float > point1, Colour colour2, Point< float > point2, bool isRadial) | |
Creates a gradient object. | |
void | clearColours () |
Removes any colours that have been added. | |
int | addColour (double proportionAlongGradient, Colour colour) |
Adds a colour at a point along the length of the gradient. | |
void | removeColour (int index) |
Removes one of the colours from the gradient. | |
void | multiplyOpacity (float multiplier) noexcept |
Multiplies the alpha value of all the colours by the given scale factor. | |
int | getNumColours () const noexcept |
Returns the number of colour-stops that have been added. | |
double | getColourPosition (int index) const noexcept |
Returns the position along the length of the gradient of the colour with this index. | |
Colour | getColour (int index) const noexcept |
Returns the colour that was added with a given index. | |
void | setColour (int index, Colour newColour) noexcept |
Changes the colour at a given index. | |
Colour | getColourAtPosition (double position) const noexcept |
Returns the an interpolated colour at any position along the gradient. | |
int | createLookupTable (const AffineTransform &transform, HeapBlock< PixelARGB > &resultLookupTable) const |
Creates a set of interpolated premultiplied ARGB values. | |
void | createLookupTable (PixelARGB *resultLookupTable, int numEntries) const noexcept |
Creates a set of interpolated premultiplied ARGB values. | |
template<size_t NumEntries> | |
void | createLookupTable (PixelARGB(&resultLookupTable)[NumEntries]) const noexcept |
Creates a set of interpolated premultiplied ARGB values. | |
bool | isOpaque () const noexcept |
Returns true if all colours are opaque. | |
bool | isInvisible () const noexcept |
Returns true if all colours are completely transparent. | |
bool | operator== (const ColourGradient &) const noexcept |
bool | operator!= (const ColourGradient &) const noexcept |
bool | operator< (const ColourGradient &) const noexcept |
This comparison, and the other ordered comparisons are provided only for compatibility with ordered container types like std::set and std::map. | |
bool | operator<= (const ColourGradient &) const noexcept |
bool | operator> (const ColourGradient &) const noexcept |
bool | operator>= (const ColourGradient &) const noexcept |
Static Public Member Functions | |
static ColourGradient | vertical (Colour colour1, float y1, Colour colour2, float y2) |
Creates a vertical linear gradient between two Y coordinates. | |
static ColourGradient | horizontal (Colour colour1, float x1, Colour colour2, float x2) |
Creates a horizontal linear gradient between two X coordinates. | |
template<typename Type> | |
static ColourGradient | vertical (Colour colourTop, Colour colourBottom, Rectangle< Type > area) |
Creates a vertical linear gradient from top to bottom in a rectangle. | |
template<typename Type> | |
static ColourGradient | horizontal (Colour colourLeft, Colour colourRight, Rectangle< Type > area) |
Creates a horizontal linear gradient from right to left in a rectangle. | |
Public Attributes | |
Point< float > | point1 |
Point< float > | point2 |
bool | isRadial |
If true, the gradient should be filled circularly, centred around point1, with point2 defining a point on the circumference. | |
Describes the layout and colours that should be used to paint a colour gradient.
|
noexcept |
Creates an uninitialised gradient.
If you use this constructor instead of the other one, be sure to set all the object's public member variables before using it!
Referenced by ColourGradient(), ColourGradient(), ColourGradient(), ColourGradient(), horizontal(), horizontal(), operator!=(), operator<(), operator<=(), operator=(), operator=(), operator==(), operator>(), operator>=(), vertical(), and vertical().
ColourGradient::ColourGradient | ( | const ColourGradient & | ) |
References ColourGradient().
|
noexcept |
References ColourGradient().
ColourGradient::ColourGradient | ( | Colour | colour1, |
float | x1, | ||
float | y1, | ||
Colour | colour2, | ||
float | x2, | ||
float | y2, | ||
bool | isRadial ) |
Creates a gradient object.
(x1, y1) is the location to draw with colour1. Likewise (x2, y2) is where colour2 should be. In between them there's a gradient.
If isRadial is true, the colours form a circular gradient with (x1, y1) at its centre.
The alpha transparencies of the colours are used, so note that if you blend from transparent to a solid colour, the RGB of the transparent colour will become visible in parts of the gradient. e.g. blending from Colour::transparentBlack to Colours::white will produce a muddy grey colour midway, but Colour::transparentWhite to Colours::white will be white all the way across.
References ColourGradient(), and isRadial.
ColourGradient::ColourGradient | ( | Colour | colour1, |
Point< float > | point1, | ||
Colour | colour2, | ||
Point< float > | point2, | ||
bool | isRadial ) |
Creates a gradient object.
point1 is the location to draw with colour1. Likewise point2 is where colour2 should be. In between them there's a gradient.
If isRadial is true, the colours form a circular gradient with point1 at its centre.
The alpha transparencies of the colours are used, so note that if you blend from transparent to a solid colour, the RGB of the transparent colour will become visible in parts of the gradient. e.g. blending from Colour::transparentBlack to Colours::white will produce a muddy grey colour midway, but Colour::transparentWhite to Colours::white will be white all the way across.
References ColourGradient(), isRadial, Point, point1, and point2.
ColourGradient & ColourGradient::operator= | ( | const ColourGradient & | ) |
References ColourGradient().
|
noexcept |
References ColourGradient().
|
static |
Creates a vertical linear gradient between two Y coordinates.
References ColourGradient(), and vertical().
Referenced by vertical(), and vertical().
|
static |
Creates a horizontal linear gradient between two X coordinates.
References ColourGradient(), and horizontal().
Referenced by horizontal(), and horizontal().
|
static |
Creates a vertical linear gradient from top to bottom in a rectangle.
References ColourGradient(), and vertical().
|
static |
Creates a horizontal linear gradient from right to left in a rectangle.
References ColourGradient(), Rectangle< ValueType >::getRight(), Rectangle< ValueType >::getX(), and horizontal().
void ColourGradient::clearColours | ( | ) |
Removes any colours that have been added.
This will also remove any start and end colours, so the gradient won't work. You'll need to add more colours with addColour().
int ColourGradient::addColour | ( | double | proportionAlongGradient, |
Colour | colour ) |
Adds a colour at a point along the length of the gradient.
This allows the gradient to go through a spectrum of colours, instead of just a start and end colour.
proportionAlongGradient | a value between 0 and 1.0, which is the proportion of the distance along the line between the two points at which the colour should occur. |
colour | the colour that should be used at this point |
void ColourGradient::removeColour | ( | int | index | ) |
Removes one of the colours from the gradient.
|
noexcept |
Multiplies the alpha value of all the colours by the given scale factor.
|
noexcept |
Returns the number of colour-stops that have been added.
|
noexcept |
Returns the position along the length of the gradient of the colour with this index.
The index is from 0 to getNumColours() - 1. The return value will be between 0.0 and 1.0
References getColourPosition().
Referenced by getColourPosition().
|
noexcept |
Returns the colour that was added with a given index.
The index is from 0 to getNumColours() - 1.
References getColour().
Referenced by getColour().
|
noexcept |
Changes the colour at a given index.
The index is from 0 to getNumColours() - 1.
References setColour().
Referenced by setColour().
|
noexcept |
Returns the an interpolated colour at any position along the gradient.
position | the position along the gradient, between 0 and 1 |
References getColourAtPosition().
Referenced by getColourAtPosition().
int ColourGradient::createLookupTable | ( | const AffineTransform & | transform, |
HeapBlock< PixelARGB > & | resultLookupTable ) const |
Creates a set of interpolated premultiplied ARGB values.
This will resize the HeapBlock, fill it with the colours, and will return the number of colours that it added. When calling this, the ColourGradient must have at least 2 colour stops specified.
References createLookupTable().
Referenced by createLookupTable(), createLookupTable(), and createLookupTable().
|
noexcept |
Creates a set of interpolated premultiplied ARGB values.
This will fill an array of a user-specified size with the gradient, interpolating to fit. The numEntries argument specifies the size of the array, and this size must be greater than zero. When calling this, the ColourGradient must have at least 2 colour stops specified.
References createLookupTable().
|
noexcept |
Creates a set of interpolated premultiplied ARGB values.
This will fill an array of a user-specified size with the gradient, interpolating to fit. When calling this, the ColourGradient must have at least 2 colour stops specified.
References createLookupTable().
|
noexcept |
Returns true if all colours are opaque.
|
noexcept |
Returns true if all colours are completely transparent.
References isInvisible().
Referenced by isInvisible().
|
noexcept |
References ColourGradient().
|
noexcept |
References ColourGradient().
|
noexcept |
This comparison, and the other ordered comparisons are provided only for compatibility with ordered container types like std::set and std::map.
References ColourGradient().
|
noexcept |
References ColourGradient().
|
noexcept |
References ColourGradient().
|
noexcept |
References ColourGradient(), operator!=(), operator<(), and operator==().
Point<float> ColourGradient::point1 |
Referenced by ColourGradient().
Point<float> ColourGradient::point2 |
Referenced by ColourGradient().
bool ColourGradient::isRadial |
If true, the gradient should be filled circularly, centred around point1, with point2 defining a point on the circumference.
If false, the gradient is linear between the two points.
Referenced by ColourGradient(), and ColourGradient().