?? line.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 + -