资源描述:
《vc++编程绘图》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、2-1源程序:#include”math.h”voidCHhhh02View::OnDraw(CDC*pDC){CHhhh02Doc*pDoc=GetDocument();ASSERT_VALID(pDoc);CRectr;GetClientRect(r);pDC->SetMapMode(7);pDC->SetWindowOrg(0,0);pDC->SetViewportOrg(r.right/2,r.bottom/2);pDC->SetWindowExt(200,100);pDC->SetViewportExt(100,-80);intpp[14][2]={0,
2、0,0,120,-240,0,240,0,0,120,-160,0,-160,40,-80,0,-80,80,0,0,80,80,80,0,160,40,160,0};pDC->MoveTo(pp[0][0],pp[0][1]);for(inti=1;i<=4;i++){pDC->LineTo(pp[i][0],pp[i][1]);}pDC->MoveTo(pp[5][0],pp[5][1]);for(i=6;i<=13;i++)pDC->LineTo(pp[i][0],pp[i][1]);}2-1运行结果:2-2源程序:#include"math.h"voidC
3、My13View::OnDraw(CDC*pDC){CMy13Doc*pDoc=GetDocument();ASSERT_VALID(pDoc);14CRectr;GetClientRect(r);pDC->SetMapMode(7);pDC->SetWindowOrg(0,0);pDC->SetViewportOrg(r.right/4,r.bottom/2);pDC->SetWindowExt(200,100);pDC->SetViewportExt(200,-100);for(inti=1;i<=15;i++){CPenpi(0,2,RGB(255-10*i
4、,10*i,20*i));pDC->SelectObject(pi);pDC->MoveTo(300,100);pDC->Arc(300-10*i,100,300+10*i,100-20*i,300,100,300,100);}}2-2运行结果:2-3源程序:#include"math.h"voidCMy24View::OnDraw(CDC*pDC){CRectr;GetClientRect(r);pDC->SetMapMode(7);pDC->SetWindowOrg(0,0);pDC->SetViewportOrg(r.right/2,r.bottom/2);
5、pDC->SetWindowExt(100,100);pDC->SetViewportExt(100,-100);CPenp1(0,2,RGB(0,0,0));doublep3[5][2],p2[5][2];doublea=3.1415926;14for(inti=0;i<=4;i++){p3[i][0]=100*cos((90+72*i)*a/180);p3[i][1]=100*sin((90+72*i)*a/180);p2[i][0]=38.2*cos((126+72*i)*a/180);p2[i][1]=38.2*sin((126+72*i)*a/180);
6、}pDC->MoveTo(0,0);pDC->SelectObject(p1);for(i=0;i<=4;i++){pDC->MoveTo(0,0);pDC->LineTo(p3[i][0],p3[i][1]);pDC->LineTo(p2[i][0],p2[i][1]);pDC->MoveTo(0,0);pDC->LineTo(p2[i][0],p2[i][1]);pDC->LineTo(p3[i+1][0],p3[i+1][1]);pDC->MoveTo(p2[4][0],p2[4][1]);pDC->LineTo(p3[0][0],p3[0][1]);}}2
7、-3运行结果:2-4源程序:voidCMy2_4View::OnDraw(CDC*pDC){CMy2_4Doc*pDoc=GetDocument();ASSERT_VALID(pDoc);CRectr;GetClientRect(r);pDC->SetMapMode(7);pDC->SetWindowOrg(0,0);pDC->SetViewportOrg(r.right/2,r.bottom*3/4);pDC->SetWindowExt(200,100);pDC->SetViewportExt(400,-200);14doublep[14][2]={0,0,10
8、,0,90