Skip to content
Permalink
Browse files

Fix limited random color ramp always returns 1 less color than set

(cherry-picked from 1d98b10)
  • Loading branch information
nyalldawson committed Aug 29, 2016
1 parent f23b778 commit e304c4d056e9f58490437fd1ddc36f9464b6eb4a
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/core/symbology-ng/qgsvectorcolorrampv2.cpp
@@ -296,8 +296,11 @@ double QgsVectorRandomColorRampV2::value( int index ) const

QColor QgsVectorRandomColorRampV2::color( double value ) const
{
if ( value < 0 || value > 1 )
return QColor();

int colorCnt = mColors.count();
int colorIdx = static_cast< int >( value * ( colorCnt - 1 ) );
int colorIdx = qMin( static_cast< int >( value * colorCnt ), colorCnt - 1 );

if ( colorIdx >= 0 && colorIdx < colorCnt )
return mColors.at( colorIdx );

0 comments on commit e304c4d

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