As I am using Unity, I can easily grab a square of pixels of any length. However, I want to find the largest circle possible within that square of pixels.

So for instance, if I had a 40 x 40 square of pixels, how would I get an array of pixels that form a circle inside of the square?

  • \$\begingroup\$ Are you just interested in the case of a square? So your question could be simplified to: "How can I draw a rasterized circle?". Or am I missing something here? \$\endgroup\$ – bummzack Apr 18 '11 at 15:40

On a 40×40 square of pixels, you can draw a circle with approximately 40×sqrt(8) pixels.

If you are looking for a circle drawing algorithm to let you pick the pixels to put in your array, an easy way is to draw an eighth of the circle, for instance using the midpoint algorithm, then mirror it three times.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.