We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 38f4f08 commit b8ec8c9Copy full SHA for b8ec8c9
1 file changed
src/core/symbology-ng/qgsvectorcolorrampv2.cpp
@@ -313,8 +313,11 @@ double QgsVectorRandomColorRampV2::value( int index ) const
313
314
QColor QgsVectorRandomColorRampV2::color( double value ) const
315
{
316
+ if ( value < 0 || value > 1 )
317
+ return QColor();
318
+
319
int colorCnt = mColors.count();
- int colorIdx = static_cast< int >( value * ( colorCnt - 1 ) );
320
+ int colorIdx = qMin( static_cast< int >( value * colorCnt ), colorCnt - 1 );
321
322
if ( colorIdx >= 0 && colorIdx < colorCnt )
323
return mColors.at( colorIdx );
0 commit comments