我有一个自绘多边形(4点和lineto(),polygon()不起作用,因为它在屏幕上移动多边形时会留下标记)需要填充。 任何人都可以帮助我吗?
这是我的函数DrawHand
void CClock::DrawHand (CDC* pDC, int nLength, int nScale, int nDegrees, COLORREF clrColor)
{
CPoint point[4];
double nRadians = (double) nDegrees * 0.017453292;
point[0].x = (int) (nLength * sin (nRadians));
point[0].y = (int) (nLength * cos (nRadians));
point[2].x = -point[0].x / nScale;
point[2].y = -point[0].y / nScale;
point[1].x = -point[2].y;
point[1].y = point[2].x;
point[3].x = -point[1].x;
point[3].y = -point[1].y;
CPen pen (PS_SOLID, 0, clrColor);
CPen* pOldPen = pDC->SelectObject (&pen);
pDC->MoveTo(point[0]);
pDC->LineTo(point[1]);
pDC->LineTo(point[2]);
pDC->LineTo(point[3]);
pDC->LineTo(point[0]);
pDC->SelectObject (pOldPen);
}
答案 0 :(得分:0)
移动时多边形“留下标记”的原因是您在重绘时不清除背景。首先绘制一个背景颜色的矩形。