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);
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}