Fix order of radial gradient stops in wxMSW.
Ensure that the order of stops is consistent with the documentation and other platforms behaviour, i.e. they are counted from inside to outside of the circle and not vice versa, which happens to be the GDI+ convention. Closes #16443. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77481 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -281,7 +281,9 @@ protected:
|
||||
private:
|
||||
// common part of Create{Linear,Radial}GradientBrush()
|
||||
template <typename T>
|
||||
void SetGradientStops(T *brush, const wxGraphicsGradientStops& stops);
|
||||
void SetGradientStops(T *brush,
|
||||
const wxGraphicsGradientStops& stops,
|
||||
bool reversed = false);
|
||||
|
||||
Brush* m_brush;
|
||||
Image* m_brushImage;
|
||||
@@ -852,7 +854,8 @@ void wxGDIPlusBrushData::Init()
|
||||
template <typename T>
|
||||
void
|
||||
wxGDIPlusBrushData::SetGradientStops(T *brush,
|
||||
const wxGraphicsGradientStops& stops)
|
||||
const wxGraphicsGradientStops& stops,
|
||||
bool reversed)
|
||||
{
|
||||
const unsigned numStops = stops.GetCount();
|
||||
if ( numStops <= 2 )
|
||||
@@ -865,12 +868,25 @@ wxGDIPlusBrushData::SetGradientStops(T *brush,
|
||||
wxVector<Color> colors(numStops);
|
||||
wxVector<REAL> positions(numStops);
|
||||
|
||||
for ( unsigned i = 0; i < numStops; i++ )
|
||||
if ( reversed )
|
||||
{
|
||||
wxGraphicsGradientStop stop = stops.Item(i);
|
||||
for ( unsigned i = 0; i < numStops; i++ )
|
||||
{
|
||||
wxGraphicsGradientStop stop = stops.Item(numStops - i - 1);
|
||||
|
||||
colors[i] = wxColourToColor(stop.GetColour());
|
||||
positions[i] = stop.GetPosition();
|
||||
colors[i] = wxColourToColor(stop.GetColour());
|
||||
positions[i] = 1.0 - stop.GetPosition();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( unsigned i = 0; i < numStops; i++ )
|
||||
{
|
||||
wxGraphicsGradientStop stop = stops.Item(i);
|
||||
|
||||
colors[i] = wxColourToColor(stop.GetColour());
|
||||
positions[i] = stop.GetPosition();
|
||||
}
|
||||
}
|
||||
|
||||
brush->SetInterpolationColors(&colors[0], &positions[0], numStops);
|
||||
@@ -909,7 +925,9 @@ wxGDIPlusBrushData::CreateRadialGradientBrush(wxDouble xo, wxDouble yo,
|
||||
int count = 1;
|
||||
brush->SetSurroundColors(&col, &count);
|
||||
|
||||
SetGradientStops(brush, stops);
|
||||
// Because the GDI+ API draws radial gradients from outside towards the
|
||||
// center we have to reverse the order of the gradient stops.
|
||||
SetGradientStops(brush, stops, true);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user