Method DrawFilledRectangle
DrawFilledRectangle(Rectangle, Color32, Color32, double)
Fills the interior of the specified rectangle and then draws its outline, using a solid fill color and a solid stroke color with the given thickness.
public Canvas DrawFilledRectangle(Rectangle rect, Color32 fillColor, Color32 strokeColor, double strokeThickness = 1)
Parameters
rectRectangleThe rectangle to fill and outline.
fillColorColor32The interior fill color.
strokeColorColor32The outline stroke color.
strokeThicknessdoubleThe stroke thickness in pixels. Must be greater than zero. Defaults to 1.
Returns
Examples
var canvas = new Canvas(image);
canvas.DrawFilledRectangle(
Rectangle.FromSize(10, 10, 200, 100),
fillColor: new Color32(200, 230, 255),
strokeColor: new Color32(0, 0, 0),
strokeThickness: 2);
Exceptions
- ArgumentNullException
Thrown if
rectis null.- ArgumentOutOfRangeException
Thrown if
strokeThicknessis less than or equal to zero.
DrawFilledRectangle(Rectangle, Brush, Pen)
Fills the interior of the specified rectangle and then draws its outline, using the given brush and pen.
public Canvas DrawFilledRectangle(Rectangle rect, Brush brush, Pen pen)
Parameters
rectRectangleThe rectangle to fill and outline.
brushBrushThe brush that defines the fill color.
penPenThe pen that defines the stroke color, thickness, line join, line cap, miter limit, and alignment.
Returns
Examples
var brush = new Brush(new Color32(200, 230, 255));
var pen = new Pen(new Color32(0, 0, 0), 2)
{
LineJoin = LineJoin.Bevel
};
var canvas = new Canvas(image);
canvas.DrawFilledRectangle(Rectangle.FromSize(10, 10, 200, 100), brush, pen);
Exceptions
- ArgumentNullException
Thrown if
rect,brush, orpenis null.