QgsPresetSchemeColorRamp class
A scheme based color ramp consisting of a list of predefined colors.
Contents
Base classes
- class QgsColorRamp
- Abstract base class for color ramps.
- class QgsColorScheme
- Abstract base class for color schemes.
Public static functions
- static auto create(const QgsStringMap& properties = QgsStringMap()) -> QgsColorRamp*
- Returns a new QgsPresetSchemeColorRamp color ramp created using the properties encoded in a string map.
Constructors, destructors, conversion operators
- QgsPresetSchemeColorRamp(const QList<QColor>& colors = QList<QColor>())
- Constructor for QgsPresetSchemeColorRamp.
- QgsPresetSchemeColorRamp(const QgsNamedColorList& colors)
- Constructor for QgsPresetColorRamp.
Public functions
- auto clone() const -> QgsPresetSchemeColorRamp* override
- Creates a clone of the color ramp.
- auto color(double value) const -> QColor override
- Returns the color corresponding to a specified value.
- auto colors() const -> QList<QColor>
- Returns the list of colors used by the ramp.
- auto count() const -> int override
- Returns number of defined colors, or -1 if undefined.
- auto fetchColors(const QString& context = QString(), const QColor& baseColor = QColor()) -> QgsNamedColorList override
- Gets a list of colors from the scheme.
- void invert() override
- Inverts the ordering of the color ramp.
- auto isEditable() const -> bool override
- Returns whether the color scheme is editable.
- auto properties() const -> QgsStringMap override
- Returns a string map containing all the color ramp's properties.
- auto schemeName() const -> QString override
- Gets the name for the color scheme.
- auto setColors(const QgsNamedColorList& colors, const QString& = QString(), const QColor& = QColor()) -> bool override
- Sets the list of colors used by the ramp.
- auto type() const -> QString override
- Returns a string representing the color ramp type.
- auto value(int index) const -> double override
- Returns relative value between [0,1] of color at specified index.
Function documentation
static QgsColorRamp* QgsPresetSchemeColorRamp:: create(const QgsStringMap& properties = QgsStringMap())
Returns a new QgsPresetSchemeColorRamp color ramp created using the properties encoded in a string map.
| Parameters | |
|---|---|
| properties | color ramp properties |
QgsPresetSchemeColorRamp:: QgsPresetSchemeColorRamp(const QList<QColor>& colors = QList<QColor>())
Constructor for QgsPresetSchemeColorRamp.
| Parameters | |
|---|---|
| colors | list of colors in ramp |
QgsPresetSchemeColorRamp:: QgsPresetSchemeColorRamp(const QgsNamedColorList& colors)
Constructor for QgsPresetColorRamp.
| Parameters | |
|---|---|
| colors | list of named colors in ramp |
QColor QgsPresetSchemeColorRamp:: color(double value) const override
Returns the color corresponding to a specified value.
| Parameters | |
|---|---|
| value | value between [0, 1] inclusive |
| Returns | color for value |
QList<QColor> QgsPresetSchemeColorRamp:: colors() const
Returns the list of colors used by the ramp.
QgsNamedColorList QgsPresetSchemeColorRamp:: fetchColors(const QString& context = QString(),
const QColor& baseColor = QColor()) override
Gets a list of colors from the scheme.
| Parameters | |
|---|---|
| context | string specifying an optional context for the returned colors. For instance, a "recent colors" scheme may filter returned colors by context so that colors used only in a "composer" context are returned. |
| baseColor | base color for the scheme's colors. Some color schemes may take advantage of this to filter or modify their returned colors to colors related to the base color. |
| Returns | a list of QPairs of color and color name |
The colors can optionally be generated using the supplied context and base color.
bool QgsPresetSchemeColorRamp:: isEditable() const override
Returns whether the color scheme is editable.
| Returns | true if scheme is editable |
|---|
QString QgsPresetSchemeColorRamp:: schemeName() const override
Gets the name for the color scheme.
| Returns | color scheme name |
|---|
bool QgsPresetSchemeColorRamp:: setColors(const QgsNamedColorList& colors,
const QString& = QString(),
const QColor& = QColor()) override
Sets the list of colors used by the ramp.
| Parameters | |
|---|---|
| colors | list of colors |