I’m currently trying to handle the bug reported by @HomineLudens in Issue # 31.

I’ve currently got it working as this:

```
void Display::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1) {
if (x0 == x1)
drawColumn(x0, y0, y1);
else if (y0 == y1)
drawRow(x0, x1, y0);
else {
signed int dx = 0;
signed char s1 = 0;
//take absolute value
if (x1 < x0) {
dx = x0 - x1;
s1 = -1;
}
else if (x1 == x0) {
dx = 0;
s1 = 0;
}
else {
dx = x1 - x0;
s1 = 1;
}
signed int dy = 0;
int_fast8_t s2 = 0;
if (y1 < y0) {
dy = y0 - y1;
s2 = -1;
}
else if (y1 == y0) {
dy = 0;
s2 = 0;
}
else {
dy = y1 - y0;
s2 = 1;
}
bool xchange = false;
if (dy > dx) {
int temp = dx;
dx = dy;
dy = temp;
xchange = true;
}
int e = ((int)dy << 1) - dx;
signed int x = x0;
signed int y = y0;
for (int j = 0; j <= dx; ++j) {
if((x < 0 || x >= width) || (y < 0 || y >= height))
break;
drawPixel(x, y);
if (e >= 0) {
if (xchange)
x += s1;
else
y += s2;
e -= ((int)dx << 1);
}
if (xchange)
y += s2;
else
x += s1;
e += ((int)dy << 1);
}
}
}
```

That’s probably going to be too slow to be the final version.

(I don’t know how fast it is, I don’t know what the best way to speed test is.)

I’m currently trying to think of some alternatives.

I know the obvious one is to limit `dx`

and `dy`

,

but the problem lies in getting the slope to match up

(i.e. if you subtract from `dx`

you have to subtract a proportionate amount from `dy`

.)

Anyone got any ideas?