如何不用Windows自带的画椭圆函数画椭圆 如何不用Windows自带的画椭圆函数画椭圆 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /////////////////////////////////////////////////////////////////////////////// Draw a ellipse mid point algorthism/////////////////////////////////////////////////////////////////////////////void CGraphicsView::midleEllipse(int xCenter, int yCenter, int Rx, int Ry, HDC dc){ int Rx2 = Rx*Rx; int Ry2 = Ry*Ry; int twoRx2 = 2*Rx2; int twoRy2 = 2*Ry2; int p; int x=0; int y=Ry; int px = 0; int py = twoRx2*y; SetPixel(dc,xCenter+x,yCenter+y,RGB(255,0,0)); SetPixel(dc,xCenter-x,yCenter+y,RGB(255,0,0)); SetPixel(dc,xCenter+x,yCenter-y,RGB(255,0,0)); SetPixel(dc,xCenter-x,yCenter-y,RGB(255,0,0)); //Region 1 p = (int)(Ry2-Rx2*Ry+0.25*Rx2); while(px<py) { x++; px+=twoRy2; if(p<0) p+=Ry2+px; else { y--; py-=twoRx2; p+=Ry2+px-py; } SetPixel(dc,xCenter+x,yCenter+y,RGB(255,0,0)); SetPixel(dc,xCenter-x,yCenter+y,RGB(255,0,0)); SetPixel(dc,xCenter+x,yCenter-y,RGB(255,0,0)); SetPixel(dc,xCenter-x,yCenter-y,RGB(255,0,0)); } //Region 2 p = (int)(Ry2*(x+0.5)*(x+0.5)+Rx2*(y-1)*(y-1)-Rx2*Ry2); while(y>0) { y--; py-=twoRx2; if(p>0) p+=Rx2-py; else { x++; px+=twoRy2; p+=Rx2-py+px; } SetPixel(dc,xCenter+x,yCenter+y,RGB(255,0,0)); SetPixel(dc,xCenter-x,yCenter+y,RGB(255,0,0)); SetPixel(dc,xCenter+x,yCenter-y,RGB(255,0,0)); SetPixel(dc,xCenter-x,yCenter-y,RGB(255,0,0)); }} /////////////////////////////////////////////////////////////////////////////// Draw a circle/////////////////////////////////////////////////////////////////////////////void circleMidpoint(int xCenter,int yCenter,int radius,HDC dc){ int x = 0; int y = radius; int p=1-radius; while(x<y) { x++; if(p<0) { p+=2*x+1; } else { y--; p+=2*(x-y)+1; } SetPixel(dc,xCenter+x,yCenter+y,RGB(255,0,0)); SetPixel(dc,xCenter-x,yCenter+y,RGB(255,0,0)); SetPixel(dc,xCenter+x,yCenter-y,RGB(255,0,0)); SetPixel(dc,xCenter-x,yCenter-y,RGB(255,0,0)); SetPixel(dc,xCenter+y,yCenter+x,RGB(255,0,0)); SetPixel(dc,xCenter-y,yCenter+x,RGB(255,0,0)); SetPixel(dc,xCenter+y,yCenter-x,RGB(255,0,0)); SetPixel(dc,xCenter-y,yCenter-x,RGB(255,0,0)); }} 如何获得对话条中的组合框的指针啊,我总是出错了啊. 能否在视图上动态创建一个控件呢? 高手请教:如何添加系统右键菜单 文本拖拉处理! 一个GDI资源释放新问题 请问如何截取EditBox的KeyDown消息? VC++打不开类视图,提示不是所有的窗口都能打开,已在另一个编译器中打开 请问如何向数据库中添加记录?代码如下(谢谢) 各位,请谈一谈现在学习COM还有没有用? 谁有这个头文件?HtmlHelp.h 两个问题:映射,CRect 由HFONT如何得到对应的LOGFONT对象?????
// Draw a ellipse mid point algorthism
/////////////////////////////////////////////////////////////////////////////
void CGraphicsView::midleEllipse(int xCenter, int yCenter, int Rx, int Ry, HDC dc)
{
int Rx2 = Rx*Rx;
int Ry2 = Ry*Ry;
int twoRx2 = 2*Rx2;
int twoRy2 = 2*Ry2;
int p;
int x=0;
int y=Ry;
int px = 0;
int py = twoRx2*y;
SetPixel(dc,xCenter+x,yCenter+y,RGB(255,0,0));
SetPixel(dc,xCenter-x,yCenter+y,RGB(255,0,0));
SetPixel(dc,xCenter+x,yCenter-y,RGB(255,0,0));
SetPixel(dc,xCenter-x,yCenter-y,RGB(255,0,0));
//Region 1
p = (int)(Ry2-Rx2*Ry+0.25*Rx2);
while(px<py)
{
x++;
px+=twoRy2;
if(p<0)
p+=Ry2+px;
else
{
y--;
py-=twoRx2;
p+=Ry2+px-py;
}
SetPixel(dc,xCenter+x,yCenter+y,RGB(255,0,0));
SetPixel(dc,xCenter-x,yCenter+y,RGB(255,0,0));
SetPixel(dc,xCenter+x,yCenter-y,RGB(255,0,0));
SetPixel(dc,xCenter-x,yCenter-y,RGB(255,0,0));
}
//Region 2
p = (int)(Ry2*(x+0.5)*(x+0.5)+Rx2*(y-1)*(y-1)-Rx2*Ry2);
while(y>0)
{
y--;
py-=twoRx2;
if(p>0)
p+=Rx2-py;
else
{
x++;
px+=twoRy2;
p+=Rx2-py+px;
}
SetPixel(dc,xCenter+x,yCenter+y,RGB(255,0,0));
SetPixel(dc,xCenter-x,yCenter+y,RGB(255,0,0));
SetPixel(dc,xCenter+x,yCenter-y,RGB(255,0,0));
SetPixel(dc,xCenter-x,yCenter-y,RGB(255,0,0));
}}
// Draw a circle
/////////////////////////////////////////////////////////////////////////////
void circleMidpoint(int xCenter,int yCenter,int radius,HDC dc)
{
int x = 0;
int y = radius;
int p=1-radius;
while(x<y)
{
x++;
if(p<0)
{
p+=2*x+1;
}
else
{
y--;
p+=2*(x-y)+1;
}
SetPixel(dc,xCenter+x,yCenter+y,RGB(255,0,0));
SetPixel(dc,xCenter-x,yCenter+y,RGB(255,0,0));
SetPixel(dc,xCenter+x,yCenter-y,RGB(255,0,0));
SetPixel(dc,xCenter-x,yCenter-y,RGB(255,0,0)); SetPixel(dc,xCenter+y,yCenter+x,RGB(255,0,0));
SetPixel(dc,xCenter-y,yCenter+x,RGB(255,0,0));
SetPixel(dc,xCenter+y,yCenter-x,RGB(255,0,0));
SetPixel(dc,xCenter-y,yCenter-x,RGB(255,0,0));
}
}