Table of Contents

Method DrawRectangle

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

DrawRectangle(Rectangle, Color32, double)

Draws the outline of the specified rectangle with a solid color and thickness. Uses default stroke settings: Miter, Butt, and Center.

public Canvas DrawRectangle(Rectangle rect, Color32 color, double thickness = 1)

Parameters

rect Rectangle

The rectangle to outline.

color Color32

The stroke color.

thickness double

The stroke 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.DrawRectangle(
    Rectangle.FromSize(10, 10, 200, 100),
    new Color32(0, 0, 0),
    thickness: 2);

Exceptions

ArgumentNullException

Thrown if rect is null.

ArgumentOutOfRangeException

Thrown if thickness is less than or equal to zero.

DrawRectangle(Rectangle, Pen)

Draws the outline of the specified rectangle using the given pen.

public Canvas DrawRectangle(Rectangle rect, Pen pen)

Parameters

rect Rectangle

The rectangle to outline.

pen Pen

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

Returns

Canvas

This Canvas instance for fluent chaining.

Examples

var pen = new Pen(new Color32(255, 0, 0), 3)
{
    LineJoin = LineJoin.Round,
    Alignment = PenAlignment.Inside
};
var canvas = new Canvas(image);
canvas.DrawRectangle(Rectangle.FromSize(10, 10, 200, 100), pen);

Exceptions

ArgumentNullException

Thrown if rect or pen is null.