setPixel(firstX, firstY, R, G, B); /// rysujemy punkt startowy (firstX, firstY) setPixel(lastX, lastY, R, G, B); /// rysujemy punkt koncowy (firstX, firstY) const int dx = abs(lastX - firstX); const int dy = abs(lastY - firstY); const int stepX = (lastX > firstX) ? 1 : -1; const int stepY = (lastY > firstY) ? 1 : -1; if (abs(dx) > abs(dy)) { int d1 = 2 * dy - dx; int di = d1; const int di_ge0_step = 2 * (dy - dx); const int di_lt0_step = 2 * dy; for (int xi = firstX, yi = firstY; xi != lastX; xi += stepX) { if (di >= 0) { di += di_ge0_step; yi += stepY; const int Ti[] = { xi, yi }; setPixel(Ti[0], Ti[1], R, G, B); } else { di += di_lt0_step; const int Si[] = { xi, yi }; setPixel(Si[0], Si[1], R, G, B); } } } else { const int d1 = 2 * dx - dy; int di = d1; const int di_ge0_step = 2 * (dx - dy); const int di_lt0_step = 2 * dx; for (int xi = firstX, yi = firstY; yi != lastY; yi += stepY) { if (di >= 0) { di += di_ge0_step; xi += stepX; const int Ti[] = { xi, yi }; setPixel(Ti[0], Ti[1], R, G, B); } else { di += di_lt0_step; const int Si[] = { xi, yi }; setPixel(Si[0], Si[1], R, G, B); } } }