📄 circle.cpp
字号:
// Circle.cpp: implementation of the CCircle class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DrawSemple.h"
#include "Circle.h"
#include "math.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
int CCircle::Ccount=0;
//int CCircle::Tflag=3;
CCircle::CCircle()
{
}
CCircle::~CCircle()
{
}
CCircle::CCircle(CPoint pt1,CPoint pt2,int stline,COLORREF linergb,COLORREF brushrgb
):CTuyuan(pt1,pt2,stline,linergb,brushrgb)
{
Tflagc=3;
}
void CCircle::DrawTuyuan(CDC *pDC)
{
CPen *pOldPen,*pNewPen;
pDC->SetROP2(R2_NOTXORPEN);
pNewPen=new CPen(PS_SOLID,styline,stylinergb);
pOldPen = pDC->SelectObject(pNewPen);
int d,x,y;
d=(int)sqrt((m_pt1.x-m_pt2.x)*(m_pt1.x-m_pt2.x)+(m_pt1.y-m_pt2.y)*(m_pt1.y-m_pt2.y))/2;
x=(int)(m_pt1.x+m_pt2.x)/2;
y=(int)(m_pt1.y+m_pt2.y)/2;
pDC->Ellipse(x-d,y-d,x+d,y+d);
pDC->SelectObject(pOldPen);
delete pNewPen;
Ccount++;
Tcount++;
}
void CCircle::BrushTuyuan(CDC *pDC)
{
if(stybrushrgb!=RGB(255,255,255))
{
CBrush *pOldBrush,*pNewBrush;
pDC->SetROP2(R2_NOTXORPEN);
pNewBrush=new CBrush(stybrushrgb);
pOldBrush = pDC->SelectObject(pNewBrush);
int d,x,y;
d=(int)sqrt((m_pt1.x-m_pt2.x)*(m_pt1.x-m_pt2.x)+(m_pt1.y-m_pt2.y)*(m_pt1.y-m_pt2.y))/2;
x=(int)(m_pt1.x+m_pt2.x)/2;
y=(int)(m_pt1.y+m_pt2.y)/2;
pDC->Ellipse(x-d,y-d,x+d,y+d);
pDC->SelectObject(pOldBrush);
delete pNewBrush;
}
}
int CCircle::GetTflag()
{
return 3;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -