title: Is there a formula to find affected square by sized-brush on a grid?
body: <p>I am not sure how to put this problem in a single sentence, sorry if the title is misleading.</p>
  
  <p>I am currently developing a simple terrain editor with a circle-shaped brush size. The image below shows a few cases that represent my problem. 
  <a href="https://i.stack.imgur.com/kn3pE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kn3pE.jpg" alt="is"></a>
  additional info: the square size is fixed and uniform and in the current version, my concern is only to find which one is hit and which one is not (the amount of region covered is important for weighting the hit, but probably not right now)</p>
  
  <p>My current solution (which is not even correct for a certain condition) is: given a hit in a position (x, y) with radius r, loop through all square from (x-radius, y-radius) to (x+radius, y+radius) and apply 2-D box to circle collision detection. But I don't think this is optimal (or even correct IMO).</p>
  
  <p>Can anyone help me with this one? Thank you</p>