Inheritance diagram for DzColorGradient:
Enumerations | |
enum | ColorModel { RGB, HSV } |
Methods | |
void | addGradientColor (Color color, Number value) |
void | clear () |
Color | getColor (Number value) |
ColorModel | getColorModel () |
Color | getGradientColor (Number index) |
Number | getGradientValue (Number index) |
Number | getNumGradients () |
void | removeGradientColor (Number index) |
void | setColorModel (ColorModel model) |
void | setGradientColor (Number index, Color color) |
Constructors | |
DzColorGradient (ColorModel model=RGB) | |
Signals | |
void | gradientChanged () |
This class encapsulates the behavior of a color gradient. The gradient color interpolation model can be set to be either RGB or HSV.
The user set points on the gradient are set via the addGradient() function and are stored in an internally sorted array.
Once the gradient is initialized the getColor() function is the primary interface to get values from the gradient. This function interpolates between the set points on the gradient to determine the color at the request position in the x-axis.
Typically the gradient endpoints are set at 0.0 and 1.0f but that is not required. The gradient is constructed as a set of user set colors at specific points along an x-axis aligned colorbar. The getColor() function returns the interpolated gradient color value at the requested point along the x-axis.
DzColorGradient::DzColorGradient | ( | ColorModel | model = RGB |
) |
Constructor.
model | The color model for the gradient. |
Adds a new color to the gradient.
color | The new color. | |
value | The x-axis value. |
void DzColorGradient::clear | ( | ) |
Removes all the colors from the gradient.
Computes the color on the gradient at the passed position on the gradient colorbar.
value | The x-axis value. |
DzColorGradient::ColorModel DzColorGradient::getColorModel | ( | ) |
Get the color at the indexed array point.
i | The index into the point array. |
Get the x-axis value at the indexed array point.
i | The index into the point array. |
Number DzColorGradient::getNumGradients | ( | ) |
Get the number of points in the gradient. Used with getGradientColor() and getGradientValue() to iterate over the gradient colors and values.
void DzColorGradient::gradientChanged | ( | ) | [signal] |
Emitted when the value of the gradient has been changed.
void DzColorGradient::removeGradientColor | ( | Number | index | ) |
Removes an existing color point from the gradient.
index | The index of the color point to remove. |
void DzColorGradient::setColorModel | ( | ColorModel | model | ) |
Sets the color model of the gradient.
model | The new color model for the gradient. |
Changes the color of an existing point in the gradient.
index | The index of the color point. | |
color | The new color. |