там ни одного комментария даже
Код:
void PixelsAntialiased::drawLineAntialiased(int16_t x1, int16_t y1, int16_t x2, int16_t y2) {
boolean steep = (y2 > y1 ? y2 - y1 : y1 - y2) > (x2 > x1 ? x2 - x1 : x1 - x2);
if (steep) {
int16_t tmp = x1;
x1 = y1;
y1 = tmp;
tmp = x2;
x2 = y2;
y2 = tmp;
}
if (x1 > x2) {
int16_t tmp = x1;
x1 = x2;
x2 = tmp;
tmp = y1;
y1 = y2;
y2 = tmp;
}
int16_t deltax = x2 - x1;
int16_t deltay = y2 - y1;
double gradient = 1.0 * deltay / deltax;
int16_t xend = x1; // round(x1);
double yend = y1 + gradient * (xend - x1);
double xgap = rfpart(x1 + 0.5);
int16_t xpxl1 = xend;
int16_t ypxl1 = ipart(yend);
putColor(xpxl1, ypxl1, steep, rfpart(yend)*xgap);
putColor(xpxl1, ypxl1 + 1, steep, fpart(yend)*xgap);
double intery = yend + gradient;
xend = x2; // round(x2);
yend = y2 + gradient * (xend - x2);
xgap = rfpart(x2 + 0.5);
int16_t xpxl2 = xend;
int16_t ypxl2 = ipart(yend);
putColor(xpxl2, ypxl2, steep, rfpart(yend)*xgap);
putColor(xpxl2, ypxl2 + 1, steep, fpart(yend)*xgap);
for ( int16_t x = xpxl1 + 1; x < xpxl2 - 1; x++ ) {
putColor(x, ipart(intery), steep, rfpart(intery));
putColor(x, ipart(intery) + 1, steep, fpart(intery));
intery += gradient;
}
}
_________________
<telepathmode>На вопросы отвечает Бригадир Телепатов!</telepathmode>
Всё уже придумано до нас!