Oddly drawn GraphicsPath with Graphics.FillPath

后端 未结 4 1205
心在旅途
心在旅途 2020-12-19 23:05

I have written some code which creates a rounded rectangle GraphicsPath, based on a custom structure, BorderRadius (which allows me to define the t

4条回答
  •  伪装坚强ぢ
    2020-12-19 23:24

    "Is it possible to fill the inside of a GraphicsPath without using FillPath?"

    Yes...but I think this is more of a parlor trick (and it might not work as you expect for more complex shapes). You can clip the graphics to the path, and then just fill the entire encompassing rectangle:

            Rectangle rc = new Rectangle(10, 10, 100, 100);
            GraphicsPath path = CreateRoundRectanglePath(new BorderRadius(8), rc);
            e.Graphics.SetClip(path);
            e.Graphics.FillRectangle(Brushes.Black, rc);
            e.Graphics.ResetClip();
    

提交回复
热议问题