Fixed drawing ellipse/circle in Direct2D wxGraphicsPath.

Instead of drawing an ellipse as a filled figure draw it as a curve (concatenation of two elliptical arcs).

Closes #17306.
This commit is contained in:
Artur Wieczorek
2015-12-28 00:07:00 +01:00
parent bad2538697
commit 846dde3b36

View File

@@ -1209,25 +1209,34 @@ void wxD2DPathData::AddCircle(wxDouble x, wxDouble y, wxDouble r)
// appends an ellipse // appends an ellipse
void wxD2DPathData::AddEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h) void wxD2DPathData::AddEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h)
{ {
Flush(); if ( w <= 0.0 || h <= 0.0 )
return;
wxCOMPtr<ID2D1EllipseGeometry> ellipseGeometry; // Calculate radii
wxCOMPtr<ID2D1PathGeometry> newPathGeometry; const wxDouble rx = w / 2.0;
const wxDouble ry = h / 2.0;
D2D1_ELLIPSE ellipse = { { (FLOAT)(x + w / 2), (FLOAT)(y + h / 2) }, (FLOAT)(w / 2), (FLOAT)(h / 2) }; MoveToPoint(x, y + ry);
m_direct2dfactory->CreateEllipseGeometry(ellipse, &ellipseGeometry); D2D1_ARC_SEGMENT arcSegmentUpper =
{
D2D1::Point2((FLOAT)(x + w), (FLOAT)(y + ry)), // end point
D2D1::SizeF((FLOAT)(rx), (FLOAT)(ry)), // size
0.0f,
D2D1_SWEEP_DIRECTION_CLOCKWISE,
D2D1_ARC_SIZE_SMALL
};
m_geometrySink->AddArc(arcSegmentUpper);
m_direct2dfactory->CreatePathGeometry(&newPathGeometry); D2D1_ARC_SEGMENT arcSegmentLower =
{
m_geometrySink = NULL; D2D1::Point2((FLOAT)(x), (FLOAT)(y + ry)), // end point
newPathGeometry->Open(&m_geometrySink); D2D1::SizeF((FLOAT)(rx), (FLOAT)(ry)), // size
0.0f,
m_geometryWritable = true; D2D1_SWEEP_DIRECTION_CLOCKWISE,
D2D1_ARC_SIZE_SMALL
ellipseGeometry->CombineWithGeometry(m_pathGeometry, D2D1_COMBINE_MODE_UNION, NULL, m_geometrySink); };
m_geometrySink->AddArc(arcSegmentLower);
m_pathGeometry = newPathGeometry;
} }
// gets the last point of the current path, (0,0) if not yet set // gets the last point of the current path, (0,0) if not yet set