QgsColorBrewerColorRamp class
Color ramp utilising "Color Brewer" preset color schemes.
Contents
Base classes
- class QgsColorRamp
- Abstract base class for color ramps.
Public static functions
- static auto create(const QgsStringMap& properties = QgsStringMap()) -> QgsColorRamp*
- Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string map.
- static auto listSchemeNames() -> QStringList
- Returns a list of all valid color brewer scheme names.
- static auto listSchemeVariants(const QString& schemeName) -> QList<int>
- Returns a list of the valid variants (numbers of colors) for a specified color brewer scheme name.
Constructors, destructors, conversion operators
-
QgsColorBrewerColorRamp(const QString& schemeName = DEFAULT_
COLORBREWER_ SCHEMENAME, int colors = DEFAULT_ COLORBREWER_ COLORS, bool inverted = false) - Constructor for QgsColorBrewerColorRamp.
Public functions
- auto clone() const -> QgsColorBrewerColorRamp* 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 -> int
- Returns the number of colors in the ramp.
- auto count() const -> int override
- Returns number of defined colors, or -1 if undefined.
- void invert() override
- Inverts the ordering of the color ramp.
- auto properties() const -> QgsStringMap override
- Returns a string map containing all the color ramp's properties.
- auto schemeName() const -> QString
- Returns the name of the color brewer color scheme.
- void setColors(int colors)
- Sets the number of colors in the ramp.
- void setSchemeName(const QString& schemeName)
- Sets the name of the color brewer color scheme.
- 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.
Protected functions
- void loadPalette()
- Generates the scheme using the current name and number of colors.
Function documentation
static QgsColorRamp* QgsColorBrewerColorRamp:: create(const QgsStringMap& properties = QgsStringMap())
Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string map.
| Parameters | |
|---|---|
| properties | color ramp properties |
static QStringList QgsColorBrewerColorRamp:: listSchemeNames()
Returns a list of all valid color brewer scheme names.
static QList<int> QgsColorBrewerColorRamp:: listSchemeVariants(const QString& schemeName)
Returns a list of the valid variants (numbers of colors) for a specified color brewer scheme name.
| Parameters | |
|---|---|
| schemeName | color brewer scheme name |
QgsColorBrewerColorRamp:: QgsColorBrewerColorRamp(const QString& schemeName = DEFAULT_ COLORBREWER_ SCHEMENAME,
int colors = DEFAULT_ COLORBREWER_ COLORS,
bool inverted = false)
Constructor for QgsColorBrewerColorRamp.
| Parameters | |
|---|---|
| schemeName | color brewer scheme name |
| colors | number of colors in ramp |
| inverted | invert ramp ordering |
QColor QgsColorBrewerColorRamp:: color(double value) const override
Returns the color corresponding to a specified value.
| Parameters | |
|---|---|
| value | value between [0, 1] inclusive |
| Returns | color for value |
int QgsColorBrewerColorRamp:: colors() const
Returns the number of colors in the ramp.
QString QgsColorBrewerColorRamp:: schemeName() const
Returns the name of the color brewer color scheme.
void QgsColorBrewerColorRamp:: setColors(int colors)
Sets the number of colors in the ramp.
| Parameters | |
|---|---|
| colors | number of colors. Must match a valid value for the scheme, which can be retrieved using listSchemeVariants() |
void QgsColorBrewerColorRamp:: setSchemeName(const QString& schemeName)
Sets the name of the color brewer color scheme.
| Parameters | |
|---|---|
| schemeName | scheme name, must match a valid color brewer scheme name |