struct cord{
int x,y;
};
void SetPixel(int x,int y); //Ставит пиксель в буффер
int test(int x,int y); //Тест на принадлежность пикселя границе области
void drawz(int x, int y){
stack<cord> st;
cord a;
a.x = x;
a.y = y;
st.push(a);
while (!st.empty()){
int xl = x, xr = x;
SetPixel(x, y);
for (int xo = x - 1; xo >= 0; xo--){
if (test(xo, y)){
xl = xo + 1;
break;
}
SetPixel(xo, y);
}
for (int xo = x + 1; xo < s_width; xo++){
if (test(xo, y)){
xr = xo - 1;
break;
}
SetPixel(xo, y);
}
y++;
if (y < s_height){
for (int xo = xl; xo <= xr; xo++){
if (test(xo, y)){
continue;
}
a.y = y;
a.x = xo;
st.push(a);
for (; xo <= xr && !test(xo, y); xo++);
}
}
y -= 2;
if (y >= 0){
for (int xo = xl; xo <= xr; xo++){
if (test(xo, y)){
continue;
}
a.y = y;
a.x = xo;
st.push(a);
for (; xo <= xr && !test(xo, y); xo++);
}
}
a = st.top();
st.pop();
x = a.x;
y = a.y;
}
}