Skip to content
Permalink
Browse files

Merge pull request #1019 from nyalldawson/random_colors

Tweak random color ramp for nicer colors
  • Loading branch information
mhugent committed Dec 11, 2013
2 parents 36c2f7f + bce3588 commit 70915ca0b08d19ac9c5deed2bc091a91d26471c7
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 70915ca

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