Declaration ​
pascal
procedure FillRect(X1, Y1, X2, Y2: Integer; Value: TColor32);
procedure FillRectS(X1, Y1, X2, Y2: Integer; Value: TColor32); overload;
procedure FillRectS(const ARect: TRect; Value: TColor32); overload;
procedure FillRectT(X1, Y1, X2, Y2: Integer; Value: TColor32);
procedure FillRectTS(X1, Y1, X2, Y2: Integer; Value: TColor32); overload;
procedure FillRectTS(const ARect: TRect; Value: TColor32); overload;Parameters ​
| Parameter | Type | Description |
|---|---|---|
X1, Y1, X2, Y2 | Integer | Rectangle corner coordinates. |
ARect | TRect | Target TRect. |
Value | TColor32 | 32-bit ARGB color. |
Description ​
The FillRect methods fill a rectangular region bounded by coordinates (X1, Y1, X2, Y2) or a TRect record ARect with a 32-bit ARGB color Value.
Method variants provide combinations of direct unclipped memory fill (FillRect), boundary clipping against ClipRect (S), and alpha blending (T).
Note
By convention, FillRect includes the left and top borders, but excludes the right and bottom borders of the rectangle.
This means that if X1 >= X2 or Y1 >= Y2, then nothing is drawn.
See also: Why are RECTs endpoint-exclusive? - The Old New Thing
Variants ​
| Variant | Coordinate / Bounds | Modifiers | Description |
|---|---|---|---|
FillRect | (X1, Y1, X2, Y2) | Direct | Fast direct fill without boundary clipping or alpha blending. Coordinates must be within bitmap bounds. |
FillRectS | (X1, Y1, X2, Y2) or TRect | Safe | Fills rectangle clipped against ClipRect. |
FillRectT | (X1, Y1, X2, Y2) | Transparent | Fills rectangle with alpha blending using DrawMode / CombineMode. Unclipped. |
FillRectTS | (X1, Y1, X2, Y2) or TRect | Transparent + Safe | Fills rectangle clipped against ClipRect with alpha blending using DrawMode / CombineMode. |
Example ​
pascal
// Direct unclipped solid fill
Bitmap.FillRect(0, 0, 100, 100, clRed32);
// Clipped alpha-blended fill
var r := Rect(20, 20, 150, 150);
Bitmap.FillRectTS(r, clTrBlue32);