⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 line.cpp

📁 这个是计算机图形学的课程设计的全部 内容。
💻 CPP
字号:
// Line.cpp: implementation of the Line class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Graph.h"
#include "Line.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Line::Line()
{

}

Line::~Line()
{

}

void Line::LineBres(CDC *pDC, CPoint pStart, CPoint pEnd, COLORREF color)
{int dx=abs(pStart.x-pEnd.x),dy=abs(pStart.y-pEnd.y);
int p=2*dy-dx;
int twoDy=2*dy,twoDyDx=2*(dy-dx);
int x,y,xEnd;
if(pStart.x>pEnd.x)
{pStart.x=pEnd.x;y=pEnd.y;xEnd=pStart.x;}
else{x=pStart.x;y=pStart.y;
xEnd=pEnd.x;}
pDC->SetPixel(x,y,color);
while(x<xEnd)
{x++;
if(p<0) p+=twoDy;
else{y++;
p+=twoDyDx;}
pDC->SetPixel(x,y,color);
}

}

void Line::draw(CDC *pDC)
{
LineBres(pDC,m_ptBegin,m_ptEnd,m_color);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -