Skip to content
Permalink
Browse files

Return rgba from ramp_color

  • Loading branch information
NathanW2 committed May 17, 2013
1 parent d472a8f commit 79623613297ac3f4a2248163b8b13de7d15cd908
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/core/qgsexpression.cpp
@@ -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 )

2 comments on commit 7962361

@bholland

This comment has been minimized.

Copy link

@bholland bholland replied May 19, 2013

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

This comment has been minimized.

Copy link
Member Author

@NathanW2 NathanW2 replied May 19, 2013

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

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