Skip to content

Commit

Permalink
Merge pull request #1019 from nyalldawson/random_colors
Browse files Browse the repository at this point in the history
Tweak random color ramp for nicer colors
  • Loading branch information
mhugent committed Dec 11, 2013
2 parents 36c2f7f + bce3588 commit 70915ca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/symbology-ng/qgsvectorcolorrampv2.cpp
Expand Up @@ -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
Expand Down

0 comments on commit 70915ca

Please sign in to comment.