Method DrawPolygon
DrawPolygon(Polygon, Color32, double)
Draws the outline of the specified polygon with a solid color and thickness.
public Canvas DrawPolygon(Polygon polygon, Color32 color, double thickness = 1)
Parameters
polygonPolygonThe polygon to outline.
colorColor32The stroke color.
thicknessdoubleThe stroke thickness in pixels. Must be greater than zero. Defaults to 1.
Returns
Examples
var pentagon = Polygon.Regular(new Point(150, 150), 60, 5);
var canvas = new Canvas(image);
canvas.DrawPolygon(pentagon, new Color32(0, 0, 0), thickness: 2);
Exceptions
- ArgumentNullException
Thrown if
polygonis null.
DrawPolygon(Polygon, Pen)
Draws the outline of the specified polygon using the given pen.
public Canvas DrawPolygon(Polygon polygon, Pen pen)
Parameters
polygonPolygonThe polygon to outline.
penPenThe pen that defines the stroke color, thickness, line join, line cap, miter limit, and alignment.
Returns
Examples
var pentagon = Polygon.Regular(new Point(150, 150), 60, 5);
var pen = new Pen(new Color32(255, 0, 0), 3) { LineJoin = LineJoin.Round };
var canvas = new Canvas(image);
canvas.DrawPolygon(pentagon, pen);
Exceptions
- ArgumentNullException
Thrown if
polygonorpenis null.