Method DrawLine
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
p1PointThe start point of the line.
p2PointThe end point of the line.
colorColor32The line color.
thicknessdoubleThe line thickness in pixels. Must be greater than zero. Defaults to 1.
Returns
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
p1orp2is 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
p1PointThe start point of the line.
p2PointThe end point of the line.
penPenThe pen that defines the stroke color, thickness, line cap, and alignment.
Returns
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, orpenis null.