Skip to content
Permalink
Browse files

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

  • Loading branch information
nyalldawson committed Aug 24, 2016
1 parent b7716aa commit 1d98b10904884d8223372fc9248c2825c85591e9
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/core/qgscolorramp.cpp
@@ -313,8 +313,11 @@ double QgsLimitedRandomColorRamp::value( int index ) const

QColor QgsLimitedRandomColorRamp::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 1d98b10

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