다음을 통해 공유


How to: Join 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.

The following illustration shows the results of the beveled line join example.

Pens

Example

You can specify the line join style by using the LineJoin property of the Pen class. The example demonstrates a beveled line join between a horizontal line and a vertical line. In the following 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.

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)
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);

Compiling the Code

The preceding example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler.

See Also

Other Resources

Using a Pen to Draw Lines and Shapes