QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra color stops. More...
#include <qgsvectorcolorrampv2.h>
Public Member Functions | |
QgsVectorGradientColorRampV2 (const QColor &color1=DEFAULT_GRADIENT_COLOR1, const QColor &color2=DEFAULT_GRADIENT_COLOR2, bool discrete=false, const QgsGradientStopsList &stops=QgsGradientStopsList()) | |
Constructor for QgsVectorGradientColorRampV2. More... | |
void | addStopsToGradient (QGradient *gradient, double alpha=1) |
Copy color ramp stops to a QGradient. More... | |
virtual QgsVectorGradientColorRampV2 * | clone () const override |
Creates a clone of the color ramp. More... | |
virtual 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... | |
virtual 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 (eg authorship notes) More... | |
bool | isDiscrete () const |
Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating between colors. More... | |
virtual QgsStringMap | 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 (eg 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... | |
virtual QString | type () const override |
Returns a string representing the color ramp type. More... | |
virtual double | value (int index) const override |
Returns relative value between [0,1] of color at specified index. More... | |
Public Member Functions inherited from QgsVectorColorRampV2 | |
virtual | ~QgsVectorColorRampV2 () |
Static Public Member Functions | |
static QgsVectorColorRampV2 * | create (const QgsStringMap &properties=QgsStringMap()) |
Creates a new QgsVectorColorRampV2 from a map of properties. 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 103 of file qgsvectorcolorrampv2.h.
QgsVectorGradientColorRampV2::QgsVectorGradientColorRampV2 | ( | const QColor & | color1 = DEFAULT_GRADIENT_COLOR1 , |
const QColor & | color2 = DEFAULT_GRADIENT_COLOR2 , |
||
bool | discrete = false , |
||
const QgsGradientStopsList & | stops = QgsGradientStopsList() |
||
) |
Constructor for QgsVectorGradientColorRampV2.
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 45 of file qgsvectorcolorrampv2.cpp.
void QgsVectorGradientColorRampV2::addStopsToGradient | ( | QGradient * | gradient, |
double | alpha = 1 |
||
) |
Copy color ramp stops to a QGradient.
gradient | gradient to copy stops into |
alpha | alpha multiplier. Opacity of colors will be multiplied by this factor before adding to the gradient. |
Definition at line 251 of file qgsvectorcolorrampv2.cpp.
|
overridevirtual |
Creates a clone of the color ramp.
Implements QgsVectorColorRampV2.
Reimplemented in QgsCptCityColorRampV2.
Definition at line 163 of file qgsvectorcolorrampv2.cpp.
|
overridevirtual |
Returns the color corresponding to a specified value.
value | value between [0, 1] inclusive |
Implements QgsVectorColorRampV2.
Definition at line 117 of file qgsvectorcolorrampv2.cpp.
|
inline |
Returns the gradient start color.
Definition at line 133 of file qgsvectorcolorrampv2.h.
|
inline |
Returns the gradient end color.
Definition at line 139 of file qgsvectorcolorrampv2.h.
void QgsVectorGradientColorRampV2::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 196 of file qgsvectorcolorrampv2.cpp.
|
inlineoverridevirtual |
Returns number of defined colors, or -1 if undefined.
Implements QgsVectorColorRampV2.
Definition at line 122 of file qgsvectorcolorrampv2.h.
|
static |
Creates a new QgsVectorColorRampV2 from a map of properties.
Definition at line 54 of file qgsvectorcolorrampv2.cpp.
|
inline |
Returns any additional info attached to the gradient ramp (eg authorship notes)
Definition at line 193 of file qgsvectorcolorrampv2.h.
|
inline |
Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating between colors.
Definition at line 159 of file qgsvectorcolorrampv2.h.
|
overridevirtual |
Returns a string map containing all the color ramp's properties.
Implements QgsVectorColorRampV2.
Reimplemented in QgsCptCityColorRampV2.
Definition at line 171 of file qgsvectorcolorrampv2.cpp.
|
inline |
Sets the gradient start color.
color | start color |
Definition at line 146 of file qgsvectorcolorrampv2.h.
|
inline |
Sets the gradient end color.
color | end color |
Definition at line 153 of file qgsvectorcolorrampv2.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 167 of file qgsvectorcolorrampv2.h.
|
inline |
Sets additional info to attach to the gradient ramp (eg authorship notes)
info | map of string info to attach |
Definition at line 199 of file qgsvectorcolorrampv2.h.
void QgsVectorGradientColorRampV2::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 243 of file qgsvectorcolorrampv2.cpp.
|
inline |
Returns the list of intermediate gradient stops for the ramp.
Definition at line 188 of file qgsvectorcolorrampv2.h.
|
inlineoverridevirtual |
Returns a string representing the color ramp type.
Implements QgsVectorColorRampV2.
Reimplemented in QgsCptCityColorRampV2.
Definition at line 125 of file qgsvectorcolorrampv2.h.
|
overridevirtual |
Returns relative value between [0,1] of color at specified index.
Implements QgsVectorColorRampV2.
Definition at line 101 of file qgsvectorcolorrampv2.cpp.
|
protected |
Definition at line 210 of file qgsvectorcolorrampv2.h.
|
protected |
Definition at line 211 of file qgsvectorcolorrampv2.h.
|
protected |
Definition at line 212 of file qgsvectorcolorrampv2.h.
|
protected |
Definition at line 214 of file qgsvectorcolorrampv2.h.
|
protected |
Definition at line 213 of file qgsvectorcolorrampv2.h.