GraphicsPath constructor.


CustomLineCap(GraphicsPath fill, GraphicsPath stroke);
CustomLineCap(GraphicsPath fill, GraphicsPath stroke, LineCap cap);

[Visual Basic]

Sub New(fill As GraphicsPath, stroke As GraphicsPath)
Sub New(fill As GraphicsPath, stroke As GraphicsPath, cap As LineCap)

Name Description
fill The fill path to use for the end cap.
stroke The stroke path to use for the end cap.
cap The default cap on which this is based.
inset The base inset for the cap. See BaseInset for details.




using (Bitmap bm = new Bitmap(600, 600)) {
  using (Graphics graphics = Graphics.FromImage(bm)) {
    GraphicsPath big = new GraphicsPath();
    big.AddEllipse(-2, -2, 4, 4);
    GraphicsPath small = new GraphicsPath();
    small.AddEllipse(-1, -1, 2, 2);
    Pen pen = new Pen(Color.Black, 20);
    pen.CustomStartCap = new CustomLineCap(null, big);
    pen.CustomEndCap = new CustomLineCap(small, null);
    for (int i = 0; i < 3; i++) {
      pen.CustomStartCap.BaseInset = i;
      pen.CustomEndCap.BaseInset = i;
      pen.Color = Color.Red;
      graphics.DrawLine(pen, 100, 100, 200, 200);
      pen.Color = Color.Green;
      graphics.DrawLine(pen, 200, 200, 100, 400);
      pen.Color = Color.Blue;
      graphics.DrawLine(pen, 100, 400, 200, 500);
      graphics.TranslateTransform(150, 0);

The code here uses two different custom line caps. We vary the BaseInset to show how it affects the end point of the line. The final output is shown below. If you are interested in designs for custom end points HTML Arrows is a good place to start.