33static QColor _interpolateRgb( 
const QColor &c1, 
const QColor &c2, 
const double value, 
const Qgis::AngularDirection )
 
   35  if ( std::isnan( value ) )
 
   38  const qreal red1 = c1.redF();
 
   39  const qreal red2 = c2.redF();
 
   40  const qreal red = ( red1 + value * ( red2 - red1 ) );
 
   42  const qreal green1 = c1.greenF();
 
   43  const qreal green2 = c2.greenF();
 
   44  const qreal green = ( green1 + value * ( green2 - green1 ) );
 
   46  const qreal blue1 = c1.blueF();
 
   47  const qreal blue2 = c2.blueF();
 
   48  const qreal blue = ( blue1 + value * ( blue2 - blue1 ) );
 
   50  const qreal alpha1 = c1.alphaF();
 
   51  const qreal alpha2 = c2.alphaF();
 
   52  const qreal alpha = ( alpha1 + value * ( alpha2 - alpha1 ) );
 
   54  return QColor::fromRgbF( red, green, blue, alpha );
 
   57static QColor _interpolateHsv( 
const QColor &c1, 
const QColor &c2, 
const double value, 
const Qgis::AngularDirection direction )
 
   59  if ( std::isnan( value ) )
 
   62  qreal hue1 = c1.hsvHueF();
 
   63  qreal hue2 = c2.hsvHueF();
 
   67  else if ( hue2 == -1 )
 
   78        hue = hue1 - value * ( hue1 - hue2 );
 
   91        hue = hue1 + value * ( hue2 - hue1 );
 
  101  const qreal saturation1 = c1.hsvSaturationF();
 
  102  const qreal saturation2 = c2.hsvSaturationF();
 
  103  const qreal saturation = ( saturation1 + value * ( saturation2 - saturation1 ) );
 
  105  const qreal value1 = c1.valueF();
 
  106  const qreal value2 = c2.valueF();
 
  107  const qreal valueOut = ( value1 + value * ( value2 - value1 ) );
 
  109  const qreal alpha1 = c1.alphaF();
 
  110  const qreal alpha2 = c2.alphaF();
 
  111  const qreal alpha = ( alpha1 + value * ( alpha2 - alpha1 ) );
 
  113  return QColor::fromHsvF( hue > 1 ? hue - 1 : hue, saturation, valueOut, alpha );
 
  116static QColor _interpolateHsl( 
const QColor &c1, 
const QColor &c2, 
const double value, 
const Qgis::AngularDirection direction )
 
  118  if ( std::isnan( value ) )
 
  121  qreal hue1 = c1.hslHueF();
 
  122  qreal hue2 = c2.hslHueF();
 
  126  else if ( hue2 == -1 )
 
  137        hue = hue1 - value * ( hue1 - hue2 );
 
  150        hue = hue1 + value * ( hue2 - hue1 );
 
  160  const qreal saturation1 = c1.hslSaturationF();
 
  161  const qreal saturation2 = c2.hslSaturationF();
 
  162  const qreal saturation = ( saturation1 + value * ( saturation2 - saturation1 ) );
 
  164  const qreal lightness1 = c1.lightnessF();
 
  165  const qreal lightness2 = c2.lightnessF();
 
  166  const qreal lightness = ( lightness1 + value * ( lightness2 - lightness1 ) );
 
  168  const qreal alpha1 = c1.alphaF();
 
  169  const qreal alpha2 = c2.alphaF();
 
  170  const qreal alpha = ( alpha1 + value * ( alpha2 - alpha1 ) );
 
  172  return QColor::fromHslF( hue > 1 ? hue - 1 : hue, saturation, lightness, alpha );
 
  175static QColor interpolateCmyk( 
const QColor &c1, 
const QColor &c2, 
const double value, 
const Qgis::AngularDirection )
 
  177  if ( std::isnan( value ) )
 
  180  const qreal cyan1 = c1.cyanF();
 
  181  const qreal cyan2 = c2.cyanF();
 
  182  const qreal cyan = ( cyan1 + value * ( cyan2 - cyan1 ) );
 
  184  const qreal magenta1 = c1.magentaF();
 
  185  const qreal magenta2 = c2.magentaF();
 
  186  const qreal magenta = ( magenta1 + value * ( magenta2 - magenta1 ) );
 
  188  const qreal yellow1 = c1.yellowF();
 
  189  const qreal yellow2 = c2.yellowF();
 
  190  const qreal yellow = ( yellow1 + value * ( yellow2 - yellow1 ) );
 
  192  const qreal black1 = c1.blackF();
 
  193  const qreal black2 = c2.blackF();
 
  194  const qreal black = ( black1 + value * ( black2 - black1 ) );
 
  196  const qreal alpha1 = c1.alphaF();
 
  197  const qreal alpha2 = c2.alphaF();
 
  198  const qreal alpha = ( alpha1 + value * ( alpha2 - alpha1 ) );
 
  200  return QColor::fromCmykF( cyan, magenta, yellow, black, alpha ); 
 
  209  , mFunc( _interpolateRgb )
 
 
  218  switch ( mColorSpec )
 
  221    case QColor::Invalid:
 
  222    case QColor::ExtendedRgb:
 
  223      mFunc = _interpolateRgb;
 
  226      mFunc = interpolateCmyk;
 
  229      mFunc = _interpolateHsv;
 
  232      mFunc = _interpolateHsl;
 
 
  241  , mDiscrete( discrete )
 
  243  , mFunc( _interpolateRgb )
 
 
  252  if ( props.contains( QStringLiteral( 
"color1" ) ) )
 
  254  if ( props.contains( QStringLiteral( 
"color2" ) ) )
 
  259  if ( props.contains( QStringLiteral( 
"stops" ) ) )
 
  261    const thread_local QRegularExpression rx( QStringLiteral( 
"(?<!,rgb)(?<!,cmyk)(?<!,hsl)(?<!,hsv):" ) );
 
  262    const auto constSplit = props[QStringLiteral( 
"stops" )].toString().split( rx );
 
  263    for ( 
const QString &stop : constSplit )
 
  265      const QStringList parts = stop.split( 
';' );
 
  266      if ( parts.size() != 2 && parts.size() != 4 )
 
  272      if ( parts.size() == 4 )
 
  274        if ( parts.at( 2 ).compare( QLatin1String( 
"rgb" ) ) == 0 )
 
  275          stops.last().setColorSpec( QColor::Spec::Rgb );
 
  276        else if ( parts.at( 2 ).compare( QLatin1String( 
"hsv" ) ) == 0 )
 
  277          stops.last().setColorSpec( QColor::Spec::Hsv );
 
  278        else if ( parts.at( 2 ).compare( QLatin1String( 
"hsl" ) ) == 0 )
 
  279          stops.last().setColorSpec( QColor::Spec::Hsl );
 
  281        if ( parts.at( 3 ).compare( QLatin1String( 
"cw" ) ) == 0 )
 
  283        else if ( parts.at( 3 ).compare( QLatin1String( 
"ccw" ) ) == 0 )
 
  290  bool discrete = 
