Runge-Kutta-Simulation/AppleX/GRAPHICS/MONOLINE.C
2015-02-11 19:34:08 +01:00

61 lines
1.2 KiB
C

/* ------------------------------------------------------------------------
System : Manx Aztec C65 Version 3.2b
MS-DOS cross-development environment
Platform : Apple IIe 128K PRODOS 8
Program : monoline.c
Description : G2 Library Routine
Hi-Res 280 x 192 monochrome
Bresenham Algorithm line drawing routine
Written by : Bill Buckels
Date Written : February 2013
Revision : 1.0 First Release
Licence : You may use this code for whatever you wish as long
as you agree that Bill Buckels has no warranty or
liability obligations whatsoever from said use.
------------------------------------------------------------------------ */
monoline(x1, y1, x2, y2, drawcolor)
int x1, y1, x2, y2, drawcolor;
{
int dx, dy, sx, sy, err, err2;
if(x1 < x2) {
dx = x2 - x1;
sx = 1;
}
else {
sx = -1;
dx = x1 - x2;
}
if(y1 < y2) {
sy = 1;
dy = y2 - y1;
}
else {
sy = -1;
dy = y1 - y2;
}
err = dx-dy;
for (;;) {
monoplot(x1,y1,y1,drawcolor);
if(x1 == x2 && y1 == y2)break;
err2 = err*2;
if(err2 > (0-dy)) {
err = err - dy;
x1 = x1 + sx;
}
if(err2 < dx) {
err = err + dx;
y1 = y1 + sy;
}
}
return;
}