MFC课程设计实验报告(8)

2019-09-02 13:38

MFC—课程设计

}

OrgY = 400;

linewidth= 1;//线宽 width = 100; high=50;

CTriangle::CTriangle(int x,int y,int w,int h,int line,int r1,int g1,int b1,int r2,int b2,int g2) {

OrgX = x;//原点坐标 OrgY = y;

linewidth=line; }

void CTriangle::Draw(CDC*pDC)//绘制函数 {

CPen pen, *pOldPen;

pen.CreatePen(PS_SOLID, linewidth,RGB(R1,G1,B1)); pOldPen = (CPen*)pDC->SelectObject(&pen); CBrush brush, *pOldBrush;

brush.CreateHatchBrush(HS_DIAGCROSS, RGB(R2,G2,B2)); width = w; high=h; R1=r1; R2=r2; G1=g1; G2=g2; B1=b1; B2=b2;

36

MFC—课程设计

pOldBrush = (CBrush*)pDC->SelectObject(&brush); POINT

polygon[3]

=

{{OrgX,OrgY-2*high/3},{OrgX-width/2,OrgY+high/3},{OrgX+width/2,OrgY+high/3}}; }

bool CTriangle::IsMatched(CPoint pnt)//图元匹配函数 {

if ((OrgX - high <= pnt.x && pnt.x <= OrgX + high) && (OrgY - pDC->Polygon(polygon,3); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush);

((sqrt(3)/2)* high) <= pnt.y && pnt.y <= OrgY + (sqrt(3) / 2)* high)) } //圆

void CCircle::Serialize(CArchive &ar) {

} else {

if (ar.IsStoring()) {

ar << OrgX<< OrgY;//原点坐标 ar <

ar<< linewidth;//线宽

return true;

else

return false;

37

MFC—课程设计

}

}

ar >> OrgX >>OrgY;//原点坐标 ar >>width;

ar >> linewidth;//线宽

CCircle::CCircle()//缺省构造函数,初始化 { }

CCircle::CCircle(int x,int y,int w,int line,int r1,int g1,int b1,int r2,int b2,int g2) {

OrgX = x;//原点坐标 OrgY = y;

OrgX = 400;//原点坐标 OrgY = 400;

linewidth= 1;//线宽 width = 100;

linewidth=line; }

width = w; R1=r1; R2=r2; G1=g1; G2=g2; B1=b1; B2=b2;

38

MFC—课程设计

void CCircle::Draw(CDC*pDC)//绘制函数 {

CPen pen, *pOldPen;

pen.CreatePen(PS_SOLID, linewidth,RGB(R1,G1,B1)); pOldPen = (CPen*)pDC->SelectObject(&pen); CBrush brush, *pOldBrush;

brush.CreateHatchBrush(HS_DIAGCROSS, RGB(R2,G2,B2)); pOldBrush = (CBrush*)pDC->SelectObject(&brush);

pDC->Ellipse(OrgX - width / 2, OrgY -width / 2, OrgX + width / 2, OrgY

+ width / 2); }

bool CCircle::IsMatched(CPoint pnt)//图元匹配函数 {

if ((OrgX - width / 2 <= pnt.x && pnt.x <= OrgX + width/ 2) && (OrgY pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush);

- width / 2 <= pnt.y && pnt.y <= OrgY + width / 2)) } //椭圆

void CEllipse::Serialize(CArchive &ar) {

if (ar.IsStoring()) {

return true;

else

return false;

39

MFC—课程设计

}

ar << OrgX<< OrgY;//原点坐标 ar << width; ar << high;

ar<< linewidth;//线宽

} else { }

ar >> OrgX >>OrgY;//原点坐标 ar >> width; ar >> high;

ar >> linewidth;//线宽

CEllipse::CEllipse()//缺省构造函数,初始化 { }

CEllipse::CEllipse(int x,int y,int w,int h,int line,int r1,int g1,int b1,int r2,int b2,int g2) {

OrgX = x;//原点坐标 OrgY = y;

OrgX = 400;//原点坐标 OrgY = 400;

linewidth= 1;//线宽 width = 100; high=50;

40


MFC课程设计实验报告(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:高中数学实施分层教学的研究

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: