FillColorRectangle(Color: IGxColor; Rect: IGxRect);
Color. Color that is used to fill a rectangle.
Rect. Integer rectangle.
The FillColorRectangle method fills the integer rectangle with the color passed by the Color parameter.
Executing the example requires a form with the button named Button1 and the ImageBox component named ImageBox1. Add links to the Drawing, Forms system assemblies.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
BMP: IGxBitmap;
Graph: IGxGraphics;
GraphClass: GxGraphicsClass;
Color: IGxColor;
Rect: IGxRect;
x, y, i, j: Integer;
Begin
BMP := GxBitmap.CreateNew(ImageBox1.ClientWidth, ImageBox1.ClientHeight, GxPixelFormat.Unknown);
Color := GxColor.FromValue(Math.RandBetweenI(0, 65536));
x := Math.RandBetweenI(0, Double.RoundInt(ImageBox1.ClientWidth / 2));
y := Math.RandBetweenI(0, Double.RoundInt(ImageBox1.ClientHeight / 2));
i := Math.RandBetweenI(Double.RoundInt(ImageBox1.ClientWidth / 2), ImageBox1.ClientWidth);
j := Math.RandBetweenI(Double.RoundInt(ImageBox1.ClientHeight / 2), ImageBox1.ClientHeight);
Rect := New GxRect.Create(x, y, i, j);
GraphClass := New GxGraphics.Create;
Graph := GraphClass.FromImage(BMP);
Graph.FillColorRectangle(Color, Rect);
ImageBox1.Image := BMP;
End Sub Button1OnClick;
After executing the example clicking the button in the ImageBox component displays a new bitmap with the rectangle of random size and color.
See also: