@wp: sorry for forgetting to mention the Jedi version number.
@others: thank you for your answers.
I had the same result (but not as well, in 3..a few lines
):
uses
Graphics, FPImage;
function CompementaryColor2(AColor: TColor): TColor;
var
aRGB: record
iRed, iGreen, iBlue: Byte;
end;
aFPColor: TFPColor;
aColorRef: TColorRef;
begin
aFPColor:= TColorToFPColor(AColor);
aColorRef:= FPColorToTColorRef(aFPColor);
//(1) verification of RGB components, from the basic AColor composite
with aRGB do begin
iRed:= Graphics.Red(aColorRef);
iGreen:= Graphics.Green(aColorRef);
iBlue:= Graphics.Blue(aColorRef);
end;
Form1.lblRedBase.Caption:= 'RedBase: ' + IntToStr(aRGB.iRed);
Form1.lblGreenBase.Caption:= 'GreenBase: ' + IntToStr(aRGB.iGreen);
Form1.lblBlueBase.Caption:= 'BlueBase: ' + IntToStr(aRGB.iBlue);
//(2) obtain the complements of the RGB components, from the basic AColor composite
with aRGB do begin
iRed:= 255 - Graphics.Red(aColorRef);
iGreen:= 255 - Graphics.Green(aColorRef);
iBlue:= 255 - Graphics.Blue(aColorRef);
end;
(* Form1.lblRedCompl:= 'RedCompl: ' + ; Form1.lblGreenCompl:= 'GreenCompl: ' + ; Form1.lblBlueCompl:= 'BlueCompl: ' + ; *)
result:= RGBToColor(aRGB.iRed, aRGB.iGreen, aRGB.iBlue);
end;
But, I have the following comprehension problem; when I code...:
procedure TForm1.Button2Click(Sender: TObject);
var
aBaseColor: TColor;
begin
aBaseColor:= TColor($AA6239); //with $00AA6239, I get the same result; //with $AA623900, this color is a light grey, not the brown displayed by websites
Panel1.Color:= aBaseColor;
end;
... then, I will check on
https://www.colorhexa.com/aa6239: I don't see the same color, as the one on the TForm??!
However, when I take a calculator, I get:
Red = $aa = 170.
Green = $62 = 98.
Blue = $39 = 57.
Nevertheless, Free Pascal tells me, that:
with aRGB do begin
iRed:= Graphics.Red(aColorRef); // == 57.
iGreen:= Graphics.Green(aColorRef); // == 98.
iBlue:= Graphics.Blue(aColorRef); // == 170.
end;
==>
So, iRed and iBlue are reversed (!!?), compared to all tested web sites of colors verification (by entering #aa6239, as in the *.css files).
➔ My question is
( using only simple RGB; no Hue, sensitivity, ..., ink that I don't know yet ): why this inversion
( i.e. how to get from $aa6239 in Free Pascal, the same color on a TForm as #aa6239 displayed by the *.css and Javascript )?