# How to make a discrete circle in a 2d array?

I’m trying to make a filled-in circle in a 2d matrix. Any value less than r is 1, and any value outside of r is zero. I’m looking for something that looks more circular as the array size grows. The circle should be centered in the array

I’m starting out with an array full of zeros, and trying to use a loop to assign values of 1, but I’m not getting anything that looks remotely like a circle.

Here’s what I’ve tried:

``width = 100 height = 100 radius = 20 halfwidth = width/2 halfheight=height/2  array = ConstantArray[0, {height, width}] For[i=0, i<width, i++; For j=0, j<height, j++; If[i*i +j*j < radius*radius, array[[i + halfheight -  radius, j+halfwidth-radius]]=1]]]] ``

The last line SHOULD iterate over the entire 2d array and then checks if that index falls within the circle. If True, it assigns a value of 1, else it does nothing. Obviously, it’s not doing that. This is what it produces: It looks like it might be creating a single quadrant of the circle, but if so its in the wrong place.

So, how do I center this, and make a complete circle?

Thanks!