Gradients can have matrix transforms too. Updates for Cairo.
This commit is contained in:
parent
fd0b19f277
commit
7c33d3f969
@ -242,7 +242,8 @@ public:
|
||||
|
||||
wxGraphicsPenInfo&
|
||||
LinearGradient(wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
||||
const wxColour& c1, const wxColour& c2)
|
||||
const wxColour& c1, const wxColour& c2,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix)
|
||||
{
|
||||
m_gradientType = wxGRADIENT_LINEAR;
|
||||
m_x1 = x1;
|
||||
@ -251,12 +252,14 @@ public:
|
||||
m_y2 = y2;
|
||||
m_stops.SetStartColour(c1);
|
||||
m_stops.SetEndColour(c2);
|
||||
m_matrix = matrix;
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxGraphicsPenInfo&
|
||||
LinearGradient(wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
||||
const wxGraphicsGradientStops& stops)
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix)
|
||||
{
|
||||
m_gradientType = wxGRADIENT_LINEAR;
|
||||
m_x1 = x1;
|
||||
@ -264,27 +267,31 @@ public:
|
||||
m_x2 = x2;
|
||||
m_y2 = y2;
|
||||
m_stops = stops;
|
||||
m_matrix = matrix;
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxGraphicsPenInfo&
|
||||
RadialGradient(wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
|
||||
const wxColour& oColor, const wxColour& cColor)
|
||||
const wxColour& oColor, const wxColour& cColor,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix)
|
||||
{
|
||||
m_gradientType = wxGRADIENT_RADIAL;
|
||||
m_x1 = xo;
|
||||
m_x1 = xo;
|
||||
m_y1 = yo;
|
||||
m_x2 = xc;
|
||||
m_y2 = yc;
|
||||
m_radius = radius;
|
||||
m_stops.SetStartColour(oColor);
|
||||
m_stops.SetEndColour(cColor);
|
||||
m_matrix = matrix;
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxGraphicsPenInfo&
|
||||
RadialGradient(wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc,
|
||||
wxDouble radius, const wxGraphicsGradientStops& stops)
|
||||
wxDouble radius, const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix)
|
||||
{
|
||||
m_gradientType = wxGRADIENT_RADIAL;
|
||||
m_x1 = xo;
|
||||
@ -293,6 +300,7 @@ public:
|
||||
m_y2 = yc;
|
||||
m_radius = radius;
|
||||
m_stops = stops;
|
||||
m_matrix = matrix;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -310,6 +318,7 @@ public:
|
||||
wxDouble GetYC() const { return m_y2; }
|
||||
wxDouble GetRadius() const { return m_radius; }
|
||||
const wxGraphicsGradientStops& GetStops() const { return m_stops; }
|
||||
const wxGraphicsMatrix& GetMatrix() const { return m_matrix; }
|
||||
|
||||
private:
|
||||
wxDouble m_width;
|
||||
@ -317,6 +326,7 @@ private:
|
||||
wxDouble m_x1, m_y1, m_x2, m_y2; // also used for m_xo, m_yo, m_xc, m_yx
|
||||
wxDouble m_radius;
|
||||
wxGraphicsGradientStops m_stops;
|
||||
wxGraphicsMatrix m_matrix;
|
||||
};
|
||||
|
||||
|
||||
@ -606,11 +616,13 @@ public:
|
||||
wxGraphicsBrush
|
||||
CreateLinearGradientBrush(wxDouble x1, wxDouble y1,
|
||||
wxDouble x2, wxDouble y2,
|
||||
const wxColour& c1, const wxColour& c2) const;
|
||||
const wxColour& c1, const wxColour& c2,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) const;
|
||||
wxGraphicsBrush
|
||||
CreateLinearGradientBrush(wxDouble x1, wxDouble y1,
|
||||
wxDouble x2, wxDouble y2,
|
||||
const wxGraphicsGradientStops& stops) const;
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) const;
|
||||
|
||||
// sets the brush to a radial gradient originating at (xo,yc) and ending
|
||||
// on a circle around (xc,yc) with the given radius; the colours may be
|
||||
@ -618,12 +630,14 @@ public:
|
||||
wxGraphicsBrush
|
||||
CreateRadialGradientBrush(wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc, wxDouble radius,
|
||||
const wxColour& oColor, const wxColour& cColor) const;
|
||||
const wxColour& oColor, const wxColour& cColor,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) const;
|
||||
|
||||
wxGraphicsBrush
|
||||
CreateRadialGradientBrush(wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc, wxDouble radius,
|
||||
const wxGraphicsGradientStops& stops) const;
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) const;
|
||||
|
||||
// creates a font
|
||||
virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) const;
|
||||
@ -999,13 +1013,15 @@ public:
|
||||
virtual wxGraphicsBrush
|
||||
CreateLinearGradientBrush(wxDouble x1, wxDouble y1,
|
||||
wxDouble x2, wxDouble y2,
|
||||
const wxGraphicsGradientStops& stops) = 0;
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) = 0;
|
||||
|
||||
virtual wxGraphicsBrush
|
||||
CreateRadialGradientBrush(wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc,
|
||||
wxDouble radius,
|
||||
const wxGraphicsGradientStops& stops) = 0;
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) = 0;
|
||||
|
||||
// sets the font
|
||||
virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) = 0;
|
||||
|
@ -644,7 +644,8 @@ public:
|
||||
wxGraphicsBrush
|
||||
CreateLinearGradientBrush(wxDouble x1, wxDouble y1,
|
||||
wxDouble x2, wxDouble y2,
|
||||
const wxColour& c1, const wxColour& c2) const;
|
||||
const wxColour& c1, const wxColour& c2,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) const;
|
||||
|
||||
/**
|
||||
@overload
|
||||
@ -652,7 +653,8 @@ public:
|
||||
wxGraphicsBrush
|
||||
CreateLinearGradientBrush(wxDouble x1, wxDouble y1,
|
||||
wxDouble x2, wxDouble y2,
|
||||
const wxGraphicsGradientStops& stops) const;
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) const;
|
||||
|
||||
/**
|
||||
Creates a native brush with a radial gradient.
|
||||
@ -670,7 +672,8 @@ public:
|
||||
wxDouble xc, wxDouble yc,
|
||||
wxDouble radius,
|
||||
const wxColour& oColor,
|
||||
const wxColour& cColor) const;
|
||||
const wxColour& cColor,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) const;
|
||||
|
||||
/**
|
||||
@overload
|
||||
@ -679,7 +682,8 @@ public:
|
||||
CreateRadialGradientBrush(wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc,
|
||||
wxDouble radius,
|
||||
const wxGraphicsGradientStops& stops) = 0;
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) = 0;
|
||||
|
||||
/**
|
||||
Sets the brush for filling paths.
|
||||
@ -1456,7 +1460,8 @@ public:
|
||||
wxDouble y1,
|
||||
wxDouble x2,
|
||||
wxDouble y2,
|
||||
const wxGraphicsGradientStops& stops) = 0;
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) = 0;
|
||||
|
||||
/**
|
||||
Creates a native affine transformation matrix from the passed in
|
||||
@ -1488,7 +1493,8 @@ public:
|
||||
virtual wxGraphicsBrush CreateRadialGradientBrush(wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc,
|
||||
wxDouble radius,
|
||||
const wxGraphicsGradientStops& stops) = 0;
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) = 0;
|
||||
|
||||
/**
|
||||
Extracts a sub-bitmap from an existing bitmap.
|
||||
@ -1630,19 +1636,23 @@ public:
|
||||
|
||||
wxGraphicsPenInfo&
|
||||
LinearGradient(wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
||||
const wxColour& c1, const wxColour& c2);
|
||||
const wxColour& c1, const wxColour& c2,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix);
|
||||
|
||||
wxGraphicsPenInfo&
|
||||
LinearGradient(wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
||||
const wxGraphicsGradientStops& stops);
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix);
|
||||
|
||||
wxGraphicsPenInfo&
|
||||
RadialGradient(wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
|
||||
const wxColour& oColor, const wxColour& cColor);
|
||||
const wxColour& oColor, const wxColour& cColor,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix);
|
||||
|
||||
wxGraphicsPenInfo&
|
||||
RadialGradient(wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc,
|
||||
wxDouble radius, const wxGraphicsGradientStops& stops);
|
||||
wxDouble radius, const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix);
|
||||
|
||||
wxColour GetColour() const;
|
||||
wxBitmap GetStipple() const;
|
||||
|
@ -883,13 +883,15 @@ wxGraphicsBrush
|
||||
wxGraphicsContext::CreateLinearGradientBrush(
|
||||
wxDouble x1, wxDouble y1,
|
||||
wxDouble x2, wxDouble y2,
|
||||
const wxColour& c1, const wxColour& c2) const
|
||||
const wxColour& c1, const wxColour& c2,
|
||||
const wxGraphicsMatrix& matrix) const
|
||||
{
|
||||
return GetRenderer()->CreateLinearGradientBrush
|
||||
(
|
||||
x1, y1,
|
||||
x2, y2,
|
||||
wxGraphicsGradientStops(c1,c2)
|
||||
wxGraphicsGradientStops(c1,c2),
|
||||
matrix
|
||||
);
|
||||
}
|
||||
|
||||
@ -897,22 +899,15 @@ wxGraphicsBrush
|
||||
wxGraphicsContext::CreateLinearGradientBrush(
|
||||
wxDouble x1, wxDouble y1,
|
||||
wxDouble x2, wxDouble y2,
|
||||
const wxGraphicsGradientStops& gradientStops) const
|
||||
const wxGraphicsGradientStops& gradientStops,
|
||||
const wxGraphicsMatrix& matrix) const
|
||||
{
|
||||
return GetRenderer()->CreateLinearGradientBrush(x1,y1,x2,y2, gradientStops);
|
||||
}
|
||||
|
||||
wxGraphicsBrush
|
||||
wxGraphicsContext::CreateRadialGradientBrush(
|
||||
wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc, wxDouble radius,
|
||||
const wxColour &oColor, const wxColour &cColor) const
|
||||
{
|
||||
return GetRenderer()->CreateRadialGradientBrush
|
||||
return GetRenderer()->CreateLinearGradientBrush
|
||||
(
|
||||
xo, yo,
|
||||
xc, yc, radius,
|
||||
wxGraphicsGradientStops(oColor, cColor)
|
||||
x1, y1,
|
||||
x2, y2,
|
||||
gradientStops,
|
||||
matrix
|
||||
);
|
||||
}
|
||||
|
||||
@ -920,13 +915,31 @@ wxGraphicsBrush
|
||||
wxGraphicsContext::CreateRadialGradientBrush(
|
||||
wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc, wxDouble radius,
|
||||
const wxGraphicsGradientStops& gradientStops) const
|
||||
const wxColour &oColor, const wxColour &cColor,
|
||||
const wxGraphicsMatrix& matrix) const
|
||||
{
|
||||
return GetRenderer()->CreateRadialGradientBrush
|
||||
(
|
||||
xo, yo,
|
||||
xc, yc, radius,
|
||||
gradientStops
|
||||
wxGraphicsGradientStops(oColor, cColor),
|
||||
matrix
|
||||
);
|
||||
}
|
||||
|
||||
wxGraphicsBrush
|
||||
wxGraphicsContext::CreateRadialGradientBrush(
|
||||
wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc, wxDouble radius,
|
||||
const wxGraphicsGradientStops& gradientStops,
|
||||
const wxGraphicsMatrix& matrix) const
|
||||
{
|
||||
return GetRenderer()->CreateRadialGradientBrush
|
||||
(
|
||||
xo, yo,
|
||||
xc, yc, radius,
|
||||
gradientStops,
|
||||
matrix
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -262,10 +262,12 @@ public:
|
||||
|
||||
void CreateLinearGradientPattern(wxDouble x1, wxDouble y1,
|
||||
wxDouble x2, wxDouble y2,
|
||||
const wxGraphicsGradientStops& stops);
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix);
|
||||
void CreateRadialGradientPattern(wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc, wxDouble radius,
|
||||
const wxGraphicsGradientStops& stops);
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix);
|
||||
|
||||
protected:
|
||||
// Call this to use the given bitmap as stipple. Bitmap must be non-null
|
||||
@ -748,10 +750,17 @@ void wxCairoPenBrushBaseData::AddGradientStops(const wxGraphicsGradientStops& st
|
||||
void
|
||||
wxCairoPenBrushBaseData::CreateLinearGradientPattern(wxDouble x1, wxDouble y1,
|
||||
wxDouble x2, wxDouble y2,
|
||||
const wxGraphicsGradientStops& stops)
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix)
|
||||
{
|
||||
m_pattern = cairo_pattern_create_linear(x1,y1,x2,y2);
|
||||
|
||||
if (! matrix.IsNull())
|
||||
{
|
||||
cairo_matrix_t m = *((cairo_matrix_t*) matrix.GetNativeMatrix());
|
||||
cairo_pattern_set_matrix(m_pattern, &m);
|
||||
}
|
||||
|
||||
AddGradientStops(stops);
|
||||
}
|
||||
|
||||
@ -759,10 +768,17 @@ void
|
||||
wxCairoPenBrushBaseData::CreateRadialGradientPattern(wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc,
|
||||
wxDouble radius,
|
||||
const wxGraphicsGradientStops& stops)
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix)
|
||||
{
|
||||
m_pattern = cairo_pattern_create_radial(xo,yo,0.0,xc,yc,radius);
|
||||
|
||||
if (! matrix.IsNull())
|
||||
{
|
||||
cairo_matrix_t m = *((cairo_matrix_t*) matrix.GetNativeMatrix());
|
||||
cairo_pattern_set_matrix(m_pattern, &m);
|
||||
}
|
||||
|
||||
AddGradientStops(stops);
|
||||
}
|
||||
|
||||
@ -922,14 +938,16 @@ wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxGraphicsPe
|
||||
case wxGRADIENT_LINEAR:
|
||||
CreateLinearGradientPattern(info.GetX1(), info.GetY1(),
|
||||
info.GetX2(), info.GetY2(),
|
||||
info.GetStops());
|
||||
info.GetStops(),
|
||||
info.GetMatrix());
|
||||
break;
|
||||
|
||||
case wxGRADIENT_RADIAL:
|
||||
CreateRadialGradientPattern(info.GetXO(), info.GetYO(),
|
||||
info.GetXC(), info.GetYC(),
|
||||
info.GetRadius(),
|
||||
info.GetStops());
|
||||
info.GetStops(),
|
||||
info.GetMatrix());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2975,13 +2993,15 @@ public :
|
||||
virtual wxGraphicsBrush
|
||||
CreateLinearGradientBrush(wxDouble x1, wxDouble y1,
|
||||
wxDouble x2, wxDouble y2,
|
||||
const wxGraphicsGradientStops& stops) wxOVERRIDE;
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) wxOVERRIDE;
|
||||
|
||||
virtual wxGraphicsBrush
|
||||
CreateRadialGradientBrush(wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc,
|
||||
wxDouble radius,
|
||||
const wxGraphicsGradientStops& stops) wxOVERRIDE;
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix=wxNullGraphicsMatrix) wxOVERRIDE;
|
||||
|
||||
// sets the font
|
||||
virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) wxOVERRIDE ;
|
||||
@ -3169,12 +3189,13 @@ wxGraphicsBrush wxCairoRenderer::CreateBrush(const wxBrush& brush )
|
||||
wxGraphicsBrush
|
||||
wxCairoRenderer::CreateLinearGradientBrush(wxDouble x1, wxDouble y1,
|
||||
wxDouble x2, wxDouble y2,
|
||||
const wxGraphicsGradientStops& stops)
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix)
|
||||
{
|
||||
wxGraphicsBrush p;
|
||||
ENSURE_LOADED_OR_RETURN(p);
|
||||
wxCairoBrushData* d = new wxCairoBrushData( this );
|
||||
d->CreateLinearGradientPattern(x1, y1, x2, y2, stops);
|
||||
d->CreateLinearGradientPattern(x1, y1, x2, y2, stops, matrix);
|
||||
p.SetRefData(d);
|
||||
return p;
|
||||
}
|
||||
@ -3182,16 +3203,18 @@ wxCairoRenderer::CreateLinearGradientBrush(wxDouble x1, wxDouble y1,
|
||||
wxGraphicsBrush
|
||||
wxCairoRenderer::CreateRadialGradientBrush(wxDouble xo, wxDouble yo,
|
||||
wxDouble xc, wxDouble yc, wxDouble r,
|
||||
const wxGraphicsGradientStops& stops)
|
||||
const wxGraphicsGradientStops& stops,
|
||||
const wxGraphicsMatrix& matrix)
|
||||
{
|
||||
wxGraphicsBrush p;
|
||||
ENSURE_LOADED_OR_RETURN(p);
|
||||
wxCairoBrushData* d = new wxCairoBrushData( this );
|
||||
d->CreateRadialGradientPattern(xo, yo, xc, yc, r, stops);
|
||||
d->CreateRadialGradientPattern(xo, yo, xc, yc, r, stops, matrix);
|
||||
p.SetRefData(d);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
wxGraphicsFont wxCairoRenderer::CreateFont( const wxFont &font , const wxColour &col )
|
||||
{
|
||||
wxGraphicsFont p;
|
||||
|
Loading…
Reference in New Issue
Block a user