ASP.NET C # Graphic Path Form

I had a problem creating a specific path for a slightly modified rectangle with a round corner. Here is the code I use to create a round rectangle:

public static System.Drawing.Drawing2D.GraphicsPath RoundedRectangle(Rectangle r, int d) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddArc(rX, rY, d, d, 180, 90); gp.AddArc(rX + r.Width - d, rY, d, d, 270, 90); gp.AddArc(rX + r.Width - d, rY + r.Height - d, d, d, 0, 90); gp.AddArc(rX, rY + r.Height - d, d, d, 90, 90); gp.AddLine(rX, rY + r.Height - d, rX, rY + d / 2); return gp; } 

Now I need to generate something like this:

enter image description here

What would be the best approach to achieve this? Maybe by deleting the left border, and then adding the right triangle?

Any help is appreciated, thanks!

+4
source share
1 answer

Look, this will help you.

 public void DrawRoundRect(Graphics g, Pen p, float x, float y, float width, float height, float radius) { GraphicsPath gp = new GraphicsPath(); gp.AddLine(x + radius, y, x + width - (radius * 2), y); // Line gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); // Corner gp.AddLine(x + width, y + radius, x + width, y + height - (radius * 2)); // Line gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); // Corner gp.AddLine(x + width - (radius * 2), y + height, x + radius, y + height); // Line gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); // Corner gp.AddLine(x, y + height - (radius * 2), x, y + radius); // Line gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); // Corner gp.CloseFigure(); g.DrawPath(p, gp); gp.Dispose(); 

}

+1
source

Source: https://habr.com/ru/post/1393527/


All Articles