求MFC画圆代码。
1个回答
展开全部
void CFIGUREView::INTERACTIVECIRCLE(CPoint start2,CPoint end2,COLORREF color)
{
{
CClientDC dc(this);
int x , y ,R,f;
R=sqrt((end2.x-start2.x)*(end2.x-start2.x)+(end2.y-start2.y)*(end2.y-start2.y));
x=0;
y=R;
f=1-R;
dc.SetPixel(start2.x+x,end2.y+y,RGB(0,0,255));
dc.SetPixel(start2.x+x,end2.y-y,RGB(0,0,255));
dc.SetPixel(start2.x-x,end2.y+y,RGB(0,0,255));
dc.SetPixel(start2.x+y,end2.y+x,RGB(0,0,255));
dc.SetPixel(start2.x+y,end2.y-x,RGB(0,0,255));
dc.SetPixel(start2.x-y,end2.y+x,RGB(0,0,255));
dc.SetPixel(start2.x-x,end2.y-y,RGB(0,0,255));
dc.SetPixel(start2.x-y,end2.y-x,RGB(0,0,255));
while (x<y)
{
if (f<0)
{
f=f+2*x+3;
x++;
}
else
{
f=f+2*(x-y)+5;
x++;
y--;
}
dc.SetPixel(start2.x+x,end2.y+y,RGB(0,0,255));
dc.SetPixel(start2.x+x,end2.y-y,RGB(0,0,255));
dc.SetPixel(start2.x-x,end2.y+y,RGB(0,0,255));
dc.SetPixel(start2.x+y,end2.y+x,RGB(0,0,255));
dc.SetPixel(start2.x+y,end2.y-x,RGB(0,0,255));
dc.SetPixel(start2.x-y,end2.y+x,RGB(0,0,255));
dc.SetPixel(start2.x-x,end2.y-y,RGB(0,0,255));
dc.SetPixel(start2.x-y,end2.y-x,RGB(0,0,255));
}
}
}
交互式画圆,自己加鼠标事件即可。
{
{
CClientDC dc(this);
int x , y ,R,f;
R=sqrt((end2.x-start2.x)*(end2.x-start2.x)+(end2.y-start2.y)*(end2.y-start2.y));
x=0;
y=R;
f=1-R;
dc.SetPixel(start2.x+x,end2.y+y,RGB(0,0,255));
dc.SetPixel(start2.x+x,end2.y-y,RGB(0,0,255));
dc.SetPixel(start2.x-x,end2.y+y,RGB(0,0,255));
dc.SetPixel(start2.x+y,end2.y+x,RGB(0,0,255));
dc.SetPixel(start2.x+y,end2.y-x,RGB(0,0,255));
dc.SetPixel(start2.x-y,end2.y+x,RGB(0,0,255));
dc.SetPixel(start2.x-x,end2.y-y,RGB(0,0,255));
dc.SetPixel(start2.x-y,end2.y-x,RGB(0,0,255));
while (x<y)
{
if (f<0)
{
f=f+2*x+3;
x++;
}
else
{
f=f+2*(x-y)+5;
x++;
y--;
}
dc.SetPixel(start2.x+x,end2.y+y,RGB(0,0,255));
dc.SetPixel(start2.x+x,end2.y-y,RGB(0,0,255));
dc.SetPixel(start2.x-x,end2.y+y,RGB(0,0,255));
dc.SetPixel(start2.x+y,end2.y+x,RGB(0,0,255));
dc.SetPixel(start2.x+y,end2.y-x,RGB(0,0,255));
dc.SetPixel(start2.x-y,end2.y+x,RGB(0,0,255));
dc.SetPixel(start2.x-x,end2.y-y,RGB(0,0,255));
dc.SetPixel(start2.x-y,end2.y-x,RGB(0,0,255));
}
}
}
交互式画圆,自己加鼠标事件即可。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询