资源描述:
《计算机图形学实验报告—图形与文本》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Windows编程实验报告题目:图形与文本专业:班级:学号:姓名:指导老师:2014年10月19日8一、实验目的熟悉MFC技术中图形和文本的使用。二、实验环境Windows7操作系统,VC++6.0三、实验内容【程序1:】编写一个单文档的应用程序,在视图窗口中显示一行文本,要求文本颜色为红色,背景色为黄色。关键代码:voidCSy2_1View::OnDraw(CDC*pDC){CSy2_1Doc*pDoc=GetDocument();ASSERT_VALID(pDoc);//TODO:adddrawcodefornative
2、datahereCStringoutstr="显示一行文本";pDC->SetBkColor(RGB(255,255,0));pDC->SetTextColor(RGB(255,0,0));pDC->TextOut(100,100,outstr);}结果截图:【程序2:】编写一个单文档的应用程序,在客户区使用不同的画笔和画刷绘制点、折线、曲线、圆角矩形、弧、扇形和多边形等几何图形。关键代码:voidCSy2_2View::OnDraw(CDC*pDC){CSy2_2Doc*pDoc=GetDocument();8ASSERT_
3、VALID(pDoc);//TODO:adddrawcodefornativedatahereCPen*PenOld,PenNew;CBrush*BrushOld,BrushNew;COLORREFrgbColor[]={RGB(255,0,0),RGB(0,255,0),RGB(0,0,255),RGB(255,255,0)};//画一个矩形PenNew.CreatePen(PS_SOLID,4,rgbColor[1]);BrushNew.CreateSolidBrush(rgbColor[3]);PenOld=pDC->S
4、electObject(&PenNew);BrushOld=pDC->SelectObject(&BrushNew);pDC->Rectangle(20,200,200,300);PenNew.DeleteObject();BrushNew.DeleteObject();//画一个椭圆弧线PenNew.CreatePen(PS_DASH,1,rgbColor[0]);BrushNew.CreateSolidBrush(rgbColor[2]);pDC->SelectObject(&PenNew);pDC->SelectObje
5、ct(&BrushNew);pDC->Arc(20,200,200,300,200,250,20,200);PenNew.DeleteObject();BrushNew.DeleteObject();//画一个扇形PenNew.CreatePen(PS_SOLID,1,rgbColor[2]);BrushNew.CreateSolidBrush(rgbColor[0]);pDC->SelectObject(&PenNew);pDC->SelectObject(&BrushNew);pDC->Pie(420,120,540,24
6、0,520,160,420,180);PenNew.DeleteObject();BrushNew.DeleteObject();//画一条折线PenNew.CreatePen(PS_SOLID,1,rgbColor[2]);pDC->SelectObject(&PenNew);POINTpt[3]={{10,100},{50,60},{120,80}};pDC->Polyline(pt,3);PenNew.DeleteObject();//画一个点pDC->SetPixel(CPoint(150,150),rgbColor[
7、0]);//画一个圆角矩形PenNew.CreatePen(PS_SOLID,1,rgbColor[1]);BrushNew.CreateSolidBrush(rgbColor[2]);pDC->SelectObject(&PenNew);8pDC->SelectObject(&BrushNew);pDC->RoundRect(210,210,410,410,30,30);PenNew.DeleteObject();BrushNew.DeleteObject();//画一条曲线PenNew.CreatePen(PS_SOLID
8、,1,rgbColor[1]);pDC->SelectObject(&PenNew);POINTpt1[4]={{20,100},{50,60},{120,80},{150,160}};pDC->PolyBezier(pt1,4);PenNew.DeleteObject();