The way I did this is to do a double for loop, as if you were doing a loop for a 2d array in normal mode. Inside this loop, however, do a check to see if the array element is within a circle of radius r using the distance formula.
For example, given the 10x10 array and the selected "center" of the array in (x, y):
for i from 0 to 9 {
for j from 0 to 9 {
a = i - x
b = j - y
if a*a + b*b <= r*r {
}
}
}
(The code is just pseudo code, not any particular language).
source
share