Table of Contents

Method DrawLine

Namespace
LMKit.Graphics.Drawing
Assembly
LM-Kit.NET.dll

DrawLine(Point, Point, Color32, double)

Draws a line segment between two points with a solid color and thickness. Uses default stroke settings: Miter, Butt.

public Canvas DrawLine(Point p1, Point p2, Color32 color, double thickness = 1)

Parameters

p1 Point

The start point of the line.

p2 Point

The end point of the line.

color Color32

The line color.

thickness double

The line thickness in pixels. Must be greater than zero. Defaults to 1.

Returns

Canvas

This Canvas instance for fluent chaining.

Examples

var canvas = new Canvas(image);
canvas.DrawLine(
    new Point(10, 10),
    new Point(200, 150),
    new Color32(0, 0, 0),
    thickness: 2);

Exceptions

ArgumentNullException

Thrown if p1 or p2 is null.

DrawLine(Point, Point, Pen)

Draws a line segment between two points using the given pen.

public Canvas DrawLine(Point p1, Point p2, Pen pen)

Parameters

p1 Point

The start point of the line.

p2 Point

The end point of the line.

pen Pen

The pen that defines the stroke color, thickness, line cap, and alignment.

Returns

Canvas

This Canvas instance for fluent chaining.

Examples

var pen = new Pen(new Color32(255, 0, 0), 3) { LineCap = LineCap.Round };
var canvas = new Canvas(image);
canvas.DrawLine(new Point(10, 10), new Point(200, 150), pen);

Exceptions

ArgumentNullException

Thrown if p1, p2, or pen is null.