⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 画椭圆.txt

📁 talk chat
💻 TXT
字号:
void CirPot(int x0,int y0,int x,int y,COLORREF color);
void MidPoint(int x0,int y0,double a,double b,COLORREF color);



void CPicView::CirPot(int x0,int y0,int x,int y,COLORREF color)
{
	CDC* pDC=GetDC();
	pDC->SetPixel((x0+x),(y0+y),color);
	pDC->SetPixel((x0+x),(y0-y),color);
	pDC->SetPixel((x0-x),(y0+y),color);
	pDC->SetPixel((x0-x),(y0-y),color);
	ReleaseDC(pDC);
}
void CPicView::MidPoint(int x0,int y0,double a,double b,COLORREF color)
{
	int x,y,d;
	y=int(b);
	x=0;
	d=int(b*b-a*a*b+0.25*a*a);
	CirPot(x0,y0,x,y,color);
	while(b*b*(x+1)<a*a*(y-0.5))
	{
		if(d<0)
			d+=int(2*b*b*x+3*b*b);
		else
		{
			d+=int(2*b*b*x-2*a*a*y+2*a*a+3*b*b);
			y--;
		}
		x++;
		CirPot(x0,y0,x,y,color);
	}
	d=int(b*b*(x+0.5)*(x+0.5)+a*a*(y-1)*(y-1)-a*a*b*b);
	while(x<=a&&y>0)
	{
		if(d<0)
		{
			d+=int(2*b*b*(1+x)+(3-2*y)*a*a);
		    x++;
		}
		else
			d+=int(a*a*(3-2*y));
			y--;
		CirPot(x0,y0,x,y,color);
	}
}


void CPicView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	int x0=point.x,y0=point.y,radius=100;
	double a=100,b=50;
	COLORREF color=RGB(123,235,21);
	MidPoint(x0,y0,a,b,color);
	CView::OnLButtonDown(nFlags, point);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -