title: How to draw a filled circle?
body: <p>I'm creating bitmap/bmp files according to the specifications with my C code and I would like to draw simple primitives on my bitmap. The following code shows how I draw a rectangle on my bitmap:</p>
  
  <pre><code>if(curline-&gt;type == 1) // draw a rectangle
  {
      int xstart = curline-&gt;x;
      int ystart = curline-&gt;y;
      int width = curline-&gt;width + xstart;
      int height = curline-&gt;height + ystart;
  
      int x = 0;
      int y = 0;
  
      for(y = ystart; y &lt; height; y++)
      {
        for(x = xstart; x &lt; width; x++)
        {
          arr[x][y].blue = curline-&gt;blue;
          arr[x][y].green = curline-&gt;green;
          arr[x][y].red = curline-&gt;red;
        }
      }
  
      printf("rect drawn.\n");
  }
  
  ...
  save_bitmap();
  </code></pre>
  
  <p><strong>Example output:</strong>
  <img src="https://i.stack.imgur.com/TXBMZ.png" alt="enter image description here"></p>
  
  <p>So basically I'm setting the red, green and blue values for all pixels within the given x and y field.</p>
  
  <p>Now I'd like to fill a circle by knowing its midpoint and radius. But how do I know which pixels are inside this circle and which pixels ain't? Any help would be appreciated, thanks for reading.</p>