Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.