We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
qgis
Learn more about funding links in repositories.
Report abuse
There was an error while loading. Please reload this page.
1 parent f23b778 commit e304c4dCopy full SHA for e304c4d
src/core/symbology-ng/qgsvectorcolorrampv2.cpp
@@ -296,8 +296,11 @@ double QgsVectorRandomColorRampV2::value( int index ) const
296
297
QColor QgsVectorRandomColorRampV2::color( double value ) const
298
{
299
+ if ( value < 0 || value > 1 )
300
+ return QColor();
301
+
302
int colorCnt = mColors.count();
- int colorIdx = static_cast< int >( value * ( colorCnt - 1 ) );
303
+ int colorIdx = qMin( static_cast< int >( value * colorCnt ), colorCnt - 1 );
304
305
if ( colorIdx >= 0 && colorIdx < colorCnt )
306
return mColors.at( colorIdx );
0 commit comments