Share via


Joining Lines

A line join is the common area that is formed by two lines whose ends meet or overlap. GDI+ provides three line join styles: miter, bevel, and round. Line join style is a property of the Pen class. When you specify a line join style for a Pen object, that join style will be applied to all the connected lines in any GraphicsPath object drawn using that pen.

You can specify the line join style by using the LineJoin property of the Pen class. The following example demonstrates a beveled line join between a horizontal line and a vertical line:

Dim path As New GraphicsPath()
Dim penJoin As New Pen(Color.FromArgb(255, 0, 0, 255), 8)

path.StartFigure()
path.AddLine(New Point(50, 200), New Point(100, 200))
path.AddLine(New Point(100, 200), New Point(100, 250))

penJoin.LineJoin = LineJoin.Bevel
e.Graphics.DrawPath(penJoin, path)
[C#]
GraphicsPath path = new GraphicsPath();
Pen penJoin = new Pen(Color.FromArgb(255, 0, 0, 255), 8);

path.StartFigure();
path.AddLine(new Point(50, 200), new Point(100, 200));
path.AddLine(new Point(100, 200), new Point(100, 250));

penJoin.LineJoin = LineJoin.Bevel;
e.Graphics.DrawPath(penJoin, path);

The following illustration shows the resulting beveled line join.

91awkw32.pens5(en-us,VS.71).gif

In the preceding code, the value Bevel assigned to the LineJoin property is a member of the LineJoin enumeration. The other members of the LineJoin enumeration are Miter and Round.