false;
 
  291  if ( props.contains( QStringLiteral( 
"discrete" ) ) )
 
  293    if ( props[QStringLiteral( 
"discrete" )] == QLatin1String( 
"1" ) )
 
  299  for ( QVariantMap::const_iterator it = props.constBegin();
 
  300        it != props.constEnd(); ++it )
 
  302    if ( it.key().startsWith( QLatin1String( 
"info_" ) ) )
 
  303      info[ it.key().mid( 5 )] = it.value().toString();
 
  309  if ( props.contains( QStringLiteral( 
"spec" ) ) )
 
  311    const QString spec = props.value( QStringLiteral( 
"spec" ) ).toString().trimmed();
 
  312    if ( spec.compare( QLatin1String( 
"rgb" ) ) == 0 )
 
  314    else if ( spec.compare( QLatin1String( 
"hsv" ) ) == 0 )
 
  316    else if ( spec.compare( QLatin1String( 
"hsl" ) ) == 0 )
 
  320  if ( props.contains( QStringLiteral( 
"direction" ) ) )
 
  322    const QString 
direction = props.value( QStringLiteral( 
"direction" ) ).toString().trimmed();
 
  323    if ( 
direction.compare( QLatin1String( 
"ccw" ) ) == 0 )
 
  325    else if ( 
direction.compare( QLatin1String( 
"cw" ) ) == 0 )
 
 
  338  else if ( index >= 
mStops.size() + 1 )
 
  344    return mStops[index - 1].offset;
 
 
  358  else if ( 
mStops.isEmpty() )
 
  367    double lower = 0, upper = 0;
 
  369    for ( QgsGradientStopsList::const_iterator it = 
mStops.begin(); it != 
mStops.end(); ++it )
 
  371      if ( it->offset > 
value )
 
  379        return qgsDoubleNear( upper, lower ) ? c1 : it->mFunc( c1, c2, ( 
value - lower ) / ( upper - lower ), it->mDirection );
 
 
  402  newStops.reserve( 
mStops.size() );
 
  408    for ( 
int k = 
mStops.size() - 1; k >= 1; k-- )
 
  419    for ( 
int k = 
mStops.size() - 1; k >= 0; k-- )
 
  435    for ( 
int i = 1, j = 
mStops.size() - 1; i < 
mStops.size(); ++i, --j )
 
  437      newStops[i].setColorSpec( 
mStops.at( j ).colorSpec() );
 
 
  465    lst.reserve( 
mStops.size() );
 
  469                  stop.colorSpec() == QColor::Rgb ? QStringLiteral( 
"rgb" )
 
  470                  : stop.colorSpec() == QColor::Hsv ? QStringLiteral( 
"hsv" )
 
  471                  : stop.colorSpec() == QColor::Hsl ? QStringLiteral( 
"hsl" ) : QString(),
 
  474    map[QStringLiteral( 
"stops" )] = lst.join( QLatin1Char( 
':' ) );
 
  477  map[QStringLiteral( 
"discrete" )] = 
mDiscrete ? 
"1" : 
"0";
 
  479  for ( QgsStringMap::const_iterator it = 
mInfo.constBegin();
 
  480        it != 
mInfo.constEnd(); ++it )
 
  482    map[
"info_" + it.key()] = it.value();
 
  488      map[QStringLiteral( 
"spec" ) ] = QStringLiteral( 
"rgb" );
 
  491      map[QStringLiteral( 
"spec" ) ] = QStringLiteral( 
"hsv" );
 
  494      map[QStringLiteral( 
"spec" ) ] = QStringLiteral( 
"hsl" );
 
  497    case QColor::Invalid:
 
  498    case QColor::ExtendedRgb:
 
  505      map[QStringLiteral( 
"direction" ) ] = QStringLiteral( 
"cw" );
 
  508      map[QStringLiteral( 
"direction" ) ] = QStringLiteral( 
"ccw" );
 
  514  map[QStringLiteral( 
"rampType" )] = 
type();
 
 
  528    int numStops = 
