/*_|_| MODE12H.CPP PUBLIC DOMAIN ( part 3 of 4 )
_|_|_| Simple demonstration of pixel manipulation
_|_|_| in 640x480x16 video mode 12h.
_|_|_| Kurt Kuzba (5/13/1998)*/
void Mode12h::Line(int x, int y, int x2, int y2, int c)
{
// draws a line from (x, y) to (x2, y2) in color c
// adapted from bresnham.c in bob Stout's SNIPPETS
int i, steep = 0, sx, sy, dx, dy, e, ex, ey;
dx = ((x2 - x) > 0) ? x2 - x : -(x2 - x);
sx = ((x2 - x) > 0) ? 1 : -1;
dy = ((y2 - y) > 0) ? y2 - y : -(y2 - y);
sy = ((y2 - y) > 0) ? 1 : -1;
if(dy > dx)
{
steep = x; x = y; y = steep; /* swap x and y */
steep = dx; dx = dy; dy = steep; /* swap dx and dy */
steep = sx; sx = sy; sy = steep; /* swap sx and sy */
steep = 1;
}
ex = dx << 1; ey = dy << 1; e = ey - dx;
for(i = 0; i < dx; i++)
{
if(steep) PutPixel(y, x, c); else PutPixel(x, y, c);
while(e >= 0) { y += sy;e -= ex; } x += sx; e += ey;
}
PutPixel(x2, y2, c);
}
/*_|_| end MODE12H.CPP PUBLIC DOMAIN ( part 3 of 4 )*/
> ] I'm so relieved... My IQ test came back negative...........
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
|