QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
|
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra color stops. More...
#include <qgscolorrampimpl.h>
Public Member Functions | |
QgsGradientColorRamp (const QColor &color1=DEFAULT_GRADIENT_COLOR1, const QColor &color2=DEFAULT_GRADIENT_COLOR2, bool discrete=false, const QgsGradientStopsList &stops=QgsGradientStopsList()) | |
Constructor for QgsGradientColorRamp. | |
void | addStopsToGradient (QGradient *gradient, double opacity=1) const |
Copy color ramp stops to a QGradient. | |
QgsGradientColorRamp * | clone () const override |
Creates a clone of the color ramp. | |
QColor | color (double value) const override |
Returns the color corresponding to a specified value. | |
QColor | color1 () const |
Returns the gradient start color. | |
QColor | color2 () const |
Returns the gradient end color. | |
QColor::Spec | colorSpec () const |
Returns the color specification in which the color component interpolation will occur. | |
void | convertToDiscrete (bool discrete) |
Converts a gradient with existing color stops to or from discrete interpolation. | |
int | count () const override |
Returns number of defined colors, or -1 if undefined. | |
Qgis::AngularDirection | direction () const |
Returns the direction to traverse the color wheel using when interpolating hue-based color specifications. | |
QgsStringMap | info () const |
Returns any additional info attached to the gradient ramp (e.g., authorship notes) | |
void | invert () override |
Inverts the ordering of the color ramp. | |
bool | isDiscrete () const |
Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating between colors. | |
QVariantMap | properties () const override |
Returns a string map containing all the color ramp's properties. | |
void | setColor1 (const QColor &color) |
Sets the gradient start color. | |
void | setColor2 (const QColor &color) |
Sets the gradient end color. | |
void | setColorSpec (QColor::Spec spec) |
Sets the color specification in which the color component interpolation will occur. | |
void | setDirection (Qgis::AngularDirection direction) |
Sets the direction to traverse the color wheel using when interpolating hue-based color specifications. | |
void | setDiscrete (bool discrete) |
Sets whether the gradient should use discrete interpolation, rather than smoothly interpolating between colors. | |
void | setInfo (const QgsStringMap &info) |
Sets additional info to attach to the gradient ramp (e.g., authorship notes) | |
void | setStops (const QgsGradientStopsList &stops) |
Sets the list of intermediate gradient stops for the ramp. | |
QgsGradientStopsList | stops () const |
Returns the list of intermediate gradient stops for the ramp. | |
QString | type () const override |
Returns a string representing the color ramp type. | |
double | value (int index) const override |
Returns relative value between [0,1] of color at specified index. | |
![]() | |
virtual | ~QgsColorRamp () |
Static Public Member Functions | |
static QgsColorRamp * | create (const QVariantMap &properties=QVariantMap()) |
Creates a new QgsColorRamp from a map of properties. | |
static QString | typeString () |
Returns the string identifier for QgsGradientColorRamp. | |
![]() | |
static QList< QPair< QString, QString > > | rampTypes () |
Returns a list of available ramp types, where the first value in each item is the QgsColorRamp::type() string and the second is a user friendly, translated name for the color ramp type. | |
Protected Attributes | |
QColor | mColor1 |
QColor | mColor2 |
QColor::Spec | mColorSpec = QColor::Spec::Rgb |
Qgis::AngularDirection | mDirection = Qgis::AngularDirection::CounterClockwise |
bool | mDiscrete |
InterpolateColorFunc | mFunc = nullptr |
QgsStringMap | mInfo |
QgsGradientStopsList | mStops |
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra color stops.
Definition at line 134 of file qgscolorrampimpl.h.
QgsGradientColorRamp::QgsGradientColorRamp | ( | const QColor & | color1 = DEFAULT_GRADIENT_COLOR1 , |
const QColor & | color2 = DEFAULT_GRADIENT_COLOR2 , |
||
bool | discrete = false , |
||
const QgsGradientStopsList & | stops = QgsGradientStopsList() |
||
) |
Constructor for QgsGradientColorRamp.
color1 | start color, corresponding to a position of 0.0 |
color2 | end color, corresponding to a position of 1.0 |
discrete | set to true for discrete interpolation instead of smoothly interpolating between colors |
stops | optional list of additional color stops |
Definition at line 208 of file qgscolorrampimpl.cpp.
void QgsGradientColorRamp::addStopsToGradient | ( | QGradient * | gradient, |
double | opacity = 1 |
||
) | const |
Copy color ramp stops to a QGradient.
gradient | gradient to copy stops into |
opacity | opacity multiplier. Opacity of colors will be multiplied by this factor before adding to the gradient. |
Definition at line 543 of file qgscolorrampimpl.cpp.
|
overridevirtual |
Creates a clone of the color ramp.
Implements QgsColorRamp.
Definition at line 418 of file qgscolorrampimpl.cpp.
|
overridevirtual |
Returns the color corresponding to a specified value.
value | value between [0, 1] inclusive |
Implements QgsColorRamp.
Definition at line 319 of file qgscolorrampimpl.cpp.
|
inline |
Returns the gradient start color.
Definition at line 175 of file qgscolorrampimpl.h.
|
inline |
Returns the gradient end color.
Definition at line 182 of file qgscolorrampimpl.h.
|
inline |
Returns the color specification in which the color component interpolation will occur.
For multi-stop gradients this color spec will be used for the portion of the color ramp leading into the final stop (i.e. color2()).
Definition at line 270 of file qgscolorrampimpl.h.
void QgsGradientColorRamp::convertToDiscrete | ( | bool | discrete | ) |
Converts a gradient with existing color stops to or from discrete interpolation.
discrete | set to true to convert the gradient stops to discrete, or false to convert them to smooth interpolation |
Definition at line 488 of file qgscolorrampimpl.cpp.
|
inlineoverridevirtual |
Returns number of defined colors, or -1 if undefined.
Implements QgsColorRamp.
Definition at line 154 of file qgscolorrampimpl.h.
|
static |
Creates a new QgsColorRamp from a map of properties.
Definition at line 218 of file qgscolorrampimpl.cpp.
|
inline |
Returns the direction to traverse the color wheel using when interpolating hue-based color specifications.
For multi-stop gradients this direction will be used for the portion of the color ramp leading into the final stop (i.e. color2()).
Definition at line 295 of file qgscolorrampimpl.h.
|
inline |
Returns any additional info attached to the gradient ramp (e.g., authorship notes)
Definition at line 244 of file qgscolorrampimpl.h.
|
overridevirtual |
Inverts the ordering of the color ramp.
Reimplemented from QgsColorRamp.
Definition at line 370 of file qgscolorrampimpl.cpp.
|
inline |
Returns true
if the gradient is using discrete interpolation, rather than smoothly interpolating between colors.
Definition at line 205 of file qgscolorrampimpl.h.
|
overridevirtual |
Returns a string map containing all the color ramp's properties.
Implements QgsColorRamp.
Definition at line 428 of file qgscolorrampimpl.cpp.
|
inline |
Sets the gradient start color.
color | start color |
Definition at line 190 of file qgscolorrampimpl.h.
|
inline |
Sets the gradient end color.
color | end color |
Definition at line 198 of file qgscolorrampimpl.h.
void QgsGradientColorRamp::setColorSpec | ( | QColor::Spec | spec | ) |
Sets the color specification in which the color component interpolation will occur.
Only QColor::Spec::Rgb, QColor::Spec::Hsv and QColor::Spec::Hsl are currently supported.
For multi-stop gradients this color spec will be used for the portion of the color ramp leading into the final stop (i.e. color2()).
Definition at line 598 of file qgscolorrampimpl.cpp.
|
inline |
Sets the direction to traverse the color wheel using when interpolating hue-based color specifications.
For multi-stop gradients this direction will be used for the portion of the color ramp leading into the final stop (i.e. color2()).
Definition at line 307 of file qgscolorrampimpl.h.
|
inline |
Sets whether the gradient should use discrete interpolation, rather than smoothly interpolating between colors.
discrete | set to true to use discrete interpolation |
Definition at line 214 of file qgscolorrampimpl.h.
|
inline |
Sets additional info to attach to the gradient ramp (e.g., authorship notes)
info | map of string info to attach |
Definition at line 251 of file qgscolorrampimpl.h.
void QgsGradientColorRamp::setStops | ( | const QgsGradientStopsList & | stops | ) |
Sets the list of intermediate gradient stops for the ramp.
stops | list of stops. Any existing color stops will be replaced. The stop list will be automatically reordered so that stops are listed in ascending offset order. |
Definition at line 535 of file qgscolorrampimpl.cpp.
|
inline |
Returns the list of intermediate gradient stops for the ramp.
Definition at line 238 of file qgscolorrampimpl.h.
|
overridevirtual |
Returns a string representing the color ramp type.
Implements QgsColorRamp.
Definition at line 365 of file qgscolorrampimpl.cpp.
|
inlinestatic |
Returns the string identifier for QgsGradientColorRamp.
Definition at line 163 of file qgscolorrampimpl.h.
|
overridevirtual |
Returns relative value between [0,1] of color at specified index.
Implements QgsColorRamp.
Definition at line 303 of file qgscolorrampimpl.cpp.
|
protected |
Definition at line 310 of file qgscolorrampimpl.h.
|
protected |
Definition at line 311 of file qgscolorrampimpl.h.
|
protected |
Definition at line 315 of file qgscolorrampimpl.h.
|
protected |
Definition at line 316 of file qgscolorrampimpl.h.
|
protected |
Definition at line 312 of file qgscolorrampimpl.h.
|
protected |
Definition at line 318 of file qgscolorrampimpl.h.
|
protected |
Definition at line 314 of file qgscolorrampimpl.h.
|
protected |
Definition at line 313 of file qgscolorrampimpl.h.