Hi again @doni,
This is linked to your previous post:
You should use a nested for loop and compute the 1D index with the x + y * width
formula.
But it seems that you don’t want to use a nested for loop to iterate over the pixels… (I find it more simple and clear )
You can do that with a single while
loop (maybe not the best solution thought):
int i = 0;
int iterations = 0;
while (i < 14) {
iterations++;
println(i + 1);
if (iterations % 2 == 0) {
i += 3;
} else {
i += 1;
}
}
// -> 1 2 5 6 9 10 13 14
Or shorter:
while (i < 14) {
iterations++;
println(i + 1);
i += ((iterations % 2) == 0) ? 3 : 1;
}