31using namespace Qt::StringLiterals;
36static QColor _interpolateRgb(
const QColor &c1,
const QColor &c2,
const double value,
const Qgis::AngularDirection )
38 if ( std::isnan( value ) )
41 const qreal red1 = c1.redF();
42 const qreal red2 = c2.redF();
43 const qreal red = ( red1 + value * ( red2 - red1 ) );
45 const qreal green1 = c1.greenF();
46 const qreal green2 = c2.greenF();
47 const qreal green = ( green1 + value * ( green2 - green1 ) );
49 const qreal blue1 = c1.blueF();
50 const qreal blue2 = c2.blueF();
51 const qreal blue = ( blue1 + value * ( blue2 - blue1 ) );
53 const qreal alpha1 = c1.alphaF();
54 const qreal alpha2 = c2.alphaF();
55 const qreal alpha = ( alpha1 + value * ( alpha2 - alpha1 ) );
57 return QColor::fromRgbF( red, green, blue, alpha );
60static QColor _interpolateHsv(
const QColor &c1,
const QColor &c2,
const double value,
const Qgis::AngularDirection direction )
62 if ( std::isnan( value ) )
65 qreal hue1 = c1.hsvHueF();
66 qreal hue2 = c2.hsvHueF();
70 else if ( hue2 == -1 )
81 hue = hue1 - value * ( hue1 - hue2 );
94 hue = hue1 + value * ( hue2 - hue1 );
104 const qreal saturation1 = c1.hsvSaturationF();
105 const qreal saturation2 = c2.hsvSaturationF();
106 const qreal saturation = ( saturation1 + value * ( saturation2 - saturation1 ) );
108 const qreal value1 = c1.valueF();
109 const qreal value2 = c2.valueF();
110 const qreal valueOut = ( value1 + value * ( value2 - value1 ) );
112 const qreal alpha1 = c1.alphaF();
113 const qreal alpha2 = c2.alphaF();
114 const qreal alpha = ( alpha1 + value * ( alpha2 - alpha1 ) );
116 return QColor::fromHsvF( hue > 1 ? hue - 1 : hue, saturation, valueOut, alpha );
119static QColor _interpolateHsl(
const QColor &c1,
const QColor &c2,
const double value,
const Qgis::AngularDirection direction )
121 if ( std::isnan( value ) )
124 qreal hue1 = c1.hslHueF();
125 qreal hue2 = c2.hslHueF();
129 else if ( hue2 == -1 )
140 hue = hue1 - value * ( hue1 - hue2 );
153 hue = hue1 + value * ( hue2 - hue1 );
163 const qreal saturation1 = c1.hslSaturationF();
164 const qreal saturation2 = c2.hslSaturationF();
165 const qreal saturation = ( saturation1 + value * ( saturation2 - saturation1 ) );
167 const qreal lightness1 = c1.lightnessF();
168 const qreal lightness2 = c2.lightnessF();
169 const qreal lightness = ( lightness1 + value * ( lightness2 - lightness1 ) );
171 const qreal alpha1 = c1.alphaF();
172 const qreal alpha2 = c2.alphaF();
173 const qreal alpha = ( alpha1 + value * ( alpha2 - alpha1 ) );
175 return QColor::fromHslF( hue > 1 ? hue - 1 : hue, saturation, lightness, alpha );
178static QColor interpolateCmyk(
const QColor &c1,
const QColor &c2,
const double value,
const Qgis::AngularDirection )
180 if ( std::isnan( value ) )
183 const qreal cyan1 = c1.cyanF();
184 const qreal cyan2 = c2.cyanF();
185 const qreal cyan = ( cyan1 + value * ( cyan2 - cyan1 ) );
187 const qreal magenta1 = c1.magentaF();
188 const qreal magenta2 = c2.magentaF();
189 const qreal magenta = ( magenta1 + value * ( magenta2 - magenta1 ) );
191 const qreal yellow1 = c1.yellowF();
192 const qreal yellow2 = c2.yellowF();
193 const qreal yellow = ( yellow1 + value * ( yellow2 - yellow1 ) );
195 const qreal black1 = c1.blackF();
196 const qreal black2 = c2.blackF();
197 const qreal black = ( black1 + value * ( black2 - black1 ) );
199 const qreal alpha1 = c1.alphaF();
200 const qreal alpha2 = c2.alphaF();
201 const qreal alpha = ( alpha1 + value * ( alpha2 - alpha1 ) );
203 return QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
212 , mFunc( _interpolateRgb )
219 switch ( mColorSpec )
222 case QColor::Invalid:
223 case QColor::ExtendedRgb:
224 mFunc = _interpolateRgb;
227 mFunc = interpolateCmyk;
230 mFunc = _interpolateHsv;
233 mFunc = _interpolateHsl;
243 ,
mFunc( _interpolateRgb )
251 if ( props.contains( u
"color1"_s ) )
253 if ( props.contains( u
"color2"_s ) )
258 if ( props.contains( u
"stops"_s ) )
260 const thread_local QRegularExpression rx( u
"(?<!,rgb)(?<!,cmyk)(?<!,hsl)(?<!,hsv):"_s );
261 const auto constSplit = props[u
"stops"_s].toString().split( rx );
262 for (
const QString &stop : constSplit )
264 const QStringList parts = stop.split(
';' );
265 if ( parts.size() != 2 && parts.size() != 4 )
271 if ( parts.size() == 4 )
273 if ( parts.at( 2 ).compare(
"rgb"_L1 ) == 0 )
274 stops.last().setColorSpec( QColor::Spec::Rgb );
275 else if ( parts.at( 2 ).compare(
"hsv"_L1 ) == 0 )
276 stops.last().setColorSpec( QColor::Spec::Hsv );
277 else if ( parts.at( 2 ).compare(
"hsl"_L1 ) == 0 )
278 stops.last().setColorSpec( QColor::Spec::Hsl );
280 if ( parts.at( 3 ).compare(
"cw"_L1 ) == 0 )
282 else if ( parts.at( 3 ).compare(
"ccw"_L1 ) == 0 )
289 bool discrete =
false;
290 if ( props.contains( u
"discrete"_s ) )
292 if ( props[u
"discrete"_s] ==
"1"_L1 )
298 for ( QVariantMap::const_iterator it = props.constBegin(); it != props.constEnd(); ++it )
300 if ( it.key().startsWith(
"info_"_L1 ) )
301 info[it.key().mid( 5 )] = it.value().toString();
307 if ( props.contains( u
"spec"_s ) )
309 const QString spec = props.value( u
"spec"_s ).toString().trimmed();
310 if ( spec.compare(
"rgb"_L1 ) == 0 )
312 else if ( spec.compare(
"hsv"_L1 ) == 0 )
314 else if ( spec.compare(
"hsl"_L1 ) == 0 )
318 if ( props.contains( u
"direction"_s ) )
320 const QString
direction = props.value( u
"direction"_s ).toString().trimmed();
321 if (
direction.compare(
"ccw"_L1 ) == 0 )
323 else if (
direction.compare(
"cw"_L1 ) == 0 )
336 else if ( index >=
mStops.size() + 1 )
342 return mStops[index - 1].offset;
356 else if (
mStops.isEmpty() )
365 double lower = 0, upper = 0;
367 for ( QgsGradientStopsList::const_iterator it =
mStops.begin(); it !=
mStops.end(); ++it )
369 if ( it->offset >
value )
377 return qgsDoubleNear( upper, lower ) ? c1 : it->mFunc( c1, c2, (
value - lower ) / ( upper - lower ), it->mDirection );
400 newStops.reserve(
mStops.size() );
406 for (
int k =
mStops.size() - 1; k >= 1; k-- )
417 for (
int k =
mStops.size() - 1; k >= 0; k-- )
433 for (
int i = 1, j =
mStops.size() - 1; i <
mStops.size(); ++i, --j )
435 newStops[i].setColorSpec(
mStops.at( j ).colorSpec() );
462 lst.reserve(
mStops.size() );
465 lst.append( u
"%1;%2;%3;%4"_s.arg( stop.offset )
468 stop.colorSpec() == QColor::Rgb ? u
"rgb"_s
469 : stop.colorSpec() == QColor::Hsv ? u
"hsv"_s
470 : stop.colorSpec() == QColor::Hsl ? u
"hsl"_s
475 map[u
"stops"_s] = lst.join(
':'_L1 );
478 map[u
"discrete"_s] =
mDiscrete ?
"1" :
"0";
480 for ( QgsStringMap::const_iterator it =
mInfo.constBegin(); it !=
mInfo.constEnd(); ++it )
482 map[
"info_" + it.key()] = it.value();
488 map[u
"spec"_s] = u
"rgb"_s;
491 map[u
"spec"_s] = u
"hsv"_s;
494 map[u
"spec"_s] = u
"hsl"_s;
497 case QColor::Invalid:
498 case QColor::ExtendedRgb:
505 map[u
"direction"_s] = u
"cw"_s;
508 map[u
"direction"_s] = u
"ccw"_s;
514 map[u
"rampType"_s] =
type();
528 int numStops =
mStops.count() + 2;
530 for ( QgsGradientStopsList::const_iterator it =
mStops.constBegin(); it !=
mStops.constEnd(); ++it )
532 newStops.append(
QgsGradientStop(
static_cast< double >( i ) / numStops, it->color ) );
533 if ( i == numStops - 1 )
543 int numStops =
mStops.count() + 2;
545 for ( QgsGradientStopsList::const_iterator it =
mStops.constBegin(); it !=
mStops.constEnd(); ++it )
547 newStops.append(
QgsGradientStop(
static_cast< double >( i ) / ( numStops - 2 ), it->color ) );
548 if ( i == numStops - 3 )
580 gradient->setColorAt( 0,
color1 );
581 gradient->setColorAt( 1,
color2 );
583 double lastOffset = 0;
586 QColor rampColor = stop.color;
589 rampColor.setAlpha( rampColor.alpha() * opacity );
591 gradient->setColorAt( stop.offset, rampColor );
593 if ( stop.colorSpec() != QColor::Rgb )
597 for (
double offset = lastOffset + 0.05; offset < stop.offset; offset += 0.05 )
599 QColor midColor =
color( offset );
602 midColor.setAlpha( midColor.alpha() * opacity );
604 gradient->setColorAt( offset, midColor );
607 lastOffset = stop.offset;
612 for (
double offset = lastOffset + 0.05; offset < 1; offset += 0.05 )
614 QColor midColor =
color( offset );
617 midColor.setAlpha( midColor.alpha() * opacity );
619 gradient->setColorAt( offset, midColor );
630 case QColor::Invalid:
631 case QColor::ExtendedRgb:
632 mFunc = _interpolateRgb;
635 mFunc = interpolateCmyk;
638 mFunc = _interpolateHsv;
641 mFunc = _interpolateHsl;
669 if ( props.contains( u
"count"_s ) )
670 count = props[u
"count"_s].toInt();
671 if ( props.contains( u
"hueMin"_s ) )
672 hueMin = props[u
"hueMin"_s].toInt();
673 if ( props.contains( u
"hueMax"_s ) )
674 hueMax = props[u
"hueMax"_s].toInt();
675 if ( props.contains( u
"satMin"_s ) )
676 satMin = props[u
"satMin"_s].toInt();
677 if ( props.contains( u
"satMax"_s ) )
678 satMax = props[u
"satMax"_s].toInt();
679 if ( props.contains( u
"valMin"_s ) )
680 valMin = props[u
"valMin"_s].toInt();
681 if ( props.contains( u
"valMax"_s ) )
682 valMax = props[u
"valMax"_s].toInt();
691 return static_cast< double >( index ) / (
mColors.size() - 1 );
699 int colorCnt =
mColors.count();
700 int colorIdx = std::min(
static_cast< int >(
value * colorCnt ), colorCnt - 1 );
702 if ( colorIdx >= 0 && colorIdx < colorCnt )
721 map[u
"count"_s] = QString::number(
mCount );
722 map[u
"hueMin"_s] = QString::number(
mHueMin );
723 map[u
"hueMax"_s] = QString::number(
mHueMax );
724 map[u
"satMin"_s] = QString::number(
mSatMin );
725 map[u
"satMax"_s] = QString::number(
mSatMax );
726 map[u
"valMin"_s] = QString::number(
mValMin );
727 map[u
"valMax"_s] = QString::number(
mValMax );
728 map[u
"rampType"_s] =
type();
735 QList<QColor> colors;
746 double currentHueAngle = 360.0 *
static_cast< double >( std::rand() ) / RAND_MAX;
748 colors.reserve(
count );
749 for (
int i = 0; i <
count; ++i )
754 currentHueAngle += 137.50776;
756 h = std::clamp( std::round( ( std::fmod( currentHueAngle, 360.0 ) / 360.0 ) * ( safeHueMax - safeHueMin ) + safeHueMin ), 0.0, 359.0 );
757 s = std::clamp( (
static_cast<int>( std::rand() ) % ( safeSatMax - safeSatMin + 1 ) ) + safeSatMin, 0, 255 );
758 v = std::clamp( (
static_cast<int>( std::rand() ) % ( safeValMax - safeValMin + 1 ) ) + safeValMin, 0, 255 );
759 colors.append( QColor::fromHsv( h, s, v ) );
788 if ( std::isnan(
value ) )
802 int h =
static_cast< int >( 360.0 * std::rand() / ( RAND_MAX + 1.0 ) );
804 int v = ( std::rand() % ( maxVal - minVal + 1 ) ) + minVal;
805 return QColor::fromHsv( h, s, v );
818 double hueOffset = ( 360.0 * std::rand() / ( RAND_MAX + 1.0 ) );
823 double hueStep = 359.0 / colorCount;
824 double currentHue = hueOffset;
827 for (
int idx = 0; idx < colorCount; ++idx )
829 int h =
static_cast< int >( std::round( currentHue ) ) % 360;
833 currentHue += hueStep;
837 std::random_device rd;
838 std::mt19937 g( rd() );
854 return QVariantMap();
871 bool inverted =
false;
873 if ( props.contains( u
"schemeName"_s ) )
874 schemeName = props[u
"schemeName"_s].toString();
875 if ( props.contains( u
"colors"_s ) )
876 colors = props[u
"colors"_s].toInt();
877 if ( props.contains( u
"inverted"_s ) )
878 inverted = props[u
"inverted"_s].toInt();
889 QList<QColor> tmpPalette;
891 for (
int k =
mPalette.size() - 1; k >= 0; k-- )
913 return static_cast< double >( index ) / (
mPalette.size() - 1 );
921 int paletteEntry =
static_cast< int >(
value *
mPalette.count() );
922 if ( paletteEntry >=
mPalette.count() )
923 paletteEntry =
mPalette.count() - 1;
942 map[u
"colors"_s] = QString::number(
mColors );
943 map[u
"inverted"_s] = QString::number(
mInverted );
944 map[u
"rampType"_s] =
type();
983 bool inverted =
false;
985 if ( props.contains( u
"schemeName"_s ) )
986 schemeName = props[u
"schemeName"_s].toString();
987 if ( props.contains( u
"variantName"_s ) )
989 if ( props.contains( u
"inverted"_s ) )
990 inverted = props[u
"inverted"_s].toInt();
1037 info[u
"cpt-city-license"_s] =
"<cpt-city>" + copyingFilename;
1048 map[u
"inverted"_s] = QString::number(
mInverted );
1049 map[u
"rampType"_s] =
type();
1093 if ( filename.isNull() )
1106 QMap<double, QPair<QColor, QColor> >::const_iterator it, prev;
1112 it = prev = colorMap.constBegin();
1113 while ( it != colorMap.constEnd() )
1116 if ( it != colorMap.constBegin() && ( it.value().first != it.value().second ) )
1118 if ( it.value().first == prev.value().second )
1134 it = prev = colorMap.constBegin();
1135 while ( it != colorMap.constEnd() )
1146 if ( (
mMultiStops ) && ( it.key() != 0.0 && it.key() != 1.0 ) )
1156 if ( !
mStops.isEmpty() &&
mStops.at( 0 ).offset == 0.0 )
1158 if ( !
mStops.isEmpty() &&
mStops.last().offset == 1.0 )
1177 const auto constColors =
colors;
1178 for (
const QColor &
color : constColors )
1183 if ( mColors.isEmpty() )
1184 mColors << qMakePair( QColor( 250, 75, 60 ), u
"#fa4b3c"_s );
1191 if ( mColors.isEmpty() )
1192 mColors << qMakePair( QColor( 250, 75, 60 ), u
"#fa4b3c"_s );
1200 QString colorString =
properties.value( u
"preset_color_%1"_s.arg( i ), QString() ).toString();
1201 QString colorName =
properties.value( u
"preset_color_name_%1"_s.arg( i ), QString() ).toString();
1202 while ( !colorString.isEmpty() )
1206 colorString =
properties.value( u
"preset_color_%1"_s.arg( i ), QString() ).toString();
1207 colorName =
properties.value( u
"preset_color_name_%1"_s.arg( i ), QString() ).toString();
1216 l.reserve( mColors.count() );
1217 for (
int i = 0; i < mColors.count(); ++i )
1219 l << mColors.at( i ).first;
1226 if ( mColors.empty() )
1228 return static_cast< double >( index ) / ( mColors.size() - 1 );
1236 int colorCnt = mColors.count();
1237 int colorIdx = std::min(
static_cast< int >(
value * colorCnt ), colorCnt - 1 );
1239 if ( colorIdx >= 0 && colorIdx < colorCnt )
1240 return mColors.at( colorIdx ).first;
1254 for (
int k = mColors.size() - 1; k >= 0; k-- )
1256 tmpColors << mColors.at( k );
1258 mColors = tmpColors;
1269 for (
int i = 0; i < mColors.count(); ++i )
1272 props.insert( u
"preset_color_name_%1"_s.arg( i ), mColors.at( i ).second );
1274 props[u
"rampType"_s] =
type();
1280 return mColors.count();
AngularDirection
Angular directions.
@ NoOrientation
Unknown orientation or sentinel value.
@ CounterClockwise
Counter-clockwise direction.
@ Clockwise
Clockwise direction.
void invert() override
Inverts the ordering of the color ramp.
static QList< int > listSchemeVariants(const QString &schemeName)
Returns a list of the valid variants (numbers of colors) for a specified color brewer scheme name.
QColor color(double value) const override
Returns the color corresponding to a specified value.
QgsColorBrewerColorRamp * clone() const override
Creates a clone of the color ramp.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string map...
static QStringList listSchemeNames()
Returns a list of all valid color brewer scheme names.
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.
QString schemeName() const
Returns the name of the color brewer color scheme.
int colors() const
Returns the number of colors in the ramp.
QVariantMap properties() const override
Returns a string map containing all the color ramp's properties.
QgsColorBrewerColorRamp(const QString &schemeName=DEFAULT_COLORBREWER_SCHEMENAME, int colors=DEFAULT_COLORBREWER_COLORS, bool inverted=false)
Constructor for QgsColorBrewerColorRamp.
void loadPalette()
Generates the scheme using the current name and number of colors.
static QStringList listSchemes()
static QList< QColor > listSchemeColors(const QString &schemeName, int colors)
static QList< int > listSchemeVariants(const QString &schemeName)
Abstract base class for color ramps.
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
static QString defaultBaseDir()
static QMap< QString, QString > copyingInfo(const QString &fileName)
static QString findFileName(const QString &target, const QString &startDir, const QString &baseDir)
static QMap< double, QPair< QColor, QColor > > gradientColorMap(const QString &fileName)
QgsCptCityColorRamp * clone() const override
Creates a clone of the color ramp.
QgsStringMap copyingInfo() const
QVariantMap properties() const override
Returns a string map containing all the color ramp's properties.
QgsCptCityColorRamp(const QString &schemeName=DEFAULT_CPTCITY_SCHEMENAME, const QString &variantName=DEFAULT_CPTCITY_VARIANTNAME, bool inverted=false, bool doLoadFile=true)
Constructor for QgsCptCityColorRamp.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Creates the symbol layer.
QStringList variantList() const
void copy(const QgsCptCityColorRamp *other)
static QString fileNameForVariant(const QString &schema, const QString &variant)
Returns the source file name for a CPT schema and variant.
static QString typeString()
Returns the string identifier for QgsCptCityColorRamp.
QString descFileName() const
QgsGradientColorRamp * cloneGradientRamp() const
QString copyingFileName() const
void invert() override
Inverts the ordering of the color ramp.
QString type() const override
Returns a string representing the color ramp type.
QString schemeName() const
QString variantName() const
QgsGradientStopsList mStops
void setInfo(const QgsStringMap &info)
Sets additional info to attach to the gradient ramp (e.g., authorship notes).
bool isDiscrete() const
Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating betw...
void setColorSpec(QColor::Spec spec)
Sets the color specification in which the color component interpolation will occur.
QVariantMap properties() const override
Returns a string map containing all the color ramp's properties.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsColorRamp from a map of properties.
QgsStringMap info() const
Returns any additional info attached to the gradient ramp (e.g., authorship notes).
void convertToDiscrete(bool discrete)
Converts a gradient with existing color stops to or from discrete interpolation.
Qgis::AngularDirection mDirection
QColor color(double value) const override
Returns the color corresponding to a specified value.
static QString typeString()
Returns the string identifier for QgsGradientColorRamp.
void setStops(const QgsGradientStopsList &stops)
Sets the list of intermediate gradient stops for the ramp.
QString type() const override
Returns a string representing the color ramp type.
QgsGradientColorRamp(const QColor &color1=DEFAULT_GRADIENT_COLOR1, const QColor &color2=DEFAULT_GRADIENT_COLOR2, bool discrete=false, const QgsGradientStopsList &stops=QgsGradientStopsList())
Constructor for QgsGradientColorRamp.
QColor color1() const
Returns the gradient start color.
void setDirection(Qgis::AngularDirection direction)
Sets the direction to traverse the color wheel using when interpolating hue-based color specification...
Qgis::AngularDirection direction() const
Returns the direction to traverse the color wheel using when interpolating hue-based color specificat...
void invert() override
Inverts the ordering of the color ramp.
void addStopsToGradient(QGradient *gradient, double opacity=1) const
Copy color ramp stops to a QGradient.
QgsGradientStopsList stops() const
Returns the list of intermediate gradient stops for the ramp.
double value(int index) const override
Returns relative value between [0,1] of color at specified index.
QgsGradientColorRamp * clone() const override
Creates a clone of the color ramp.
InterpolateColorFunc mFunc
QColor color2() const
Returns the gradient end color.
Represents a color stop within a QgsGradientColorRamp color ramp.
void setColorSpec(QColor::Spec spec)
Sets the color specification in which the color component interpolation will occur.
double offset
Relative positional offset, between 0 and 1.
QColor color
Gradient color at stop.
QgsGradientStop(double offset, const QColor &color)
Constructor for QgsGradientStop.
static QString typeString()
Returns the string identifier for QgsLimitedRandomColorRamp.
void updateColors()
Must be called after changing the properties of the color ramp to regenerate the list of random color...
static QList< QColor > randomColors(int count, int hueMax=DEFAULT_RANDOM_HUE_MAX, int hueMin=DEFAULT_RANDOM_HUE_MIN, int satMax=DEFAULT_RANDOM_SAT_MAX, int satMin=DEFAULT_RANDOM_SAT_MIN, int valMax=DEFAULT_RANDOM_VAL_MAX, int valMin=DEFAULT_RANDOM_VAL_MIN)
Gets a list of random colors.
int count() const override
Returns number of defined colors, or -1 if undefined.
QColor color(double value) const override
Returns the color corresponding to a specified value.
double value(int index) const override
Returns relative value between [0,1] of color at specified index.
QVariantMap properties() const override
Returns a string map containing all the color ramp's properties.
int valMax() const
Returns the maximum value for generated colors.
QString type() const override
Returns a string representing the color ramp type.
int satMax() const
Returns the maximum saturation for generated colors.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Returns a new QgsLimitedRandomColorRamp color ramp created using the properties encoded in a string m...
QgsLimitedRandomColorRamp * clone() const override
Creates a clone of the color ramp.
int hueMax() const
Returns the maximum hue for generated colors.
int hueMin() const
Returns the minimum hue for generated colors.
int valMin() const
Returns the minimum value for generated colors.
QgsLimitedRandomColorRamp(int count=DEFAULT_RANDOM_COUNT, int hueMin=DEFAULT_RANDOM_HUE_MIN, int hueMax=DEFAULT_RANDOM_HUE_MAX, int satMin=DEFAULT_RANDOM_SAT_MIN, int satMax=DEFAULT_RANDOM_SAT_MAX, int valMin=DEFAULT_RANDOM_VAL_MIN, int valMax=DEFAULT_RANDOM_VAL_MAX)
Constructor for QgsLimitedRandomColorRamp.
int satMin() const
Returns the minimum saturation for generated colors.
double value(int index) const override
Returns relative value between [0,1] of color at specified index.
QColor color(double value) const override
Returns the color corresponding to a specified value.
QString type() const override
Returns a string representing the color ramp type.
QList< QColor > colors() const
Returns the list of colors used by the ramp.
static QString typeString()
Returns the string identifier for QgsPresetSchemeColorRamp.
void invert() override
Inverts the ordering of the color ramp.
QVariantMap properties() const override
Returns a string map containing all the color ramp's properties.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Returns a new QgsPresetSchemeColorRamp color ramp created using the properties encoded in a string ma...
int count() const override
Returns number of defined colors, or -1 if undefined.
QgsPresetSchemeColorRamp(const QList< QColor > &colors=QList< QColor >())
Constructor for QgsPresetSchemeColorRamp.
QgsNamedColorList fetchColors(const QString &context=QString(), const QColor &baseColor=QColor()) override
Gets a list of colors from the scheme.
QgsPresetSchemeColorRamp * clone() const override
Creates a clone of the color ramp.
double value(int index) const override
Returns relative value between [0,1] of color at specified index.
QList< QColor > mPrecalculatedColors
QgsRandomColorRamp * clone() const override
Creates a clone of the color ramp.
QgsRandomColorRamp()=default
static QString typeString()
Returns the string identifier for QgsRandomColorRamp.
int count() const override
Returns number of defined colors, or -1 if undefined.
QString type() const override
Returns a string representing the color ramp type.
virtual void setTotalColorCount(int colorCount)
Sets the desired total number of unique colors for the resultant ramp.
QVariantMap properties() const override
Returns a string map containing all the color ramp's properties.
QColor color(double value) const override
Returns the color corresponding to a specified value.
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
QMap< QString, QString > QgsStringMap
bool stopLessThan(const QgsGradientStop &s1, const QgsGradientStop &s2)
#define DEFAULT_COLORBREWER_COLORS
#define DEFAULT_COLORBREWER_SCHEMENAME
#define DEFAULT_RANDOM_HUE_MAX
#define DEFAULT_CPTCITY_SCHEMENAME
#define DEFAULT_RANDOM_HUE_MIN
#define DEFAULT_RANDOM_COUNT
#define DEFAULT_RANDOM_SAT_MAX
#define DEFAULT_RANDOM_SAT_MIN
#define DEFAULT_CPTCITY_VARIANTNAME
#define DEFAULT_GRADIENT_COLOR1
#define DEFAULT_RANDOM_VAL_MIN
QList< QgsGradientStop > QgsGradientStopsList
List of gradient stops.
#define DEFAULT_GRADIENT_COLOR2
#define DEFAULT_RANDOM_VAL_MAX
#define QgsDebugMsgLevel(str, level)