Use wxPoint2DDouble in wxGCDC::DrawSpline

Code can be simplified by using wxPoint2DDouble in the calculations.
This commit is contained in:
Artur Wieczorek
2021-07-04 22:02:20 +02:00
parent fb21a9096e
commit 7da2f989a0

View File

@@ -856,31 +856,25 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points)
wxPointList::const_iterator itPt = points->begin(); wxPointList::const_iterator itPt = points->begin();
const wxPoint* p = *itPt; ++itPt; const wxPoint* p = *itPt; ++itPt;
wxCoord x1 = p->x; wxPoint2DDouble p1(*p);
wxCoord y1 = p->y;
p = *itPt; ++itPt; p = *itPt; ++itPt;
wxCoord x2 = p->x; wxPoint2DDouble p2(*p);
wxCoord y2 = p->y; wxPoint2DDouble c1 = (p1 + p2) / 2.0;
wxCoord cx1 = ( x1 + x2 ) / 2;
wxCoord cy1 = ( y1 + y2 ) / 2;
path.MoveToPoint( x1 , y1 ); path.MoveToPoint(p1);
path.AddLineToPoint( cx1 , cy1 ); path.AddLineToPoint(c1);
while ( itPt != points->end() ) while ( itPt != points->end() )
{ {
p = *itPt; ++itPt; p = *itPt; ++itPt;
x1 = x2; p1 = p2;
y1 = y2; p2 = *p;
x2 = p->x; wxPoint2DDouble c4 = (p1 + p2) / 2.0;
y2 = p->y;
wxCoord cx4 = (x1 + x2) / 2;
wxCoord cy4 = (y1 + y2) / 2;
path.AddQuadCurveToPoint(x1 , y1 ,cx4 , cy4 ); path.AddQuadCurveToPoint(p1.m_x , p1.m_y, c4.m_x, c4.m_y);
} }
path.AddLineToPoint( x2 , y2 ); path.AddLineToPoint(p2);
m_graphicContext->StrokePath( path ); m_graphicContext->StrokePath( path );