0

I have implemented a solution to achieve soft edges for forms or controls in C# by using the following code:

int arcSize = 30;
using (GraphicsPath path = new GraphicsPath())
{
    path.AddArc(0, 0, arcSize, arcSize, 180, 90);
    path.AddArc(panel1.Width - arcSize, 0, arcSize, arcSize, 270, 90);
    path.AddArc(panel1.Width - arcSize, panel1.Height - arcSize, arcSize, arcSize, 0, 90);
    path.AddArc(0, panel1.Height - arcSize, arcSize, arcSize, 90, 90);
    path.CloseFigure();
    panel1.Region = new Region(path);
}

While this code successfully provides the desired soft edges, I am interested in exploring alternative approaches that might be more efficient or offer better performance.

I would greatly appreciate any suggestions or insights from the community on whether there is a better way to achieve soft edges for forms or controls in C#. Are there any alternative methods or libraries that can be used to accomplish this task more effectively?

Thank you in advance for your assistance!

Frost Dream
  • 1
  • 2
  • 13
  • 1
    https://stackoverflow.com/a/54794097/14171304 -- https://stackoverflow.com/a/56533229/14171304 -- ..etc. Btw, you don't get soft edges when you set control's `Region`. It doesn't support anti-aliasing. – dr.null Jun 27 '23 at 00:16

0 Answers0