3
\$\begingroup\$

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?

\$\endgroup\$
1
  • \$\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, 2011 at 15:40

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .