simplest inner loop part of a addition-only line-draw
one slope case only. just to show the concept.
|----
dy| -----
| ----
|_________________
dx
int dx=8, dy=3;
int x=0, y=0, acc=0;
for (int i=0; i dx) {
acc -= dx;
y++;
}
}
thinking help: the "trick" is to lay out the dy:s over the dx
until it overflows, and that's where the ratio of dx/dy tells
us to tick down the slope.
dy --- --- --- -|-- --- --- --|- --- --- ---
dx _____________|_____________|_____________
do y++ here
this is how i did it on the 286 in asm,
no floating point unit available.
/Niklas Lundberg