| QGIS API Documentation
    3.22.4-Białowieża (ce8e65e95e)
    | 
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra color stops. More...
#include <qgscolorramp.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.  More... | |
| void | addStopsToGradient (QGradient *gradient, double opacity=1) | 
| Copy color ramp stops to a QGradient.  More... | |
| QgsGradientColorRamp * | clone () const override | 
| Creates a clone of the color ramp.  More... | |
| QColor | color (double value) const override | 
| Returns the color corresponding to a specified value.  More... | |
| QColor | color1 () const | 
| Returns the gradient start color.  More... | |
| QColor | color2 () const | 
| Returns the gradient end color.  More... | |
| void | convertToDiscrete (bool discrete) | 
| Converts a gradient with existing color stops to or from discrete interpolation.  More... | |
| int | count () const override | 
| Returns number of defined colors, or -1 if undefined.  More... | |
| QgsStringMap | info () const | 
| Returns any additional info attached to the gradient ramp (e.g., authorship notes)  More... | |
| void | invert () override | 
| Inverts the ordering of the color ramp.  More... | |
| bool | isDiscrete () const | 
| Returns trueif the gradient is using discrete interpolation, rather than smoothly interpolating between colors.  More... | |
| QVariantMap | properties () const override | 
| Returns a string map containing all the color ramp's properties.  More... | |
| void | setColor1 (const QColor &color) | 
| Sets the gradient start color.  More... | |
| void | setColor2 (const QColor &color) | 
| Sets the gradient end color.  More... | |
| void | setDiscrete (bool discrete) | 
| Sets whether the gradient should use discrete interpolation, rather than smoothly interpolating between colors.  More... | |
| void | setInfo (const QgsStringMap &info) | 
| Sets additional info to attach to the gradient ramp (e.g., authorship notes)  More... | |
| void | setStops (const QgsGradientStopsList &stops) | 
| Sets the list of intermediate gradient stops for the ramp.  More... | |
| QgsGradientStopsList | stops () const | 
| Returns the list of intermediate gradient stops for the ramp.  More... | |
| QString | type () const override | 
| Returns a string representing the color ramp type.  More... | |
| double | value (int index) const override | 
| Returns relative value between [0,1] of color at specified index.  More... | |
|  Public Member Functions inherited from QgsColorRamp | |
| virtual | ~QgsColorRamp ()=default | 
| Static Public Member Functions | |
| static QgsColorRamp * | create (const QVariantMap &properties=QVariantMap()) | 
| Creates a new QgsColorRamp from a map of properties.  More... | |
| static QString | typeString () | 
| Returns the string identifier for QgsGradientColorRamp.  More... | |
|  Static Public Member Functions inherited from QgsColorRamp | |
| 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.  More... | |
| Protected Attributes | |
| QColor | mColor1 | 
| QColor | mColor2 | 
| bool | mDiscrete | 
| QgsStringMap | mInfo | 
| QgsGradientStopsList | mStops | 
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra color stops.
Definition at line 152 of file qgscolorramp.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 truefor discrete interpolation instead of smoothly interpolating between colors | 
| stops | optional list of additional color stops | 
Definition at line 47 of file qgscolorramp.cpp.
| void QgsGradientColorRamp::addStopsToGradient | ( | QGradient * | gradient, | 
| double | opacity = 1 | ||
| ) | 
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 291 of file qgscolorramp.cpp.
| 
 | overridevirtual | 
Creates a clone of the color ramp.
Implements QgsColorRamp.
Reimplemented in QgsCptCityColorRamp.
Definition at line 202 of file qgscolorramp.cpp.
| 
 | overridevirtual | 
Returns the color corresponding to a specified value.
| value | value between [0, 1] inclusive | 
Implements QgsColorRamp.
Definition at line 124 of file qgscolorramp.cpp.
| 
 | inline | 
Returns the gradient start color.
Definition at line 193 of file qgscolorramp.h.
| 
 | inline | 
Returns the gradient end color.
Definition at line 200 of file qgscolorramp.h.
| void QgsGradientColorRamp::convertToDiscrete | ( | bool | discrete | ) | 
Converts a gradient with existing color stops to or from discrete interpolation.
| discrete | set to trueto convert the gradient stops to discrete, orfalseto convert them to smooth interpolation | 
Definition at line 236 of file qgscolorramp.cpp.
| 
 | inlineoverridevirtual | 
Returns number of defined colors, or -1 if undefined.
Implements QgsColorRamp.
Definition at line 172 of file qgscolorramp.h.
| 
 | static | 
Creates a new QgsColorRamp from a map of properties.
Definition at line 56 of file qgscolorramp.cpp.
| 
 | inline | 
Returns any additional info attached to the gradient ramp (e.g., authorship notes)
Definition at line 262 of file qgscolorramp.h.
| 
 | overridevirtual | 
Inverts the ordering of the color ramp.
Reimplemented from QgsColorRamp.
Reimplemented in QgsCptCityColorRamp.
Definition at line 175 of file qgscolorramp.cpp.
| 
 | inline | 
Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating between colors. 
Definition at line 223 of file qgscolorramp.h.
| 
 | overridevirtual | 
Returns a string map containing all the color ramp's properties.
Implements QgsColorRamp.
Reimplemented in QgsCptCityColorRamp.
Definition at line 210 of file qgscolorramp.cpp.
| 
 | inline | 
Sets the gradient start color.
| color | start color | 
Definition at line 208 of file qgscolorramp.h.
| 
 | inline | 
Sets the gradient end color.
| color | end color | 
Definition at line 216 of file qgscolorramp.h.
| 
 | inline | 
Sets whether the gradient should use discrete interpolation, rather than smoothly interpolating between colors.
| discrete | set to trueto use discrete interpolation | 
Definition at line 232 of file qgscolorramp.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 269 of file qgscolorramp.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 283 of file qgscolorramp.cpp.
| 
 | inline | 
Returns the list of intermediate gradient stops for the ramp.
Definition at line 256 of file qgscolorramp.h.
| 
 | overridevirtual | 
Returns a string representing the color ramp type.
Implements QgsColorRamp.
Reimplemented in QgsCptCityColorRamp.
Definition at line 170 of file qgscolorramp.cpp.
| 
 | inlinestatic | 
Returns the string identifier for QgsGradientColorRamp.
Definition at line 181 of file qgscolorramp.h.
| 
 | overridevirtual | 
Returns relative value between [0,1] of color at specified index.
Implements QgsColorRamp.
Definition at line 108 of file qgscolorramp.cpp.
| 
 | protected | 
Definition at line 281 of file qgscolorramp.h.
| 
 | protected | 
Definition at line 282 of file qgscolorramp.h.
| 
 | protected | 
Definition at line 283 of file qgscolorramp.h.
| 
 | protected | 
Definition at line 285 of file qgscolorramp.h.
| 
 | protected | 
Definition at line 284 of file qgscolorramp.h.