mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Fix limited random color ramp always returns 1 less color than set
This commit is contained in:
parent
b7716aa7fb
commit
1d98b10904
@ -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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user