www.pudn.com > assigment1.zip > graph.cpp


#include  
#include "graph.h" 
#define ROUND(a) ((int)(a+0.5)) 
 
CGraph::CGraph(CWnd *cp) : CClientDC(cp) 
{ 
	 
} 
 
void CGraph::lineDDA(int xa, int ya, int xb, int yb, COLORREF color) 
{ 
	int dx=xb-xa, dy=yb-ya,steps,k; 
	float xIncrement,yIncrement,x=(float)xa,y=(float)ya; 
 
	if(abs(dx)>abs(dy)) steps = abs(dx); 
	else steps=abs(dy); 
	xIncrement = dx/(float)steps; 
	yIncrement = dy/(float)steps; 
	 
	SetPixel(ROUND(x),ROUND(y),color); 
	for(k=0;k