欢迎来到天天文库
浏览记录
ID:1377159
大小:40.00 KB
页数:4页
时间:2017-11-11
《计算机图形学--绘制直线》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、计算机图形学实验报告专业:信息与计算科学班级:1002班学号:10080602**姓名:*****1.实验目的熟悉CDC类的MoveTo()和LineTo()直线段绘制函数。熟悉斜率-12、classCLine{public:CLine();virtual~CLine();voidMoveTo(double,double);voidLineTo(CDC*pDC,double,double,double);public:CPointm_p1;CPointm_p2;};#Line.cppCLine::CLine(){}CLine::~CLine(){}voidCLine::MoveTo(doublex,doubley){m_p1=CPoint(x,y);}voidCLine::LineTo(CDC*pDC,doublex,do3、ubley,doublek){m_p2=CPoint(x,y);CPointp,t;pDC->SetMapMode(MM_LOMETRIC);pDC->SetViewportOrg(200,200);doubled;if(k>=-1.0&&k<0.0){if(m_p1.x>m_p2.x){t=m_p1;m_p1=m_p2;m_p2=t;}d=-0.5-k;for(p=m_p1;p.xSetPixel(p.x,p.y,RGB(0,0,255));if(d>0){p.y--;d-=1+k;}else{4、d-=k;}}}}voidCTEXTView::OnDraw(CDC*pDC){CTEXTDoc*pDoc=GetDocument();ASSERT_VALID(pDoc);CLinecline;cline.MoveTo(-200,300);cline.LineTo(pDC,200,-300,-0.3);}5.程序效果图6.实验总结本实验实现了一个类似于CDC类的MoveTo()函数和LineTo()函数,用于绘制任意斜率的直线段,这次只是绘制固定斜率的直线段,但还是出现了很多问题,经过与同学的讨论解决了问题。
2、classCLine{public:CLine();virtual~CLine();voidMoveTo(double,double);voidLineTo(CDC*pDC,double,double,double);public:CPointm_p1;CPointm_p2;};#Line.cppCLine::CLine(){}CLine::~CLine(){}voidCLine::MoveTo(doublex,doubley){m_p1=CPoint(x,y);}voidCLine::LineTo(CDC*pDC,doublex,do
3、ubley,doublek){m_p2=CPoint(x,y);CPointp,t;pDC->SetMapMode(MM_LOMETRIC);pDC->SetViewportOrg(200,200);doubled;if(k>=-1.0&&k<0.0){if(m_p1.x>m_p2.x){t=m_p1;m_p1=m_p2;m_p2=t;}d=-0.5-k;for(p=m_p1;p.xSetPixel(p.x,p.y,RGB(0,0,255));if(d>0){p.y--;d-=1+k;}else{
4、d-=k;}}}}voidCTEXTView::OnDraw(CDC*pDC){CTEXTDoc*pDoc=GetDocument();ASSERT_VALID(pDoc);CLinecline;cline.MoveTo(-200,300);cline.LineTo(pDC,200,-300,-0.3);}5.程序效果图6.实验总结本实验实现了一个类似于CDC类的MoveTo()函数和LineTo()函数,用于绘制任意斜率的直线段,这次只是绘制固定斜率的直线段,但还是出现了很多问题,经过与同学的讨论解决了问题。
此文档下载收益归作者所有