File tree Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ class QgsVectorGradientColorRampV2 : QgsVectorColorRampV2
83
83
84
84
/**copy color ramp stops to a QGradient
85
85
* @note added in 2.1 */
86
- void addStopsToGradient( QGradient* gradient );
86
+ void addStopsToGradient( QGradient* gradient, double alpha = 1 );
87
87
};
88
88
89
89
class QgsVectorRandomColorRampV2 : QgsVectorColorRampV2
Original file line number Diff line number Diff line change @@ -678,7 +678,7 @@ void QgsGradientFillSymbolLayerV2::applyGradient( const QgsSymbolV2RenderContext
678
678
{
679
679
// color ramp gradient
680
680
QgsVectorGradientColorRampV2* gradRamp = static_cast <QgsVectorGradientColorRampV2*>( gradientRamp );
681
- gradRamp->addStopsToGradient ( &gradient );
681
+ gradRamp->addStopsToGradient ( &gradient, context. alpha () );
682
682
}
683
683
else
684
684
{
Original file line number Diff line number Diff line change @@ -219,16 +219,28 @@ void QgsVectorGradientColorRampV2::convertToDiscrete( bool discrete )
219
219
mDiscrete = discrete;
220
220
}
221
221
222
- void QgsVectorGradientColorRampV2::addStopsToGradient ( QGradient* gradient )
222
+ void QgsVectorGradientColorRampV2::addStopsToGradient ( QGradient* gradient, double alpha )
223
223
{
224
224
// copy color ramp stops to a QGradient
225
- gradient->setColorAt ( 0 , mColor1 );
226
- gradient->setColorAt ( 1 , mColor2 );
225
+ QColor color1 = mColor1 ;
226
+ QColor color2 = mColor2 ;
227
+ if ( alpha < 1 )
228
+ {
229
+ color1.setAlpha ( color1.alpha () * alpha );
230
+ color2.setAlpha ( color2.alpha () * alpha );
231
+ }
232
+ gradient->setColorAt ( 0 , color1 );
233
+ gradient->setColorAt ( 1 , color2 );
227
234
228
235
for ( QgsGradientStopsList::const_iterator it = mStops .begin ();
229
236
it != mStops .end (); ++it )
230
237
{
231
- gradient->setColorAt ( it->offset , it->color );
238
+ QColor rampColor = it->color ;
239
+ if ( alpha < 1 )
240
+ {
241
+ rampColor.setAlpha ( rampColor.alpha () * alpha );
242
+ }
243
+ gradient->setColorAt ( it->offset , rampColor );
232
244
}
233
245
}
234
246
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ class CORE_EXPORT QgsVectorGradientColorRampV2 : public QgsVectorColorRampV2
94
94
95
95
/* *copy color ramp stops to a QGradient
96
96
* @note added in 2.1 */
97
- void addStopsToGradient ( QGradient* gradient );
97
+ void addStopsToGradient ( QGradient* gradient, double alpha = 1 );
98
98
99
99
protected:
100
100
QColor mColor1 , mColor2 ;
You can’t perform that action at this time.
0 commit comments