CSharp examples for System.Drawing.Drawing2D:GraphicsPath
Create a round rect
using System.Drawing.Drawing2D; using System.Drawing; public class Main{ /// <summary> /// Create a round rect /// </summary> /// <param name="x">X</param> /// <param name="y">Y</param> /// <param name="width">Witdh</param> /// <param name="height">Height</param> /// <param name="radius">Round Radius</param> /// <returns>Rounded Rect</returns> public static GraphicsPath CreateRoundRect(float x, float y, float width, float height, float radius) {/*from w ww. j a v a2 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)); gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); gp.AddLine(x + width - (radius * 2), y + height, x + radius, y + height); gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); gp.AddLine(x, y + height - (radius * 2), x, y + radius); gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); gp.CloseFigure(); return gp; } }