Hi!
The situation with the color constants in BGRA is not satisfying:
The Css-Color values are variables in BGRA and so they can't be used as constant.
For BGRAPixel it is a lot of typing to define a const:
colorWood : TBGRAPixel =(red : 180;green:112;blue :64; alpha:255);
Okay, it is anounced that in the unit UITypes the color constant will soon appear.
But those constants do NOT start with 'cl' !! This was default since Delphi 1.
Always the same discussion: Do we have to copy all mistakes from Delphi in fpc???
To get out of all that trouble I made a mini project that take all 140 (??) Web colors from BGRA, converts them to TColor values and creates an pascal INC file, that can be put into every project.
The heart of it is just this simple procedure:
procedure CreateColorInc(FName: string);
var i: integer;
s,hex,color : string;
col : TBGRAPixel;
list : TStringList;
begin
list := TStringList.Create;
// ... header
for i := 0 to CSSColors.Count-1 do
begin
color := CssColors.Name[i];
col := cssColors.ByIndex[i];
hex := '$'+IntToHex(col.blue,2)+IntToHex(col.green,2)+IntToHex(col.Red,2);
s := ' cl'+color+' = '+hex+';';
List.add(s);
end; // i
List.SaveToFile(fname);
//showMessage (List.text);
List.free;
end;
Hope it helps to save typing
Winni