Skip to content

Commit

Permalink
Return rgba from ramp_color
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed May 17, 2013
1 parent d472a8f commit 7962361
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/qgsexpression.cpp
Expand Up @@ -1231,7 +1231,7 @@ QVariant fcnRampColor( const QVariantList &values, QgsFeature *, QgsExpression *
}
double value = getDoubleValue( values.at( 1 ), parent );
QColor color = mRamp->color( value );
return QString( "%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
return QgsSymbolLayerV2Utils::encodeColor( color );
}

static QVariant fcnColorHsl( const QVariantList &values, QgsFeature *, QgsExpression *parent )
Expand Down

2 comments on commit 7962361

@bholland
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I don't know if this should be a static function as all other functions like this are marked as static and it is defined here as static:
new StaticFunction( "ramp_color", 2, fcnRampColor, QObject::tr( "Color" ) )

Also I think these changes broke the unit tests:
FAIL! : TestQgsExpression::evaluation(ramp color) Compared values are not the same
Actual (res.toString()): 253,190,115,255
Expected (result.toString()): #fdbe73
Loc: [/home/ben/git/Quantum-GIS/tests/src/core/testqgsexpression.cpp(399)]
FAIL! : TestQgsExpression::evaluation(color rgb) Compared values are not the same
Actual (res.toString()): 255,127,0
Expected (result.toString()): #ff7f00
Loc: [/home/ben/git/Quantum-GIS/tests/src/core/testqgsexpression.cpp(399)]
FAIL! : TestQgsExpression::evaluation(color hsl) Compared values are not the same
Actual (res.toString()): 166,217,140
Expected (result.toString()): #a6d98c
Loc: [/home/ben/git/Quantum-GIS/tests/src/core/testqgsexpression.cpp(399)]
FAIL! : TestQgsExpression::evaluation(color hsv) Compared values are not the same
Actual (res.toString()): 255,170,0
Expected (result.toString()): #ffaa00
Loc: [/home/ben/git/Quantum-GIS/tests/src/core/testqgsexpression.cpp(399)]
FAIL! : TestQgsExpression::evaluation(color cmyk) Compared values are not the same
Actual (res.toString()): 0,115,154
Expected (result.toString()): #00739a
Loc: [/home/ben/git/Quantum-GIS/tests/src/core/testqgsexpression.cpp(399)]

It looks like they were returning hex values before and now are returning RGB(A) values instead. If this is true, I can update the unit tests.

@NathanW2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes both are true. It should be a static and the return value is now rgba

Please sign in to comment.