Skip to content
Permalink
Browse files

Tweak random color ramp for nicer colors

  • Loading branch information
nyalldawson committed Dec 6, 2013
1 parent 330b46b commit bce3588d2a882c67fab37683f46c8624125eba65
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/core/symbology-ng/qgsvectorcolorrampv2.cpp
@@ -345,10 +345,12 @@ double QgsRandomColorsV2::value( int index ) const
QColor QgsRandomColorsV2::color( double value ) const
{
Q_UNUSED( value );
int r = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
int g = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
int b = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
return QColor( r, g, b );
int minVal = 130;
int maxVal = 255;
int h = 1 + ( int )( 360.0 * rand() / ( RAND_MAX + 1.0 ) );
int s = ( rand() % ( DEFAULT_RANDOM_SAT_MAX - DEFAULT_RANDOM_SAT_MIN + 1 ) ) + DEFAULT_RANDOM_SAT_MIN;
int v = ( rand() % ( maxVal - minVal + 1 ) ) + minVal;
return QColor::fromHsv( h, s, v );
}

QString QgsRandomColorsV2::type() const

0 comments on commit bce3588

Please sign in to comment.
You can’t perform that action at this time.