All pastes #11928 Raw Edit

Untitled

public cpp v1 · immutable
#11928 ·published 2005-05-16 20:55 UTC
rendered paste body
void CG1_DrawTool::DrawDDALine(CG1_Line Line, RGB_Color color){	float dx, dy, m;	dx = Line.X1() - Line.X0();	dy = Line.Y1() - Line.Y0();	if (dx == 0 && dy == 0) // avoid division by zero		return;		if (fabs(dx) > fabs(dy))	{		int x;		float fy;		m = dy/dx;		if (Line.X0() > Line.X1())			Line.SetData(Line.X1(), Line.Y1(), Line.X0(), Line.Y0());		for (fy=Line.Y0(), x=Line.X0(); x<=Line.X1(); x++, fy+=m)			PutPixel(x, (int)floor(fy + 0.5f), color);	}	else	{		int y;		float fx;		m = dx/dy;		if (Line.Y0() > Line.Y1())			Line.SetData(Line.X1(), Line.Y1(), Line.X0(), Line.Y0());		for (fx=Line.X0(), y=Line.Y0(); y<=Line.Y1(); y++, fx+=m)			PutPixel((int)floor(fx + 0.5f), y, color);	}}