```
var X = array_length_2d(arr, 0),
Y = array_height_2d(arr),
xx = 0,
yy = 0,
dx = 0,
dy = -1;
repeat (sqr(max(X, Y))) {
if ((-X/2 <= xx) && (xx <= X/2) && (-Y/2 <= yy) && (yy <= Y/2)) {
// DO STUFF...
}
if ((xx == yy) || ((xx < 0) && (xx == -yy)) || ((xx > 0) && (xx == 1-yy))) {
var t = dx;
dx = -dy;
dy = t;
}
xx += dx;
yy += dy;
}
```