Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can I mix two TColors 1

Status
Not open for further replies.

cerverza

Programmer
Nov 13, 2002
4
ES
Hola Amigos
I´m trying to mix two TColor
For example if the two TColors are white the result should be white and if I had a black and a white TColor the result should be Grey
Which´s the function to make this?
Thanks to everyone!!
 
I dont know if there are any predefined functions to do this but TColour's (sorry TColor's) are just Integer values the Top 8 bits define other attributes but the low 24 define the colours
In hex $FFFFFFFF is white, so provided you mask the top two nybbles you can do Bitwise manipulation of the values
OR, AND, XOR each of the 3 lower Bytes is a colour.

I haven't bothered with the masking but this works.
You get a purple panel.

procedure TForm1.Button1Click(Sender: TObject);
var C1,C2,C3: Tcolor;
begin
C1 := CLRed;
C2 := ClBlue;
C3 := C1 or C2;
Panel.Color := C3
end;

Hope this helps
Steve.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top