mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Fix gradient fills using color ramps not respecting symbol transparency
This commit is contained in:
parent
6685932c09
commit
a0c2c7aaad
@ -83,7 +83,7 @@ class QgsVectorGradientColorRampV2 : QgsVectorColorRampV2
|
|||||||
|
|
||||||
/**copy color ramp stops to a QGradient
|
/**copy color ramp stops to a QGradient
|
||||||
* @note added in 2.1 */
|
* @note added in 2.1 */
|
||||||
void addStopsToGradient( QGradient* gradient );
|
void addStopsToGradient( QGradient* gradient, double alpha = 1 );
|
||||||
};
|
};
|
||||||
|
|
||||||
class QgsVectorRandomColorRampV2 : QgsVectorColorRampV2
|
class QgsVectorRandomColorRampV2 : QgsVectorColorRampV2
|
||||||
|
@ -678,7 +678,7 @@ void QgsGradientFillSymbolLayerV2::applyGradient( const QgsSymbolV2RenderContext
|
|||||||
{
|
{
|
||||||
//color ramp gradient
|
//color ramp gradient
|
||||||
QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( gradientRamp );
|
QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( gradientRamp );
|
||||||
gradRamp->addStopsToGradient( &gradient );
|
gradRamp->addStopsToGradient( &gradient, context.alpha() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -219,16 +219,28 @@ void QgsVectorGradientColorRampV2::convertToDiscrete( bool discrete )
|
|||||||
mDiscrete = discrete;
|
mDiscrete = discrete;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsVectorGradientColorRampV2::addStopsToGradient( QGradient* gradient )
|
void QgsVectorGradientColorRampV2::addStopsToGradient( QGradient* gradient, double alpha )
|
||||||
{
|
{
|
||||||
//copy color ramp stops to a QGradient
|
//copy color ramp stops to a QGradient
|
||||||
gradient->setColorAt( 0, mColor1 );
|
QColor color1 = mColor1;
|
||||||
gradient->setColorAt( 1, mColor2 );
|
QColor color2 = mColor2;
|
||||||
|
if ( alpha < 1 )
|
||||||
|
{
|
||||||
|
color1.setAlpha( color1.alpha() * alpha );
|
||||||
|
color2.setAlpha( color2.alpha() * alpha );
|
||||||
|
}
|
||||||
|
gradient->setColorAt( 0, color1 );
|
||||||
|
gradient->setColorAt( 1, color2 );
|
||||||
|
|
||||||
for ( QgsGradientStopsList::const_iterator it = mStops.begin();
|
for ( QgsGradientStopsList::const_iterator it = mStops.begin();
|
||||||
it != mStops.end(); ++it )
|
it != mStops.end(); ++it )
|
||||||
{
|
{
|
||||||
gradient->setColorAt( it->offset , it->color );
|
QColor rampColor = it->color;
|
||||||
|
if ( alpha < 1 )
|
||||||
|
{
|
||||||
|
rampColor.setAlpha( rampColor.alpha() * alpha );
|
||||||
|
}
|
||||||
|
gradient->setColorAt( it->offset , rampColor );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ class CORE_EXPORT QgsVectorGradientColorRampV2 : public QgsVectorColorRampV2
|
|||||||
|
|
||||||
/**copy color ramp stops to a QGradient
|
/**copy color ramp stops to a QGradient
|
||||||
* @note added in 2.1 */
|
* @note added in 2.1 */
|
||||||
void addStopsToGradient( QGradient* gradient );
|
void addStopsToGradient( QGradient* gradient, double alpha = 1 );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QColor mColor1, mColor2;
|
QColor mColor1, mColor2;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user