program RandomRGBA;
{$mode delphi}{$H+}
{
Generate a random RGBA color string.
Produces full‑range RGB values and a floating‑point opacity.
}
uses
SysUtils; { for Format() }
// Generate a random integer in the range [0..255]
function RandomChannel: Integer;
begin
Result := Random(256);
end;
// Generate a random opacity in the range [0..1]
function RandomOpacity: Double;
begin
Result := Random; { Random returns a float in [0..1) }
end;
// Create a random RGBA color string
function RandomRGBAString: String;
var
r, g, b: Integer;
a: Double;
begin
r := RandomChannel();
g := RandomChannel();
b := RandomChannel();
a := RandomOpacity();
{ Format as rgba(r, g, b, a) with two decimal places }
Result := Format('rgba(%d, %d, %d, %.2f)', [r, g, b, a]);
end;
var
color: String;
begin
Randomize; { ensure different results each run }
color := RandomRGBAString;
WriteLn(color);
end.
{
run:
rgba(233, 61, 100, 0.92)
}