Graphics.DrawLine Method (Pen, Int32, Int32, Int32, Int32)

Draws a line connecting the two points specified by the coordinate pairs.

Namespace: Aurigma.GraphicsMill.Drawing
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

C#
public void DrawLine(
	Pen pen,
	int x1,
	int y1,
	int x2,
	int y2
)

Parameters

pen

Type: Aurigma.GraphicsMill.Drawing.Pen

A Pen that determines the color, width, and style of the line.
x1

Type: System.Int32

The x-coordinate of the first point.
y1

Type: System.Int32

The y-coordinate of the first point.
x2

Type: System.Int32

The x-coordinate of the second point.
y2

Type: System.Int32

The y-coordinate of the second point.

Remarks

In this method line is defined with two points which should be connected with this line.

Examples

C#
using (var bitmap = new Bitmap(185, 145, PixelFormat.Format24bppRgb, RgbColor.White))
{
    using (Graphics graphics = bitmap.GetGraphics())
    {
        //Draw line
        var pen = new Pen(RgbColor.Red, 5);
        graphics.DrawLine(pen, 10, 10, 100, 60);

        //Draw polyline
        pen.Color = RgbColor.LawnGreen;
        pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
        pen.Width = 2;
        System.Drawing.Point[] points1 = { 
            new System.Drawing.Point(20, 30), new System.Drawing.Point(50, 2), 
            new System.Drawing.Point(180, 30), new System.Drawing.Point(80, 140)
        };
        graphics.DrawLines(pen, points1);

        //Draw beizer
        pen.Color = RgbColor.Blue;
        pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
        System.Drawing.Point[] points2 = { 
            new System.Drawing.Point(5, 5), new System.Drawing.Point(20, 150), 
            new System.Drawing.Point(165, 80), new System.Drawing.Point(175, 10)
        };
        graphics.DrawBeziers(pen, points2);
    }
    bitmap.Save(@"Images\Output\lines.png");
}

See Also

Reference