Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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? – bummzack Apr 18 '11 at 15:40
up vote 1 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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