title: XNA Draw a filled circle
body: <p>In another thread on XNA, <a href="https://stackoverflow.com/a/2984527/">Callum Rogers wrote some code</a> which creates a texture with the outline of a circle, but I'm trying to create a circle filled with a color. What I have to modify on this code to fill the circle with color?</p>
  
  <pre><code>public Texture2D CreateCircle(int radius)
  {
      int outerRadius = radius*2 + 2; // So circle doesn't go out of bounds
      Texture2D texture = new Texture2D(GraphicsDevice, outerRadius, outerRadius);
  
      Color[] data = new Color[outerRadius * outerRadius];
  
      // Colour the entire texture transparent first.
      for (int i = 0; i &lt; data.Length; i++)
          data[i] = Color.Transparent;
  
      // Work out the minimum step necessary using trigonometry + sine approximation.
      double angleStep = 1f/radius;
  
      for (double angle = 0; angle &lt; Math.PI*2; angle += angleStep)
      {
          // Use the parametric definition of a circle: http://en.wikipedia.org/wiki/Circle#Cartesian_coordinates
          int x = (int)Math.Round(radius + radius * Math.Cos(angle));
          int y = (int)Math.Round(radius + radius * Math.Sin(angle));
  
          data[y * outerRadius + x + 1] = Color.White;
      }
  
      texture.SetData(data);
      return texture;
  }
  </code></pre>