收藏 分享(赏)

计算机图形学实验报告_34学时.pdf

上传人:精品资料 文档编号:11134287 上传时间:2020-02-09 格式:PDF 页数:37 大小:1.27MB
下载 相关 举报
计算机图形学实验报告_34学时.pdf_第1页
第1页 / 共37页
计算机图形学实验报告_34学时.pdf_第2页
第2页 / 共37页
计算机图形学实验报告_34学时.pdf_第3页
第3页 / 共37页
计算机图形学实验报告_34学时.pdf_第4页
第4页 / 共37页
计算机图形学实验报告_34学时.pdf_第5页
第5页 / 共37页
点击查看更多>>
资源描述

1、 VC VC MFC / GDI 1 Windows MFC Cview 2 (NotePad) (Word) 3 DC Device Context Windows DC Display DC Printer DC Memory DC Information DC 4 DC MFC Windows (HDC) CDC CDC CDC 170 CPaintDC OnPaint() CClientDC CWindowDC CMetaFileDC Windows Windows GDI 5 GDI GDI GDI CDC:SelectObject() GDI pOldObject SelectOb

2、ject pOldObject 6 GDI OnDraw() CView (WM_PAINT-OnPaint-OnDraw) 7 OnDraw : p20 ! ! ! 1. P28 2.2 VC GDI 2 ( 20 2. 3. project / 4. 1 VC | MFC Appwizard (exe) My / 0714050105-1 2 OK Single Document Finish 3 MyView.cpp OnDraw pDC-MoveTo(100,100); pDC-LineTo(200,200); CPen *pOldPen; CPen dashPen; dashPen.

3、CreatePen(PS_DASH,1,RGB(255,0,0); pOldPen = pDC-SelectObject( pDC-LineTo(300,100); pDC-SelectObject(pOldPen); pDC-LineTo(400,200); OnDraw CExercise2Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); OnDraw pDC-MoveTo(300,400); pDC-LineTo(500,600); CPen *pOldPen; CPen dashPen; dashPen.CreatePen(PS_DASH,1

4、,RGB(0,200,255); pOldPen = pDC-SelectObject( pDC-LineTo(300,100); pDC-SelectObject(pOldPen); pDC-LineTo(300,100); 1 CDC 2 3 dashPen.CreatePen(PS_DASH,1,RGB(0,200,255); RGB 4 VC project project MFC GDI OnDraw DDA Bresenham Visual C DDA Bresenham 1 p75 3.1 DDA : DDA Bresenham 2 2 p75 3.5 3 MFC CDC Set

5、Pixel() LineTo Polyline Ellipse 4 5 project / 6 DDA Bresenham Visual C+6.0 1 VC MFC Appwizard SDI CG 1 2 1 2 2 2 Finish 3 CGView.cpp CCGView include “math.h” / fabs void DDALine(int x0, int y0, int x1, int y1, COLORREF color) VC ClassView CCGView 3 Add Member Function 4 DDALine 3 4 4 void DDALine(in

6、t x0, int y0, int x1, int y1, COLORREF color) DDA P30P31 Setpixel CDC *pDC = this-GetDC(); pDC-SetPixel(int (x + 0.5), int (y + 0.5), color); SetPixel(int (x + 0.5), int (y + 0.5), color); Bresenham SetPixel 5 3 CGView.cpp CCGView void Bresenham_Line(int x0, int y0, int x1, int y1, COLORREF color) P

7、33 Bresenham 4 Setpixel OnDraw 2 DDA Bresenham 1 OnDraw 2 | k| 1 3 4 P73 3.5 1 1 LineTo Polyline 2 Visual C+ Visual C+ MSDN Visual C 1 MFC CDC SetPixel() LineTo Polyline Ellipse 2 x y 3 Visual C+6.0 1 VC CG cg.dsw 2 CGView.cpp CCGView void MidPointCircle(int r, COLORREF color) void CirclePoints(int

8、x, int y, COLORREF color) VC ClassView CCGView 1 Add Member Function 2 MidPointCircle CirclePoints 1 2 3 void MidPointCircle(int r, COLORREF color) void CirclePoints(int x, int y, COLORREF color) P34 P36 CirclePoints Setpixel CDC *pDC = this-GetDC(); this-ReleaseDC(pDC); DC 4 onDraw OnDraw 2 MidPoin

9、tCircle CirclePoints 1 Windows void MidPointCircle(int r, COLORREF color) void CirclePoints(int x, int y, COLORREF color) dx,dy 2 cg.dsw ccgview.cpp 1 Ellipse 2 Visual C 1 OnDraw CPen 2 C*View FloodFill4 p44 3 OnDraw 4 5 project / 6 Visual C+6.0 1 VC CG cg.dsw 2 CGView.cpp CCGView void FloodFill4(in

10、t x, int y, COLORREF oldColor, COLORREF newColor) VC ClassView CCGView 1 Add Member Function 2 FloodFill 1 2 3 void FloodFill4(int x, int y, COLORREF oldColor, COLORREF newColor) 4 P44 FloodFill4 GetPixel SetPixel CDC *pDC = this-GetDC(); COLORREF color = pDC-GetPixel(x,y) SetPixel pDC-SetPixel(x,y,

11、newColor); FloodFill4 this-ReleaseDC(pDC); DC 4 OnDraw / CPen newPen(PS_DOT,5,RGB(255,0,0);/red color CPen *pOldPen=pDC-SelectObject( / CPoint point5;/ point0.x=55;/ 0 point0.y=55; point1.x=55;/ 1 point1.y=120; point2.x=120;/ 2 point2.y=120; point3.x=170;/ 3 point3.y=88; point4.x=120;/ 4 point4.y=55

12、; pDC-Polygon(point,5);/ point pDC-SelectObject(pOldPen);/ / (80,90) FloodFill4(80,90,RGB(255,255,255),RGB(0,0,255); OnDraw FloodFill4 1 OnDraw FloodFill4(80,90,RGB(255,255,255),RGB(0,0,255) 2 3 ReleaseDC DC 4 1 2 1 Visual C 2 3 Visual C+6.0 1 VC MFC Appwizard SDI Transform 1 2 1 2 2 2 Finish 3 Tran

13、sformView.h public: CPoint Pt3; / float dAngle; / 4 CTransformView dAngle CTransformView:CTransformView() / TODO: add construction code here Pt0.x = 200; Pt0.y = 220; Pt1.x = 260; Pt1.y = 300; Pt2.x = 360; Pt2.y = 180; dAngle = 0.0; 5 CTransformView void DrawTriangle(CDC *pDC) MoveTo LineTo 2 DDA Br

14、esenham 6 CTransformView OnDraw() void CTransformView:OnDraw(CDC* pDC) CTransformDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); / TODO: add draw code for native data here DrawTriangle(pDC); 7 ResourceView MENU IDR_MAINFRAME 3 3 8 TransformView.cpp CTransformView void CTransformView:OnMenuTransformTr

15、anslate() / TODO: Add your command handler code here int nX = 50; int nY = 80; / X Y for(int i=0; i3; i+) Pti.x += nX; Pti.y += nY; RedrawWindow(); / OnDraw() 9 10 TransformView.cpp ClassWizard 4 WM_KEYDOWN void CTransformView:OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) / TODO: Add your message

16、 handler code here and/or call default int i=0; CPoint TmpPt = Pt0; switch (nChar) case VK_UP: / for(i=0; i3; i+) Pti.y -= 5; break; case VK_DOWN: / for(i=0; i3; i+) Pti.y += 5; break; / RedrawWindow(); CView:OnKeyDown(nChar, nRepCnt, nFlags); 4 11 WM_KEYDOWN VK_LEFT, VK_RIGHT 12 WM_KEYDOWN Z X 1 1

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报