title: Fill Octagon in C#
body: <p>I have created a method that draws an octagon, and it works well, as long as the size is 200 or higher</p>
  
  <pre><code>public static void FillOctagon(PaintEventArgs e, Color color, int x, int y, int width, int height)
  {
       e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  
       var points = new []
       {
            new Point(((x + width) / 2) - (width / 4), y), //side 1
            new Point(x, ((y + height) / 2) - (height / 4)), //side 2
            new Point(x, ((y + height) / 2) + (height / 4)), //side 3
            new Point(((x + width) / 2) - (width / 4), y + height), //side 4
            new Point((x + width) - (width / 4), y + height), //side 5
            new Point(x + width, ((y + height) / 2) + (height / 4)), //side 6
            new Point(x + width, ((y + height) / 2) - (height / 4)), //side 7
            new Point((x + width) - (width / 4), y) //side 8
       };
  
       using (var br = new SolidBrush(color))
       {
            using (var gpath = new GraphicsPath())
            {
                gpath.AddPolygon(points);
                e.Graphics.FillPath(br, gpath);
            }
       }
  }
  
  protected override void OnPaint(PaintEventArgs e)
  {
       base.OnPaint(e);
       FillOctagon(e, Color.DodgerBlue, 20, 20, 50, 50);
  }
  </code></pre>
  
  <p>Well, my problem is that if the size is less than 200 or if width is different from height and vice versa, the figure is deformed.
  My goal is to create a self-adapting figure, that retains its shape when the width and height is less than 200 or that width is different from height</p>
  
  <blockquote>
    <p>This is what happens if, for example, I set the size to 50x50:</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/4Ak6s.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Ak6s.jpg" alt="enter image description here"></a></p>