建设工程公司网站,高端建站行业,vue网站开发,2016市网站建设总结实验内容#xff1a;
【MFC】计算机图形学实验1#xff1a;熟悉开发环境及工具_绘制多义线mfc-CSDN博客 画笔和字体只给出两处代码#xff1a;
//创建刷子#xff0c;设置填充色为黑色
CBrush NewBrush;
NewBrush.CreateSolidBrush(RGB(0, 0, 0));
pDC-SelectObjec…实验内容
【MFC】计算机图形学实验1熟悉开发环境及工具_绘制多义线mfc-CSDN博客 画笔和字体只给出两处代码
//创建刷子设置填充色为黑色
CBrush NewBrush;
NewBrush.CreateSolidBrush(RGB(0, 0, 0));
pDC-SelectObject(NewBrush);
//创建画笔设置为实线宽度为 4 像素黑色
CPen NewPen;
NewPen.CreatePen(PS_SOLID, 4, RGB(0, 0, 0));
pDC-SelectObject(NewPen);
//删除原来的画笔并重新设置为黑色虚线
NewPen.DeleteObject();
NewPen.CreatePen(PS_DASH, 1, RGB(0, 0, 0));
pDC-SelectObject(NewPen);
//创建逻辑字体字体高度为 22显示角度为 75 度字体使用 Arial宽度默认
newfont.CreateFont(22,0,750,0,FW_NORMAL,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PR
ECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,_T(Arial));
//删除原有字体并重新设置显示角度为-22.5
newfont.DeleteObject();
newfont.CreateFont(22,0,-225,0,FW_NORMAL,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_P
RECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH| FF_SWISS,_T(Arial));圆模块
//左圆
x1 x0 - 56*8, y1y0-25*8, x2x0-6*8, y2 y025 * 8;
pDC-Ellipse(x1, y1, x2, y2 );
//右大圆
x1 x0 (31 - 19) * 8, y1 y0 - 19 * 8, x2 x0 (31
19) * 8, y2 y0 19 * 8;
pDC-Ellipse(x1, y1, x2, y2);
//右小圆
x1 x0 (31 - 11) * 8, y1 y0 - 11 * 8, x2 x0 (31
11) * 8, y2 y0 11 * 8;
pDC-Ellipse(x1, y1, x2, y2);//画上方圆弧
//获取圆心三角形左下角的正余弦值
cosx (50 * 50.0 - 44.0 * 44 62 * 62.0) / (2 * 50.0 * 62.0);
sinx sin(acos(cosx));
//计算上圆弧的圆心坐标并绘制
double x7 50.0* 8 * cosxx0-31* 8, y7 -50.0* 8 * sinx y0;
pDC-Arc(x7-25* 8,y7-25* 8,x7 25* 8,y7 25* 8,x0-31* 8,y0, x031*8,y0);//画下方圆弧
//获取圆心三角形左下角的正余弦值
double a8 94 - 25, b8 94 - 19;
cosx (a8 * a8 - b8 * b8 62 * 62.0) / (2 * a8 * 62.0);
sinx sin(acos(cosx));
//计算下圆弧的圆心坐标并绘制
double x8 a8* 8 * cosx x0 - 31* 8, y8 -a8* 8 * sinx y0;
pDC-Arc(x8 - 94* 8, y8 - 94* 8, x8 94* 8, y8 94* 8, x0 - 3
1* 8, y0, x0 31* 8, y0);
直线模块
//画虚线
NewPen.DeleteObject();
NewPen.CreatePen(PS_DASH, 1, RGB(0, 0, 0));// 黑色虚线
pDC-SelectObject(NewPen); //确定边框的颜色
//画辅助线竖直贯穿左圆
pDC-MoveTo(points8[0].x, points8[0].y-6.5*8-6.5*8);
pDC-LineTo(points8[4].x, points8[4].y 6.5 * 811.5*8);
//画辅助线竖直贯穿右圆
pDC-MoveTo(x0 31 * 8, points8[0].y - 6.5 * 8 - 6.5 * 8);
pDC-LineTo(x0 31 * 8, points8[4].y 6.5 * 8 11.5 * 8);
/画辅助线水平贯穿两个圆
pDC-MoveTo(x9, y0);
pDC-LineTo(x0 (31 19) * 8 6 * 8, y0);//画虚线
NewPen.DeleteObject();
NewPen.CreatePen(PS_DASH, 1, RGB(0, 0, 0));// 黑色虚线
pDC-SelectObject(NewPen); //确定边框的颜色
//画辅助线竖直贯穿左圆
pDC-MoveTo(points8[0].x, points8[0].y-6.5*8-6.5*8);
pDC-LineTo(points8[4].x, points8[4].y 6.5 * 811.5*8);
//画辅助线竖直贯穿右圆
pDC-MoveTo(x0 31 * 8, points8[0].y - 6.5 * 8 - 6.5 * 8);
pDC-LineTo(x0 31 * 8, points8[4].y 6.5 * 8 11.5 * 8);
/画辅助线水平贯穿两个圆
pDC-MoveTo(x9, y0);
pDC-LineTo(x0 (31 19) * 8 6 * 8, y0);多边形模块
//顶上
x4 x0 - 31 * 8, y4 y0 - 18.5 * 8;
points8[0] CPoint(x4, y4);
//右上
x3 x0 - 31 * 8 18.5 * 8 * cos(45 / 360.0 * (pai * 2)), y3y0 - 18.5 * 8 * sin(45 / 360.0 * (pai * 2));
points8[1] CPoint(x3, y3);
//右
x4 x0 - 31 * 8 18.5 * 8, y4 y0;
points8[2] CPoint(x4, y4);
//右下
x3 x0 - 31 * 8 18.5 * 8 * cos(45 / 360.0 * (pai * 2)), y3y0 18.5 * 8 * sin(45 / 360.0 * (pai * 2));
points8[3] CPoint(x3, y3);
//下
x4 x0 - 31 * 8, y4 y0 18.5 * 8;
points8[4] CPoint(x4, y4);
//左下
x5x0 - 31 * 8- 18.5 * 8* cos(45 / 360.0 * (pai * 2)),y5y0 18.
5 * 8* sin(45 / 360.0 * (pai * 2));
points8[5] CPoint(x5, y5);
//左
x6x0 - 31* 8-18.5* 8,y6y0;
points8[6] CPoint(x6, y6);
//左上
x5x0 - 31 * 8- 18.5 * 8* cos(45 / 360.0 * (pai * 2)),y5y0 - 18.
5 * 8* sin(45 / 360.0 * (pai * 2));
points8[7] CPoint(x5, y5);
//绘制八边形
pDC-Polygon(points8, 8);箭头模块
//上圆弧上的箭头绘制
cosx cos(75/180.0*pai); sinx sin(75/ 180.0 * pai);
double xuparc x7-25*8*cosx, yuparc y7 25*8*sinx;//上圆弧
double degree 60.0 / 180 * pai;
points[0].x xuparc, points[0].y yuparc;
points[1].x xuparc 3.5 * 8 * cos(degree), points[1].y yuparc -
3.5 * 8 * sin(degree);
points[2].x xuparc , points[2].y yuparc - 3.5 * 8 ;
pDC-Polygon(points, 3);
pDC-MoveTo((points[1].x points[2].x) / 2,(points[1].y points[2].y)/2);
pDC-LineTo(x7, y7);
//下圆弧上的箭头绘制
double xdarc8 94 * 8 * cosx,ydarc y8 94 * 8 * sinx;
degree 60.0 / 180 * pai;
points[0].x xdarc, points[0].y ydarc;
points[1].x xdarc - 3.5 * 8 * cos(degree), points[1].y ydarc - 3
.5 * 8 * sin(degree);
points[2].x xdarc, points[2].y ydarc - 3.5 * 8;
pDC-Polygon(points, 3);
x2 x8 83 * 8 * cosx,y2 y8 83 * 8 * sinx;
pDC-MoveTo((points[1].x points[2].x) / 2, (points[1].y points[2].y)
/ 2);
pDC-LineTo(x2, y2);//标注八边形上下顶点距离长度的两条水平实线和箭头线
x4 points8[0].x, y4 points8[0].y; //多边形上方顶点
pDC-MoveTo(x4, y4);
pDC-LineTo(x0 - 56 * 8 - 7 * 8, y4);
//绘制上方箭头
x9 x0 - 56 * 8 - 6 * 8, y9 y4 3 * 8;
points[1] CPoint(x9, y9);
x9 x0 - 56 * 8 - 4 * 8, y9 y4 3 * 8;
points[2] CPoint(x9, y9);
x9 x0 - 56 * 8 - 5 * 8, y9 y4;
points[0] CPoint(x9, y9);
pDC-Polygon(points, 3);
x4 points8[4].x, y4 points8[4].y; //多边形下方顶点
pDC-MoveTo(x4, y4);
pDC-LineTo(x0 - 56 * 8 - 7 * 8, y4);
//绘制下方箭头
x10 x0 - 56 * 8 - 6 * 8, y10 y4-3*8;
points[1] CPoint(x10, y10);
x10 x0 - 56 * 8 - 4 * 8, y10 y4 - 3 * 8;
points[2] CPoint(x10, y10);
x10 x0 - 56 * 8 - 5 * 8, y10 y4;
points[0] CPoint(x10, y10);
pDC-Polygon(points, 3);
//连接箭头
pDC-MoveTo(x9, y9 3 * 8);
pDC-LineTo(x10, y10 - 3 * 8);
//两个圆心间距离的箭头
x1 x0 - 31 * 83*8, y1 9 * 8;
points[0] CPoint(x1, y1);
x1 x0 - 31 * 8 3 * 8, y1 2 * 8;
points[1] CPoint(x1, y1);
x1 x0 - 31 * 8 , y1 - 8;
points[2] CPoint(x1, y1);
pDC-Polygon(points, 3);
x2 x0 31 * 8, y2 y1;
points[0] CPoint(x2, y2);
x2 x0 31 * 8-3*8, y2 y1-8;
points[1] CPoint(x2, y2);
y2 y1 8;
points[2] CPoint(x2, y2);
pDC-Polygon(points, 3);
//连接箭头两个圆心间距离的箭头
pDC-MoveTo(x1 3 * 8, y1);
pDC-LineTo(x2, y1);
double xd (x1 3 * 8x2)/2, ydy1;//存下辅助线的中点
//右小圆的箭头线
x1 x0 31 * 8, y1 y0;//右小圆圆心
cosx cos(45 / 180.0 * pai);//获取小圆辅助线与水平线的角度余弦值
sinx sin(45 / 180.0 * pai);
//贯穿右小圆 45 度实线
pDC-MoveTo(x1 11 * 8 * cosx, y1 - 11 * 8 * sinx);
pDC-LineTo(x1 - 11 * 8 * cosx, y1 11 * 8 * sinx);
//小圆画箭头左下45 度
x1 x1 - 11 * 8 * cosx, y1 y1 11 * 8 * sinx;
degree 30.0/180*pai;//箭头三角形角度
points[0].x x1 , points[0].y y1 ;
points[1].x x1 -3.5*8*cos(degree), points[1].y y1 3.5*8*sin(degree);
points[2].x x1 - 3.5 * 8 * cos(degree30.0/180*pai), points[2].y y
1 3.5 * 8 * sin(degree30.0 / 180 * pai);
pDC-Polygon(points, 3);
x1 x0 31 * 8, y1 y0;//右小圆圆心
pDC-MoveTo((points[1].x points[2].x)/2, (points[1].y points[2].y) / 2);
pDC-LineTo(x1 - 17 * 8 * cosx, y1 17 * 8 * sinx);
//小圆画箭头右上
x1 x1 11 * 8 * cosx, y1 y1 - 11 * 8 * sinx;
points[0].x x1, points[0].y y1;
points[1].x x1 3.5 * 8 * cos(degree), points[1].y y1 - 3.5 *
8 * sin(degree);
points[2].x x1 3.5 * 8 * cos(degree 30.0 / 180 * pai), point
s[2].y y1 - 3.5 * 8 * sin(degree 30.0 / 180 * pai);
pDC-Polygon(points, 3);
x1 x0 31 * 8, y1 y0;//右小圆圆心
pDC-MoveTo((points[1].x points[2].x) / 2, (points[1].y points[2].y)
/ 2);
pDC-LineTo(x1 22 * 8 * cosx, y1 - 22 * 8 * sinx);
//延伸出的水平线
DC-MoveTo(x1 22 * 8 * cosx5*8, y1 - 22 * 8 * sinx);
pDC-LineTo(x1 22 * 8 * cosx, y1 - 22 * 8 * sinx);//右大圆的箭头线
x1 x0 (31) * 8, y1 y0 ;//右大圆圆心
cosx cos(15 / 180.0 * pai);//获取大圆辅助线与水平线的角度余弦值
sinx sin(15 / 180.0 * pai);
//贯穿右小圆 15 度实线
pDC-MoveTo(x1 - 19 * 8 * cosx, y1 - 19 * 8 * sinx);
pDC-LineTo(x1 19 * 8 * cosx, y1 19 * 8 * sinx);
//右大圆箭头左上贯穿线变成 15 度
x1 x1 -19 * 8 * cosx, y1 y1 - 19 * 8 * sinx;
points[0].x x1, points[0].y y1;
points[1].x x1 - 3.5 * 8 , points[1].y y1;
points[2].x x1 - 3.5 * 8 * cos(degree), points[2].y y1 - 3.5 *
8 * sin(degree);
pDC-Polygon(points, 3);
x1 x0 (31) * 8, y1 y0;//右大圆圆心
pDC-MoveTo((points[1].x points[2].x) / 2, (points[1].y points[2].y)
/ 2);
pDC-LineTo(x1 - 26 * 8 * cosx, y1 - 26 * 8 * sinx);
//右大圆箭头右下贯穿线变成 15 度
x1 x1 19 * 8 * cosx, y1 y1 19 * 8 * sinx;
points[0].x x1, points[0].y y1;
points[1].x x1 3.5 * 8 , points[1].y y1;
points[2].x x1 3.5 * 8 * cos(degree), points[2].y y1 3.5 *
8 * sin(degree);
pDC-Polygon(points, 3);
x1 x0 (31) * 8, y1 y0;//右大圆圆心
pDC-MoveTo((points[1].x points[2].x) / 2, (points[1].y points[2].y)
/ 2);
pDC-LineTo(x1 25 * 8 * cosx, y1 25 * 8 * sinx);
//延伸出的水平线
pDC-MoveTo(x1 25 * 8 * cosx, y1 25 * 8 * sinx);
pDC-LineTo(x1 25 * 8 * cosx5*8, y1 25 * 8 * sinx);//左圆圆内箭头线22.5 度
x1 x0 - 31 * 8, y1 y0;//左圆
cosx cos(22.5 / 180.0 * pai);//获取辅助线与水平线的角度余弦值
sinx sin(22.5 / 180.0 * pai);
//箭头左上
x1 x1 - 25 * 8 * cosx, y1 y1 - 25 * 8 * sinx;
degree 37.5 / 180 * pai;
points[0].x x1, points[0].y y1;
points[1].x x1 3.5 * 8 * cos(degree), points[1].y y1 3.5 *
8 * sin(degree);
degree 7.5 / 180 * pai;
points[2].x x1 3.5 * 8 * cos(degree), points[2].y y1 3.5 *
8 * sin(degree);
pDC-Polygon(points, 3);
double xm (points[1].x points[2].x) / 2, ym (points[1].y points[2
].y) / 2;//存箭头中点
//箭头右下
x1 x1 (50) * 8 * cosx, y1 y1 (50) * 8 * sinx;
degree 7.5 / 180 * pai;
points[0].x x1, points[0].y y1;
points[1].x x1 - 3.5 * 8 * cos(degree), points[1].y y1 - 3.5 *
8 * sin(degree);
degree 37.5 / 180 * pai;
points[2].x x1 - 3.5 * 8 * cos(degree), points[2].y y1 - 3.5 *
8 * sin(degree);
pDC-Polygon(points, 3);
//箭头连接线
pDC-MoveTo((points[1].x points[2].x) / 2, (points[1].y points[2].y)
/ 2);
pDC-LineTo(xm, ym);文本模块
//上圆弧箭头文字
pDC-TextOut((x7 (points[1].x points[2].x) / 2) / 2 - 3 * 8, (y7(points[1].y points[2].y) / 2) / 2 - 4 * 8, _T(R25), 3);
//下圆弧箭头文字
pDC-TextOut((x2 (points[1].x points[2].x) / 2) / 2 3 * 8, (y2(points[1].y points[2].y) / 2) / 2 - 4 * 8, _T(R94), 3);
//右小圆箭头文字
pDC-TextOut(x1 22 * 8 * cosx8, y1 - 22 * 8 * sinx-3*8, _T(R22
), 3);
//右大圆箭头文字
pDC-TextOut(x1 25 * 8 * cosx 8, y1 25 * 8 * sinx - 3 *
8, _T(R38), 3);
//左圆箭头文字
pDC-TextOut((xm(points[1].x points[2].x) / 2)/2-6*8, (ym(points[1].y
points[2].y) / 2)/2-7*8, _T(R50), 3);
//八边形左箭头文字
pDC-TextOut(x9-4*8, y088, _T(37), 2);
//圆心距离箭头文字
pDC-TextOut(xd, yd-25, _T(62), 2);效果图