mStops.count() + 2;
 
  530    for ( QgsGradientStopsList::const_iterator it = 
mStops.constBegin();
 
  531          it != 
mStops.constEnd(); ++it )
 
  533      newStops.append( 
QgsGradientStop( 
static_cast< double >( i ) / numStops, it->color ) );
 
  534      if ( i == numStops - 1 )
 
  544    int numStops = 
mStops.count() + 2;
 
  546    for ( QgsGradientStopsList::const_iterator it = 
mStops.constBegin();
 
  547          it != 
mStops.constEnd(); ++it )
 
  549      newStops.append( 
QgsGradientStop( 
static_cast< double >( i ) / ( numStops - 2 ), it->color ) );
 
  550      if ( i == numStops - 3 )
 
 
  582  gradient->setColorAt( 0, 
color1 );
 
  583  gradient->setColorAt( 1, 
color2 );
 
  585  double lastOffset = 0;
 
  589    QColor rampColor = stop.color;
 
  592      rampColor.setAlpha( rampColor.alpha() * opacity );
 
  594    gradient->setColorAt( stop.offset, rampColor );
 
  596    if ( stop.colorSpec() != QColor::Rgb )
 
  600      for ( 
double offset = lastOffset + 0.05; offset < stop.offset; offset += 0.05 )
 
  602        QColor midColor = 
color( offset );
 
  605          midColor.setAlpha( midColor.alpha() * opacity );
 
  607        gradient->setColorAt( offset, midColor );
 
  610    lastOffset = stop.offset;
 
  615    for ( 
double offset = lastOffset + 0.05; offset < 1; offset += 0.05 )
 
  617      QColor midColor = 
color( offset );
 
  620        midColor.setAlpha( midColor.alpha() * opacity );
 
  622      gradient->setColorAt( offset, midColor );
 
 
  633    case QColor::Invalid:
 
  634    case QColor::ExtendedRgb:
 
  635      mFunc = _interpolateRgb;
 
  638      mFunc = interpolateCmyk;
 
  641      mFunc = _interpolateHsv;
 
  644      mFunc = _interpolateHsl;
 
 
  654    int satMin, 
int satMax, 
int valMin, 
int valMax )
 
  656  , mHueMin( hueMin ), mHueMax( hueMax )
 
  657  , mSatMin( satMin ), mSatMax( satMax )
 
  658  , mValMin( valMin ), mValMax( valMax )
 
 
  670  if ( props.contains( QStringLiteral( 
"count" ) ) ) 
count = props[QStringLiteral( 
"count" )].toInt();
 
  671  if ( props.contains( QStringLiteral( 
"hueMin" ) ) ) 
hueMin = props[QStringLiteral( 
"hueMin" )].toInt();
 
  672  if ( props.contains( QStringLiteral( 
"hueMax" ) ) ) 
hueMax = props[QStringLiteral( 
"hueMax" )].toInt();
 
  673  if ( props.contains( QStringLiteral( 
"satMin" ) ) ) 
satMin = props[QStringLiteral( 
"satMin" )].toInt();
 
  674  if ( props.contains( QStringLiteral( 
"satMax" ) ) ) 
satMax = props[QStringLiteral( 
"satMax" )].toInt();
 
  675  if ( props.contains( QStringLiteral( 
"valMin" ) ) ) 
valMin = props[QStringLiteral( 
"valMin" )].toInt();
 
  676  if ( props.contains( QStringLiteral( 
"valMax" ) ) ) 
valMax = props[QStringLiteral( 
"valMax" )].toInt();
 
 
  685  return static_cast< double >( index ) / ( 
mColors.size() - 1 );
 
 
  690  if ( value < 0 || value > 1 )
 
  693  int colorCnt = 
mColors.count();
 
  694  int colorIdx = std::min( 
static_cast< int >( 
value * colorCnt ), colorCnt - 1 );
 
  696  if ( colorIdx >= 0 && colorIdx < colorCnt )
 
 
  715  map[QStringLiteral( 
"count" )] = QString::number( 
mCount );
 
  716  map[QStringLiteral( 
"hueMin" )] = QString::number( 
mHueMin );
 
  717  map[QStringLiteral( 
"hueMax" )] = QString::number( 
mHueMax );
 
  718  map[QStringLiteral( 
"satMin" )] = QString::number( 
mSatMin );
 
  719  map[QStringLiteral( 
"satMax" )] = QString::number( 
mSatMax );
 
  720  map[QStringLiteral( 
"valMin" )] = QString::number( 
mValMin );
 
  721  map[QStringLiteral( 
"valMax" )] = QString::number( 
mValMax );
 
  722  map[QStringLiteral( 
"rampType" )] = 
type();
 
 
  727    int hueMax, 
int hueMin, 
int satMax, 
int satMin, 
int valMax, 
int valMin )
 
  730  QList<QColor> colors;
 
  741  double currentHueAngle = 360.0 * 
static_cast< double >( std::rand() ) / RAND_MAX;
 
  743  colors.reserve( 
count );
 
  744  for ( 
int i = 0; i < 
count; ++i )
 
  749    currentHueAngle += 137.50776;
 
  751    h = std::clamp( std::round( ( std::fmod( currentHueAngle, 360.0 ) / 360.0 ) * ( safeHueMax - safeHueMin ) + safeHueMin ), 0.0, 359.0 );
 
  752    s = std::clamp( ( 
static_cast<int>( std::rand() ) % ( safeSatMax - safeSatMin + 1 ) ) + safeSatMin, 0, 255 );
 
  753    v = std::clamp( ( 
static_cast<int>( std::rand() ) % ( safeValMax - safeValMin + 1 ) ) + safeValMin, 0, 255 );
 
  754    colors.append( QColor::fromHsv( h, s, v ) );
 
 
  783  if ( std::isnan( 
value ) )
 
  797  int h = 
static_cast< int >( 360.0 * std::rand() / ( RAND_MAX + 1.0 ) );
 
  799  int v = ( std::rand() % ( maxVal - minVal + 1 ) ) + minVal;
 
  800  return QColor::fromHsv( h, s, v );
 
 
  813  double hueOffset = ( 360.0 * std::rand() / ( RAND_MAX + 1.0 ) );
 
  818  double hueStep = 359.0 / colorCount;
 
  819  double currentHue = hueOffset;
 
  822  for ( 
int idx = 0; idx < colorCount; ++ idx )
 
  824    int h = 
static_cast< int >( std::round( currentHue ) ) % 360;
 
  828    currentHue += hueStep;
 
  832  std::random_device rd;
 
  833  std::mt19937 g( rd() );
 
 
  849  return QVariantMap();
 
 
  855  : mSchemeName( schemeName )
 
  857  , mInverted( inverted )
 
 
  866  bool inverted = 
false;
 
  868  if ( props.contains( QStringLiteral( 
"schemeName" ) ) )
 
  869    schemeName = props[QStringLiteral( 
"schemeName" )].toString();
 
  870  if ( props.contains( QStringLiteral( 
"colors" ) ) )
 
  871    colors = props[QStringLiteral( 
"colors" )].toInt();
 
  872  if ( props.contains( QStringLiteral( 
"inverted" ) ) )
 
  873    inverted = props[QStringLiteral( 
"inverted" )].toInt();
 
 
  884    QList<QColor> tmpPalette;
 
  886    for ( 
int k = 
mPalette.size() - 1; k >= 0; k-- )
 
 
  908  return static_cast< double >( index ) / ( 
mPalette.size() - 1 );
 
 
  913  if ( 
mPalette.isEmpty() || value < 0 || value > 1 || std::isnan( 
value ) )
 
  916  int paletteEntry = 
static_cast< int >( 
value * 
mPalette.count() );
 
  917  if ( paletteEntry >= 
mPalette.count() )
 
  918    paletteEntry = 
mPalette.count() - 1;
 
 
  937  map[QStringLiteral( 
"colors" )] = QString::number( 
mColors );
 
  938  map[QStringLiteral( 
"inverted" )] = QString::number( 
mInverted );
 
  939  map[QStringLiteral( 
"rampType" )] = 
type();
 
 
  948    bool inverted, 
bool doLoadFile )
 
  950  , mSchemeName( schemeName )
 
  951  , mVariantName( variantName )
 
  952  , mInverted( inverted )
 
 
  961    const QString &variantName, 
bool inverted, 
bool doLoadFile )
 
  963  , mSchemeName( schemeName )
 
  964  , mVariantName( variantName )
 
  965  , mVariantList( variantList )
 
  966  , mInverted( inverted )
 
 
  980  bool inverted = 
false;
 
  982  if ( props.contains( QStringLiteral( 
"schemeName" ) ) )
 
  983    schemeName = props[QStringLiteral( 
"schemeName" )].toString();
 
  984  if ( props.contains( QStringLiteral( 
"variantName" ) ) )
 
  985    variantName = props[QStringLiteral( 
"variantName" )].toString();
 
  986  if ( props.contains( QStringLiteral( 
"inverted" ) ) )
 
  987    inverted = props[QStringLiteral( 
"inverted" )].toInt();
 
 
 1035  info[QStringLiteral( 
"cpt-city-license" )] = 
"<cpt-city>" + copyingFilename;
 
 
 1044  map[QStringLiteral( 
"schemeName" )] = 
mSchemeName;
 
 1046  map[QStringLiteral( 
"inverted" )] = QString::number( 
mInverted );
 
 1047  map[QStringLiteral( 
"rampType" )] = 
type();
 
 
 1093  if ( filename.isNull() )
 
 1101  QMap< double, QPair<QColor, QColor> > colorMap =
 
 1107  QMap<double, QPair<QColor, QColor> >::const_iterator it, prev;
 
 1113  it = prev = colorMap.constBegin();
 
 1114  while ( it != colorMap.constEnd() )
 
 1117    if ( it != colorMap.constBegin() && ( it.value().first != it.value().second ) )
 
 1119      if ( it.value().first == prev.value().second )
 
 1135  it = prev = colorMap.constBegin();
 
 1136  while ( it != colorMap.constEnd() )
 
 1148           ( it.key() != 0.0 && it.key() != 1.0 ) )
 
 1158  if ( ! 
mStops.isEmpty() && 
mStops.at( 0 ).offset == 0.0 )
 
 1160  if ( ! 
mStops.isEmpty() && 
mStops.last().offset == 1.0 )
 
 
 1179  const auto constColors = 
colors;
 
 1180  for ( 
const QColor &
color : constColors )
 
 1185  if ( mColors.isEmpty() )
 
 1186    mColors << qMakePair( QColor( 250, 75, 60 ), QStringLiteral( 
"#fa4b3c" ) );
 
 
 1193  if ( mColors.isEmpty() )
 
 1194    mColors << qMakePair( QColor( 250, 75, 60 ), QStringLiteral( 
"#fa4b3c" ) );
 
 
 1202  QString colorString = 
properties.
value( QStringLiteral( 
"preset_color_%1" ).arg( i ), QString() ).toString();
 
 1203  QString colorName = 
properties.value( QStringLiteral( 
"preset_color_name_%1" ).arg( i ), QString() ).toString();
 
 1204  while ( !colorString.isEmpty() )
 
 1208    colorString = 
properties.value( QStringLiteral( 
"preset_color_%1" ).arg( i ), QString() ).toString();
 
 1209    colorName = 
properties.value( QStringLiteral( 
"preset_color_name_%1" ).arg( i ), QString() ).toString();
 
 
 1218  l.reserve( mColors.count() );
 
 1219  for ( 
int i = 0; i < mColors.count(); ++i )
 
 1221    l << mColors.at( i ).first;
 
 
 1228  if ( mColors.empty() )
 
 1230  return static_cast< double >( index ) / ( mColors.size() - 1 );
 
 
 1235  if ( value < 0 || value > 1 )
 
 1238  int colorCnt = mColors.count();
 
 1239  int colorIdx = std::min( 
static_cast< int >( 
value * colorCnt ), colorCnt - 1 );
 
 1241  if ( colorIdx >= 0 && colorIdx < colorCnt )
 
 1242    return mColors.at( colorIdx ).first;
 
 
 1256  for ( 
int k = mColors.size() - 1; k >= 0; k-- )
 
 1258    tmpColors << mColors.at( k );
 
 1260  mColors = tmpColors;
 
 
 1271  for ( 
int i = 0; i < mColors.count(); ++i )
 
 1274    props.insert( QStringLiteral( 
"preset_color_name_%1" ).arg( i ), mColors.at( i ).second );
 
 1276  props[QStringLiteral( 
"rampType" )] = 
type();
 
 
 1282  return mColors.count();
 
 
AngularDirection
Angular directions.
@ NoOrientation
Unknown orientation or sentinel value.
@ CounterClockwise
Counter-clockwise direction.
@ Clockwise
Clockwise direction.
Color ramp utilising "Color Brewer" preset color schemes.
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.
virtual double value(int index) const =0
Returns relative value between [0,1] of color at specified index.
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)
A color ramp from the CPT City collection.
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
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
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.
QgsGradientStop(double offset, const QColor &color)
Constructor for QgsGradientStop.
Constrained random color ramp, which returns random colors based on preset parameters.
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.
A scheme based color ramp consisting of a list of predefined 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.
A color ramp consisting of random colors, constrained within component ranges.
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)