Cosmetics

This commit is contained in:
3djc
2020-10-17 10:23:54 +02:00
parent 2c0e4df2eb
commit 7f1ec02066
+45 -43
View File
@@ -126,53 +126,55 @@ void BitmapBuffer::drawVerticalLine(coord_t x, coord_t y, coord_t h, uint8_t pat
} }
} }
void BitmapBuffer::drawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFlags att) { void BitmapBuffer::drawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFlags att)
// Offsets {
x1 += offsetX; // Offsets
y1 += offsetY; x1 += offsetX;
x2 += offsetX; y1 += offsetY;
y2 += offsetY; x2 += offsetX;
y2 += offsetY;
pixel_t color = lcdColorTable[COLOR_IDX(att)]; pixel_t color = lcdColorTable[COLOR_IDX(att)];
int dx = x2 - x1; /* the horizontal distance of the line */ int dx = x2 - x1; /* the horizontal distance of the line */
int dy = y2 - y1; /* the vertical distance of the line */ int dy = y2 - y1; /* the vertical distance of the line */
int dxabs = abs(dx); int dxabs = abs(dx);
int dyabs = abs(dy); int dyabs = abs(dy);
int sdx = sgn(dx); int sdx = sgn(dx);
int sdy = sgn(dy); int sdy = sgn(dy);
int x = dyabs >> 1; int x = dyabs >> 1;
int y = dxabs >> 1; int y = dxabs >> 1;
int px = x1; int px = x1;
int py = y1; int py = y1;
if (dxabs >= dyabs) { if (dxabs >= dyabs) {
/* the line is more horizontal than vertical */ /* the line is more horizontal than vertical */
for (int i = 0; i <= dxabs; i++) { for (int i = 0; i <= dxabs; i++) {
if ((1 << (px % 8)) & pat) { if ((1 << (px % 8)) & pat) {
drawPixel(px, py, color); drawPixel(px, py, color);
} }
y += dyabs; y += dyabs;
if (y >= dxabs) { if (y >= dxabs) {
y -= dxabs; y -= dxabs;
py += sdy; py += sdy;
} }
px += sdx; px += sdx;
}
} else {
/* the line is more vertical than horizontal */
for (int i = 0; i <= dyabs; i++) {
if ((1 << (py % 8)) & pat) {
drawPixel(px, py, color);
}
x += dxabs;
if (x >= dyabs) {
x -= dyabs;
px += sdx;
}
py += sdy;
}
} }
}
else {
/* the line is more vertical than horizontal */
for (int i = 0; i <= dyabs; i++) {
if ((1 << (py % 8)) & pat) {
drawPixel(px, py, color);
}
x += dxabs;
if (x >= dyabs) {
x -= dyabs;
px += sdx;
}
py += sdy;
}
}
} }