Create Up Round Rect - CSharp System.Drawing.Drawing2D

CSharp examples for System.Drawing.Drawing2D:GraphicsPath

Description

Create Up Round Rect

Demo Code


using System.Drawing.Drawing2D;
using System.Drawing;

public class Main{
        public static GraphicsPath CreateUpRoundRect(float x, float y, float width, float height, float radius)
        {//from   ww w.jav  a 2 s.  c  om
            GraphicsPath gp = new GraphicsPath();

            gp.AddLine(x + radius, y, x + width - (radius * 2), y);
            gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90);

            gp.AddLine(x + width, y + radius, x + width, y + height - (radius * 2) + 1);
            gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, 2, 0, 90);

            gp.AddLine(x + width, y + height, x + radius, y + height);
            gp.AddArc(x, y + height - (radius * 2) + 1, radius * 2, 1, 90, 90);

            gp.AddLine(x, y + height, x, y + radius);
            gp.AddArc(x, y, radius * 2, radius * 2, 180, 90);

            gp.CloseFigure();
            return gp;
        }
}

Related Tutorials