C # populate everything except GraphicsPath

I have a code that looks like this:

GraphicsPath p = new GraphicsPath(); // Add some elements to p ... // ... g.FillPath(bgBrush, p); // where g : Graphics and bgBrush : Brush 

This leads to what it looks like:

  ### |
   ## |
  ## |

How can I fill out the exact complement to the path?

Required Conclusion:

  # |
 ## |
 # # |
+4
source share
1 answer

I am surprised that no one has answered so far - the solution is quite simple. Just add a rectangle to the path and everything inside is back.

  protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; g.Clear(BackColor); GraphicsPath p = new GraphicsPath(); // add the desired path p.AddPie(100, 100, 100, 100, 0, 270); // add the rectangle to invert the inside p.AddRectangle(new Rectangle(50, 50, 200, 200)); g.FillPath(Brushes.Black, p); } 
+8
source

All Articles